Problem with flashdisk and partition_manager

Hi,

I'm upgrading our application from v2.3.0 to v2.5.0 and I ran into an issue where I can't even get the code to compile any more. 

We are using USB mass storage with a filesystem mounted on an external memory device. Since we also use the bootloader we have to rely on partition_manager to set up the partitions. In the older version I had to have an ugly hack in flashdisk.c to make this work as this combination was not supported by your SDK. Now I see that this should be fixed but I'm completely lost and can't get this to work at all.

Here is the errors I get

[286/314] Building C object zephyr/drivers/disk/CMakeFiles/drivers__disk.dir/flashdisk.c.obj
FAILED: zephyr/drivers/disk/CMakeFiles/drivers__disk.dir/flashdisk.c.obj 
ccache /home/tiit/ncs/toolchains/7795df4459/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DKERNEL -DNRF52840_XXAA -DUSE_PARTITION_MANAGER=1 -D_ANSI_SOURCE -D_FORTIFY_SOURCE=1 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR_SUPERVISOR__ -D__ZEPHYR__=1 -I/home/tiit/ncs/v2.5.0/nrf/drivers/mpsl/clock_control -I/home/tiit/ncs/v2.5.0/zephyr/include -Izephyr/include/generated -I/home/tiit/ncs/v2.5.0/zephyr/soc/arm/nordic_nrf/nrf52 -I/home/tiit/ncs/v2.5.0/zephyr/lib/libc/newlib/include -I/home/tiit/ncs/v2.5.0/zephyr/soc/arm/nordic_nrf/common/. -I/home/tiit/ncs/v2.5.0/zephyr/subsys/mgmt/mcumgr/util/include -I/home/tiit/ncs/v2.5.0/bootloader/mcuboot/boot/bootutil/include -I/home/tiit/ncs/v2.5.0/zephyr/subsys/mgmt/mcumgr/transport/include -I/home/tiit/ncs/v2.5.0/zephyr/subsys/usb/device -I/home/tiit/ncs/v2.5.0/zephyr/subsys/bluetooth -I/home/tiit/ncs/v2.5.0/zephyr/subsys/settings/include -I/home/tiit/ncs/v2.5.0/nrf/include -I/home/tiit/ncs/v2.5.0/nrf/lib/multithreading_lock/. -I/home/tiit/ncs/v2.5.0/nrf/subsys/bluetooth/controller/. -I/home/tiit/ncs/v2.5.0/zephyr/drivers/flash -I/home/tiit/ncs/v2.5.0/nrf/tests/include -I/home/tiit/ncs/v2.5.0/modules/hal/cmsis/CMSIS/Core/Include -I/home/tiit/ncs/v2.5.0/zephyr/modules/cmsis/. -I/home/tiit/ncs/v2.5.0/modules/hal/nordic/nrfx -I/home/tiit/ncs/v2.5.0/modules/hal/nordic/nrfx/drivers/include -I/home/tiit/ncs/v2.5.0/modules/hal/nordic/nrfx/mdk -I/home/tiit/ncs/v2.5.0/zephyr/modules/hal_nordic/nrfx/. -I/home/tiit/ncs/v2.5.0/modules/debug/segger/SEGGER -I/home/tiit/ncs/v2.5.0/modules/debug/segger/Config -I/home/tiit/ncs/v2.5.0/modules/crypto/tinycrypt/lib/include -I/home/tiit/ncs/v2.5.0/modules/lib/zcbor/include -I/home/tiit/ncs/v2.5.0/nrfxlib/mpsl/fem/common/include -I/home/tiit/ncs/v2.5.0/nrfxlib/mpsl/fem/nrf21540_gpio/include -I/home/tiit/ncs/v2.5.0/nrfxlib/mpsl/fem/nrf21540_gpio_spi/include -I/home/tiit/ncs/v2.5.0/nrfxlib/mpsl/fem/simple_gpio/include -I/home/tiit/ncs/v2.5.0/nrfxlib/mpsl/fem/include -I/home/tiit/ncs/v2.5.0/nrfxlib/mpsl/fem/include/protocol -I/home/tiit/ncs/v2.5.0/nrfxlib/mpsl/include -I/home/tiit/ncs/v2.5.0/nrfxlib/mpsl/include/protocol -I/home/tiit/ncs/v2.5.0/nrfxlib/softdevice_controller/include -isystem /home/tiit/ncs/v2.5.0/nrfxlib/crypto/nrf_cc310_platform/include -Wshadow -fno-strict-aliasing -Os -imacros /home/tiit/code/blindy_v3/build/zephyr/include/generated/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=/home/tiit/ncs/toolchains/7795df4459/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros /home/tiit/ncs/v2.5.0/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/home/tiit/code/blindy_v3=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/tiit/ncs/v2.5.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/tiit/ncs/v2.5.0=WEST_TOPDIR -ffunction-sections -fdata-sections -specs=nano.specs -std=c99 -MD -MT zephyr/drivers/disk/CMakeFiles/drivers__disk.dir/flashdisk.c.obj -MF zephyr/drivers/disk/CMakeFiles/drivers__disk.dir/flashdisk.c.obj.d -o zephyr/drivers/disk/CMakeFiles/drivers__disk.dir/flashdisk.c.obj -c /home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:484:1: error: return type defaults to 'int' [-Werror=implicit-int]
  484 | PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_CACHE)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c: In function 'PM_FOREACH_AFFILIATED_TO_disk':
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:523:30: error: storage class specified for parameter 'flash_disks'
  523 | static struct flashdisk_data flash_disks[] = {
      |                              ^~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:523:15: error: parameter 'flash_disks' is initialized
  523 | static struct flashdisk_data flash_disks[] = {
      |               ^~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:524:39: error: 'DEFINE_FLASHDISKS_DEVICE' undeclared (first use in this function)
  524 |         PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_DEVICE)
      |                                       ^~~~~~~~~~~~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:524:39: note: each undeclared identifier is reported only once for each function it appears in
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:533:1: error: expected declaration specifiers before 'PM_FOREACH_AFFILIATED_TO_disk'
  533 | PM_FOREACH_AFFILIATED_TO_disk(VERIFY_CACHE_SIZE_IS_NOT_ZERO_IF_NOT_READ_ONLY)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/tiit/ncs/v2.5.0/zephyr/include/zephyr/toolchain/gcc.h:92,
                 from /home/tiit/ncs/v2.5.0/zephyr/include/zephyr/toolchain.h:50,
                 from /home/tiit/ncs/v2.5.0/zephyr/include/zephyr/sys/__assert.h:11,
                 from /home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:10:
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:125:44: error: storage class specified for parameter '__init_disk_flash_init'
  125 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                            ^~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/toolchain/common.h:132:26: note: in definition of macro '_DO_CONCAT'
  132 | #define _DO_CONCAT(x, y) x ## y
      |                          ^
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:125:36: note: in expansion of macro '_CONCAT'
  125 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                    ^~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:192:17: note: in expansion of macro 'Z_INIT_ENTRY_NAME'
  192 |                 Z_INIT_ENTRY_NAME(name) = {                                    \
      |                 ^~~~~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:174:9: note: in expansion of macro 'SYS_INIT_NAMED'
  174 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:563:1: note: in expansion of macro 'SYS_INIT'
  563 | SYS_INIT(disk_flash_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:190:42: error: parameter '__init_disk_flash_init' is initialized
  190 |         static const Z_DECL_ALIGN(struct init_entry)                           \
      |                                          ^~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:190:22: note: in expansion of macro 'Z_DECL_ALIGN'
  190 |         static const Z_DECL_ALIGN(struct init_entry)                           \
      |                      ^~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:174:9: note: in expansion of macro 'SYS_INIT_NAMED'
  174 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:563:1: note: in expansion of macro 'SYS_INIT'
  563 | SYS_INIT(disk_flash_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:125:44: error: section attribute not allowed for '__init_disk_flash_init'
  125 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                            ^~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/toolchain/common.h:132:26: note: in definition of macro '_DO_CONCAT'
  132 | #define _DO_CONCAT(x, y) x ## y
      |                          ^
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:125:36: note: in expansion of macro '_CONCAT'
  125 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                    ^~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:192:17: note: in expansion of macro 'Z_INIT_ENTRY_NAME'
  192 |                 Z_INIT_ENTRY_NAME(name) = {                                    \
      |                 ^~~~~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:174:9: note: in expansion of macro 'SYS_INIT_NAMED'
  174 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:563:1: note: in expansion of macro 'SYS_INIT'
  563 | SYS_INIT(disk_flash_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:190:42: warning: 'used' attribute ignored [-Wattributes]
  190 |         static const Z_DECL_ALIGN(struct init_entry)                           \
      |                                          ^~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:190:22: note: in expansion of macro 'Z_DECL_ALIGN'
  190 |         static const Z_DECL_ALIGN(struct init_entry)                           \
      |                      ^~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:174:9: note: in expansion of macro 'SYS_INIT_NAMED'
  174 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:563:1: note: in expansion of macro 'SYS_INIT'
  563 | SYS_INIT(disk_flash_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:125:44: error: alignment may not be specified for '__init_disk_flash_init'
  125 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                            ^~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/toolchain/common.h:132:26: note: in definition of macro '_DO_CONCAT'
  132 | #define _DO_CONCAT(x, y) x ## y
      |                          ^
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:125:36: note: in expansion of macro '_CONCAT'
  125 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                    ^~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:192:17: note: in expansion of macro 'Z_INIT_ENTRY_NAME'
  192 |                 Z_INIT_ENTRY_NAME(name) = {                                    \
      |                 ^~~~~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:174:9: note: in expansion of macro 'SYS_INIT_NAMED'
  174 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:563:1: note: in expansion of macro 'SYS_INIT'
  563 | SYS_INIT(disk_flash_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
In file included from /home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:14:
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:563:10: error: 'disk_flash_init' undeclared (first use in this function)
  563 | SYS_INIT(disk_flash_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      |          ^~~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:193:45: note: in definition of macro 'SYS_INIT_NAMED'
  193 |                         .init_fn = {.sys = (init_fn_)},                        \
      |                                             ^~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:563:1: note: in expansion of macro 'SYS_INIT'
  563 | SYS_INIT(disk_flash_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:484:1: error: type of 'DEFINE_FLASHDISKS_CACHE' defaults to 'int' [-Werror=implicit-int]
  484 | PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_CACHE)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:125:44: error: declaration for parameter '__init_disk_flash_init' but no such parameter
  125 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                            ^~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/toolchain/common.h:132:26: note: in definition of macro '_DO_CONCAT'
  132 | #define _DO_CONCAT(x, y) x ## y
      |                          ^
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:125:36: note: in expansion of macro '_CONCAT'
  125 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                    ^~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:192:17: note: in expansion of macro 'Z_INIT_ENTRY_NAME'
  192 |                 Z_INIT_ENTRY_NAME(name) = {                                    \
      |                 ^~~~~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:174:9: note: in expansion of macro 'SYS_INIT_NAMED'
  174 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:563:1: note: in expansion of macro 'SYS_INIT'
  563 | SYS_INIT(disk_flash_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:523:30: error: declaration for parameter 'flash_disks' but no such parameter
  523 | static struct flashdisk_data flash_disks[] = {
      |                              ^~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:564: error: expected '{' at end of input
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:564: warning: control reaches end of non-void function [-Wreturn-type]
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c: At top level:
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:415:37: warning: 'flash_disk_ops' defined but not used [-Wunused-const-variable=]
  415 | static const struct disk_operations flash_disk_ops = {
      |                                     ^~~~~~~~~~~~~~
cc1: some warnings being treated as errors
[294/314] Building C object modules/mcuboot/boot/bootutil/zephyr/CMakeFiles/mcuboot_util.dir/home/tiit/ncs/v2.5.0/bootloader/mcuboot/boot/bootutil/src/bootutil_public.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /home/tiit/ncs/toolchains/7795df4459/usr/local/bin/cmake --build /home/tiit/code/blindy_v3/build

It looks to me that partition_manager is probably supposed to replace the "PM_FOREACH_AFFILIATED_TO_disk" part with something as this does not seem to be a C macro defined anywhere. But how this is actually supposed to happen is not clear to me. I have tried grep-ing for that macro and it only appears in that file and it is never defined. The comments in this file seem to tell me to add some extra parameters to the partition manager definition file but I've tried multiple combinations and nothing seems to work. It doesn't look like this combination is ever used in any of the examples either.

It seems that this macro was added here https://github.com/nrfconnect/sdk-zephyr/commit/6fba504e5e4026e1b563013ac6e7858ca73ea260 by Dominik Ermel <[email protected]>. Would it be possible to ask him to provide any help on this issue? It looks to me like maybe this macro definition was mistakenly not added to the release.

Hoping to hear back from you soon,

Tiit

  • Hi,

     

    It looks to me that partition_manager is probably supposed to replace the "PM_FOREACH_AFFILIATED_TO_disk" part with something as this does not seem to be a C macro defined anywhere. But how this is actually supposed to happen is not clear to me. I have tried grep-ing for that macro and it only appears in that file and it is never defined. The comments in this file seem to tell me to add some extra parameters to the partition manager definition file but I've tried multiple combinations and nothing seems to work. It doesn't look like this combination is ever used in any of the examples either.

    This is a special define that partition manager will pick up, see PM_FOREACH_AFFILIATED_TO_ mentioned here in the docs:

    https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/scripts/partition_manager/partition_manager.html 

    We are using USB mass storage with a filesystem mounted on an external memory device. Since we also use the bootloader we have to rely on partition_manager to set up the partitions. In the older version I had to have an ugly hack in flashdisk.c to make this work as this combination was not supported by your SDK. Now I see that this should be fixed but I'm completely lost and can't get this to work at all.

    Q1: Could you share a bit more information about your project? If you are using a pm_static.yml, can you for debugging purposes, rename that file (ie. take a backup) and let partition manager generate a new one? 

    Q2: Could you share your pm_static.yml and which project you've used as a base, so I can try to recreate the issue locally? Ie. are you able to recreate the issue with for instance zephyr/samples/subsys/usb/mass ?

     

    Kind regards,

    Håkon

  • Thank you for the link to the special define thing. That will at least give me some things to try for now.

    Q1: I don't want to publicly share the whole project here. But I can share the partition manager file.

    mcuboot:
        address: 0x0
        size: 0x7000
        region: flash_primary
    mcuboot_pad:
        address: 0x7000
        size: 0x200
    app:
        address: 0x7200
        size: 0xf3e00
    mcuboot_primary:
        orig_span: &id001
            - mcuboot_pad
            - app
        span: *id001
        address: 0x7000
        size: 0xf4000
        region: flash_primary
    mcuboot_primary_app:
        orig_span: &id002
            - app
        span: *id002
        address: 0x7200
        size: 0xf3e00
    factory_data:
        address: 0xfb000
        size: 0x1000
        region: flash_primary
    settings_storage:
        address: 0xfc000
        size: 0x4000
        region: flash_primary
    mcuboot_secondary:
        address: 0x0
        size: 0xf4000
        device: MX25R64
        region: external_flash
    external_flash:
        address: 0xf4000
        size: 0x70c000
        device: MX25R64
        region: external_flash

    What I want to have is the FatFS/LittleFS occupy the whole "external_flash" partition. We also need to have the bootloader secondary slot in external memory as we need to work with Matter at some point and we are already shipping products based on this that we want to ideally update at a later point. We currently have FatFS in the external memory at the right location but that required an ugly hack to get working that we can hopefully avoid now with the new SDK version. But we want to be able to update existing devices (with FatFS in the memory) to the new SDK version (with LittleFS occupying the same memory area). I will try renaming the partition manager file and see what it tried to create now with the new SDK.

    Q2: I don't remember exactly what project we had as a base and it has been modified so extensively by now that this would probably not help at this point. But we have used examples as starting points for adding in all the new functionality in our application. Searching for this error on your forums I get just one result ( code build issue with mcuboot and mass storage ) and that seems to have the issue due to the build being "out of tree". Now I'm not really exactly sure what that means but we also have our project in an external folder not in the samples folder. Not sure if that has anything to do with this here though. I kind of feel like my partition manager conf file is just missing something important but I'm not sure what and how to add this as I've not found any examples for that.

  • Hello,

     

    Thank you for sharing. I have been in touch with the developer behind the commit and gotten confirmation that this needs to be handled in a specific way.

    If one takes the zephyr/samples/subsys/fs/fs_sample as a basis, with CONFIG_BOOTLOADER_MCUBOOT=y set, the correct pm_static.yml will look like this:

    app:
      address: 0xc200
      end_address: 0x7e000
      region: flash_primary
      size: 0x71e00
    fatfs_storage:
      address: 0xf0000
      affiliation:
      - disk
      end_address: 0x100000
      extra_params:
        disk_cache_size: 0x1000
        disk_name: SD
        disk_read_only: 0x0
        disk_sector_size: 0x200
      placement:
        align:
          start: 0x1000
        before:
        - end
      region: flash_primary
      size: 0x10000
    mcuboot:
      address: 0x0
      end_address: 0xc000
      placement:
        before:
        - mcuboot_primary
      region: flash_primary
      size: 0xc000
    mcuboot_pad:
      address: 0xc000
      end_address: 0xc200
      placement:
        align:
          start: 0x1000
        before:
        - mcuboot_primary_app
      region: flash_primary
      size: 0x200
    mcuboot_primary:
      address: 0xc000
      end_address: 0x7e000
      orig_span: &id001
      - mcuboot_pad
      - app
      region: flash_primary
      sharers: 0x1
      size: 0x72000
      span: *id001
    mcuboot_primary_app:
      address: 0xc200
      end_address: 0x7e000
      orig_span: &id002
      - app
      region: flash_primary
      size: 0x71e00
      span: *id002
    mcuboot_secondary:
      address: 0x7e000
      end_address: 0xf0000
      placement:
        after:
        - mcuboot_primary
        align:
          start: 0x1000
      region: flash_primary
      share_size:
      - mcuboot_primary
      size: 0x72000
    sram_primary:
      address: 0x20000000
      end_address: 0x20040000
      region: sram_primary
      size: 0x40000

     

    In your case, given that "external_flash" is the partition that holds the disk subsys, it needs to have:

      affiliation:
      - disk
     

    And extra parameters corresponding to your settings (parameters are subject to change according to your local settings):

    external_flash:
      ...
      affiliation:
      - disk
      ...
      extra_params:
        disk_cache_size: 0x1000
        disk_name: SD
        disk_read_only: 0x0
        disk_sector_size: 0x200

     

    Could you try this and see if it now works on your side?

     

    Kind regards,

    Håkon

  • Hi,Tiit

    I have the same problem as you now, can you solve it now, can you share it?

    My pm_static.yml

  • Hi,

    What version of the SDK are you using? I just checked and at least for me in older versions the only way to get this working was to modify /zephyr/drivers/disk/flashdisk.c in the SDK. I think there is a fix in the newer versions but I have not worked on this issue or upgraded my SDK in a long time so I can't be sure if the fix helps. We have also moved to using LittleFS from FAT so that may have changed something. I just tried and it seems that I no longer need the manual fix in the SDK for my code to at least compile in SDK 2.5.0. I will be upgrading to the latest SDK in week or so and if there is any problems in that upgrade I will write that here.

    Tiit 

Related