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 Reply Children
  • 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
  • Result with CONFIG_PM_PARTITION_REGION_SETTINGS_STORAGE_EXTERNAL=n


    Result Open:0
    fa_id 7 device_id 0
    Result Erase:0 size=8192 <<<--- ERROR, SHOULD BE 12287 INSTEAD 8192
    1  Data read: ffffffff
    2  Status Read:0
    3  Status Write:0
    4  Data read: 51525357
    5  Status Read:0
    Result Erase:0
    6  Status Write:0
    7  Data read: 51525358
    8  Status Read:0
    LOG Circular Buffer hh:mm:ss at 00:01:00

  • Result with CONFIG_PM_PARTITION_REGION_SETTINGS_STORAGE_EXTERNAL=y

        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.  Command:

  • Hi,

    Which board do you use? Could you specify your build target from the requirements page?

    Could you provide the structure of your project? Where did you put your pm-static.yml and regions.yml files?

    Could you specify all changes that you made to nrf peripheral_uart sample?

    Could you provide full logs in both working and non-working case?

    FlavioPiracicaba said:
    Here are the codes:

    Could you specify what is shown in the code snippets?

    Best regards,
    Dejan

  • Hi Dejan,

    For the case can be compilated it's possible to generate logs. First of all, I think if you could see the full project instead parts of it in github will be easier.

    It's all here: https://github.com/flavioafferreira/peripheral_uart_new

    I am using a PCA10095 nRF5340-DK

    Basicaly I created some Threads.  When I press button 1, send some informations through bluetooth, Button 2 try to save on external memory, The AD device is reading 4 ports.

    Thanks,

    Flavio.

Related