Bug in partition_manager_output.py leading to incorrect PM_FOREACH_AFFILIATED_TO_disk

I have noticed while trying to use LitteFS with USB Mass Storage a bug with partition_manager_output.py when using the affiliated key in pm_static.yml.

The documentation suggested the following:

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


However if this this used the output produced by `partition_manager_output.py` in `pm.config` and `pm_config.h` is:
PM_FOREACH_AFFILIATED_TO_d(fn)= fn(LITTLEFS_STORAGE)
PM_FOREACH_AFFILIATED_TO_i(fn)= fn(LITTLEFS_STORAGE)
PM_FOREACH_AFFILIATED_TO_s(fn)= fn(LITTLEFS_STORAGE)
PM_FOREACH_AFFILIATED_TO_k(fn)= fn(LITTLEFS_STORAGE)

(This is taken from my code, so its LITTLEFS_STORAGE, not FATFS_STORAGE but the issue is the same).

This issue is fixed with the above `pm_static.yml` is modified to:

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

with the "disk" being indented.

This is due to the following piece of code in partition_manager_output.py: 

for paf in partition['affiliation']:
    ptd = affiliations.get(paf)
    if not ptd:
        affiliations[paf] = list()

    if ptd not in affiliations[paf]:
        affiliations[paf].append(name)

Which assumes `partition['affiliation']` would be a list and not a single string.

This issue appears in the same way as this issue.


I hope this issue can be resolved in future updates and help other people with similar issues.

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

    Tanks!

  • The solution is in the OP.

    Go from this (see `disk` is on the same line as `affiliation`):

    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


    To this (`disk` is now below `affiliation` so is part of a "list"):
    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

Reply
  • The solution is in the OP.

    Go from this (see `disk` is on the same line as `affiliation`):

    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


    To this (`disk` is now below `affiliation` so is part of a "list"):
    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

Children
No Data
Related