Skip to content

Commit b206511

Browse files
committed
boards: arm: mps2: Fix NS flash layout
The mps2/an521/cpu0/ns define flash layouts in tf-m to allow CONFIG_TFM_MCUBOOT_IMAGE_NUMBER be 1 or 2. In the Zephyr project when building the samples the value selected is 2. The layout changes are necessary to allow use the --max-sectors options when signing the images. It ensures that flash layout is respected. To allow this the compatible "soc-nv-flash" was added in the reserved memory and the fixed-partitions were defined. Signed-off-by: BUDKE Gerson Fernando <[email protected]>
1 parent b3bb237 commit b206511

File tree

2 files changed

+46
-11
lines changed

2 files changed

+46
-11
lines changed

boards/arm/mps2/Kconfig.defconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ choice NULL_POINTER_EXCEPTION_DETECTION
4646

4747
endchoice
4848

49+
# Get flash configuration for NS image from dts flash partition
50+
config USE_DT_CODE_PARTITION
51+
default y if TRUSTED_EXECUTION_NONSECURE
52+
4953
# By default, if we build for a Non-Secure version of the board,
5054
# force building with TF-M as the Secure Execution Environment.
5155
config BUILD_WITH_TFM

boards/arm/mps2/mps2_an521_cpu0_ns.dts

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
zephyr,console = &uart0;
3030
zephyr,shell-uart = &uart0;
3131
zephyr,sram = &ram;
32-
zephyr,flash = &code;
32+
zephyr,flash = &reserved_memory;
33+
zephyr,code-partition = &slot0_ns_partition;
3334
};
3435

3536
leds {
@@ -107,19 +108,49 @@
107108
reg = <0x80000000 DT_SIZE_M(16)>;
108109
};
109110

110-
reserved-memory {
111+
reserved_memory: reserved-memory@0 {
112+
compatible = "soc-nv-flash";
113+
reg = <0x0 DT_SIZE_M(4)>;
114+
erase-block-size = <4096>;
115+
write-block-size = <4>;
111116
#address-cells = <1>;
112117
#size-cells = <1>;
113-
ranges;
114118

115-
/* This code memory region must match what the TF-M
116-
* project has defined for that board - a single image boot is
117-
* assumed. Please see the memory layout in:
118-
*
119-
* https://github.com/zephyrproject-rtos/trusted-firmware-m/blob/master/platform/ext/target/arm/mps2/an521/partition/flash_layout.h
120-
*/
121-
code: memory@100000 {
122-
reg = <0x00100000 DT_SIZE_K(512)>;
119+
partitions {
120+
compatible = "fixed-partitions";
121+
#address-cells = <1>;
122+
#size-cells = <1>;
123+
124+
/* This code memory region must match what the TF-M
125+
* project has defined for that board - the milti-image
126+
* boot is used in Zephyr. See memory layout details in:
127+
*
128+
* https://github.com/zephyrproject-rtos/trusted-firmware-m/blob/master/platform/ext/target/arm/mps2/an521/partition/flash_layout.h
129+
*/
130+
boot_partition: partition@0 {
131+
reg = <0x00000000 DT_SIZE_K(512)>;
132+
read-only;
133+
};
134+
135+
slot0_partition: partition@80000 {
136+
reg = <0x00080000 DT_SIZE_K(512)>;
137+
};
138+
139+
slot0_ns_partition: partition@100000 {
140+
reg = <0x00100000 DT_SIZE_K(512)>;
141+
};
142+
143+
slot1_partition: partition@180000 {
144+
reg = <0x00180000 DT_SIZE_K(512)>;
145+
};
146+
147+
slot1_ns_partition: partition@200000 {
148+
reg = <0x00200000 DT_SIZE_K(512)>;
149+
};
150+
151+
scratch_partition: partition@280000 {
152+
reg = <0x00280000 DT_SIZE_K(512)>;
153+
};
123154
};
124155

125156
/* This ram memory region's size is chosen to avoid conflict

0 commit comments

Comments
 (0)