-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add a sample that demonstrates use of UICR.SECONDARY.TRIGGER #25002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6e30c13
manifest: update zephyr
SebastianBoe ca2402b
ci: tags: run ci_samples_sdfw on nrf/samples/ironside_se changes
SebastianBoe e0f6af5
samples: ironside_se: secondary_boot_gen_uicr: Minor doc/yaml fixes
SebastianBoe 03d7630
ironside: Add a sample that uses UICR.SECONDARY.TRIGGER
SebastianBoe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
samples/ironside_se/secondary_boot_trigger_lockup/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright (c) 2025 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
|
||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(secondary_boot_trigger_lockup) | ||
|
||
# Source files | ||
target_sources(app PRIVATE src/main.c) |
109 changes: 109 additions & 0 deletions
109
samples/ironside_se/secondary_boot_trigger_lockup/README.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
.. _secondary_boot_trigger_lockup_sample: | ||
|
||
Secondary boot with APPLICATIONLOCKUP trigger | ||
############################################## | ||
|
||
.. contents:: | ||
:local: | ||
:depth: 2 | ||
|
||
This sample demonstrates an automatic secondary boot triggered by a lockup of the application core CPU on the nRF54H20 DK. | ||
When the primary application triggers a CPU lockup, IronSide SE automatically boots the secondary image without requiring any application-level software intervention. | ||
|
||
Requirements | ||
************ | ||
|
||
The sample supports the following development kit: | ||
|
||
.. table-from-sample-yaml:: | ||
|
||
Overview | ||
******** | ||
|
||
The sample consists of two applications: | ||
|
||
* *Primary Image*: Runs initially on the application core (``cpuapp``), prints status messages, and deliberately triggers a CPU lockup by disabling fault exceptions and then causing a fault. | ||
* *Secondary Image*: Automatically boots after the lockup is detected and runs continuously. | ||
|
||
The UICR.SECONDARY.TRIGGER.APPLICATIONLOCKUP configuration causes IronSide SE to automatically boot the secondary image when a CPU lockup is detected. | ||
|
||
Configuration | ||
************* | ||
|
||
The sample uses the following UICR configuration in the :file:`sysbuild/uicr.conf` file: | ||
|
||
.. code-block:: kconfig | ||
|
||
CONFIG_GEN_UICR_SECONDARY=y | ||
CONFIG_GEN_UICR_SECONDARY_TRIGGER=y | ||
CONFIG_GEN_UICR_SECONDARY_TRIGGER_APPLICATIONLOCKUP=y | ||
|
||
This enables automatic secondary boot when the application core experiences a CPU lockup. | ||
|
||
For more information about secondary firmware configuration and other available triggers, see :ref:`ug_nrf54h20_ironside_se_secondary_firmware`. | ||
|
||
Building and running | ||
******************** | ||
|
||
.. |sample path| replace:: :file:`samples/ironside_se/secondary_boot_trigger_lockup` | ||
|
||
.. include:: /includes/build_and_run_ns.txt | ||
|
||
To build the sample for the nRF54H20 DK, run the following command: | ||
|
||
.. code-block:: console | ||
|
||
west build -b nrf54h20dk/nrf54h20/cpuapp samples/ironside_se/secondary_boot_trigger_lockup | ||
|
||
To program the sample on the device, run the following command: | ||
|
||
.. code-block:: console | ||
|
||
west flash | ||
|
||
Testing | ||
******* | ||
|
||
After programming the sample to your development kit, complete the following steps to test it: | ||
|
||
1. |connect_terminal| | ||
#. Reset the kit. | ||
#. Observe in the console output the primary image startup and lockup trigger: | ||
|
||
.. code-block:: console | ||
|
||
=== Primary Image: Demonstrating APPLICATIONLOCKUP trigger === | ||
This image will intentionally trigger a CPU lockup. | ||
The UICR.SECONDARY.TRIGGER.APPLICATIONLOCKUP configuration will | ||
automatically boot the secondary image. | ||
|
||
Triggering CPU lockup now! | ||
Step 1: Disabling fault exceptions and then accessing invalid memory... | ||
|
||
#. Observe in the console output that the system automatically reboots into the secondary image: | ||
|
||
.. code-block:: console | ||
|
||
=== Secondary Image: Successfully booted! === | ||
The system automatically booted the secondary image due to | ||
APPLICATION LOCKUP in the primary image. | ||
|
||
This demonstrates UICR.SECONDARY.TRIGGER.APPLICATIONLOCKUP | ||
automatic failover capability. | ||
|
||
Secondary image heartbeat - system is stable | ||
Secondary image heartbeat - system is stable | ||
... | ||
|
||
Dependencies | ||
************ | ||
|
||
This sample uses the following |NCS| subsystems: | ||
|
||
* Sysbuild - Enables building multiple images in a single build process | ||
* UICR generation - Configures the User Information Configuration Registers for automatic secondary boot on lockup | ||
|
||
In addition, it uses the following Zephyr subsystems: | ||
|
||
* :ref:`Kernel <kernel>` - Provides basic system functionality and threading | ||
* :ref:`Console <console>` - Enables UART console output for debugging and user interaction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# | ||
# Copyright (c) 2025 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
# | ||
|
||
# This file is intentionally left empty |
26 changes: 26 additions & 0 deletions
26
samples/ironside_se/secondary_boot_trigger_lockup/sample.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
sample: | ||
name: Secondary Boot APPLICATIONLOCKUP Trigger Sample | ||
description: | | ||
Sample demonstrating automatic secondary boot triggered by APPLICATIONLOCKUP | ||
on nRF54H20DK. The primary image deliberately triggers a CPU lockup, and the | ||
UICR.SECONDARY.TRIGGER.APPLICATIONLOCKUP configuration causes IronSide SE to | ||
automatically boot the secondary image. | ||
|
||
common: | ||
sysbuild: true | ||
harness: console | ||
harness_config: | ||
type: multi_line | ||
regex: | ||
- "=== Primary Image: Demonstrating APPLICATIONLOCKUP trigger ===" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it needed specific order of the lines? |
||
- "=== Secondary Image: Successfully booted! ===" | ||
|
||
tests: | ||
samples.secondary_boot_trigger_lockup.nrf54h20dk: | ||
tags: | ||
- sysbuild | ||
- ci_samples_sdfw | ||
platform_allow: | ||
- nrf54h20dk/nrf54h20/cpuapp | ||
integration_platforms: | ||
- nrf54h20dk/nrf54h20/cpuapp |
9 changes: 9 additions & 0 deletions
9
samples/ironside_se/secondary_boot_trigger_lockup/secondary/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Copyright (c) 2025 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
|
||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(secondary_image) | ||
|
||
target_sources(app PRIVATE src/main.c) |
11 changes: 11 additions & 0 deletions
11
samples/ironside_se/secondary_boot_trigger_lockup/secondary/app.overlay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* Copyright (c) 2025 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
/ { | ||
chosen { | ||
zephyr,code-partition = &secondary_partition; | ||
}; | ||
}; |
12 changes: 12 additions & 0 deletions
12
samples/ironside_se/secondary_boot_trigger_lockup/secondary/prj.conf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# | ||
# Copyright (c) 2025 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
# | ||
|
||
CONFIG_IS_IRONSIDE_SE_SECONDARY_IMAGE=y | ||
|
||
# Use the devicetree chosen code-partition to determine flash load offset | ||
CONFIG_USE_DT_CODE_PARTITION=y | ||
|
||
# NB: app.overlay sets zephyr,code-partition to secondary_partition |
25 changes: 25 additions & 0 deletions
25
samples/ironside_se/secondary_boot_trigger_lockup/secondary/src/main.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) 2025 Nordic Semiconductor ASA. | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/sys/printk.h> | ||
|
||
int main(void) | ||
{ | ||
printk("\n=== Secondary Image: Successfully booted! ===\n"); | ||
printk("The system automatically booted the secondary image due to\n"); | ||
printk("APPLICATION LOCKUP in the primary image.\n"); | ||
printk("\nThis demonstrates UICR.SECONDARY.TRIGGER.APPLICATIONLOCKUP\n"); | ||
printk("automatic failover capability.\n"); | ||
|
||
/* Secondary firmware runs continuously */ | ||
while (1) { | ||
k_msleep(5000); | ||
printk("Secondary image heartbeat - system is stable\n"); | ||
} | ||
|
||
return 0; | ||
} |
32 changes: 32 additions & 0 deletions
32
samples/ironside_se/secondary_boot_trigger_lockup/src/main.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2025 Nordic Semiconductor ASA. | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/sys/printk.h> | ||
|
||
int main(void) | ||
{ | ||
printk("=== Primary Image: Demonstrating APPLICATIONLOCKUP trigger ===\n"); | ||
printk("This image will intentionally trigger a CPU lockup.\n"); | ||
printk("The UICR.SECONDARY.TRIGGER.APPLICATIONLOCKUP configuration will\n"); | ||
printk("automatically boot the secondary image.\n"); | ||
printk("\nTriggering CPU lockup now!\n"); | ||
printk("Step 1: Disabling fault exceptions and then accessing invalid memory...\n"); | ||
|
||
/* Set FAULTMASK to disable all exceptions except NMI. | ||
* Then trigger a fault - since faults are disabled, this causes lockup. | ||
* Any fault (unaligned access, invalid memory, etc.) will trigger lockup. | ||
*/ | ||
__asm volatile("cpsid f" ::: "memory"); | ||
|
||
/* Trigger fault by accessing invalid memory */ | ||
*(volatile uint32_t *)0xFFFFFFFF = 0xDEADBEEF; | ||
|
||
/* This line will never be reached */ | ||
printk("ERROR: Should have triggered lockup!\n"); | ||
|
||
return 0; | ||
} |
7 changes: 7 additions & 0 deletions
7
samples/ironside_se/secondary_boot_trigger_lockup/sysbuild.cmake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Copyright (c) 2025 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
|
||
ExternalZephyrProject_Add( | ||
hakonfam marked this conversation as resolved.
Show resolved
Hide resolved
|
||
APPLICATION secondary | ||
SOURCE_DIR ${APP_DIR}/secondary | ||
) |
8 changes: 8 additions & 0 deletions
8
samples/ironside_se/secondary_boot_trigger_lockup/sysbuild/uicr.conf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Copyright (c) 2025 Nordic Semiconductor ASA | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
|
||
# Configuration overlay for uicr image | ||
# Enable UICR.SECONDARY with automatic trigger on APPLICATIONLOCKUP | ||
CONFIG_GEN_UICR_SECONDARY=y | ||
CONFIG_GEN_UICR_SECONDARY_TRIGGER=y | ||
CONFIG_GEN_UICR_SECONDARY_TRIGGER_APPLICATIONLOCKUP=y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.