I'm trying to modify the flash layout used for b_u585i_iot2a in TF-M. Please see the details below.
The reason that I'm doing this is because I want to sign the mcuboot bootloader used by TF-M.
The flash layout looks like this:
/* Flash layout for b_u585i_iot02a with BL2 (multiple image boot):
*
* 0x0000_0000 SCRATCH (64KB)
* 0x0001_0000 BL2 - counters(16 KB)
* 0x0001_4000 BL2 - MCUBoot (84 KB)
* 0x0002_7000 OTP Write Protect (4KB)
* 0x0002_8000 NV counters area (16 KB)
* 0x0002_c000 Secure Storage Area (16 KB)
* 0x0003_0000 Internal Trusted Storage Area (16 KB)
* 0x0003_4000 Secure image primary slot (256 KB)
* 0x0007_4000 Non-secure image primary slot (512 KB)
* 0x000f_4000 Secure image secondary slot (256 KB)
* 0x0013_4000 Non-secure image secondary slot (512 KB)
*
* Bl2 binary is written at 0x1_2000:
* it contains bl2_counter init value, OTP write protect, NV counters area init.
*/I added space for the header before "BL2 - counters" - there is 8 KiB free at this offset, as the counters start 8 KiB into this area. This solved my issue with the script used to sign binaries.
But now I have issues with MCUboot not being able to find the two (secure/non-secure) images. I don't understand this. It looks like I added space to the output image and this moved the secure/non-secure images without updating some offsets.
The linker config looks like this:
#include "region_defs.h"
MEMORY
{
/* Header used by signing script: /
FLASH_SIGN_HEADER(rx) : ORIGIN = BL2_SIGN_AREA_BASE, LENGTH = BL2_SIGN_AREA_SIZE
#if defined(BL2_NVMCNT_AREA_BASE)
FLASH_NVMCNT(rx) : ORIGIN = BL2_NVMCNT_AREA_BASE, LENGTH = BL2_NVMCNT_AREA_SIZE
#endif
FLASH (rx) : ORIGIN = BL2_CODE_START, LENGTH = BL2_CODE_SIZE
FLASH_NOHDP (rx) : ORIGIN = BL2_NOHDP_CODE_START, LENGTH = BL2_NOHDP_CODE_SIZE
#if defined(BL2_OTP_AREA_BASE)
FLASH_OTP(rx) : ORIGIN = BL2_OTP_AREA_BASE, LENGTH = BL2_OTP_AREA_SIZE
#endif
#if defined(BL2_NVM_AREA_BASE)
FLASH_NVM(rx) : ORIGIN = BL2_NVM_AREA_BASE, LENGTH = BL2_NVM_AREA_SIZE
#endif
RAM (rwx) : ORIGIN = BL2_DATA_START, LENGTH = BL2_DATA_SIZE
}In region_defs.h from same directory I have the following:
/* Define Area for initializing BL2_NVCNT */
/* backup sector is initialised */
#define BL2_NVMCNT_AREA_BASE S_ROM_ALIAS(FLASH_BL2_NVCNT_AREA_OFFSET+FLASH_AREA_IMAGE_SECTOR_SIZE)
#define BL2_NVMCNT_AREA_SIZE (FLASH_AREA_IMAGE_SECTOR_SIZE)
#define BL2_SIGN_AREA_BASE S_ROM_ALIAS(FLASH_BL2_NVCNT_AREA_OFFSET)
#define BL2_SIGN_AREA_SIZE (FLASH_AREA_IMAGE_SECTOR_SIZE)Any hints as to what I'm doing wrong?
Can you point me to any example which sign the bootloader but not the different areas used for counters etc?
