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 Sigurd,

    I appreciate the pointers on partition management, and the simplification of CONFIG_PM_SINGLE_IMAGE.

    Just to keep things up to date, here's how it's going.

    I transitioned this project from static to dynamic partitioning.

    I removed pm_static.yml

    I added pm.yml

    Result: memory report no longer contains a partitions tab

    I believe this is due to the note here (https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/scripts/partition_manager/partition_manager.html#configuration)

    (The root application does not need to define a pm.yml file, because its partition size and placement is implied by the size and placement of the child image partitions. If a root application defines a pm.yml file, it is silently ignored.)

    Next, I define a child image using the multi-image build tooling.

    add configuration/nrf52840dk_nrf52840/child_image.

    I'm concerned about this on the grounds that PM_CONFIG_SINGLE_IMAGE seems to conflict with adding child images.

    I think maybe the best way forward would be for me to take a step back and ask for more general guidance.

    What's the correct way to implement a partition manager while PM_SINGLE_IMAGE is enabled?

    What do you recommend for a DFU-compatible Filesystem?

    What would be the right resource to go learn about these tools so I don't eat up time on DevZone?

    Apologies for not being as helpful as I'd like to be, I'm new to this and feeling lost.

    Thank you very much for any help you can provide.

    All the best,

        - Finn

  • FinnBiggs said:
    I added pm.yml

    No wait.
    pm.yml should not be parsed by user applications. This file is specifically only used for the build system, and not to be used by applications. Applications use pm_static.yml.

    FinnBiggs said:
    (The root application does not need to define a pm.yml file, because its partition size and placement is implied by the size and placement of the child image partitions. If a root application defines a pm.yml file, it is silently ignored.)

    Ah yes I see you already learned what I said above.

    FinnBiggs said:
    What's the correct way to implement a partition manager while PM_SINGLE_IMAGE is enabled?

    Just configure the already enabled partition manager with pm_static.yml.

    FinnBiggs said:
    What do you recommend for a DFU-compatible Filesystem?

    Let us fix the file system alone first and then add DFU?
    Or are you considering using another file-system than the one you try to handle now altogether?
    I do not think I understand the question fully.

    FinnBiggs said:
    What would be the right resource to go learn about these tools so I don't eat up time on DevZone?

    All I got are these:
    https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-8-bootloaders-and-dfu-fota/
    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/scripts/partition_manager/partition_manager.html
    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/config_and_build/multi_image.html

    However, this mostly just requires experience, and this stuff is complicated.
    I think that you can still continue to ask here on DevZone.
    That being said, summer vacations will start here from next week, so we will be a bit low on staff in the following weeks.

    FinnBiggs said:
    Apologies for not being as helpful as I'd like to be, I'm new to this and feeling lost.

    No worries at all, this is not easy, and we know it.
    We should be making it easier, and I hope that we will in the future, but for now we use tech support as a way to make it easier for you guys to use. (At least that is how I see it).
    I think that you are doing a great job, both in trying to learn this and in being friendly!

    Alright, now let me try to explain how I would do this:

    Create the following pm_static.yml:

    fatfs_storage:
      address: 0xf0000
      end_address: 0x100000
      region: flash_primary
      size: 0x10000
      affiliation: disk
      extra_params: {
          disk_name: "SD",
          disk_cache_size: 4096,
          disk_sector_size: 512,
          disk_read_only: 0
      }
    

    You may want to change the region to your external storage, and the address range to either the start or end of that region.

    I also used an arbitrary size, so maybe tweak that a bit.

    When you build with this, you should be able to verify that it was added to partitioning by looking at build/partitioning.yml, which contains the final partitioning for the project.

    Now that the partition does have the affiliation "disk", you should hopefully no longer get the error PM_FOREACH_SOMETHING_SOMETHING_disk that I was getting when building the project.

    Let me know how this goes.

  • Hi Sigurd,

    Thanks for the kind words. I've made a little bit of progress here, but mostly I've been on other issues. After devoting my whole workday to this issue I've decided to come back for more help.

    Or are you considering using another file-system than the one you try to handle now altogether?
    I do not think I understand the question fully.

    At this point I'm open to any solution that meets my two needs -- DFU OTA that works alongside a USB File System. If there's a way to those features that uses some different Zephyr tool set, I'd be happy to swap.

    In this thread, we've boiled down the problem to some conflict between partition manager and flash.

    In the ReadMe here: https://github.com/FinnWBiggs/MCUBoot_ExFat, I lay out build instructions, and the config options which lead to the error.

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

    In the process of trying to debug and come up with a minimal example that narrows the scope of this problem, I went back to the mass sample.

    I believe it may be a valid minimal example add CONFIG_PM_SINGLE_IMAGE to zephyr\samples\subsys\usb\mass sample.

    How can I enable the partition manager in this sample?

    Thanks again for the help.

    Best regards,

        - Finn

  • I have been on vacation the last two weeks, but I am back now.
    Seems like this ticket has not been picket up in the meantime in the summer rush.

    FinnBiggs said:

    In the process of trying to debug and come up with a minimal example that narrows the scope of this problem, I went back to the mass sample.

    I believe it may be a valid minimal example add CONFIG_PM_SINGLE_IMAGE to zephyr\samples\subsys\usb\mass sample.

    How can I enable the partition manager in this sample?

    I think this is a good plan. I will try to make this example work with the partition manager on my side.

    By the way, another customer recently also asked about this in  USB MASS sample and partition manager build issues

  • I think this should solve the USB mass sample (with a workaround. There seems to be a bug in partititon manager)
    Bug in partition_manager_output.py leading to incorrect PM_FOREACH_AFFILIATED_TO_disk 

    Can you give it a go and let me know what you think?

Related