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

Parents
  • Welcome back!

    Great job on the formatting on the ticket! As you say this project is starting to become complicated, so good formatting on the ticket will enable us to help you a loot faster than if not.

    I tried to build your project for the xiao baord and the nRF52840DK, but get a different error. So I think I am doing something wrong.
    Could you include build instructions, so I know I am getting to the right issue?
    I work from the CLI, so a single west command would be preffered, if not too much to ask.

    Regards,
    Sigurd Hellesvik

  • Hi again Sigurd,

    I'm happy to provide a build command. The error you ran into was likely my fault -- I checked to see if I could build from the zip I sent, and it looks like having the build directories included there has some interaction with CMakeCache.txt that prevents a build.

    That cache problem can be fixed either by removing all build* directories, or by using the new zip at the end of this file (which is the old zip, but with the builds removed).

    For brevity, I'm going to say "dk" in place of "nrf52840dk_nrf52840", and "xiao" instead of "xiao_ble_sense".

    • My build configuration
      • Configuration file (both xiao and dk)
        • ./configuration/common/prj_mcuboot_smp.conf
      • Board
        • xiao
          • xiao_ble_sense
        • dk
          • nrf52840dk_nrf52840
      • DeviceTree Overlay
        • xiao
          • ./configuration/xiao_ble_sense/xiao_ble_sense.overlay
        • dk
          • ./configuration/nrf52840dk_nrf52840/nrf52840dk_nrf52840.overlay
      • Optimization
        • xiao and dk
          • Default is fine
    • West commands
      • xiao
        • west build --build-dir ./build_xiao . --pristine --board xiao_ble_sense --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION=NONE -DCONF_FILE=./configuration/common/prj_mcuboot_smp.conf -DEXTRA_DTC_OVERLAY_FILE=configuration/xiao_ble_sense/xiao_ble_sense.overlay
      • dk
        • west build --build-dir ./build_dk . --pristine --board nrf52840dk_nrf52840 --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION=NONE -DCONF_FILE=./configuration/common/prj_mcuboot_smp.conf -DEXTRA_DTC_OVERLAY_FILE=configuration/nrf52840dk_nrf52840/nrf52840dk_nrf52840.overlay

    Thank you for all your time.

    Best,

        - Finn

    ATTACHED: mass_pm_dfu.zip (same project as before, but with build directories absent and some unused files deleted)

    7587.mass_pm_dfu.zip

    As an aside, I had to delete and remake this reply. Putting the zip file in the middle of the text block caused a number of bizarre formatting problems that rendered my reply unreadable.

Reply
  • Hi again Sigurd,

    I'm happy to provide a build command. The error you ran into was likely my fault -- I checked to see if I could build from the zip I sent, and it looks like having the build directories included there has some interaction with CMakeCache.txt that prevents a build.

    That cache problem can be fixed either by removing all build* directories, or by using the new zip at the end of this file (which is the old zip, but with the builds removed).

    For brevity, I'm going to say "dk" in place of "nrf52840dk_nrf52840", and "xiao" instead of "xiao_ble_sense".

    • My build configuration
      • Configuration file (both xiao and dk)
        • ./configuration/common/prj_mcuboot_smp.conf
      • Board
        • xiao
          • xiao_ble_sense
        • dk
          • nrf52840dk_nrf52840
      • DeviceTree Overlay
        • xiao
          • ./configuration/xiao_ble_sense/xiao_ble_sense.overlay
        • dk
          • ./configuration/nrf52840dk_nrf52840/nrf52840dk_nrf52840.overlay
      • Optimization
        • xiao and dk
          • Default is fine
    • West commands
      • xiao
        • west build --build-dir ./build_xiao . --pristine --board xiao_ble_sense --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION=NONE -DCONF_FILE=./configuration/common/prj_mcuboot_smp.conf -DEXTRA_DTC_OVERLAY_FILE=configuration/xiao_ble_sense/xiao_ble_sense.overlay
      • dk
        • west build --build-dir ./build_dk . --pristine --board nrf52840dk_nrf52840 --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION=NONE -DCONF_FILE=./configuration/common/prj_mcuboot_smp.conf -DEXTRA_DTC_OVERLAY_FILE=configuration/nrf52840dk_nrf52840/nrf52840dk_nrf52840.overlay

    Thank you for all your time.

    Best,

        - Finn

    ATTACHED: mass_pm_dfu.zip (same project as before, but with build directories absent and some unused files deleted)

    7587.mass_pm_dfu.zip

    As an aside, I had to delete and remake this reply. Putting the zip file in the middle of the text block caused a number of bizarre formatting problems that rendered my reply unreadable.

Children
No Data
Related