Skip to content

Commit d0f7201

Browse files
committed
M2354: Fix potential issues in TF-M
Fix the following issues in TF-M to avoid emergence in the future: 1. Enable initial stack not located in SRAM bank0 On reset, only SRAM bank0 is enabled. And SRAM bank1/2 will be enabled in immediately following SystemInit(). When initial stack is located in SRAM bank1/2, we will meet trouble because SystemInit() itself needs to use initial stack. To conquer the dilemma, we add preceding code in front of original Systeminit(), which is responsible for enabling SRAM bank1/2 and guarantees no using initial stack. 2. Fix sector maps of internal/external (SDH) Flash are incompatible, caused by TF-M's MCUboot port. This is done by adapting external (SDH) Flash sector size to internal Flash's. 3. Enlarge firmware upgrade scratch size. There are two advantages: (1) Get around MCUboot limit which requires scratch size not smaller than image trailer size (2) Improve wear leveling for the scratch area
1 parent 0db0445 commit d0f7201

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

targets/TARGET_NUVOTON/TARGET_M2354/TARGET_TFM/TARGET_NU_M2354/COMPONENT_TFM_S_FW/partition/flash_layout.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
* 0x0010_0000 Secondary image area (2KB):
3232
* 0x0010_0000 Secure image secondary (320KB) (Dummy)
3333
* 0x0015_0000 Non-secure image secondary (576KB) (Dummy)
34-
* 0x001E_0000 Scratch area (4KB) (Dummy)
34+
* 0x001E_0000 Scratch area (16KB) (Dummy)
3535
*
3636
* SDH Flash:
3737
* 0x0000_0000 Secondary image area (896KB)
3838
* 0x0000_0000 Secure image secondary (320KB)
3939
* 0x0005_0000 Non-secure image secondary (576KB)
40-
* 0x0020_0000 Scratch area (4 KB)
40+
* 0x0020_0000 Scratch area (16 KB)
4141
*
4242
* Flash layout on M2354 with BL2 (multiple image boot):
4343
*
@@ -50,12 +50,12 @@
5050
* 0x0007_0000 Non-secure image primary slot (576KB)
5151
* 0x0010_0000 Secure image secondary slot (320KB) (Dummy)
5252
* 0x0015_0000 Non-secure image secondary slot (576KB) (Dummy)
53-
* 0x001E_0000 Scratch area (4KB) (Dummy)
53+
* 0x001E_0000 Scratch area (16KB) (Dummy)
5454
*
5555
* SDH Flash:
5656
* 0x0000_0000 Secure image secondary slot (320KB)
5757
* 0x0010_0000 Non-secure image secondary slot (576KB)
58-
* 0x0020_0000 Scratch area (2 KB)
58+
* 0x0020_0000 Scratch area (16 KB)
5959
*/
6060

6161
/* This header file is included from linker scatter file as well, where only a
@@ -123,13 +123,13 @@
123123
#if NU_UPDATE_STAGE_SDH
124124
#define FLASH_AREA_SCRATCH_ID (FLASH_AREA_2_ID + 1)
125125
#define FLASH_AREA_SCRATCH_OFFSET (0x200000)
126-
#define FLASH_AREA_SCRATCH_SIZE (0x1000)
126+
#define FLASH_AREA_SCRATCH_SIZE (0x4000)
127127
#define FLASH_DEVICE_ID_SCRATCH SDH_FLASH_DEVICE_ID
128128
#define FLASH_DEV_NAME_SCRATCH SDH_FLASH_DEV_NAME
129129
#else
130130
#define FLASH_AREA_SCRATCH_ID (FLASH_AREA_2_ID + 1)
131131
#define FLASH_AREA_SCRATCH_OFFSET (FLASH_AREA_2_OFFSET + FLASH_AREA_2_SIZE)
132-
#define FLASH_AREA_SCRATCH_SIZE (0x1000)
132+
#define FLASH_AREA_SCRATCH_SIZE (0x4000)
133133
#endif
134134

135135
/* The maximum number of status entries supported by the bootloader. */
@@ -181,13 +181,13 @@
181181
#if NU_UPDATE_STAGE_SDH
182182
#define FLASH_AREA_SCRATCH_ID (FLASH_AREA_3_ID + 1)
183183
#define FLASH_AREA_SCRATCH_OFFSET (0x200000)
184-
#define FLASH_AREA_SCRATCH_SIZE (0x1000)
184+
#define FLASH_AREA_SCRATCH_SIZE (0x4000)
185185
#define FLASH_DEVICE_ID_SCRATCH SDH_FLASH_DEVICE_ID
186186
#define FLASH_DEV_NAME_SCRATCH SDH_FLASH_DEV_NAME
187187
#else
188188
#define FLASH_AREA_SCRATCH_ID (FLASH_AREA_3_ID + 1)
189189
#define FLASH_AREA_SCRATCH_OFFSET (FLASH_AREA_3_OFFSET + FLASH_AREA_3_SIZE)
190-
#define FLASH_AREA_SCRATCH_SIZE (0x1000)
190+
#define FLASH_AREA_SCRATCH_SIZE (0x4000)
191191
#endif
192192

193193
/* The maximum number of status entries supported by the bootloader. */

0 commit comments

Comments
 (0)