DFU method of nrf5340

Hi,

In our custom board, currently we using SWD with segger J-link for DFU

Is there any another option except segger/dev-kit ?

Can we do DFU through USB/UART ?

  • Hello,

    Yes, you can DFU the nRF5340 via UART or USB. However, before doing so, you need to flash the bootloader that supports DFU via UART or USB. Please refer to the bootloader and DFU section in the Developer Academy course. This tutorial explains how to update the application to support UART/USB DFU.

    Kind Regards,

    Abhijith

  • On our previous conversations regarding the Device Firmware Update (DFU), as per courses we have able to do DFU over WIFi but still unclear about the partition and image size.

    Our partition as in DTS is given below

                    flash0: flash@0 {
                        compatible = "soc-nv-flash";
                        erase-block-size = < 0x1000 >;
                        write-block-size = < 0x4 >;
                        reg = < 0x0 0x100000 >;
                        partitions {
                            compatible = "fixed-partitions";
                            #address-cells = < 0x1 >;
                            #size-cells = < 0x1 >;
                            boot_partition: partition@0 {
                                label = "mcuboot";
                                reg = < 0x0 0x10000 >;
                            };
                            slot0_partition: partition@10000 {
                                label = "image-0";
                                reg = < 0x10000 0x40000 >;
                            };
                            slot0_ns_partition: partition@50000 {
                                label = "image-0-nonsecure";
                                reg = < 0x50000 0x30000 >;
                            };
                            slot1_partition: partition@80000 {
                                label = "image-1";
                                reg = < 0x80000 0x40000 >;
                            };
                            slot1_ns_partition: partition@c0000 {
                                label = "image-1-nonsecure";
                                reg = < 0xc0000 0x30000 >;
                            };
                            scratch_partition: partition@f0000 {
                                label = "image-scratch";
                                reg = < 0xf0000 0xa000 >;
                            };
                            storage_partition: partition@fa000 {
                                label = "storage";
                                reg = < 0xfa000 0x6000 >;
                            };
                        };
                    };
                };

    But While compiling we can able to see 3 memory region 
    2 zephyr.elf and 1 tfm_s.axf 
    Our flash partition is less than 250kb but the DFU memory region is very large in size. It shows 784kb. Attach log for you reference.

    Please clarify.
      


  • Hello,

    The files you mentioned, zephyr.elf and tfm_s.axf, are the main Zephyr firmware binary and the Trusted Firmware-M secure binary, respectively, see output build files. If your application binary (zephyr.elf) or any other firmware component (e.g., tfm_s.axf) exceeds the size of its designated partition, it will not fit, leading to potential flash write errors or runtime issues. According to your DTS, the image-0 partition can hold up to 256 KB. If your application exceeds this size, you must either optimize the application to reduce its size or redefine the partition layout. You can follow the memory optimization guide for assistance.

    Kind Regards,

    Abhijith

  • Hi Menon,

    Using the nRF5340 with a W25Q16RV external flash (2 MB) for FOTA DFU.  While configuring the external flash, I faced an issue where the internal flash overflowed by 168 bytes:

    Interestingly, I did not encounter this issue when configuring the system with an 8 MB external flash, even though the external flash is primarily used for FOTA image storage.

    Could you provide guidance on how to resolve this overflow issue, given that I would like to keep the external flash configuration with the W25Q16RV (2 MB)? I'm also interested in understanding how the external flash configuration might influence the internal flash utilization and if there are recommended approaches to optimize memory usage to prevent such overflows.


  • Hello Lavanya,

    I will try to answer your questions here, but I recommend creating a new ticket as these questions are a bit outside the scope of your original query. This will help keep the Devzone tidy and assist other users who refer to Devzone threads.

    Lavanya_Manohar said:
    Interestingly, I did not encounter this issue when configuring the system with an 8 MB external flash, even though the external flash is primarily used for FOTA image storage.

    Switching to an 8 MB external flash resolved the issue suggests that your build configuration may rely on the size of the external flash. It could be using some of the external flash for code execution or data storage, which impacts the total memory usage. The error message states that the internal flash region FLASH is overflowing by 168 bytes. This indicates that the current configuration of your application or firmware requires more internal flash memory than what is available on the nRF5340's internal flash.

    Try following the memory optimization guide I pointed out in my last response. I recommend reviewing your application code and configuration to see if there is any unnecessary code or configuration that can be removed. Try building with Optimization for size (-Os) when adding the build configuration. Adjust the partition sizes to ensure critical partitions fit within the internal flash. Modify your pm_static.yml or pm.yml file to fine-tune how memory is allocated.

    You can also refer to the memory optimization with the nRF connect sdk.

    Kind regards,

    Abhijith

Related