I cannot get MCUBoot to create a image on external spi flash. Using the spi_flash sample I can read/write/erase fine with spi flash configuration in my device tree.
I am creating a child_image for mcuboot which contains mcuboot.conf and the board.overlay file.
Relevant details:
Version: Nordic Connect SDK v2.0.0
Board: Custom NRF52832 - Using nrf52dk_nrf52832.overlay
partitions.yml:
app:
address: 0xc200
end_address: 0x80000
region: flash_primary
size: 0x73e00
external_flash:
address: 0x74000
end_address: 0x80000
region: external_flash
size: 0xc000
mcuboot:
address: 0x0
end_address: 0xc000
placement:
before:
- mcuboot_primary
region: flash_primary
size: 0xc000
mcuboot_pad:
address: 0xc000
end_address: 0xc200
placement:
align:
start: 0x1000
before:
- mcuboot_primary_app
region: flash_primary
size: 0x200
mcuboot_primary:
address: 0xc000
end_address: 0x80000
orig_span: &id001
- app
- mcuboot_pad
region: flash_primary
size: 0x74000
span: *id001
mcuboot_primary_app:
address: 0xc200
end_address: 0x80000
orig_span: &id002
- app
region: flash_primary
size: 0x73e00
span: *id002
mcuboot_secondary:
address: 0x0
device: /soc/spi@40003000/at25df041b@0
end_address: 0x74000
placement:
align:
start: 0x4
region: external_flash
share_size:
- mcuboot_primary
size: 0x74000
sram_primary:
address: 0x20000000
end_address: 0x20010000
region: sram_primary
size: 0x10000
.overlay: Used for both MCUBoot and main.
/ {
chosen {
nordic,pm-ext-flash = &at25df041b;
};
};
&pinctrl {
spi0_default_alt: spi0_default_alt {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 9)>,
<NRF_PSEL(SPIM_MOSI, 0, 10)>,
<NRF_PSEL(SPIM_MISO, 0, 8)>;
};
};
spi0_sleep_alt: spi0_sleep_alt {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 9)>,
<NRF_PSEL(SPIM_MOSI, 0, 10)>,
<NRF_PSEL(SPIM_MISO, 0, 8)>;
low-power-enable;
};
};
uart0_default: uart0_default {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 20)>,
<NRF_PSEL(UART_RX, 0, 19)>,
<NRF_PSEL(UART_RTS, 0, 5)>,
<NRF_PSEL(UART_CTS, 0, 24)>;
};
};
uart0_sleep: uart0_sleep {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 20)>,
<NRF_PSEL(UART_RX, 0, 19)>,
<NRF_PSEL(UART_RTS, 0, 5)>,
<NRF_PSEL(UART_CTS, 0, 24)>;
low-power-enable;
};
};
};
&spi0 {
status = "okay";
label = "SPI_0";
pinctrl-0 = <&spi0_default_alt>;
pinctrl-1 = <&spi0_sleep_alt>;
pinctrl-names = "default", "sleep";
cs-gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;
at25df041b: at25df041b@0 {
compatible = "jedec,spi-nor";
label = "AT25DF041B";
spi-max-frequency = <1000000>;
reg = <0>;
jedec-id = [ 1F 44 02 ];
size = <0x400000>;
has-dpd;
t-enter-dpd = <10000>;
t-exit-dpd = <35000>;
wp-gpios = <&gpio0 7 GPIO_ACTIVE_LOW>;
hold-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>;
has-lock = <0xff>;
};
};
&pwm0 {
status = "disabled";
};
prj.conf:
CONFIG_SPI=y CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 CONFIG_BOOTLOADER_MCUBOOT=y CONFIG_FLASH=y CONFIG_FLASH_PAGE_LAYOUT=y CONFIG_NFCT_PINS_AS_GPIOS=y CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y
mcuboot.conf:
CONFIG_MAIN_STACK_SIZE=10240 CONFIG_SPI=y CONFIG_FLASH=y CONFIG_FLASH_PAGE_LAYOUT=y CONFIG_BOOTLOADER_MCUBOOT=y CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y CONFIG_BOOT_MAX_IMG_SECTORS=1024 CONFIG_LOG=y CONFIG_LOG_MODE_IMMEDIATE=y CONFIG_LOG_DEFAULT_LEVEL=4 CONFIG_PRINTK=y CONFIG_LOG_MODE_MINIMAL=n CONFIG_UART_CONSOLE=y CONFIG_RTT_CONSOLE=n CONFIG_CONSOLE_HANDLER=y CONFIG_NFCT_PINS_AS_GPIOS=y # If you don't add this when setting CONFIG_SPI=y, you'll get a lot of undefined references from the nrfx spim driver # E.G. "undefined reference to `z_impl_k_sleep'" CONFIG_MULTITHREADING=y CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y
Output:

I can't seem to understand why this configuration would work for the main program but mcuboot doesn't work.
I have tried almost every prj.conf, mcuboot.conf and pm_static.yml configurations I can think of with no luck.
Any ideas on what might be causing this? Changing CONFIG_BOOT_MAX_IMG_SECTORS doesn't seem to change anything.
Thanks for any help you can provide.