Adafruit Feather nRF52840 Sense Not Booting with SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y, Works with Simple DFU

I am using the Adafruit Feather nRF52840 Sense with a W25Q32 external flash and MCUBoot. I can successfully read and write to external flash using NVS, and simple DFU works fine.

Issues:

  1. When I enable SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y, the device does not start.

  2. If I first flash a DFU-compatible build (without SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y), the device boots correctly.

  3. When I update via DFU to a new build with SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y, the DFU process completes successfully, but after reboot, the device does not boot.

Observations:

  • External flash (W25Q32) works fine with NVS.

  • Simple DFU works correctly if the build does not have SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y.

  • MCUBoot does not boot when SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y is enabled, whether flashed directly or updated via DFU.

Questions:

  1. Why does the device fail to start when SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y is enabled?

  2. Are there additional configurations needed for MCUBoot to work with W25Q32 external flash?

  3. Why does the device not boot after a successful DFU update using a build with SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y?

  4. How can I debug this? Are there specific MCUBoot logs, settings, or hardware checks I should look into?

  5. Is there a known issue with SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y on the Adafruit Feather nRF52840 Sense?

Any help or insights would be greatly appreciated!

  • Hello,

    Why does the device fail to start when SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y is enabled?

    Have you mapped the external flash in the partition manager file? You also need to initialize the external flash controller and include the correct driver for the external flash in the mcuboot.config file.

    The issue is likely because your application knows that the secondary slot is in external flash, but MCUBoot doesn’t ,so it fails when trying to access it.

    Are there additional configurations needed for MCUBoot to work with W25Q32 external flash?

    Take a look at this sample from developer academy course. Check the mcuboot.config and mcuboot.overlay files inside the sysbuild folder.

    Why does the device not boot after a successful DFU update using a build with SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y?

    It's probably because your MCUBoot image wasn't built with external flash support.

    How can I debug this? Are there specific MCUBoot logs, settings, or hardware checks I should look into?

    Try enabling MCUBoot logs and review the boot logs during startup. You can follow the steps mentioned here to enable MCUBoot logging.

    Is there a known issue with SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y on the Adafruit Feather nRF52840 Sense?

    I don’t think there’s any known issue, but I’m not 100% sure. Did a quick search online and didn’t find anything. I haven’t used or tested this board myself.

    Kind Regards,

    Abhijith

  • Hi Abhijith
     

    I have attached all the configuration files and the project below. I have made all the necessary changes, but I am still facing this issue. Here is the error:

    *** Booting MCUboot v2.1.0-dev-12e5ee106034 ***
    *** Using nRF Connect SDK v2.9.0-7787b2649840 ***
    *** Using Zephyr OS v3.7.99-1f8f3dc29142 ***
    I: Starting bootloader
    E: Failed to open flash area ID 2 (image 0 slot 1): -19, cannot continue
    0763.mcuboot.overlay

    4073.mcuboot.conf

    0272.prj.conf

    1667.sysbuild.conf

    8015.nrf21540dk_nrf52840.overlay

    8524.peripheral_lbs.zip

  • Hello,

    From the error message, it looks like MCUboot still can't access the external flash.

    I'm not completely sure, but while checking the shared project overlay and mcuboot.overlay file, I noticed that mcuboot.overlay is missing the full flash node. For the application, you have defined the full flash node inside the boards folder, but this is missing in the mcuboot.overlay.

    Try defining the flash node and SPI controller in the mcuboot.overlay, just like you did in the project overlay. I tried including something like the following inside mcuboot.overlay, samplet builds fine, but I'm not sure if it throws the same error you mentioned after flashing (as I haven’t flashed it myself).

    'mcuboot.overly
    
    / {
        aliases {
            mcuboot-button0 = &button1;
            mcuboot-led0 = &led1;
        };
    
        chosen {
            nordic,pm-ext-flash = &w25q32jv;
        };
    };
    
    &spi1 {
        compatible = "nordic,nrf-spim";
        status = "okay";
        cs-gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;
        pinctrl-0 = <&spi1_default>;
        pinctrl-1 = <&spi1_sleep>;
        pinctrl-names = "default", "sleep";
    
        w25q32jv: w25q32jv@0 {
            compatible = "jedec,spi-nor";
            reg = <0>;
            spi-max-frequency = <40000000>;
            size = <0x200000>;
            has-dpd;
            t-enter-dpd = <3000>;
            t-exit-dpd = <30000>;
            jedec-id = [ ef 40 16 ];
        };
    };
    
    &spi1_default {
        group1 {
            psels = <NRF_PSEL(SPIM_MOSI, 0, 13)>,
                    <NRF_PSEL(SPIM_SCK, 0, 14)>,
                    <NRF_PSEL(SPIM_MISO, 0, 15)>;
        };
    };
    
    &spi1_sleep {
        group1 {
            psels = <NRF_PSEL(SPIM_MOSI, 0, 13)>,
                    <NRF_PSEL(SPIM_SCK, 0, 14)>,
                    <NRF_PSEL(SPIM_MISO, 0, 15)>;
        };
    };

    Kind Regards,

    Abhijith

  • Hi Abhijith
     

    I also tried this, but I am getting the same error. The external flash (W25Q32) works fine with NVS, so it seems to be working correctly. However, if I remove one wire from the external flash, NVS stops working. Otherwise, both read and write operations work fine.

  • Hi Dhaval, Abhijith is away so I will try to assist you.

    Can you please show how your flash0 partition looks in your mcuboot overlay file? It should look something like this

    &flash0 {
        partitions {
            compatible = "fixed-partitions";
            #address-cells = <1>;
            #size-cells = <1>;
    
            mcuboot_secondary: partition@0 {
                label = "mcuboot_secondary";
                reg = <0x00000000 0x00400000>; /* 4 MiB */
                region = "external_flash";
            };
        };
    };

    If that does not help then please enable the logs and enable boot logs so that we can get some debug info for this.

    # Logging for debug
    CONFIG_LOG=y
    CONFIG_LOG_MODE_IMMEDIATE=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_BOOT_SERIAL_BOOT_MODE=y

Related