BLE OTA DFU using external flash

I'm using the NCS 2.5.2 sdk and nrf 5340 with 7002, and I want to do BLE OTA DFU using external flash.

I've found this guide Add DFU support to your application - Software - nRF Connect SDK guides - Nordic DevZone (nordicsemi.com), and successfully  done BLE OTA DFU using internal flash, just add the commands below,

#Enable MCUBOOT bootloader build in the application
CONFIG_BOOTLOADER_MCUBOOT=y
#Include MCUMGR and the dependencies in the build
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y

but I don't know how to do with external flash, I've tried looking at main.c in mcuboot, and I didn't find where to modify the code.

Parents
  • Hi,

    See https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/ instead. This is up to date with the newest nRF Connect SDK.

    Regards,
    Sigurd Hellesvik

  • Hi, when I add the config to the prj.conf and set the devicetree of the external flash, it has few error occur.

    prj.conf

    device tree
        chosen {
            zephyr,sram = &sram0_image;
            zephyr,flash = &flash0;
            zephyr,code-partition = &slot0_partition;
            zephyr,sram-secure-partition = &sram0_s;
            zephyr,sram-non-secure-partition = &sram0_ns;
            nordic,pm-ext-flash = &mx25l3233;
        };
    &spi3 {
        compatible = "nordic,nrf-spim";
        status = "okay";
        pinctrl-0 = <&spi3_default>;
        pinctrl-1 = <&spi3_sleep>;
        pinctrl-names = "default", "sleep";
        cs-gpios = <&gpio0 10 GPIO_ACTIVE_LOW>;
        mx25l3233: mx25l3233@0 {
                compatible = "jedec,spi-nor";
                reg = <0>;
                spi-max-frequency = <8000000>;
                label = "extflash";
                jedec-id = [ C2 20 16  ];
                sfdp-bfp = [ E5 20 F1 FF FF FF FF 01 44 EB 08 6B 08 3B 04 BB EE FF 00 00 FF 00 00 FF FF 00 00 FF 0C 20 0F 52 10 D8 00 FF 00 36 50 26 9E F9 77 64 FE CF FF FF FF FF FF FF  ];
                size = <33554432>;
                // has-dpd;
                // t-enter-dpd = <10000>;
                // t-exit-dpd = <35000>;
        };
    };
    error message

  • That error may not be as bad as it seems. The nRF5340 has a "simulated" netcore partition.
    In short, it may cause the "list" command to return an error, but it should not have other consequences.

    Does the rest of OTA work as expected, if you ignore this error?

  • No, the state always stuck in  “sending the request failed.” after “uploading” state.

           And after this, I,ve rebooted the board, and checked the log,

           but it’s still the old application, it didn’t Ota successfully.

  • What were the differences in your app between the old and new firmware?

  •        I've added this line in the code,
    "printk("build time: " __DATE__ " " __TIME__ "\n")" to check the build time.
          and add  "printk("test\n")" to make the differences easy to see.
  • Hmm,

    Let us take a step back then:
    Can you test this sample for the nRF5340DK and see if that works?

Reply Children
  • "Can you test this sample for the nRF5340DK and see if that works?"

    Yes, it works and can see the change after ota.

    I think I know what's the problem, last time I said it is failed and stuck in  "sending the request failed", the reason is I'm doing spi transmit simultaneously in my application , so I commented out the line,

    but after this, it has other problems,

    it sometimes uploaded completely but when I checked the log it's still old application.

    and sometimes the state said "There is no free slot to place the image." "  

  • allenyang said:
    and sometimes the state said "There is no free slot to place the image."

    Could you use the nRF Logger app to see what more logs come before this error?

    allenyang said:
    it sometimes uploaded completely but when I checked the log it's still old application.

    If you enable advanced settings in the Device Manager App, you can use an "image list" command. What does that show when you still load the old app?

  • I have new observations.

    After the application flash to the board, do the first build of the image and do ota to the board, it always run normally on Device Manager App and it states Upload Complete but it's still a old app. And use the same file to OTA again, it still states Upload Complete but it still get nothing change. 

    After that, when do the second or third ...build of the image, and do ota, it  will state "There is no free slot to place the image."

    It seems it has something wrong when doing first OTA.

    "If you enable advanced settings in the Device Manager App, you can use an "image list" command. What does that show when you still load the old app?"

    "Could you use the nRF Logger app to see what more logs come before this error?"

    Does it have an IOS version?

  • Hi, the problem above is resolved when I commented out this line  

    "k_sem_take(&ble_init_ok, K_FOREVER);" in my application.
    I think the ota program is locked by semaphore.
    so it is be sure to ota successfully(it is dynamic partition, without pm_static.yml),
    but when I add the pm_static.yml, the OTA  App always states "There is no free slot to place the image."  
    and I've checked the partition.yml, it's changed correctly what I added the pm_static. 
    I'm not sure whether the use of partition is correct.
    (external flash total size is 0x400000) 
    partition.yml 
    and I've checked the Nrf Logger App when it states "There is no free slot to place the image" came out
  • allenyang said:

    the problem above is resolved when I commented out this line  

    "k_sem_take(&ble_init_ok, K_FOREVER);" in my application.

    Do you ever give back that semaphore?