MCUBoot, ExFat USB Filesystem, and Flash Region Overflows.

Hello again folks,

Recently, I closed a ticket regarding MCUBoot, DFU, and the USB Mass Filesystem. Unfortunately, I'm still having problems. That ticket, for the curious, is here:  MCUBoot DFU Interference with ExFat Filesystem In that ticket, the problem ended up being to do with the method of adding an affiliation tag to my external storage partition.

When that was resolved, I closed the ticket. However, I'm still stuck in trying to get DFU Enabled alongside a USB Filesystem. Not on the DevKit, where it's working, but in the transfer from devKit to my production board.

As always, here are the details of my environment.

Nordic SDK v2.5.0

Hardware: (working) nRF52840dk

Hardware: (faulting) Xiao BLE Sense

Now, I'll describe the problem.

I have developed an application based on a few different nordic samples. In particular, I am using the usb/mass sample for my filesystem (configured as an ExFat, not littlefs system). I am also using pieces of the LBS sample, and nRF Desktop to enable OTA DFU that preserves my filesystem.

This application compiles, runs, and performs DFU OTA on my nRF52840dk. My current application (if anyone wants it as a sample) is built on top of this one, which was the resolution of my last ticket. https://github.com/FinnWBiggs/mass_pm

From there, I've added child_image subdirectories, and changed my partition manager tool from CONFIG_PM_SINGLE_IMAGE to CONFIG_BOOTLOADER_MCUBOOT, which does add a layer of complexity.

Additionally, I've enabled the options used in nRF Desktop for DFU by following the options implied by those options and including them in my prj.conf

All together, this makes for a complicated app. Regardless, it runs well on the dev kit, and updates the firmware while preserving our filesystem.

The complication arises when building for Xiao BLE sense. Despite sharing a common prj.conf (actually a prj_mcuboot_smp.conf), and having identical structures for the creation of the child image, the Xiao build overflows by the same exact same amount of space no matter what changes I make.

Rather than attaching a git repository, I will attach a zip file of this project so that it can't disappear in the future. (As an aside, what is the preferred method of attaching a lot of information to these help forum posts? Git / Zip / In-text code blocks?)

In this attached zip is a Notes.md, which details a large portion of the changes I've made and the effects those changes have had.

The ones I will call out here to keep folks from having to dig in:

  • Adding a chosen nordic,pm-ext-flash to the xiao build (using the &p2516h), the occupied flash size of a compiled test application with no DFU.
  • The pm_static.yml that is shared by both xiao_ble_sense and nrf52840dk_nrf52840 provides:
    • a primary and secondary mcuboot partition of 488kB (size = 0x7a000)
    • which yields (allotting for the mcuboot pad) an app and mcuboot_primary_app partition size of 0x79e00
  • The changes made to the pm_static.yml that differ from the default partitioning are as follows:
    • Before: 1MB 52840 flash divided as:
      • (And please ignore arbitrary_partition, I was using it for other tests and it got left in while I was taking notes)
    • After: 1MB 52840 flash divided as:
      • Notable changes:
        • settings storage moved from primary->external flash
        • mcuboot primary and secondary expanded by half of the size of settings_storage
        • app increased by half size of settings_storage
        • address of mcuboot_secondary shifted to match new endpoint of app and mcuboot_primary
  • The size of my compiled application is significantly smaller than my app partition (which is fine, but important to note regarding the overflow on the other board)
    • The compiled application size for nrf52840 is 378216B (378.2 kB), which is placed in a partition of size 487.5 kB.
  • I can't validate the compiled size of the application for the xiao_ble_sense, since the application will not compile and always fails in the same way.
    • c:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: zephyr\zephyr_pre0.elf section `rodata' will not fit in region `FLASH'
      c:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: region `FLASH' overflowed by 2408 bytes
  • Changing the compiler optimizations does not change the amount by which the flash overflows.
    • All of Debug, Speed, and Size optimizations overflow by 2408B (2.4 kB), which is significantly less than the ~100kB I had spare in my build for nrf52840dk

I would be very grateful for advice on how to proceed. Thank you very much in advance for your time.

All the best,

   -  Finn

ATTACHED FILE: mass_pm_dfu.zip (zip of relevant project directory, including my builds).

mass_pm_dfu_TOSHARE.zip

Related