-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
samples: suit: add flash companion application
The flash companion serves as a proxy for the secure domain firmware on nRF54H20 devices, allowing the SUIT firmware upgrade process to access data on the external memory devices. Signed-off-by: Rafał Kuźnia <[email protected]>
- Loading branch information
Showing
13 changed files
with
299 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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 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 @@ | ||
.. _suit_samples: | ||
|
||
SUIT samples | ||
############ | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:caption: Subpages | ||
:glob: | ||
|
||
../../../samples/suit/*/README |
This file contains 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) 2024 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(flash_companion) | ||
|
||
target_sources(app PRIVATE src/main.c) |
This file contains 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,118 @@ | ||
:orphan: | ||
|
||
.. _suit_flash_companion: | ||
|
||
SUIT flash companion | ||
#################### | ||
|
||
.. contents:: | ||
:local: | ||
:depth: 2 | ||
|
||
The SUIT flash companion sample allows the Secure Domain Firmware to access the external memory during the :ref:`Software Updates for Internet of Things (SUIT) <ug_nrf54h20_suit_dfu>` firmware upgrade. | ||
|
||
Requirements | ||
************ | ||
|
||
The sample supports the following development kit: | ||
|
||
.. table-from-rows:: /includes/sample_board_rows.txt | ||
:header: heading | ||
:rows: nrf54h20dk_nrf54h20_cpuapp | ||
|
||
Overview | ||
******** | ||
|
||
The flash companion sample implements a device driver for the external flash device and provides an IPC service to the Secure Domain Firmware. | ||
The Secure Domain Firmware uses the IPC service to read, erase, or write data to the external memory. | ||
|
||
The sample is meant to be booted by the Secure Domain while performing the firmware update process using the :ref:`SUIT <ug_nrf54h20_suit_dfu>` firmware upgrade. | ||
|
||
The flash companion sample is not a stand-alone firmware, it is intended to be used with the ``nrf54h_suit_sample`` to complete a firmware transfer with external flash. | ||
|
||
Configuration | ||
************* | ||
|
||
|config| | ||
|
||
Setup | ||
===== | ||
|
||
You can build the sample using Sysbuild by enabling the :kconfig:option:`SB_CONFIG_SUIT_BUILD_FLASH_COMPANION` Kconfig option. | ||
The memory partition from which the firmware will run can be configured by providing a devicetree overlay through Sysbuild. | ||
You should create a dedicated partition in non-volatile memory and override the ``zephyr,code-partition``. | ||
The memory partition must not be used by any other firmware image. | ||
|
||
The sample is booted during the SUIT firmware upgrade process. | ||
See the :ref:`ug_nrf54h20_suit_external_memory` user guide to learn how to setup your sample to boot and use the flash companion's services during firmware upgrade. | ||
|
||
Configuration options | ||
===================== | ||
|
||
Check and configure the following configuration option: | ||
|
||
.. _SB_CONFIG_SUIT_BUILD_FLASH_COMPANION: | ||
|
||
SB_CONFIG_SUIT_BUILD_FLASH_COMPANION - Configuration for the firmware | ||
This option enables the sample and builds it during the Sysbuild. | ||
|
||
Building and running | ||
******************** | ||
|
||
The flash companion sample is not a stand-alone firmware. | ||
To build it, open a different sample or application, such as :file:`samples/suit/smp_transfer`. | ||
Make sure that both the main application and the flash companion support your target platform. | ||
|
||
Perform the following steps in the main application directory: | ||
|
||
1. Enable the :kconfig:option:`SB_CONFIG_SUIT_BUILD_FLASH_COMPANION` Sysbuild option. | ||
|
||
#. Create :file:`sysbuild/flash_companion.overlay` devicetree overlay file and add the following content: | ||
|
||
a. Create a dedicated partition in non-volatile memory: | ||
|
||
.. code-block:: devicetree | ||
&cpuapp_rx_partitions { | ||
cpuapp_slot0_partition: partition@a6000 { | ||
reg = <0xa6000 DT_SIZE_K(448)>; | ||
}; | ||
companion_partition: partition@116000 { | ||
reg = <0x116000 DT_SIZE_K(64)>; | ||
}; | ||
}; | ||
In the above example the executable memory partition of the main application (``cpuapp_slot0_partition``) is shrunk to make space for the flash companion executable memory partition (``companion_partition``). | ||
|
||
#. Apply the same memory partition configuration to the main application's devicetree overlay. | ||
|
||
#. Enable SPI NOR devicetree node. | ||
In the case of nRF54H20 DK, you can enable the following node: | ||
|
||
.. code-block:: devicetree | ||
&mx25uw63 { | ||
status = "okay"; | ||
}; | ||
#. Build the main application: | ||
|
||
.. code-block:: console | ||
$ west build -b nrf54h20dk/nrf54h20/cpuapp --sysbuild | ||
The flash companion sample will be built automatically by Sysbuild. | ||
|
||
Dependencies | ||
************ | ||
|
||
This sample uses the following |NCS| libraries: | ||
|
||
* :file:`include/sdfw_services/ssf_client.h` | ||
* `zcbor`_ | ||
|
||
It uses the following Zephyr library: | ||
|
||
* :ref:`zephyr:flash_api` | ||
|
||
The sample also uses drivers from `nrfx`_. |
27 changes: 27 additions & 0 deletions
27
samples/suit/flash_companion/boards/nrf54h20dk_nrf54h20_cpuapp.overlay
This file contains 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,27 @@ | ||
/* | ||
* Copyright (c) 2024 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
/ { | ||
chosen { | ||
extmem-device = &mx25uw63; | ||
}; | ||
}; | ||
|
||
&cpusec_cpuapp_ipc { | ||
status = "okay"; | ||
}; | ||
|
||
&cpusec_bellboard { | ||
status = "okay"; | ||
}; | ||
|
||
&cpuapp_bellboard { | ||
status = "okay"; | ||
}; | ||
|
||
&mx25uw63 { | ||
status = "okay"; | ||
}; |
This file contains 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,59 @@ | ||
# | ||
# Copyright (c) 2024 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
# | ||
|
||
# Minimal scheduler configuration | ||
CONFIG_NUM_PREEMPT_PRIORITIES=0 | ||
CONFIG_MULTITHREADING=y | ||
CONFIG_NUM_COOP_PRIORITIES=16 | ||
CONFIG_NUM_METAIRQ_PRIORITIES=0 | ||
CONFIG_SCHED_DUMB=y | ||
CONFIG_WAITQ_DUMB=y | ||
|
||
# Enable peripherals needed by the flash companion firmware | ||
CONFIG_GPIO=y | ||
CONFIG_PINCTRL=y | ||
CONFIG_FLASH=y | ||
|
||
# Disable power management | ||
CONFIG_PM=n | ||
|
||
# Disable unneeded interrupt features | ||
CONFIG_DYNAMIC_INTERRUPTS=n | ||
CONFIG_IRQ_OFFLOAD=n | ||
|
||
# Disable memory protection | ||
CONFIG_THREAD_STACK_INFO=n | ||
CONFIG_THREAD_CUSTOM_DATA=n | ||
|
||
# Disable unneeded ARM core functionality | ||
CONFIG_ARM_MPU=n | ||
CONFIG_FPU=n | ||
|
||
# Disable boot banner | ||
CONFIG_BOOT_BANNER=n | ||
CONFIG_BOOT_DELAY=0 | ||
|
||
# Disable serial communication | ||
CONFIG_CONSOLE=n | ||
CONFIG_UART_CONSOLE=n | ||
CONFIG_STDOUT_CONSOLE=n | ||
CONFIG_PRINTK=n | ||
CONFIG_EARLY_CONSOLE=n | ||
|
||
# Build | ||
CONFIG_SIZE_OPTIMIZATIONS=y | ||
|
||
# Enable external memory service | ||
CONFIG_SSF_EXTMEM_SERVICE_ENABLED=y | ||
|
||
# Link against zephyr,code-partition | ||
CONFIG_USE_DT_CODE_PARTITION=y | ||
|
||
CONFIG_SUIT_LOCAL_ENVELOPE_GENERATE=n | ||
CONFIG_NRF_REGTOOL_GENERATE_UICR=n | ||
|
||
# Enable canonical zcbor encoding | ||
CONFIG_ZCBOR_CANONICAL=y |
This file contains 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,14 @@ | ||
/* | ||
* Copyright (c) 2024 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <sdfw/sdfw_services/extmem_remote.h> | ||
|
||
int main(void) | ||
{ | ||
extmem_remote_init(); | ||
return 0; | ||
} |
This file contains 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 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 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 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 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) 2024 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
# | ||
|
||
if(SB_CONFIG_SUIT_BUILD_FLASH_COMPANION) | ||
# Calculate the network board target | ||
string(REPLACE "/" ";" split_board_qualifiers "${BOARD_QUALIFIERS}") | ||
list(GET split_board_qualifiers 1 target_soc) | ||
list(GET split_board_qualifiers 2 target_cpucluster) | ||
|
||
if(DEFINED BOARD_REVISION) | ||
set(board_target "${BOARD}@${BOARD_REVISION}/${target_soc}/${SB_CONFIG_FLASH_COMPANION_TARGET_CPUCLUSTER}") | ||
else() | ||
set(board_target "${BOARD}/${target_soc}/${SB_CONFIG_FLASH_COMPANION_TARGET_CPUCLUSTER}") | ||
endif() | ||
|
||
ExternalZephyrProject_Add( | ||
APPLICATION flash_companion | ||
SOURCE_DIR "${ZEPHYR_NRF_MODULE_DIR}/samples/suit/flash_companion" | ||
BOARD ${board_target} | ||
BUILD_ONLY TRUE | ||
) | ||
endif() |