Skip to content

Conversation

@hakonfam
Copy link
Contributor

@hakonfam hakonfam commented Dec 6, 2025

See commit message for details on how to test.

@NordicBuilder NordicBuilder added the changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. label Dec 6, 2025
@NordicBuilder
Copy link
Contributor

NordicBuilder commented Dec 6, 2025

CI Information

To view the history of this post, click the 'edited' button above
Build number: 6

Inputs:

Sources:

more details

Github labels

Enabled Name Description
ci-disabled Disable the ci execution
ci-all-test Run all of ci, no test spec filtering will be done
ci-force-downstream Force execution of downstream even if twister fails
ci-run-twister Force run twister
ci-run-zephyr-twister Force run zephyr twister
List of changed files detected by CI (0)

Outputs:

Toolchain

Version:
Build docker image:

Test Spec & Results: ✅ Success; ❌ Failure; 🟠 Queued; 🟡 Progress; ◻️ Skipped; ⚠️ Quarantine

  • ◻️ Toolchain
  • ◻️ Build twister
  • ◻️ Integration tests

Note: This message is automatically posted and updated by the CI

@hakonfam hakonfam added the CI-disable Disable CI for this PR label Dec 6, 2025
@hakonfam hakonfam force-pushed the pc-xip branch 3 times, most recently from e6490c2 to fd0f086 Compare December 10, 2025 14:24
Demonstrate how to update the PERIPHCONF blob pointed to by
UICR.PERIPHCONF in a system where Direct XIP is used.

The application firmware is executed from one of two slots when Direct
XIP is in use, this means that the global PERIPHCONF blob contained in
the periphconf partition needs to be updated by the application firmware
if it has to be updated.

Firstly, we integrate the PERIPHCONF blob of each image within the
firmware of the image. This way its contents is covered by the signature
validation performed by MCUBoot, and any updates to the PERIPHCONF is
contained within the firmware itself.

Next, we add a function that is executed in SYS_INIT(EARLY), that is
before any device driver setup is done, which ensures that the global
PERIPHCONF matches the local one contained in the image firmware. If it
does not match, the global PERIPHCONF is updated from the point of the
first mismatch.

We also add a mechanism showing how to re-order the PERIPHCONF so that
the entries from MCUBoot are first. This is done to ensure that MCUBoot
is not affected by any updates to the global PERIPHCONF, and that the
system is power-failure safe during an update to the global PERIPHCONF.

Some comments on the changes introduced in this commit:
- The swap snippet simply swaps which UART is used for an image
- We re-use an existing application
  (tests/subsys/bootloader/upgrade/ref_smp_svr/CMakeLists.txt)
  and create a CMake parameter 'PERIPHCONF_BIN' that is used to pass
  local PERIPHCONF to the image firmware. When this is set, the lib
  for copying the local PERIPHCONF to the global one is included.
- The copy lib does not use any driver as that code is not available
  at the time of execution (SYS_INIT(EARLY)).
- Add build configurations for this application to make build
  commands more understandable.
- The rest of the commit are helper scripts to create the new
  PERIPHCONF blob and verify the functionality.

The steps to build and verify the changes are:

 # cd to the test application
cd $(west topdir)/nrf/tests/subsys/bootloader/upgrade/ref_smp_svr

 # Build the sample and generate all required artifacts
./move_mcuboot_periphconf_first.sh

 # Program the initial firmware
west flash --build-dir build_no_mcuboot_uart --recover

 # Program the updated periphconf which has MCUBoot entries first
nrfutil device program  --firmware build_no_mcuboot_uart/periphconf_final.hex \
--options chip_erase_mode=ERASE_NONE

 # Reset and verify that app works as expected
nrfutil device reset --reset-kind RESET_PIN --traits jlink

 # Close any UART connection at this point, otherwise next step will fail

 # Upload the update (takes some minutes)
mcumgr --conntype serial --connstring "/dev/ttyACM0,baud=115200" image upload \
build_swapped_uart_v2/zephyr_secondary_app.signed.bin

 # Open UART to see logs, then trigger a reset
nrfutil device reset --reset-kind RESET_PIN --traits jlink

Signed-off-by: Håkon Amundsen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. CI-disable Disable CI for this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants