Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Partition Manager for External Memory doesn't create correctly the partitions.

Hello,


   I created the regions.yml and pm_static.yml. If I enable this flag the compiler works well

but doesn't create the correct partitions I wrote on pm_static.

##CONFIG_PM_PARTITION_REGION_SETTINGS_STORAGE_EXTERNAL=y

  If I uncomment, these errors appears:


-- Found partition manager static configuration: C:/Nordic/peripheral_uart/pm_static.yml
Dropping partition 'nonsecure_storage' since it is empty.
Traceback (most recent call last):
  File "C:/ncs/v2.3.0-rc1/nrf/scripts/partition_manager.py", line 1978, in <module>
    main()
  File "C:/ncs/v2.3.0-rc1/nrf/scripts/partition_manager.py", line 1028, in main
    solution.update(solve_region(pm_config, region, region_config,
  File "C:/ncs/v2.3.0-rc1/nrf/scripts/partition_manager.py", line 971, in solve_region
    get_region_config(partitions, region_config, static_partitions, system_reqs=pm_config)
  File "C:/ncs/v2.3.0-rc1/nrf/scripts/partition_manager.py", line 742, in get_region_config
    solve_simple_region(pm_config, start, size, placement_strategy, region_name, device,
  File "C:/ncs/v2.3.0-rc1/nrf/scripts/partition_manager.py", line 790, in solve_simple_region
    address += pm_config[partition_name]['size']
KeyError: 'size'
CMake Error at C:/ncs/v2.3.0-rc1/nrf/cmake/partition_manager.cmake:304 (message):
  Partition Manager failed, aborting.

   Could you help me?

Thanks,

Flavio.

  

file app.overlay

/{
   
    chosen {
        nordic,nus-uart = &uart0;
        nordic,pm-ext-flash = &mx25r64;
        nordic,nrf-adc  = &adc;
    };

    aliases {
        adc = &adc;
        dg0 = &dig0;
        dg1 = &dig1;
        dg2 = &dig2;
        dg3 = &dig3;
        dg4 = &dig4;
    };
file prj.conf

CONFIG_NORDIC_QSPI_NOR=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=1024

CONFIG_SETTINGS_NVS=y

CONFIG_NVS=y
CONFIG_SETTINGS=y
CONFIG_PARTITION_MANAGER_ENABLED=y

CONFIG_FILE_SYSTEM=y
CONFIG_FILE_SYSTEM_LITTLEFS=y
CONFIG_PM_PARTITION_REGION_LITTLEFS_EXTERNAL=y
CONFIG_PM_PARTITION_REGION_SETTINGS_STORAGE_EXTERNAL=y
CONFIG_PM_PARTITION_REGION_NVS_STORAGE_EXTERNAL=y


file regions.yml
external_flash:
  base_address: 0x0
  default_driver_kconfig: CONFIG_PM_EXTERNAL_FLASH_HAS_DRIVER
  device: DT_CHOSEN(nordic_pm_ext_flash)
  dynamic_partition: null
  name: external_flash
  placement_strategy: start_to_end
  size: 0x800000
file pm_static.yml
partition_1:
  address: 0x0
  end_address: 0x7FFFFF
  region: external_flash
  size: 0x800000
Created by build:
file regions.yml
external_flash:
  base_address: 0x0
  default_driver_kconfig: CONFIG_PM_EXTERNAL_FLASH_HAS_DRIVER
  device: DT_CHOSEN(nordic_pm_ext_flash)
  dynamic_partition: null
  name: external_flash
  placement_strategy: start_to_end
  size: 0x800000
flash_primary:
  base_address: 0x0
  default_driver_kconfig: CONFIG_SOC_FLASH_NRF
  device: flash_controller
  dynamic_partition: null
  name: flash_primary
  placement_strategy: complex
  size: 0x100000
file partitions.yml
app:
  address: 0x8000
  end_address: 0xfc000
  region: flash_primary
  size: 0xf4000
external_flash:
  address: 0x0
  end_address: 0x800000
  region: external_flash
  size: 0x800000
nonsecure_storage:
  address: 0xfc000
  end_address: 0xfe000
  orig_span: &id001
  - settings_storage
  region: flash_primary
  size: 0x2000
  span: *id001
  • Hi 3Nigma,

       Worked very well with your suggestion on makefile.

       On the file partitions , it's ok with two partitions created (partition_0 and partition_1). One thing I didn't understand is why was created automacatily a partition external_partition with negative size. Do you know if it's possible don't create this external_partition?

    Thanks,

    Flavio.

       

    EMPTY_0:
      address: 0xfe000
      end_address: 0x100000
      placement:
        after:
        - littlefs_storage
      region: flash_primary
      size: 0x2000
    app:
      address: 0x8000
      end_address: 0xf8000
      region: flash_primary
      size: 0xf0000
    external_flash:
      address: 0x802000
      end_address: 0x800000
      region: external_flash
      size: -0x2000
    littlefs_storage:
      address: 0xf8000
      end_address: 0xfe000
      inside:
      - nonsecure_storage
      placement:
        align:
          start: 0x4000
        before:
        - end
      region: flash_primary
      size: 0x6000
    nonsecure_storage:
      address: 0xf8000
      end_address: 0xfe000
      orig_span: &id001
      - littlefs_storage
      region: flash_primary
      size: 0x6000
      span: *id001
    otp:
      address: 0xff8100
      end_address: 0xff83fc
      region: otp
      size: 0x2fc
    partition_0:
      address: 0x0
      end_address: 0x400000
      region: external_flash
      size: 0x400000
    partition_1:
      address: 0x400000
      end_address: 0x800000
      region: external_flash
      size: 0x400000
    rpmsg_nrf53_sram:
      address: 0x20070000
      end_address: 0x20080000
      placement:
        before:
        - end
      region: sram_primary
      size: 0x10000
    settings_storage:
      address: 0x800000
      device: DT_CHOSEN(nordic_pm_ext_flash)
      end_address: 0x802000
      inside:
      - nonsecure_storage
      placement:
        align:
          start: 0x4000
        before:
        - tfm_storage
        - end
      region: external_flash
      size: 0x2000
    sram_nonsecure:
      address: 0x20008000
      end_address: 0x20080000
      orig_span: &id002
      - sram_primary
      - rpmsg_nrf53_sram
      region: sram_primary
      size: 0x78000
      span: *id002
    sram_primary:
      address: 0x20008000
      end_address: 0x20070000
      region: sram_primary
      size: 0x68000
    sram_secure:
      address: 0x20000000
      end_address: 0x20008000
      orig_span: &id003
      - tfm_sram
      region: sram_primary
      size: 0x8000
      span: *id003
    tfm:
      address: 0x0
      end_address: 0x8000
      placement:
        before:
        - app
      region: flash_primary
      size: 0x8000
    tfm_nonsecure:
      address: 0x8000
      end_address: 0xf8000
      orig_span: &id004
      - app
      region: flash_primary
      size: 0xf0000
      span: *id004
    tfm_secure:
      address: 0x0
      end_address: 0x8000
      orig_span: &id005
      - tfm
      region: flash_primary
      size: 0x8000
      span: *id005
    tfm_sram:
      address: 0x20000000
      end_address: 0x20008000
      inside:
      - sram_secure
      placement:
        after:
        - start
      region: sram_primary
      size: 0x8000

  • Hey Flavio,

    I think this code explains why an external_flash region is being generated: if you have a chosennordic,pm-ext-flash value, then an external_region is provided to you.

    So if you do a

    /{
    	chosen {
    		/delete-property/ nordic,pm-ext-flash;
    	}
    }

    it should, in theory, work. But you will need to change your main.c code a bit (saw that you are using 

    DEVICE_DT_GET(DT_CHOSEN(nordic_pm_ext_flash)) there).
    One thing to mention here is that, if you remove the nordic,pm-ext-flash chosen value, 
    CONFIG_PM_PARTITION_REGION_SETTINGS_STORAGE_EXTERNAL also becomes unavailable due to the way it's Kconfig is defined. This leads, in your case, to no external_flash partitions being generated.

    V

  • Hello 3Nigma,

    I edited the partition_manager.cmake and added manualy the region. Removed nordic,pm-ext-flash from chosen.

    Now it's creating the partitions.yml correctly and the regions.yml too.

    And don't have the size negative on partition external_flash.

    Do you know if there is another way to create this region without edit the partition_manager.cmake?

    Thanks,

    Flavio.

    dt_chosen(ext_flash_dev PROPERTY nordic,pm-ext-flash)
    if (DEFINED ext_flash_dev)
      dt_prop(num_bits PATH ${ext_flash_dev} PROPERTY size)
      math(EXPR num_bytes "${num_bits} / 8")
    
      set(external_flash_driver_kconfig CONFIG_PM_EXTERNAL_FLASH_HAS_DRIVER)
    
      add_region(
        NAME external_flash
        SIZE ${num_bytes}
        BASE ${CONFIG_PM_EXTERNAL_FLASH_BASE}
        PLACEMENT start_to_end
        DEVICE "DT_CHOSEN(nordic_pm_ext_flash)"
        DEFAULT_DRIVER_KCONFIG ${external_flash_driver_kconfig}
        )
    endif()
    
    
    add_region(
      NAME external_flash
      SIZE 0X800000
      BASE 0
      PLACEMENT start_to_end
      DEVICE "DT_ALIAS(external-mx25)"
      DEFAULT_DRIVER_KCONFIG CONFIG_PM_EXTERNAL_FLASH_HAS_DRIVER
      )
    

  • Hey Flavio,

    Why do you want to keep the external_flash region around if you don't want to put any partition in it? 

    By the way, I would not edit the partition_manager.cmake directly since, unlike the previous discussion (eg. with the pm.yml.settings file), the partition_manager.cmake code behaves correctly (it is not a bug).

    Depending on what you are trying to achieve, I think there are other solutions that would help instead of forcing a region to be defined.

    Best wishes,

    V

  • Hi Flavio,

    Have you achieved progress on your initial issue? Could you provide an update on the current status? 

    Best regards,
    Dejan

Related