Skip to content

[Zephyr] Silabs Zephyr OTA Support#72696

Closed
malbert-silabs wants to merge 3 commits into
project-chip:masterfrom
malbert-silabs:zephyr-ota-v1
Closed

[Zephyr] Silabs Zephyr OTA Support#72696
malbert-silabs wants to merge 3 commits into
project-chip:masterfrom
malbert-silabs:zephyr-ota-v1

Conversation

@malbert-silabs

Copy link
Copy Markdown
Contributor

Summary

Implements Zephyr OTA support to the Silabs Zephyr Lighting app.
Specifically tested for MG24, but other Silabs platforms should work with minimal modifications to their configs or overlays.
Changes in src/platform/Zephyr were due to the use of deprecated APIs
This implementation on the 4187C uses external flash to store the OTA image.

Related issues

N/A

Testing

Tested 2 subsequent OTAs on 4187C. (Initial flash using commander for v1 -> OTA to v2 -> OTA to v3)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements Matter Over-The-Air (OTA) software update support for Silicon Labs Zephyr targets using MCUboot, introducing post-build CMake scripts, configuration overlays, and board-specific partition layouts. Feedback on these changes focuses on improving build portability by replacing platform-specific commands like 'cp' and 'dd' with portable alternatives, resolving the configured signing key path dynamically, explicitly defining storage partitions in device tree overlays to prevent potential flash corruption, reverting unrelated changes in NXP platform files, and correcting a duplicate step number in the README.

I am having trouble creating individual review comments. Click here to see my feedback.

examples/platform/nxp/common/ota_requestor/source/OTARequestorInitiatorCommon.cpp (30)

medium

This PR implements Zephyr OTA support for Silabs. Modifying NXP platform files to remove comments seems unrelated and should be reverted to avoid unnecessary changes in other platforms' code.

    // Set the global instance of the OTA requestor core component
References
  1. When performing code moves, avoid introducing unrelated changes, refactorings, or fixes. Such modifications should be deferred to subsequent pull requests to maintain a clear and focused review process.

config/silabs/app/zephyr-post-build.cmake (41-42)

medium

The signing key path is hardcoded to "${ZEPHYR_BASE}/../bootloader/mcuboot/root-ec-p256.pem", which ignores any custom key file configured via CONFIG_MCUBOOT_SIGNATURE_KEY_FILE. It should resolve CONFIG_MCUBOOT_SIGNATURE_KEY_FILE to an absolute path instead.

    if(IS_ABSOLUTE "${CONFIG_MCUBOOT_SIGNATURE_KEY_FILE}")
        set(MCUBOOT_SIGNING_KEY "${CONFIG_MCUBOOT_SIGNATURE_KEY_FILE}")
    else()
        get_filename_component(MCUBOOT_SIGNING_KEY
            "${ZEPHYR_BASE}/../${CONFIG_MCUBOOT_SIGNATURE_KEY_FILE}" ABSOLUTE)
    endif()

config/silabs/app/zephyr-post-build.cmake (54-55)

medium

Using cp is Unix-specific and will fail on Windows build hosts. Use cmake -E copy instead for a platform-independent file copy.

        COMMAND
        ${CMAKE_COMMAND} -E copy ${ZEPHYR_OUTPUT_DIR}/../build_mcuboot/zephyr/zephyr.bin ${ZEPHYR_OUTPUT_DIR}/zephyr.mcuboot.bin

config/silabs/app/zephyr-post-build.cmake (59-69)

medium

Using dd for merging binaries makes the build non-portable and will fail on Windows development hosts. Since Python is guaranteed to be available in a Zephyr environment, you can use a portable Python command to merge the bootloader and application binaries. This also allows you to seek directly to ${mcuboot_size} (which is already in bytes), eliminating the need for BLOCK_SIZE and boot_blocks math.

    dt_nodelabel(dts_partition_path NODELABEL "boot_partition")
    dt_reg_size(mcuboot_size PATH ${dts_partition_path})

    add_custom_command(
        OUTPUT ${ZEPHYR_OUTPUT_DIR}/zephyr_full.bin
        DEPENDS build_mcuboot ${ZEPHYR_OUTPUT_DIR}/${ZEPHYR_OUTPUT_NAME}.bin
        COMMAND ${PYTHON_EXECUTABLE} -c "import sys; f = open(sys.argv[1], 'wb'); f.write(open(sys.argv[2], 'rb').read()); f.seek(int(sys.argv[3])); f.write(open(sys.argv[4], 'rb').read()); f.close()"
            ${ZEPHYR_OUTPUT_DIR}/zephyr_full.bin
            ${ZEPHYR_OUTPUT_DIR}/zephyr.mcuboot.bin
            ${mcuboot_size}
            ${ZEPHYR_OUTPUT_DIR}/${ZEPHYR_OUTPUT_NAME}.bin
    )

examples/lighting-app/silabs/zephyr/boards/xg24_rb4187c.overlay (27-33)

medium

The settings_partition and storage_partition have been removed from the overlay. Matter typically requires a larger storage partition (e.g., 40 KB) for NVS to store fabric and security credentials safely without running out of space. Relying on the board's default partition layout can lead to insufficient space or unexpected overlaps with the new slot0_partition and factory_partition boundaries. It is highly recommended to explicitly define the storage_partition (and/or settings_partition) in this overlay.

examples/lighting-app/silabs/zephyr/boards/xg26_rb4118a.overlay (23-34)

medium

The storage_partition (used for Matter NVS persistent storage) is not explicitly defined or relocated in this overlay. Since slot0_partition, slot1_partition, and factory_partition have been resized and shifted, the board's default storage_partition location might now overlap with these partitions, leading to silent flash corruption at runtime. It is highly recommended to explicitly define and place the storage_partition at a safe, non-overlapping offset (e.g., starting at 0x318000 after the factory_partition).

examples/lighting-app/silabs/zephyr/README.md (340)

medium

There is a duplicate step number 3. in the list. This step should be numbered 4., and the subsequent steps should be incremented accordingly.

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.76%. Comparing base (10dc250) to head (31afbb9).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #72696      +/-   ##
==========================================
+ Coverage   56.74%   56.76%   +0.01%     
==========================================
  Files        1630     1634       +4     
  Lines      112290   112660     +370     
  Branches    13114    13143      +29     
==========================================
+ Hits        63719    63948     +229     
- Misses      48571    48712     +141     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown

PR #72696: Size comparison from 44fb474 to 31afbb9

Full report (41 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, psoc6, qpg, realtek, stm32, telink)
platform target config section 44fb474 31afbb9 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1098674 1098674 0 0.0
RAM 133418 133418 0 0.0
bl702 lighting-app bl702+eth FLASH 1085226 1085226 0 0.0
RAM 109029 109029 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 882208 882208 0 0.0
RAM 108596 108596 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 777352 777352 0 0.0
RAM 103404 103404 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 790096 790096 0 0.0
RAM 108684 108684 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 739368 739368 0 0.0
RAM 97612 97612 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 719540 719540 0 0.0
RAM 97644 97644 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 569646 569646 0 0.0
RAM 205112 205112 0 0.0
lock CC3235SF_LAUNCHXL FLASH 597198 597198 0 0.0
RAM 205272 205272 0 0.0
efr32 lighting-app BRD4187C FLASH 1094924 1094924 0 0.0
RAM 135256 135256 0 0.0
lock-app BRD4187C FLASH 994816 994816 0 0.0
RAM 131292 131292 0 0.0
BRD4338a FLASH 799793 799793 0 0.0
RAM 243432 243432 0 0.0
esp32 all-clusters-app c3devkit DRAM 99884 99884 0 0.0
FLASH 1626700 1626700 0 0.0
IRAM 94776 94776 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 842960 842960 0 0.0
RAM 157755 157755 0 0.0
nrf54l15dk_nrf54l15_cpuapp FLASH 958460 958460 0 0.0
RAM 159143 159143 0 0.0
light-switch-app nrf52840dk_nrf52840 FLASH 784932 784932 0 0.0
RAM 122575 122575 0 0.0
lighting-app nrf52840dk_nrf52840+rpc FLASH 843036 843036 0 0.0
RAM 137847 137847 0 0.0
nrf52840dongle_nrf52840 FLASH 783044 783044 0 0.0
RAM 143785 143785 0 0.0
nrf54l15dk_nrf54l15_cpuapp FLASH 819484 819484 0 0.0
RAM 136959 136959 0 0.0
lock-app nrf52840dk_nrf52840 FLASH 769656 769656 0 0.0
RAM 122360 122360 0 0.0
nrf54l15dk_nrf54l15_cpuapp FLASH 783196 783196 0 0.0
RAM 123594 123594 0 0.0
shell nrf52840dk_nrf52840 FLASH 511512 511512 0 0.0
RAM 110450 110450 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1749140 1749140 0 0.0
RAM 215476 215476 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1626532 1626532 0 0.0
RAM 211604 211604 0 0.0
light cy8ckit_062s2_43012 FLASH 1470844 1470844 0 0.0
RAM 197436 197436 0 0.0
lock cy8ckit_062s2_43012 FLASH 1504292 1504292 0 0.0
RAM 225268 225268 0 0.0
qpg lighting-app qpg6200+debug FLASH 843076 843076 0 0.0
RAM 127908 127908 0 0.0
lock-app qpg6200+debug FLASH 782960 782960 0 0.0
RAM 118840 118840 0 0.0
realtek light-switch-app rtl8777g FLASH 689344 689344 0 0.0
RAM 101780 101780 0 0.0
lighting-app rtl8777g FLASH 730288 730288 0 0.0
RAM 102052 102052 0 0.0
stm32 light STM32WB5MM-DK FLASH 478968 478968 0 0.0
RAM 141492 141492 0 0.0
telink all-devices-app tl7218x FLASH 849046 849046 0 0.0
RAM 99036 99036 0 0.0
tlsr9118bdk40d FLASH 640646 640646 0 0.0
RAM 120168 120168 0 0.0
bridge-app tl7218x FLASH 734126 734126 0 0.0
RAM 97700 97700 0 0.0
light-app-ota-compress-lzma-factory-data tl3218x FLASH 800656 800656 0 0.0
RAM 42380 42380 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl7218x FLASH 845796 845796 0 0.0
RAM 101492 101492 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 734616 734616 0 0.0
RAM 57816 57816 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 795678 795678 0 0.0
RAM 75176 75176 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 734532 734532 0 0.0
RAM 34472 34472 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 615188 615188 0 0.0
RAM 118508 118508 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 841744 841748 4 0.0
RAM 97376 97376 0 0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant