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
Parents
  • Hi,

    If I enable this flag the compiler works well
    If I uncomment, these errors appears:

    Could you please clarify what works well and what not, and in which cases - enabled or disabled configuration option?

    Could you elaborate on what you try to achieve?

    Best regards,
    Dejan

  • I would like to create custom partitions (partition_1) on external flash memory. I created the pm-static.yml and the regions.yml.

    on pm-static.yml
    partition_1:
      address: 0x0
      end_address: 0x7FFFFF
      region: external_flash
      size: 0x800000

    After "Build all configurations" it's not appearing correctly on file /built/partitions.yml. On this file apears only:

    external_flash:
      address: 0x0
      end_address: 0x800000
      region: external_flash
      size: 0x800000
    If I setup this command: CONFIG_PM_PARTITION_REGION_SETTINGS_STORAGE_EXTERNAL=y
    on file prj.conf and I press "Build all configurations" return this error I showed.
    With CONFIG_PM_PARTITION_REGION_SETTINGS_STORAGE_EXTERNAL=n works but don't create any
    partition.
    I used as base, peripheral-uart example.
    Here are the codes:
    #
    # Copyright (c) 2018 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    
    # Enable the UART driver
    CONFIG_UART_ASYNC_API=y
    CONFIG_NRFX_UARTE0=y
    CONFIG_SERIAL=y
    
    CONFIG_GPIO=y
    
    # Make sure printk is printing to the UART console
    CONFIG_CONSOLE=y
    CONFIG_UART_CONSOLE=y
    
    CONFIG_HEAP_MEM_POOL_SIZE=10000
    
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="Flavio_Service"
    CONFIG_BT_DEVICE_APPEARANCE=833
    CONFIG_BT_MAX_CONN=1
    CONFIG_BT_MAX_PAIRED=1
    CONFIG_BT_L2CAP_TX_MTU=247
    
    
    CONFIG_BT_L2CAP_TX_BUF_COUNT=2
    ###CONFIG_BT_CTLR_RX_BUFFERS=1
    CONFIG_BT_BUF_ACL_TX_SIZE=247
    
    
    
    # Enable the NUS service
    CONFIG_BT_NUS=y
    
    # Enable bonding
    CONFIG_BT_SETTINGS=y
    CONFIG_SETTINGS=y
    
    
    CONFIG_NORDIC_QSPI_NOR=y
    CONFIG_FLASH=y
    ##CONFIG_MPU_ALLOW_FLASH_WRITE=y
    
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    ##CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=1024
    CONFIG_SETTINGS_NVS=y
    CONFIG_NVS=y
    CONFIG_PARTITION_MANAGER_ENABLED=y
    CONFIG_FILE_SYSTEM=y
    
    CONFIG_PM_PARTITION_REGION_SETTINGS_STORAGE_EXTERNAL=y
    
    
    
    # Enable DK LED and Buttons library
    CONFIG_DK_LIBRARY=y
    
    # This example requires more workqueue stack
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    # Config logger
    CONFIG_LOG=y
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_LOG_BACKEND_RTT=y
    CONFIG_LOG_BACKEND_UART=n
    CONFIG_LOG_PRINTK=n
    
    CONFIG_ASSERT=y
    
    
    
    # SPI
    CONFIG_SPI=y
    
    ## enable timer funcions
    ##https://docs.zephyrproject.org/latest/kernel/timing_functions/index.html
    CONFIG_TIMING_FUNCTIONS=y
    
    ##https://docs.zephyrproject.org/1.14.1/reference/kernel/timing/clocks.html
    CONFIG_SYS_CLOCK_EXISTS=y
    
    
    ###FLASH CONFIG -- FLAVIO
    CONFIG_PRINTK=y
    
    
    ##CONFIG_CBPRINTF_FP_SUPPORT=y
    
    CONFIG_NEWLIB_LIBC=y
    CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
    
    CONFIG_ADC=y
    
    CONFIG_ADC_NRFX_ADC=y
    CONFIG_ADC_NRFX_ADC_CHANNEL_COUNT=6
    
    void flash_test_(void) {
      //C:\ncs\v2.3.0-rc1\zephyr\include\zephyr\devicetree\fixed-partitions.h
       //https://elinux.org/Device_Tree_Usage#How_Addressing_Works
    
       int err = 0;
       uint32_t size;
    
    
    #define FLASH_DEVICE "mx25r6435f@0" 
    
    const struct device *flash_dev = device_get_binding(FLASH_DEVICE);
    struct flash_area *my_area_partition;
    my_area_partition = (struct flash_area*)k_malloc(sizeof(struct flash_area));
    my_area_partition->fa_dev=&flash_dev;
    //err=flash_area_open(FIXED_PARITION_ID(external_partition), &my_area_partition);
    //err=flash_area_open(external_partition, &my_area_partition);
    err=flash_area_open(DT_FIXED_PARTITION_ID(DT_NODE_BY_FIXED_PARTITION_LABEL(partition_0)), &my_area_partition);
    
       printf("Result Open:%d \n", err);
    
       printf("fa_id %d device_id %d\n", my_area_partition->fa_id,my_area_partition->fa_device_id);
      
       err = flash_area_erase(my_area_partition, 0, my_area_partition->fa_size);
       printf("Result Erase:%d size=%lu \n", err,my_area_partition->fa_size);
     
       uint32_t position_info = 20;
       uint32_t quantity_of_bytes = sizeof(uint32_t);
       uint32_t buf_word = 0U;
    
       err = flash_area_read(my_area_partition, position_info, &buf_word, quantity_of_bytes);
       printf("1  Data read: %x\n", buf_word);
       printf("2  Status Read:%d \n", err);
    
       buf_word = 0x51525357;
       err = flash_area_write(my_area_partition, position_info, &buf_word, quantity_of_bytes);
       printf("3  Status Write:%d \n", err);
    
       buf_word = 0x0;
       err = flash_area_read(my_area_partition, position_info, &buf_word, quantity_of_bytes);
       printf("4  Data read: %x\n", buf_word);
       printf("5  Status Read:%d \n", err);
    
       err = flash_area_erase(my_area_partition, 0, my_area_partition->fa_size);
       printf("Result Erase:%d \n", err);
    
       buf_word = 0x51525358;
       err = flash_area_write(my_area_partition, position_info, &buf_word, quantity_of_bytes);
       printf("6  Status Write:%d \n", err);
    
       buf_word = 0x0;
    
       err = flash_area_read(my_area_partition, position_info, &buf_word, quantity_of_bytes);
       printf("7  Data read: %x\n", buf_word);
       printf("8  Status Read:%d \n", err);
    
    
    }
    /*
     * Copyright (c) 2022 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
     */
    
    /{
    	
    	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;
    	};
    
    	digital {
    		compatible = "gpio-keys";
    		dig0: dig_0 {
    			gpios = < &gpio1 0x04 (GPIO_PULL_UP | GPIO_ACTIVE_HIGH) >;
    			label = "Digital Input 0";
    			
    		};
    		dig1: dig_1 {
    			gpios = < &gpio1 0x05 (GPIO_PULL_UP | GPIO_ACTIVE_HIGH) >;
    			label = "Digital Input 1";
    		};
    		dig2: dig_2 {
    			gpios = < &gpio1 0x06 (GPIO_PULL_UP | GPIO_ACTIVE_HIGH) >;
    			label = "Digital Input 2";
    		};
    		dig3: dig_3 {
    			gpios = < &gpio1 0x07 (GPIO_PULL_UP | GPIO_ACTIVE_HIGH) >;
    			label = "Digital Input 3";
    		};
    		dig4: dig_4 {
    			gpios = < &gpio1 0x08 (GPIO_PULL_UP | GPIO_ACTIVE_HIGH) >;
    			label = "Digital Input 4";
    		};
    
    	};
    
     };
    
    //https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/build/dts/api/bindings/adc/nordic%2Cnrf-adc.html#dtbinding-nordic-nrf-adc
    //https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/build/dts/api/bindings.html#nordic-semiconductor-nordic
    
    
    &adc {
    	#address-cells = <1>;
    	#size-cells = <0>;
    	
       /* verify c:\ncs\v2.3.0-rc1\zephyr\boards\arm\nrf5340dk_nrf5340\nrf5340_cpuapp_common.dts
       <0 &adc 0>,	/* A0 = P0.4 = AIN0 
       <1 &adc 1>,	/* A1 = P0.5 = AIN1 
       <2 &adc 2>,	/* A2 = P0.6 = AIN2 
       <3 &adc 3>,	/* A3 = P0.7 = AIN3 
       <4 &adc 4>,	/* A4 = P0.25 = AIN4 */
    
    
    	channel@0 {
    		reg = <0>;
    		zephyr,gain = "ADC_GAIN_1_6";
    		zephyr,reference = "ADC_REF_INTERNAL";
    		zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
    		zephyr,input-positive = <NRF_SAADC_AIN1>; /* P0.05 */
    		zephyr,resolution = <14>;
    	};
    
    	channel@1 {
    		reg = <1>;
    		zephyr,gain = "ADC_GAIN_1_6";
    		zephyr,reference = "ADC_REF_INTERNAL";
    		zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
    		zephyr,input-positive = <NRF_SAADC_AIN2>; /* P0.06 */
    		zephyr,resolution = <14>;
    		zephyr,oversampling = <8>;
    	};
    
    	channel@2 {
    		reg = <2>;
    		zephyr,gain = "ADC_GAIN_1_6";
    		zephyr,reference = "ADC_REF_INTERNAL";
    		zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
    		zephyr,input-positive = <NRF_SAADC_AIN3>; /* P0.07 */
    		zephyr,resolution = <14>;
    		zephyr,oversampling = <8>;
    	};
    
    	channel@3 {
    		reg = <3>;
    		zephyr,gain = "ADC_GAIN_1_6";
    		zephyr,reference = "ADC_REF_INTERNAL";
    		zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
    		zephyr,input-positive = <NRF_SAADC_AIN4>;/* P0.25 */ 
    		zephyr,resolution = <14>;
    		zephyr,oversampling = <8>;
    	};
    
    	channel@4 {
    		reg = <4>;
    		zephyr,gain = "ADC_GAIN_1_6";
    		zephyr,reference = "ADC_REF_INTERNAL";
    		zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
    		zephyr,input-positive = <NRF_SAADC_VDD>; //VDD
    		zephyr,resolution = <14>;
    		zephyr,oversampling = <8>;
    	};
    
    	channel@7 {
    		reg = <7>;
    		zephyr,gain = "ADC_GAIN_1_5";
    		zephyr,reference = "ADC_REF_VDD_1_4";
    		zephyr,vref-mv = <750>;
    		zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
    		zephyr,input-positive = <NRF_SAADC_AIN6>; /* P0.30 */
    		zephyr,input-negative = <NRF_SAADC_AIN7>; /* P0.31 */
    		zephyr,resolution = <12>;
    	};
    	io-channels = <&adc 0>, <&adc 1>,<&adc 2>,<&adc 3>,<&adc 4>,<&adc 7>;
    };
    
    
    
    
    
    &mx25r64 {
    	label ="memoria";
    	
    	partitions {
    	 compatible = "fixed-partitions";
    	 #address-cells = <1>;
    	 #size-cells = <1>;
    	 
    	 partition1_label: partition@0 {
    		label = "partition_0";  //32 pages of 4kbytes = 128k
    		reg = <0x00000000 0x000002FFF>;
    	
    	 };
         
    	 partition2_label: partition@3000 {
    		label = "partition_1"; //32 pages of 4kbytes = 128k
    		reg = <0x00003000 0x000003FFF>;
    	
    	 };
    
    	 partition3_label: partition@40000 {
    		label = "partition_2";      //48 pages of 4bytes = 192k
    		reg = <0x00040000 0x00002FFFF>;
    	
    	 };
    
    	 partition4_label: partition@70000 {
    		label = "partition_3";   //48 pages of 4kbytes = 192k
    		reg = <0x00070000 0x00002FFFF>;
    	
    	 };
    
    	 partition5_label: partition@110000 {
    		label = "partition_4"; //1797 pages of 4kbytes = 7Mb
    		reg = <0x00110000 0x0007FFFFF>;
    	
    	 };
            //TOTAL USED 768K
    
    	};
    
    };
    
    
    
    
    partition_0:
      address: 0x0
      end_address: 0x1FFF
      region: external_flash
      size: 0x2000
    
    partition_1:
      address: 0x2000
      end_address: 0x3FFF
      region: external_flash
      size: 0x2000
    
    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
  • I'm having the same problem.

    Traceback (most recent call last):
      File "/home/eetnev/git/ncs/v2.3.0/nrf/scripts/partition_manager.py", line 1978, in <module>
        main()
      File "/home/eetnev/git/ncs/v2.3.0/nrf/scripts/partition_manager.py", line 1028, in main
        solution.update(solve_region(pm_config, region, region_config,
      File "/home/eetnev/git/ncs/v2.3.0/nrf/scripts/partition_manager.py", line 971, in solve_region
        get_region_config(partitions, region_config, static_partitions, system_reqs=pm_config)
      File "/home/eetnev/git/ncs/v2.3.0/nrf/scripts/partition_manager.py", line 742, in get_region_config
        solve_simple_region(pm_config, start, size, placement_strategy, region_name, device,
      File "/home/eetnev/git/ncs/v2.3.0/nrf/scripts/partition_manager.py", line 790, in solve_simple_region
        address += pm_config[partition_name]['size']
    KeyError: 'size'

    I changed pm.yml.settings as  described and now I'm getting:

    v2.3.0/nrf/modules/tfm/tfm/boards/common/assert.c:17:2: error: #error "TF-M non-secure address start is not aligned on SPU region size"

    Which relates to this.

  • Hello 3Nigma,

        With this patch you created worked fine.  Now is building without any error. I have some difficulties in understand why is creating automaticly the partition "external-flash". I defined on pm-static.yml other partitions but the builder create only the partition external-flash.

    Thanks,

    Flavio.

  • Hello Eetu,

        It's not easy to put to work. I couldn't find examples.Unfortunately the explanation on Nordic web site is not clear.

  • Hey Flavio,

    I will look into your issue more carefully and come back to you, hopefully, with some feedback (if you don't find the solution in the meantime).

    Take care,

    V

  • Flavio,

    I think I understand better what's happening. The short version is that, if you rename your pm-static.yml file to pm_static.yml and remove the line "ncs_add_partition_manager_config(pm-static.yml)" from your CMakeLists.txt, your static definitions will be picked up by the partition-manager  The partition-manager will then complain that the partitions aren't properly defined -- I'll let you investigate the cause of this.

    The longer answer to this is that ncs_add_partition_manager_config doesn't have effect after calling "find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})". That's because, by the time cmake executes your "ncs_add_partition_manager_config " function call, it has already executed the partition-manager script with whatever it had at its disposal.

    Just as a FYI: in order to investigate this, I added a couple of cmake message statements:

    1. "message(STATUS "Found zephyr!!!")" after your "project(NONE)" line
    2. another one in <nrf>/subsys/partition_manager/CMakeLists.txt (line 155) that reads: "
      message(STATUS "PM_SUBSYS_PATHS is ${PM_SUBSYS_PATHS}")"

    And, sure enough, after I ran "west build", I saw the "PM_SUBSYS_PATHS is..." message BEFORE the "Found zephyr!!!" one!

    If you still want to use the non-standard pm-static.yml file name, you can do a "set(PM_STATIC_YML_FILE "C:/Nordic/peripheral_uart/pm-static.yml")" just before the "find_package(Zephyr ...)" call in your CMakeLists.txt file as described in the nrf docs.

    I hope this helps,

    Best wishes,

    V

Reply
  • Flavio,

    I think I understand better what's happening. The short version is that, if you rename your pm-static.yml file to pm_static.yml and remove the line "ncs_add_partition_manager_config(pm-static.yml)" from your CMakeLists.txt, your static definitions will be picked up by the partition-manager  The partition-manager will then complain that the partitions aren't properly defined -- I'll let you investigate the cause of this.

    The longer answer to this is that ncs_add_partition_manager_config doesn't have effect after calling "find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})". That's because, by the time cmake executes your "ncs_add_partition_manager_config " function call, it has already executed the partition-manager script with whatever it had at its disposal.

    Just as a FYI: in order to investigate this, I added a couple of cmake message statements:

    1. "message(STATUS "Found zephyr!!!")" after your "project(NONE)" line
    2. another one in <nrf>/subsys/partition_manager/CMakeLists.txt (line 155) that reads: "
      message(STATUS "PM_SUBSYS_PATHS is ${PM_SUBSYS_PATHS}")"

    And, sure enough, after I ran "west build", I saw the "PM_SUBSYS_PATHS is..." message BEFORE the "Found zephyr!!!" one!

    If you still want to use the non-standard pm-static.yml file name, you can do a "set(PM_STATIC_YML_FILE "C:/Nordic/peripheral_uart/pm-static.yml")" just before the "find_package(Zephyr ...)" call in your CMakeLists.txt file as described in the nrf docs.

    I hope this helps,

    Best wishes,

    V

Children
  • 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