Skip to content

Commit e411ad5

Browse files
annwojnordicjm
authored andcommitted
doc: mcuboot signing app with flpr payload
added a new article. reordered the index page. Signed-off-by: Anna Wojdylo <[email protected]>
1 parent f38b454 commit e411ad5

File tree

3 files changed

+257
-7
lines changed

3 files changed

+257
-7
lines changed

doc/nrf/app_dev/device_guides/nrf54l/index.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ Zephyr and the |NCS| provide support and contain board definitions for developin
2626
| `User Guide <nRF54L15 DK User Guide_>`_
2727
- | `nRF54L15 DK product page <nRF54L15 DK_>`_
2828
| `nRF54L15 System-on-Chip (SoC) <nRF54L05_>`_
29-
* - nRF54L05 emulation on the nRF54L15 DK
30-
- PCA10156
31-
- ``nrf54l15dk/nrf54l05/cpuapp``
32-
- | `Datasheet <nRF54L15 Datasheet_>`_
33-
- | `nRF54L05 System-on-Chip (SoC) <nRF54L15 System-on-Chip_>`_
3429
* - nRF54L10 emulation on the nRF54L15 DK
3530
- PCA10156
3631
- ``nrf54l15dk/nrf54l10/cpuapp``
3732
- | `Datasheet <nRF54L15 Datasheet_>`_
3833
- | `nRF54L10 System-on-Chip (SoC) <nRF54L10_>`_
34+
* - nRF54L05 emulation on the nRF54L15 DK
35+
- PCA10156
36+
- ``nrf54l15dk/nrf54l05/cpuapp``
37+
- | `Datasheet <nRF54L15 Datasheet_>`_
38+
- | `nRF54L05 System-on-Chip (SoC) <nRF54L15 System-on-Chip_>`_
3939

4040
.. _ug_nrf54L15_revision:
4141

@@ -64,8 +64,9 @@ Ensure to check the revision of your nRF54L15 device to see if it is supported:
6464
features
6565
zms
6666
cryptography
67-
fota_update
68-
kmu_provision
6967
testing_dfu
7068
vpr_flpr
7169
building_nrf54l
70+
nrf54l_signing_with_payload
71+
fota_update
72+
kmu_provision
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
.. _nRF54l_signing_app_with_flpr_payload:
2+
3+
Signing applications with integrated FLPR payload
4+
#################################################
5+
6+
.. contents::
7+
:local:
8+
:depth: 2
9+
10+
The nRF54L SoCs include a FLPR CPU designed to handle fast communication with external devices independently, enhancing flexibility in protocol implementation.
11+
For details, see :ref:`vpr_flpr_nrf54l`.
12+
13+
You can dynamically load and modify the FLPR code during runtime.
14+
This guide describes how to build the application and FLPR cores, creating a single file, signed and managed by MCUboot, with FLPR integrated and executable from the application slot.
15+
16+
Requirements and limitations
17+
****************************
18+
19+
MCUboot requires the application and the FLPR application to be concatenated and signed together to treat them as a single image.
20+
To do this, you have to build the main application (CPUAPP application) and the FLPR application separately, manually merge them, and sign them for MCUboot.
21+
22+
In addition to these requirements, there are also limitations caused by sysbuild.
23+
The FLPR application cannot be built as part of the main sysbuild process.
24+
Instead, the CPUAPP application can be built with MCUboot integration, while the FLPR must be built separately and then merged.
25+
For details, see :ref:`building_nrf54l`.
26+
Note that the DTS file for the CPUAPP application must reserve a required area for the FLPR binary.
27+
28+
Using Partition Manager
29+
=======================
30+
31+
For :ref:`partition_manager`, applications can only use static definitions.
32+
In the current version of the |NCS|, the CPUAPP application and the FLPR application use different partitioning definitions.
33+
The CPUAPP application follows the Partition Manager's scheme, while FLPR relies on DTS partitioning and disregards the Partition Manager scheme.
34+
For this reason, partitions defined for FLPR in DTS must also be reserved in the Partition Manager to ensure consistency.
35+
In addition, FLPR partition parameters such as size and offset must be aligned in the DTS definition, the FLPR application project, and the Partition Manager scheme of the CPUAPP project.
36+
37+
Placement of the FLPR binary on storage devices is flexible, however, the loading mechanism must be aware of its starting point, which is specified in the DTS file.
38+
You must ensure that the FLPR partition in both the DTS and Partition Manager leaves sufficient space at the end for MCUboot swap information, which is necessary to update the application image.
39+
The build system will not check if the compiled application satisfies the size requirements (see the NCSDK-20567 issue on the :ref:`known_issues` page).
40+
41+
Creating a project with FLPR core
42+
*********************************
43+
44+
Each project (CPUAPP application and the FLPR application) can independently enable sysbuild.
45+
The CPUAPP application, operating on the application core, requires the integration of MCUboot as the bootloader to ensure proper boot management and security.
46+
The FLPR application operates independently from the main project structure, allowing it to be built separately.
47+
48+
Configuring memory partitions
49+
*****************************
50+
51+
When the FLPR application is built, partitioning must be done through DTS.
52+
This is necessary because the Partition Manager does not currently support or recognize the FLPR application.
53+
54+
When building the main application that incorporates FLPR, ensure that the Partition Manager is enabled.
55+
Your setup must reserve a partition for the FLPR that reflects the layout defined by the FLPR application.
56+
For details on configuring partitions, see the following sections.
57+
58+
DTS memory definitions for FLPR application
59+
===========================================
60+
61+
Define FLPR partitions for the FLPR application as follows, using example addresses:
62+
63+
.. code-block:: dts
64+
65+
&cpuflpr_rram {
66+
reg = <0x98000 0x20000>;
67+
};
68+
69+
This configuration sets up a partition starting at address ``0x98000`` with a size of ``0x20000``.
70+
71+
DTS memory definitions for CPUAPP application
72+
=============================================
73+
74+
To ensure the CPUAPP application functions correctly with the FLPR payload, you must apply specific configurations.
75+
76+
Memory partition configuration
77+
------------------------------
78+
79+
See an example of memory partition configuration:
80+
81+
.. code-block:: dts
82+
83+
/{
84+
soc {
85+
reserved-memory {
86+
#address-cells = <1>;
87+
#size-cells = <1>;
88+
cpuflpr_code_partition: image@98000 {
89+
/* FLPR core code partition */
90+
reg = <0x98000 0x20000>;
91+
};
92+
};
93+
cpuflpr_sram_code_data: memory@20028000 {
94+
compatible = "mmio-sram";
95+
reg = <0x20028000 DT_SIZE_K(96)>;
96+
#address-cells = <1>;
97+
#size-cells = <1>;
98+
ranges = <0x0 0x20028000 0x18000>;
99+
};
100+
};
101+
};
102+
&cpuapp_sram {
103+
reg = <0x20000000 DT_SIZE_K(160)>;
104+
ranges = <0x0 0x20000000 0x28000>;
105+
};
106+
107+
1. Adjust the following partitions:
108+
109+
* ``cpuflpr_code_partition`` - This partition defines where the FLPR code is placed on the storage device.
110+
The code is later loaded by the CPUAPP application.
111+
112+
* Location: 0x98000
113+
* Size: 0x20000
114+
115+
Ensure the ``cpuflpr_code_partition`` does not extend to the end of the image slot.
116+
You must leave space for the MCUboot swap information.
117+
118+
.. note::
119+
120+
When using the Partition Manager, ensure this partition is reserved for FLPR.
121+
The Partition Manager will ignore this setting while allocating space for the application running on CPUAPP, but the :ref:`FLPR minimal sample <vpr_flpr_nrf54l15_initiating>` will still utilize it.
122+
123+
* ``cpuflpr_sram_code_data`` - This configuration defines the RAM space reserved only for the FLPR.
124+
It is not available for the application core and should be excluded from its memory allocation.
125+
126+
* Compatible with ``mmio-sram``.
127+
* Location: 0x20028000
128+
* Size: 96KB
129+
130+
* ``cpuapp_sram`` - This configuration defines the RAM limit for the CPUAPP application.
131+
132+
* Location: 0x20000000
133+
* Size: 160KB
134+
135+
#. Configure the CPUAPP application as follows for it to recognize the placement of the FLPR code:
136+
137+
.. code-block:: dts
138+
139+
&cpuflpr_vpr {
140+
execution-memory = <&cpuflpr_sram_code_data>;
141+
source-memory = <&cpuflpr_code_partition>;
142+
};
143+
144+
where
145+
146+
* The ``execution-memory`` links SRAM definitions to FLPR (``cpuflpr_sram_code_data``).
147+
* The ``source-memory`` links RRAM definitions to FLPR (``cpuflpr_code_partition``).
148+
149+
These links inform the main application about the memory usage by the FLPR core.
150+
151+
Partition Manager configuration
152+
-------------------------------
153+
154+
Adjust the static definitions in the Partition Manager as follows:
155+
156+
* For the FLPR partition (``flpr0``):
157+
158+
.. code-block:: dts
159+
160+
flpr0:
161+
address: 0x98000
162+
end_address: 0xb8000
163+
region: flash_primary
164+
size: 0x20000
165+
166+
The ``address`` and ``size`` must match the DTS definitions.
167+
The ``end_address`` is the sum of the address and size.
168+
169+
* For the ``mcuboot_primary_app`` configuration:
170+
171+
.. code-block:: dts
172+
173+
mcuboot_primary_app:
174+
address: 0xc800
175+
end_address: 0xb8000
176+
orig_span: &id002
177+
- app
178+
- flpr0
179+
region: flash_primary
180+
size: 0xab800
181+
span: *id002
182+
183+
This configuration indicates that ``flpr0`` is now set within ``mcuboot_primary_app``, meaning it is part of the image.
184+
185+
Building project
186+
****************
187+
188+
For detailed instructions on how to build your project, see :ref:`building_nrf54l`.
189+
190+
Creating a single image
191+
***********************
192+
193+
After the build is complete, you must manually collect the artifacts into a single image for MCUboot to work correctly.
194+
195+
Merging binaries
196+
================
197+
198+
Once you have successfully built the CPUAPP and FLPR applications separately and using sysbuild, you can merge the files.
199+
200+
1. Locate the :file:`zephyr.hex` files for both applications:
201+
202+
* For CPUAPP, find the :file:`build/<cpuapp_application_dir_name>/zephyr/zephyr.hex` file.
203+
* For FLPR, find the :file:`<flpr_build>/zephyr/zephyr.hex` file.
204+
205+
#. If you do not have your environment set up, first source the :file:`zephyr_env.sh` script or ensure you have set the ``ZEPHYR_BASE`` environmental variable to the Zephyr directory used for building.
206+
207+
#. Execute the merge command:
208+
209+
.. code-block:: console
210+
211+
python3 ${ZEPHYR_BASE}/scripts/build/mergehex.py <flpr_build>/zephyr/zephyr.hex build/<cpuapp_application>/zephyr/zephyr.hex -o app_and_flpr_merged.hex
212+
213+
It results in creating the :file:`app_and_flpr_merged.hex` file that contains both the FLPR and CPUAPP application.
214+
215+
.. note::
216+
217+
Merging errors, where memory locations overlap in both HEX files, indicate misalignment between DTS and Partition Manager definitions for FLPR and CPUAPP. This suggests that FLPR is built in an area already allocated to the application.
218+
To resolve this issue, you must check and adjust the settings in either the Partition Manager, the DTS, or both, to ensure that the FLPR-designated area does not overlap with the application-designated area.
219+
220+
Signing binaries
221+
================
222+
223+
For MCUboot, the merged HEX file (:file:`app_and_flpr_merged.hex`) is a single application that must be signed.
224+
225+
1. Calculate the slot size by using the ``mcuboot_primary_app`` configuration.
226+
The ``0xac000`` comes from the following calculation: ``0xab800 + 0x800 = 0xac000``, where ``0xab800`` represents the total size of the primary application area, and ``0x800`` is added to accommodate the metadata required by MCUboot, resulting in a total ``slot_size`` of ``0xac000``.
227+
228+
#. Using the :doc:`imgtool<mcuboot:imgtool>`, sign the merged application.
229+
230+
.. code-block:: console
231+
232+
python3 ${ZEPHYR_BASE}/bootloader/mcuboot/scripts/imgtool.py sign --version <version> --align 16 --slot-size 0xac000 --pad-header --header-size 0x800 -k <key> app_and_flpr_merged.hex app_and_flpr_merged.signed.hex
233+
python3 ${ZEPHYR_BASE}/bootloader/mcuboot/scripts/imgtool.py sign --version <version> --align 16 --slot-size 0xac000 --pad-header --header-size 0x800 -k <key> app_and_flpr_merged.hex app_and_flpr_merged.signed.bin
234+
235+
Adjust the following values in the script:
236+
237+
* Replace ``0xac000`` in the command line with the calculated value.
238+
* Replace ``<version>`` with the application version and ``<key>`` with the :ref:`signature key <ug_bootloader_adding_sysbuild_immutable_mcuboot_keys>`.
239+
240+
At the end of this process, you will have two files:
241+
242+
* The :file:`app_and_flpr_merged.signed.hex` file, that is an application you can :ref:`program directly to the device<gs_programming>`.
243+
* The :file:`app_and_flpr_merged.signed.bin` file, that is an application that can be :ref:`uploaded as an update<ug_nrf54l_developing_ble_fota>`.

doc/nrf/app_dev/device_guides/nrf54l/vpr_flpr.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ Snippet's primary function is to enable the code that transfers the FLPR code to
3838
When building for the ``nrf54l15dk/nrf54l15/cpuflpr`` target, a minimal sample is automatically loaded onto the application core.
3939
See more information on :ref:`building_nrf54l_app_flpr_core`.
4040

41+
Using MCUboot with FLPR
42+
***********************
43+
44+
To ensure that MCUboot functions correctly with a FLPR-integrated application, several manual configurations are necessary.
45+
For details, see :ref:`nRF54l_signing_app_with_flpr_payload`.
46+
4147
Memory allocation
4248
*****************
4349

0 commit comments

Comments
 (0)