PM_Static with MCU_Boot and external Flash

Hello and thanks for reading. I am working with the NRF5340DK and Zephyr (SDK 2.5.0).

As our project has grown, we can no longer fit all our code and MCU boot in the internal flash. Seeing as the DK has an external flash chip on QSPI, we figured we would use that to store our code.

We started out with the example provided in the developer academy, and that worked well.

It seemed wasteful, however, to have 8K of flash and to only use ~1K, keeping the second MCUBOOT image on the NRF5340's internal flash.

Also, our code has kept growing, so we decided to try and put both the primary and secondary slots for MCUBOOT on the external flash, with two images of 4K each.

This is leading to problems with setting up our PM_Static.yml, and I was hopeful you could take a look and help us figure out what we are doing wrong.

Here is my PM_Static.yml right now:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Custom NVS storage partition (flash_primary)
custom_nvs_storage:
address: 0x00000
size: 0x2000 # 8 KB
region: flash_primary
# Settings storage partition (flash_primary)
settings_storage:
address: 0x2000
size: 0x2000 # 8 KB
region: flash_primary
# External QSPI Flash (8 MB)
qspi_flash:
address: 0x0
region: external_flash
size: 0x800000 # 8 MB
# mcuboot partitions in QSPI flash (external flash)
mcuboot_primary:
address: 0x0
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

And here are the relevant error messages:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- Found partition manager static configuration: C:/Users/foo/Documents/GitHub/foo/pm_static.yml
Partition 'settings_storage' is not included in the dynamic resolving since it is statically defined.
Partition 'mcuboot_primary' is not included in the dynamic resolving since it is statically defined.
Partition 'mcuboot_secondary' is not included in the dynamic resolving since it is statically defined.
Partition manager failed: End of last partition is after last valid address
Failed to partition region flash_primary, size of region: 1048576
Partition Configuration:
custom_nvs_storage:
size: 8192
mcuboot:
placement: {}
size: 49152
mcuboot_pad:
placement:
before:
- mcuboot_primary_app
size: 512
settings_storage:
size: 8192
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

And here are the project configs in case that helps you:

MCUBoot project config:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
CONFIG_FLASH=y
CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256=y
# CONFIG_BOOT_SIGNATURE_KEY_FILE="dev_ec256_priv.pem"
CONFIG_MAIN_STACK_SIZE=10240
CONFIG_MULTITHREADING=y
CONFIG_LOG=y
CONFIG_LOG_MODE_MINIMAL=y
CONFIG_BOOT_ENCRYPT_IMAGE=y
# CONFIG_BOOT_ENCRYPTION_KEY_FILE="dev_ec256_priv.pem"
#clock config
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y
CONFIG_SOC_HFXO_CAP_EXTERNAL=n
CONFIG_SOC_HFXO_CAP_INTERNAL=y
CONFIG_SOC_HFXO_CAP_INT_VALUE_X2=16
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

mcuboot overlay:

Fullscreen
1
2
3
4
5
/ {
chosen {
nordic,pm-ext-flash = &mx25r64;
};
};
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

prj.conf

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#GPIO
CONFIG_GPIO=y
CONFIG_PINCTRL=y
#UART & SERIAL & system
CONFIG_SERIAL=y
CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_MAIN_STACK_SIZE=8192
CONFIG_LOG=y
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=8192
CONFIG_TIMESLICING=y
#CPP
CONFIG_CPP=y
CONFIG_REQUIRES_FULL_LIBCPP=y
CONFIG_STD_CPP20=y
#i2C
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX