nRF52840 with MCUBOOT over SMP using SPI Flash - Fails to boot

Hello,

I'm trying to use MCUBOOT with external flash on a nRF52840 board that has 4MB SPI flash. I'm using nRF Connect SDK v2.6.0.

I've verified that the SPI flash works fine using the "spi_flash" sample.

With CONFIG_BOOTLOADER_MCUBOOT=n, SMP with SPI flash runs fine. I'm able to connect to the "Zephyr" BLE device from nRF Connect for mobile.

However, with CONFIG_BOOTLOADER_MCUBOOT=y, the build is successful but the nRF52840 board fails to boot.

As the nRF52840 board (particle_xenon) has SPI flash instead of QSPI, I've set CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=n and added the required Kconfig dependencies.

Here is the prj.conf:

CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_MCUMGR=y
CONFIG_ZCBOR=y
CONFIG_CRC=y
CONFIG_MCUMGR_TRANSPORT_BT=y
CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL=y
CONFIG_IMG_MANAGER=y
CONFIG_STREAM_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_MCUMGR_GRP_IMG=y
CONFIG_MCUMGR_GRP_OS=y
CONFIG_MCUMGR_GRP_OS_BOOTLOADER_INFO=y
CONFIG_MCUMGR_TRANSPORT_BT_REASSEMBLY=y
CONFIG_BASE64=y
CONFIG_MCUMGR_TRANSPORT_SHELL=y

CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=n
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU_SPEEDUP=y
CONFIG_BOOTLOADER_MCUBOOT=y

CONFIG_NORDIC_QSPI_NOR=n
CONFIG_FLASH=y
CONFIG_SPI=y
CONFIG_SPI_NOR=y
CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096

CONFIG_LOG=y
CONFIG_PRINTK=y
CONFIG_CONSOLE=y
CONFIG_SERIAL=y

# Preferred SHELL options
CONFIG_SHELL=y
CONFIG_BOOT_BANNER=y
CONFIG_DATE_SHELL=y
CONFIG_POSIX_CLOCK=y
CONFIG_DEVICE_SHELL=n
CONFIG_INIT_STACKS=y
CONFIG_KERNEL_SHELL=y
CONFIG_SHELL_STATS=n
The board configuration "particle_xenon.conf" is set to use SPI flash:
CONFIG_FLASH=y
CONFIG_SPI=y
CONFIG_SPI_NOR=y


The board "particle_xenon.overlay" is configured to use the external SPI flash (
&mx25l32 is defined in "particle_xenon.dts" board):
/ {
	chosen {
		nordic,pm-ext-flash = &mx25l32;
	};
};
For MCUBOOT, folder "child_image > mcuboot > boards" has the board configuration & overlay files as,

particle_xenon.conf:

CONFIG_PM=n

CONFIG_MAIN_STACK_SIZE=10240
CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h"

CONFIG_BOOT_SWAP_SAVE_ENCTLV=n
CONFIG_BOOT_ENCRYPT_IMAGE=n

CONFIG_BOOT_UPGRADE_ONLY=n
CONFIG_BOOT_BOOTSTRAP=n

### mbedTLS has its own heap
# CONFIG_HEAP_MEM_POOL_SIZE is not set

### We never want Zephyr's copy of tinycrypt.  If tinycrypt is needed,
### MCUboot has its own copy in tree.
# CONFIG_TINYCRYPT is not set
# CONFIG_TINYCRYPT_ECC_DSA is not set
# CONFIG_TINYCRYPT_SHA256 is not set

CONFIG_FLASH=y
CONFIG_FPROTECT=y

### Various Zephyr boards enable features that we don't want.
# CONFIG_BT is not set
# CONFIG_BT_CTLR is not set
# CONFIG_I2C is not set

CONFIG_LOG=y
CONFIG_LOG_MODE_MINIMAL=y # former CONFIG_MODE_MINIMAL
### Ensure Zephyr logging changes don't use more resources
CONFIG_LOG_DEFAULT_LEVEL=0
### Use info log level by default
CONFIG_MCUBOOT_LOG_LEVEL_INF=y
### Decrease footprint by ~4 KB in comparison to CBPRINTF_COMPLETE=y
CONFIG_CBPRINTF_NANO=y
CONFIG_NRF_RTC_TIMER_USER_CHAN_COUNT=0
### Use the minimal C library to reduce flash usage
CONFIG_MINIMAL_LIBC=y

### Enable serial recovery
CONFIG_MCUBOOT_SERIAL=y
CONFIG_BOOT_SERIAL_CDC_ACM=y
CONFIG_BOOT_SERIAL_NO_APPLICATION=y
CONFIG_UART_CONSOLE=n

### Increase receive buffer to improve transfer speed in serial recovery mode
CONFIG_BOOT_MAX_LINE_INPUT_LEN=8192
CONFIG_BOOT_SERIAL_MAX_RECEIVE_SIZE=4096

### Enable SPI flash
CONFIG_NORDIC_QSPI_NOR=n
CONFIG_SPI=y
CONFIG_SPI_NOR=y
CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096

### Partition size allocated to bootloader - can be reduced if logging is disabled
CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x12000


particle_xenon.overlay:

/ {
	chosen {
		nordic,pm-ext-flash = &mx25l32;
	};

	aliases {
		mcuboot-button0 = &mode_button;
	};
};



MCUBOOT > zephyr > zephyr.dts does include the "nordic,pm-ext-flash". 
Here's a snippet from the file:

	model = "Particle Xenon";
	compatible = "particle,xenon", "particle,feather";
	chosen {
		zephyr,entropy = &cryptocell;
		zephyr,flash-controller = &flash_controller;
		zephyr,console = &uart0;
		zephyr,uart-mcumgr = &uart0;
		zephyr,shell-uart = &uart0;
		zephyr,sram = &sram0;
		zephyr,flash = &flash0;
		zephyr,code-partition = &slot0_partition;
		zephyr,ieee802154 = &ieee802154;
		nordic,pm-ext-flash = &mx25l32;
	};



What could be the reason for the application not running?

Am I missing some configuration or is part of it incorrect?  Thank you.
Regards,
Ravi
Related