error: 'PM_storage_log_ID' undeclared here (not in a function)

I am trying to create a partition on my external flash using littlefs

Here is the line that is returning me an error

FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage);
static struct fs_mount_t lfs_storage_mnt = {
.type = FS_LITTLEFS,
.fs_data = &storage,
//.storage_dev = (void *)FIXED_PARTITION_ID(storage_log),
.storage_dev = (void *)FLASH_AREA_ID(storage_log),

.mnt_point = "/lfs",
};

Here is the error I am receiving

r/src/main.c.obj -MF CMakeFiles/app.dir/src/main.c.obj.d -o CMakeFiles/app.dir/src/main.c.obj -c project/app/src/main.c
In file included from /home/marlon/ncs/v2.6.0/zephyr/include/zephyr/storage/flash_map.h:275,
                 from /home/marlon/ncs/v2.6.0/zephyr/include/zephyr/fs/littlefs.h:12,
                 from project/app/src/main.c:344:
/home/marlon/ncs/v2.6.0/nrf/include/flash_map_pm.h:43:22: error: 'PM_storage_log_ID' undeclared here (not in a function)
   43 | #define PM_ID(label) PM_##label##_ID
      |                      ^~~
/home/marlon/ncs/v2.6.0/nrf/include/flash_map_pm.h:43:22: note: in definition of macro 'PM_ID'
   43 | #define PM_ID(label) PM_##label##_ID
      |                      ^~~
/home/marlon/ncs/v2.6.0/nrf/include/flash_map_pm.h:49:30: note: in expansion of macro 'FIXED_PARTITION_ID'
   49 | #define FLASH_AREA_ID(label) FIXED_PARTITION_ID(label)
      |                              ^~~~~~~~~~~~~~~~~~
project/app/src/main.c:366:28: note: in expansion of macro 'FLASH_AREA_ID'
  366 |     .storage_dev = (void *)FLASH_AREA_ID(storage_log),
      |                            ^~~~~~~~~~~~~
project/app/src/main.c:362:26: warning: 'lfs_storage_mnt' defined but not used [-Wunused-variable]
  362 | static struct fs_mount_t lfs_storage_mnt = {
      |                          ^~~~~~~~~~~~~~~

WHen hovering over FLASH_AREA_ID, I have this message

identifier "PM_storage_log_ID" is undefinedC/C++(20)
#define FLASH_AREA_ID(label) FIXED_PARTITION_ID(label)

Expands to:

PM_storage_log_ID

(I have basically the same error if I use FIXED_PARTITION_ID)

This is the relevant part of my dts

&qspi {
status = "okay";
pinctrl-0 = <&qspi_default>;
pinctrl-1 = <&qspi_sleep>;
pinctrl-names = "default", "sleep";

external_flash: w25q128jv@0 {
compatible = "nordic,qspi-nor";
reg = <0>;
jedec-id = [ ef 40 18 ];
writeoc = "pp4o";
readoc = "read4io";
sck-frequency = <8000000>;
size-in-bytes = <16777216>; // 16 MB total

partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

storage_log: partition@0 {
label = "storage_log";
reg = <0x00000000 0x00200000>;
};

external_data: partition@200000 {
label = "external_data";
reg = <0x00200000 0x00E00000>;
};
};
};
};

and this is the relevant part on my pm_static.yml

sram_primary:
address: 0x20000000
end_address: 0x20038000
region: sram_primary
size: 0x38000

volatile_app_data:
address: 0x20038000
end_address: 0x20040000
placement:
before:
- end
region: sram_primary
size: 0x8000


external_flash:
address: 0x08000000
region: external_flash
size: 0x1000000 # 16 MB
placement:
storage_log:
offset: 0x00000000
size: 0x00200000
external_data:
offset: 0x00200000
size: 0x00E00000

Parents
  • Hi,

     

    Without seeing the generated build/partitions.yml, it is a bit of guesswork from my side, but it does seem like the labels are not generated for the "storage_log" partition.

    Could you try to declare storage_log and external_data in the pm_static.yml similar to this?

     RE: Unable to use LittleFS on External Flash on nrf9160 

     

    Kind regards,

    HĂĄkon

  • Hi! Thanks for your answer.

    This is my partitions.yml

    EMPTY_0:
    address: 0xf7000
    end_address: 0xf8000
    placement:
    after:
    - mcuboot_secondary
    region: flash_primary
    size: 0x1000
    app:
    address: 0x1b200
    end_address: 0x89000
    region: flash_primary
    size: 0x6de00
    app_image:
    address: 0x1b200
    end_address: 0x89000
    orig_span: &id001
    - app
    region: flash_primary
    size: 0x6de00
    span: *id001
    b0:
    address: 0x0
    end_address: 0x8000
    placement:
    after:
    - start
    region: flash_primary
    size: 0x8000
    b0_container:
    address: 0x0
    end_address: 0x9000
    orig_span: &id002
    - b0
    - provision
    region: flash_primary
    size: 0x9000
    span: *id002
    littlefs_storage:
    address: 0xfa000
    end_address: 0x100000
    placement:
    before:
    - end
    region: flash_primary
    size: 0x6000
    mcuboot:
    address: 0x9200
    end_address: 0x12000
    placement:
    before:
    - mcuboot_primary
    region: flash_primary
    sharers: 0x1
    size: 0x8e00
    mcuboot_pad:
    address: 0x1b000
    end_address: 0x1b200
    placement:
    align:
    start: 0x1000
    before:
    - mcuboot_primary_app
    region: flash_primary
    sharers: 0x2
    size: 0x200
    mcuboot_primary:
    address: 0x1b000
    end_address: 0x89000
    orig_span: &id003
    - mcuboot_pad
    - app
    region: flash_primary
    sharers: 0x1
    size: 0x6e000
    span: *id003
    mcuboot_primary_app:
    address: 0x1b200
    end_address: 0x89000
    orig_span: &id004
    - app
    region: flash_primary
    size: 0x6de00
    span: *id004
    mcuboot_secondary:
    address: 0x89000
    end_address: 0xf7000
    placement:
    after:
    - mcuboot_primary
    align:
    start: 0x1000
    region: flash_primary
    share_size:
    - mcuboot_primary
    size: 0x6e000
    provision:
    address: 0x8000
    end_address: 0x9000
    placement:
    after:
    - b0
    align:
    start: 0x1000
    region: flash_primary
    size: 0x1000
    s0:
    address: 0x9000
    end_address: 0x12000
    orig_span: &id005
    - mcuboot
    - s0_pad
    region: flash_primary
    size: 0x9000
    span: *id005
    s0_image:
    address: 0x9200
    end_address: 0x12000
    orig_span: &id006
    - mcuboot
    region: flash_primary
    size: 0x8e00
    span: *id006
    s0_pad:
    address: 0x9000
    end_address: 0x9200
    placement:
    after:
    - b0_container
    align:
    start: 0x1000
    region: flash_primary
    share_size:
    - mcuboot_pad
    size: 0x200
    s1:
    address: 0x12000
    end_address: 0x1b000
    orig_span: &id007
    - s1_pad
    - s1_image
    region: flash_primary
    size: 0x9000
    span: *id007
    s1_image:
    address: 0x12200
    end_address: 0x1b000
    placement:
    after:
    - s1_pad
    - s0
    region: flash_primary
    share_size:
    - mcuboot
    size: 0x8e00
    s1_pad:
    address: 0x12000
    end_address: 0x12200
    placement:
    after:
    - s0
    align:
    start: 0x1000
    region: flash_primary
    share_size:
    - mcuboot_pad
    size: 0x200
    settings_storage:
    address: 0xf8000
    end_address: 0xfa000
    placement:
    align:
    start: 0x1000
    before:
    - end
    region: flash_primary
    size: 0x2000
    sram_primary:
    address: 0x20000000
    end_address: 0x20038000
    region: sram_primary
    size: 0x38000
    volatile_app_data:
    address: 0x20038000
    end_address: 0x20040000
    placement:
    before:
    - end
    region: sram_primary
    size: 0x8000
Reply
  • Hi! Thanks for your answer.

    This is my partitions.yml

    EMPTY_0:
    address: 0xf7000
    end_address: 0xf8000
    placement:
    after:
    - mcuboot_secondary
    region: flash_primary
    size: 0x1000
    app:
    address: 0x1b200
    end_address: 0x89000
    region: flash_primary
    size: 0x6de00
    app_image:
    address: 0x1b200
    end_address: 0x89000
    orig_span: &id001
    - app
    region: flash_primary
    size: 0x6de00
    span: *id001
    b0:
    address: 0x0
    end_address: 0x8000
    placement:
    after:
    - start
    region: flash_primary
    size: 0x8000
    b0_container:
    address: 0x0
    end_address: 0x9000
    orig_span: &id002
    - b0
    - provision
    region: flash_primary
    size: 0x9000
    span: *id002
    littlefs_storage:
    address: 0xfa000
    end_address: 0x100000
    placement:
    before:
    - end
    region: flash_primary
    size: 0x6000
    mcuboot:
    address: 0x9200
    end_address: 0x12000
    placement:
    before:
    - mcuboot_primary
    region: flash_primary
    sharers: 0x1
    size: 0x8e00
    mcuboot_pad:
    address: 0x1b000
    end_address: 0x1b200
    placement:
    align:
    start: 0x1000
    before:
    - mcuboot_primary_app
    region: flash_primary
    sharers: 0x2
    size: 0x200
    mcuboot_primary:
    address: 0x1b000
    end_address: 0x89000
    orig_span: &id003
    - mcuboot_pad
    - app
    region: flash_primary
    sharers: 0x1
    size: 0x6e000
    span: *id003
    mcuboot_primary_app:
    address: 0x1b200
    end_address: 0x89000
    orig_span: &id004
    - app
    region: flash_primary
    size: 0x6de00
    span: *id004
    mcuboot_secondary:
    address: 0x89000
    end_address: 0xf7000
    placement:
    after:
    - mcuboot_primary
    align:
    start: 0x1000
    region: flash_primary
    share_size:
    - mcuboot_primary
    size: 0x6e000
    provision:
    address: 0x8000
    end_address: 0x9000
    placement:
    after:
    - b0
    align:
    start: 0x1000
    region: flash_primary
    size: 0x1000
    s0:
    address: 0x9000
    end_address: 0x12000
    orig_span: &id005
    - mcuboot
    - s0_pad
    region: flash_primary
    size: 0x9000
    span: *id005
    s0_image:
    address: 0x9200
    end_address: 0x12000
    orig_span: &id006
    - mcuboot
    region: flash_primary
    size: 0x8e00
    span: *id006
    s0_pad:
    address: 0x9000
    end_address: 0x9200
    placement:
    after:
    - b0_container
    align:
    start: 0x1000
    region: flash_primary
    share_size:
    - mcuboot_pad
    size: 0x200
    s1:
    address: 0x12000
    end_address: 0x1b000
    orig_span: &id007
    - s1_pad
    - s1_image
    region: flash_primary
    size: 0x9000
    span: *id007
    s1_image:
    address: 0x12200
    end_address: 0x1b000
    placement:
    after:
    - s1_pad
    - s0
    region: flash_primary
    share_size:
    - mcuboot
    size: 0x8e00
    s1_pad:
    address: 0x12000
    end_address: 0x12200
    placement:
    after:
    - s0
    align:
    start: 0x1000
    region: flash_primary
    share_size:
    - mcuboot_pad
    size: 0x200
    settings_storage:
    address: 0xf8000
    end_address: 0xfa000
    placement:
    align:
    start: 0x1000
    before:
    - end
    region: flash_primary
    size: 0x2000
    sram_primary:
    address: 0x20000000
    end_address: 0x20038000
    region: sram_primary
    size: 0x38000
    volatile_app_data:
    address: 0x20038000
    end_address: 0x20040000
    placement:
    before:
    - end
    region: sram_primary
    size: 0x8000
Children
No Data
Related