Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions config/silabs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,24 @@ config CHIP_DEVICE_VENDOR_NAME
string "Vendor Name"
default "Silicon Laboratories"

# See config/zephyr/Kconfig for full definition
# See config/zephyr/Kconfig for full definition.
# SiWx917 uses the NWP/Security Bootloader RPS path (SIWX91X_FIRMWARE_UPGRADE).
# EFR32 uses MCUboot (slot-based DFU).
config CHIP_OTA_REQUESTOR
bool "Enable OTA Requestor"
default n
imply BOOTLOADER_MCUBOOT
imply IMG_MANAGER
imply STREAM_FLASH
imply STREAM_FLASH_ERASE
select SIWX91X_FIRMWARE_UPGRADE if SOC_SERIES_SIWG917
imply REBOOT if SOC_SERIES_SIWG917
imply BOOTLOADER_MCUBOOT if !SOC_SERIES_SIWG917
imply IMG_MANAGER if !SOC_SERIES_SIWG917
imply STREAM_FLASH if !SOC_SERIES_SIWG917
imply STREAM_FLASH_ERASE if !SOC_SERIES_SIWG917
Comment thread
arun-silabs marked this conversation as resolved.
Outdated

config CHIP_OTA_IMAGE_BUILD
bool
default y if CHIP_OTA_REQUESTOR
depends on SIGN_IMAGES
# EFR32 OTA images wrap the MCUboot-signed app; SiWx917 wraps zephyr.rps.
depends on SIGN_IMAGES || SOC_SERIES_SIWG917

# Sign the application with the MCUboot ECDSA-P256 development key. Only relevant
# for MCUboot/OTA builds; replace with a private key for production.
Expand Down
84 changes: 72 additions & 12 deletions config/silabs/app/zephyr-post-build.cmake
Comment thread
arun-silabs marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,78 @@ include(${CHIP_ROOT}/config/zephyr/ota-image.cmake)

# ==============================================================================
# Create the Matter OTA image for Silabs Zephyr targets.
#
# EFR32: wrap the MCUboot-signed application .bin.
# SiWx917: wrap the SoC-generated zephyr.rps (NWP / Security Bootloader path).
# ==============================================================================
if(CONFIG_CHIP_OTA_REQUESTOR)
if(CONFIG_MCUBOOT_SIGNATURE_KEY_FILE STREQUAL "")
set(ZEPHYR_OUTPUT_NAME "zephyr")
set(ZEPHYR_OUTPUT_DIR ${PROJECT_BINARY_DIR}/zephyr)

if(CONFIG_SOC_SERIES_SIWG917)
# ------------------------------------------------------------------
# SiWx917: Matter OTA payload is the RPS produced by SoC post-build.
# Depend on zephyr.bin (known CMake output); post-build creates the RPS
# in the same step, so it is present when ota_image_tool runs.
# Do not use add_custom_command(TARGET zephyr_final) — that target is
# not created in this CMakeLists directory.
# ------------------------------------------------------------------
if(CONFIG_SIWX91X_SIGN_KEY OR CONFIG_SIWX91X_MIC_KEY)
set(SIWX_RPS_INPUT ${ZEPHYR_OUTPUT_DIR}/zephyr.signed.rps)
else()
set(SIWX_RPS_INPUT ${ZEPHYR_OUTPUT_DIR}/zephyr.rps)
endif()

if(CONFIG_CHIP_OTA_IMAGE_BUILD)
set(SIWX_OTA_OUTPUT ${ZEPHYR_OUTPUT_DIR}/${CONFIG_CHIP_OTA_IMAGE_FILE_NAME})

if(DEFINED APPVERSION)
set(SIWX_OTA_ARGS
"--vendor-id" ${CONFIG_CHIP_DEVICE_VENDOR_ID}
"--product-id" ${CONFIG_CHIP_DEVICE_PRODUCT_ID}
"--version" ${APPVERSION}
"--version-str" ${APP_VERSION_EXTENDED_STRING}
"--digest-algorithm" "sha256"
)
else()
set(SIWX_OTA_ARGS
"--vendor-id" ${CONFIG_CHIP_DEVICE_VENDOR_ID}
"--product-id" ${CONFIG_CHIP_DEVICE_PRODUCT_ID}
"--version" ${CONFIG_CHIP_DEVICE_SOFTWARE_VERSION}
"--version-str" ${CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING}
"--digest-algorithm" "sha256"
)
endif()

separate_arguments(SIWX_OTA_EXTRA_ARGS NATIVE_COMMAND "${CONFIG_CHIP_OTA_IMAGE_EXTRA_ARGS}")
list(APPEND SIWX_OTA_ARGS ${SIWX_OTA_EXTRA_ARGS})
list(APPEND SIWX_OTA_ARGS ${SIWX_RPS_INPUT} ${SIWX_OTA_OUTPUT})
string(REPLACE ";" "\n" SIWX_OTA_ARGS_FILE "${SIWX_OTA_ARGS}")
file(GENERATE OUTPUT ${SIWX_OTA_OUTPUT}.args CONTENT ${SIWX_OTA_ARGS_FILE})

add_custom_command(
OUTPUT ${SIWX_OTA_OUTPUT}
COMMAND ${Python3_EXECUTABLE} ${CHIP_ROOT}/src/app/ota_image_tool.py create @${SIWX_OTA_OUTPUT}.args
DEPENDS ${ZEPHYR_OUTPUT_DIR}/zephyr.bin ${CHIP_ROOT}/src/app/ota_image_tool.py
Comment thread
arun-silabs marked this conversation as resolved.
Outdated
COMMENT "Generating Matter OTA image from ${SIWX_RPS_INPUT}"
VERBATIM
)
add_custom_target(chip-ota-image ALL DEPENDS ${SIWX_OTA_OUTPUT})
endif()
else()
set(ZEPHYR_OUTPUT_NAME "zephyr.signed")
endif()

if(CONFIG_CHIP_OTA_IMAGE_BUILD)
chip_ota_image(chip-ota-image
INPUT_FILES ${PROJECT_BINARY_DIR}/zephyr/${ZEPHYR_OUTPUT_NAME}.bin
OUTPUT_FILE ${PROJECT_BINARY_DIR}/zephyr/${CONFIG_CHIP_OTA_IMAGE_FILE_NAME}
)
endif()
endif()
# ------------------------------------------------------------------
# EFR32 / MCUboot: wrap the signed application binary.
# ------------------------------------------------------------------
if(CONFIG_MCUBOOT_SIGNATURE_KEY_FILE STREQUAL "")
set(ZEPHYR_OUTPUT_NAME "zephyr")
else()
set(ZEPHYR_OUTPUT_NAME "zephyr.signed")
endif()

if(CONFIG_CHIP_OTA_IMAGE_BUILD)
chip_ota_image(chip-ota-image
INPUT_FILES ${ZEPHYR_OUTPUT_DIR}/${ZEPHYR_OUTPUT_NAME}.bin
OUTPUT_FILE ${ZEPHYR_OUTPUT_DIR}/${CONFIG_CHIP_OTA_IMAGE_FILE_NAME}
)
endif()
endif() # CONFIG_SOC_SERIES_SIWG917
endif() # CONFIG_CHIP_OTA_REQUESTOR
6 changes: 6 additions & 0 deletions config/silabs/cmake/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ matter_add_gn_arg_bool ("chip_system_config_provide_statistics" CONFIG_CHIP_ST
matter_add_gn_arg_bool ("chip_enable_icd_server" CONFIG_CHIP_ENABLE_ICD_SUPPORT)
matter_add_gn_arg_bool ("chip_enable_ota_requestor" CONFIG_CHIP_OTA_REQUESTOR)

# SiWx917 uses RPS firmware-upgrade instead of the default Zephyr MCUboot processor.
if(CONFIG_SOC_SERIES_SIWG917)
matter_add_gn_arg_string("chip_zephyr_ota_image_processor"
"//src/platform/silabs/zephyr:ota-image-processor")
endif()

Comment thread
arun-silabs marked this conversation as resolved.
Outdated
if(CONFIG_DEBUG)
matter_add_gn_arg_bool("optimize_debug" true)
matter_add_gn_arg_string("optimize_debug_level" "0")
Expand Down
27 changes: 16 additions & 11 deletions examples/lighting-app/silabs/zephyr/boards/siwx917_rb4338a.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,27 @@
*/

&flash0 {
partitions {
factory_partition: partition@3e0000 {
reg = <0x003e0000 DT_SIZE_K(4)>;
};
partitions {
/*
* M4 free space ends at 0x400000 (start of SoC ota_swap_partition).
* code (1912) + factory (4) + settings (32) + storage (92) = 2040 KiB.
* Do not place app NVM inside ota_swap — that region is owned by the
* NWP/Security Bootloader for RPS firmware upgrade.
*/
factory_partition: partition@3e0000 {
reg = <0x003e0000 DT_SIZE_K(4)>;
};

settings_partition: partition@3e1000 {
reg = <0x003e1000 DT_SIZE_K(32)>;
};
};
settings_partition: partition@3e1000 {
reg = <0x003e1000 DT_SIZE_K(32)>;
};
};
};

&code_partition {
reg = <0x00202000 DT_SIZE_K(1912)>;
reg = <0x00202000 DT_SIZE_K(1912)>;
};


&storage_partition {
reg = <0x003e9000 DT_SIZE_K(92)>;
reg = <0x003e9000 DT_SIZE_K(92)>;
};
27 changes: 16 additions & 11 deletions examples/lighting-app/silabs/zephyr/boards/siwx917_rb4342a.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,27 @@
*/

&flash0 {
partitions {
factory_partition: partition@3e0000 {
reg = <0x003e0000 DT_SIZE_K(4)>;
};
partitions {
/*
* M4 free space ends at 0x400000 (start of SoC ota_swap_partition).
* code (1912) + factory (4) + settings (32) + storage (92) = 2040 KiB.
* Do not place app NVM inside ota_swap — that region is owned by the
* NWP/Security Bootloader for RPS firmware upgrade.
*/
factory_partition: partition@3e0000 {
reg = <0x003e0000 DT_SIZE_K(4)>;
};

settings_partition: partition@3e1000 {
reg = <0x003e1000 DT_SIZE_K(32)>;
};
};
settings_partition: partition@3e1000 {
reg = <0x003e1000 DT_SIZE_K(32)>;
};
};
};

&code_partition {
reg = <0x00202000 DT_SIZE_K(1912)>;
reg = <0x00202000 DT_SIZE_K(1912)>;
};


&storage_partition {
reg = <0x003e9000 DT_SIZE_K(92)>;
reg = <0x003e9000 DT_SIZE_K(92)>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
#include "app/clusters/ota-requestor/DefaultOTARequestorDriver.h"
#include "app/clusters/ota-requestor/DefaultOTARequestorStorage.h"

#if defined(CONFIG_SOC_SERIES_SIWG917)
#include <platform/silabs/zephyr/OTAImageProcessorImpl.h>
Comment thread
arun-silabs marked this conversation as resolved.
Outdated
#else
#include <platform/Zephyr/OTAImageProcessorImpl.h>
#endif

#include <stdint.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,17 @@

#include "OTARequestorInitiator.h"

#include <zephyr/dfu/mcuboot.h>
#include <zephyr/logging/log.h>
Comment thread
arun-silabs marked this conversation as resolved.
#if defined(CONFIG_SOC_SERIES_SIWG917)
Comment thread
arun-silabs marked this conversation as resolved.
Outdated

void chip::Zephyr::App::OTARequestorInitiator::HandleSelfTest()
{
// SiWx917 Security Bootloader installs the RPS from ota_swap on reboot.
// There is no MCUboot trial/confirm swap to finalize.
}

#else

using namespace chip;
#include <zephyr/dfu/mcuboot.h>

void chip::Zephyr::App::OTARequestorInitiator::HandleSelfTest()
Comment thread
coderabbitai[bot] marked this conversation as resolved.
{
Expand All @@ -38,3 +45,5 @@ void chip::Zephyr::App::OTARequestorInitiator::HandleSelfTest()
}
}
}

#endif // CONFIG_SOC_SERIES_SIWG917
12 changes: 8 additions & 4 deletions src/platform/Zephyr/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,14 @@ static_library("Zephyr") {
}

if (chip_enable_ota_requestor) {
sources += [
"OTAImageProcessorImpl.cpp",
"OTAImageProcessorImpl.h",
]
if (chip_zephyr_ota_image_processor != "") {
Comment thread
arun-silabs marked this conversation as resolved.
Outdated
deps += [ chip_zephyr_ota_image_processor ]
} else {
sources += [
"OTAImageProcessorImpl.cpp",
"OTAImageProcessorImpl.h",
]
}
deps += [ "${chip_root}/src/app/clusters/ota-requestor:interface" ]
}

Expand Down
2 changes: 1 addition & 1 deletion src/platform/Zephyr/OTAImageProcessorImpl.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024-2025 Project CHIP Authors
* Copyright (c) 2024-2026 Project CHIP Authors
Comment thread
arun-silabs marked this conversation as resolved.
Outdated
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
5 changes: 5 additions & 0 deletions src/platform/Zephyr/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ chip_device_platform = "zephyr"

declare_args() {
chip_malloc_sys_heap = false

# Optional GN label for an alternate OTA image processor source_set.
# Empty uses the built-in Zephyr MCUboot OTAImageProcessorImpl.
# Platform integrations may set this from CMake to supply their own processor.
chip_zephyr_ota_image_processor = ""
}
30 changes: 30 additions & 0 deletions src/platform/silabs/zephyr/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (c) 2026 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build_overrides/chip.gni")

# SiWx917 RPS Matter OTA image processor.
# Selected via chip_zephyr_ota_image_processor from Silabs CMake.
source_set("ota-image-processor") {
sources = [
"OTAImageProcessorImpl.cpp",
"OTAImageProcessorImpl.h",
]

public_deps = [ "${chip_root}/src/platform:platform_base" ]

deps = [ "${chip_root}/src/app/clusters/ota-requestor:interface" ]

cflags = [ "-Wconversion" ]
}
Loading
Loading