Disclaimer: I'm new to both Nordic SDK and Zephyr in general so apologize in advance for glaring mistakes
Using SDK v2.1.2
Trying to implement OTA DFU functionality, hence need bootloader.
Using MCUboot (version enclosed with SDK) for that purpose.
My Zephyr-based app image is too large (>250KB) to fit twice in the internal flash of nRF52833 (512KB), so I have to place secondary partition in external SPI-connected NOR flash (Winbond W25Q80DV).
I managed to build both mcuboot and app, but when I load merged file, I get a warning from MCUBoot.
** Booting Zephyr OS build v3.1.99-ncs1-1 ***
I: Starting bootloader
W: Failed reading sectors; BOOT_MAX_IMG_SECTORS=128 - too small?
W: Cannot upgrade: not a compatible amount of sectors
I: Bootloader chainload address offset: 0x10000
*** Booting Zephyr OS build v3.1.99-ncs1-1 ***
Starting app...
Upon further inspection, the chain of errors is as following:
boot_initialize_area --> flash_area_get_sectors--> flash_area_layout --> flash_area_open --> get_flash_area_from_id
static inline struct flash_area const *get_flash_area_from_id(int idx)
{
for (int i = 0; i < flash_map_entries; i++) {
if (flash_map[i].fa_id == idx) {
return &flash_map[i];
}
}
return NULL; <----------------------
}
After the warnings, MCUboot proceeds to load the app, but app misbehaves, which it doesn't do when loaded standalone or when bootloader is built without external flash configuration.
Misbehavior is strangely confined to BLE stack (my app implements a BLE peripheral)
E: Too big advertising data
Failed to set advertising data (-22)
W: opcode 0x2039 status 0x42
E: Failed to start advertiser
Failed to start advertising set (-5)
Another piece of information, I tried
CONFIG_SINGLE_APPLICATION_SLOT=y
in bootloader's config overlay file, which eliminates the need for configuring external flash in device tree and config
That makes both MCUBoot and app happy, but of course this is not an acceptable workaround, need two images for OTA DFU.
Any advice on what am I doing wrong with the external flash configuration (or in general) would be greatly appreciated
My prj.conf
4628.prj.conf
Main device tree
myboard.dts
Device tree overlay (used by both app and bootloader)
myboard_uart.overlay
Bootloader config overlay
bootloader_uart.conf
Build command line
west build --build-dir $BUILD_DIR $TOP_DIR --pristine --board 32-00008618 -- -DUSE_PARTITION_MANAGER=1 -DNCS_TOOLCHAIN_VERSION:STRING="NONE" -DCONFIG_SIZE_OPTIMIZATIONS=y -DCONFIG_DEBUG_THREAD_INFO=y -DCONF_FILE:STRING="${TOP_DIR}/prj.conf" -DBOARD_ROOT:STRING="$TOP_DIR" -DDTC_OVERLAY_FILE:STRING="${TOP_DIR}/myboard_uart.overlay" -DOVERLAY_CONFIG:STRING="${TOP_DIR}/factory_mode.conf" -Dmcuboot_OVERLAY_CONFIG="${TOP_DIR}/bootloader_uart.conf" -Dmcuboot_DTC_OVERLAY_FILE="${TOP_DIR}/myboard_uart.overlay"