MCUBoot DFU Interference with ExFat Filesystem

Hi Folks!

I've got a rather bulky project that's having a rather bulky project. In short, my project tries to enable both MCUBoot DFU and an ExFat Filesystem. I've narrowed the problem down to some kind of conflict happening between KConfig option for enabling each of these features.

In particular, CONFIG_DISK_DRIVER_FLASH, an implication by CONFIG_APP_MSC_STORAGE_FLASH_FATFS, causes a cascade of errors.

I've created a public Github repo that includes my entire project, configuration settings and files, and a readme that details how to set up my project and enable both of these features at once.

That's located here: https://github.com/FinnWBiggs/mini_desktop

I would be quite grateful for any help detangling DFU and Filesystem options.

Best,

    - Finn

  • Hi,

    I've got a rather bulky project that's having a rather bulky project. In short, my project tries to enable both MCUBoot DFU and an ExFat Filesystem. I've narrowed the problem down to some kind of conflict happening between KConfig option for enabling each of these features.

    You probably have thought about this, but:

    Can I suggest that you try a simpler sample with only MCUboot and ExFat and see if that works?
    I find that having a lot of other things in a project as well tent to complicate debugging

    Regards,
    Sigurd Hellesvik

  • Hi Sigurd,

    I'll set up a minimized version and update here.

    Update:

    Here is a minimized sample causing a collision between ExFat and MCUBoot.

    https://github.com/FinnWBiggs/MCUBoot_ExFat

    I do get a different error than I did in mini_desktop, but that's okay. I believe that if we can find where the two tools conflict, it will tell me enough about the system that I can follow the same logic to get my project working.

    When MCUBoot is disabled, my application finds my devicetree's "some_storage_partition" (whose name I changed to avoid potential naming and defines, such as in flash_map_pm).The sample runs and sets up a USB storage system as intended.

    When I enable MCUBoot, I get errors regarding the definition of PM_some_storage_partition_ID, which implies that MCUBoot is somehow affecting my devicetree's storage partitioning IDs. 

    How do you recommend making MCUBoot and Mass storage compatible based on this?

    Thank you very much for your time,

        - Finn

  • Sweet, having a smaller sample to look at is always good!

    I have to be a bit difficult out of principle:
    Please give me SDK version and build instructions (command/board config is enough, if nothing else is needed). Then, I can test the project.

    FinnBiggs said:
    When I enable MCUBoot, I get errors regarding the definition of PM_some_storage_partition_ID, which implies that MCUBoot is somehow affecting my devicetree's storage partitioning IDs. 

    MCUboot will enable the Partition Manager, which will override DTS partitioning. See this lesson I wrote.

    If you set this, which you have not, MCUboot will automatically use the external flash for its partitions. Other file systems can also be directed to external flash in this way by Kconfig, for example CONFIG_PM_PARTITION_REGION_NVS_STORAGE_EXTERNAL. See pm.yml.nvs for how our build system uses it to define partitions.

    For file systems specifically:

    These lines can be frustrating when working with file systems. As you can see they map different stuff to "storage", which may cause conflicts. So be aware of that

  • Hi Sigurd,

    My mistake on the build instructions! I wrote up build instructions for the first version, but didn't add any to this version.

    Thanks for sticking with me.

    I have added build instructions to the ReadMe.

    github.com/.../MCUBoot_ExFat

    ------------------

    I've been working on this for a few hours now. Good news and bad news.

    Good news!

    I've added a pm_static.yml to configure the partition management. This solves the problem where the PM_some_storage_partition_ID was undefined. I can set up a file system using this partition.

    Bad news

    The new system, which contains a pm_static.yml recreates my initial problem -- flashdisk driver problems.

    ------------------

    How do you advise I make these compatible?

    Best,

        - Finn

  • I have not solved it yet, but I were able to build your project, and i have found some things that could help.

    First some basic partitioning:
    You do not need to define your whole partitioning scheme. Just place your partition somewhere, and the partition manager will try to partition around it. Easiest if you put yours in an end.

    And, try to build with CONFIG_PM_SINGLE_IMAGE=y instead of MCUboot. This way, you get the same error and do not use MCUboot. This is good because it proves that the issue is specifically partition manager and not MCUboot, which narrows it down.

    Then for this specific error:

    Just under where one of the errors point to, I see this:
    https://github.com/nrfconnect/sdk-zephyr/blob/2e2523efe52a7ac89f0567b8798fd857b1e71ae3/drivers/disk/flashdisk.c#L486-L503

    Looking into this, i found something interresting in Partition Manager docs:

    fatfs_storage:
        affiliation: disk
        extra_params: {
            disk_name: "SD",
            disk_cache_size: 4096,
            disk_sector_size: 512,
            disk_read_only: 0
        }
        placement:
            before: [end]
            align: {start: 4096}
        inside: [nonsecure_storage]
        size: 65536

    I suspect that your partition may need such an affiliation and extra parameters.
    I tried to do this for your example, and it did not work first try, so I suggest that you do some more testing with this info as well, and let me know what you find

Related