Issue with flash definitions on nCS v2.9.0

Hello,

I have dts files defined with flash partitions which build & work fine on nCS v2.6.0

But the moment i add same definitions to dts of nCS v2.9.0 it gives me redefinition error:

-- Found BOARD.dts: /opt/nordic/ncs/v2.9.0/zephyr/boards/nordic/nrf52840dk/nrf52840dk_nrf52840.dts
devicetree error: Label 'boot_partition' appears on /soc/flash-controller@4001e000/flash@0/partitions/partition@0 and on /soc/flash-controller@4001e000/flash@0/partitions/partition@f8000
CMake Error at /opt/nordic/ncs/v2.9.0/zephyr/cmake/modules/dts.cmake:295 (execute_process):
  execute_process failed command indexes:



If i try to define flash partitions in dts it says:

You are using Partition Manager to define the partitions. Devicetree definitions are ignored for this build.

If i define in pm_static file as :

nvs_storage:
  address: 0xD7000
  end_address: 0xf7000
  placement:
    align:
      start: 0x1000
    before:
    - device_info
  region: flash_primary
  size: 0x20000

& try to fetch it anyways in code as:

// #define NVS_PARTITION_OFFSET      PM_NVS_STORAGE_ADDRESS
// #define NVS_PARTITION_SIZE        PM_NVS_STORAGE_SIZE
// #define NVS_PARTITION_DEVICE      DEVICE_DT_GET(PM_NVS_STORAGE_DEV)

// #define NVS_PARTITION_OFFSET_TEMP PM_DEVICE_INFO_ADDRESS
// #define NVS_PARTITION_SIZE_TEMP   PM_DEVICE_INFO_SIZE
// #define NVS_PARTITION_DEVICE_TEMP DEVICE_DT_GET(PM_DEVICE_INFO_DEV)

#define NVS_PARTITION_OFFSET PM_NVS_STORAGE_ADDRESS
#define NVS_PARTITION_SIZE   PM_NVS_STORAGE_SIZE
#define NVS_PARTITION_DEVICE DEVICE_DT_GET(DT_NODELABEL(flash0))

#define NVS_PARTITION_OFFSET_TEMP PM_DEVICE_INFO_ADDRESS
#define NVS_PARTITION_SIZE_TEMP   PM_DEVICE_INFO_SIZE
#define NVS_PARTITION_DEVICE_TEMP DEVICE_DT_GET(DT_NODELABEL(flash0))

	fs_temp.flash_device = NVS_PARTITION_DEVICE_TEMP;
	if (!device_is_ready(fs_temp.flash_device)) {
		printk("Flash device %s is not ready\n", fs.flash_device->name);
		return;
	}
	fs_temp.offset = NVS_PARTITION_OFFSET_TEMP;


I get errors as :
error: 'PM_NVS_STORAGE_ADDRESS' undeclared (first use in this function); did you mean 'PM_SETTINGS_STORAGE_ADDRESS'?
   28 | #define NVS_PARTITION_OFFSET PM_NVS_STORAGE_ADDRESS
   
error: 'PM_NVS_STORAGE_SIZE' undeclared (first use in this function); did you mean 'PM_SETTINGS_STORAGE_SIZE'?
   29 | #define NVS_PARTITION_SIZE   PM_NVS_STORAGE_SIZE
   
error: 'PM_DEVICE_INFO_ADDRESS' undeclared (first use in this function)
   32 | #define NVS_PARTITION_OFFSET_TEMP PM_DEVICE_INFO_ADDRESS
      |                                   ^~~~~~~~~~~~~~~~~~~~~~   

Parents
  • Hi, 

    Did you use partition manager in NCS v2.6.0 in combination with dts partitioning? If so, you still need to use both in v2.9.0 as well.

    There might also be some migrating that needs to be done w.r.t configs and naming, but you should be able to see this here https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/releases_and_maturity.html 

    Are the node-properties you're trying to set up present in the dts? Could you share the dts and/or overlay where you set up the NVS device and/or other flash devices?

    Kind regards,
    Andreas

  • Hello,

    So far was able to work around most issues, now just stuck with the final one which is getting flash0 label:

    main.c:22: undefined reference to `__device_dts_ord_126'

    Have attached the sample project as in below, kindly help me resolve the same:
    8130.PM_Stat_Sample.zip

  • Thank you for clarifying it all. I now understand your issue. I will have to look through some samples (which you also can do while waiting), such as for instance the NVS sample. I will get back to you regarding that.

    Sure Thanks  .

    first error you described also with the nRF5340DK? 

    If i mention flash0 partition, "boot_partition" etc in nrf5340dk_nrf5340.dts then yes it gets recreated.
    For now i have removed it from nrf5340dk_nrf5340.dts

  • The Matter samples (for instance light bulb) uses pm static

    I saw the defined pm_static.yml, but not even a single usage in code i found in. all the source files.
    That is what I am looking for, regarding how to get partitions from pm_static.yml for usage in code.

    Like to populate nvs_fs struct . flash_device with a partition as in below:
    /** Flash device runtime structure */
    const struct device *flash_device;

    struct nvs_fs {
    	 /** File system offset in flash **/
    	off_t offset;
    	/** Allocation table entry write address.
    	 * Addresses are stored as uint32_t:
    	 * - high 2 bytes correspond to the sector
    	 * - low 2 bytes are the offset in the sector
    	 */
    	uint32_t ate_wra;
    	/** Data write address */
    	uint32_t data_wra;
    	/** File system is split into sectors, each sector must be multiple of erase-block-size */
    	uint16_t sector_size;
    	/** Number of sectors in the file system */
    	uint16_t sector_count;
    	/** Flag indicating if the file system is initialized */
    	bool ready;
    	/** Mutex */
    	struct k_mutex nvs_lock;
    	/** Flash device runtime structure */
    	const struct device *flash_device;
    	/** Flash memory parameters structure */
    	const struct flash_parameters *flash_parameters;
    #if CONFIG_NVS_LOOKUP_CACHE
    	uint32_t lookup_cache[CONFIG_NVS_LOOKUP_CACHE_SIZE];
    #endif
    };

  • Hi again,

    Mohammed Ubaid said:
    1. How to define flash0 partitions in overlay / pm_static.yml and read in code.?

    So the issue is that you can't define #define NVS_PARTITION_DEVICE DEVICE_DT_GET(DT_NODELABEL(flash0)) using the nodelabel flash0, because it does not exist in your board files. 

    &flash0 {
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		/* Use the last 32KB of NVM as dfu partition. */
    		dfu_partition: partition@f8000 {
    			reg = <0xf8000 DT_SIZE_K(32)>;
    		};
    	};
    };

    You have to define this in your board files (for instance your .overlay, both for app and bootloader) before you can declare it with the DT_NODELABEL. The above snippet is from https://github.com/nrfconnect/sdk-nrf/blob/main/tests/subsys/suit/flash_sink/boards/nrf52840dk_nrf52840.overlay 

    Kind regards,
    Andreas

  • Hello  ,

    I was able to resolve all the build issues:

    1. Related to redundant flash partition declaration : turns out partitions are to be defined in a dedicated partition file present at "ncs/v2.9.0/zephyr/dts/common/nordic" , was not aware of this change in nCS v2.9.0.

    2. Related to pm_static.yml definitions : turns out nCS v2.9.0 needs an explicit "pm_static.yml" defined and present at root directory, unlike earlier in nCS v2.6.0 i had my partition file named as : "pm_static_nrf52840dk_nrf52840.yml" & present at <prj_root_dir/boards/>. In nCS v2.9.0 build, it doesn't detect it at all.


    But now I am getting a hardfault for the exact same code which was working on nCS v2.6.1. I think it has something to do with memory partitions itself. As in below, for nrf52840.

    Can you please guide on how I can proceed further to resolve this issue.?

    Regards,

  • Mohammed Ubaid said:

    I was able to resolve all the build issues:

    1. Related to redundant flash partition declaration : turns out partitions are to be defined in a dedicated partition file present at "ncs/v2.9.0/zephyr/dts/common/nordic" , was not aware of this change in nCS v2.9.0.

    2. Related to pm_static.yml definitions : turns out nCS v2.9.0 needs an explicit "pm_static.yml" defined and present at root directory, unlike earlier in nCS v2.6.0 i had my partition file named as : "pm_static_nrf52840dk_nrf52840.yml" & present at <prj_root_dir/boards/>. In nCS v2.9.0 build, it doesn't detect it at all.

    Happy to hear that and thank you for explaining what went wrong.

    Mohammed Ubaid said:
    But now I am getting a hardfault for the exact same code which was working on nCS v2.6.1. I think it has something to do with memory partitions itself. As in below, for nrf52840.

    Are you able to provide some device logs and state where the fault occurs? I.e is it in bootup, or application?

    Kind regards,
    Andreas

Reply
  • Mohammed Ubaid said:

    I was able to resolve all the build issues:

    1. Related to redundant flash partition declaration : turns out partitions are to be defined in a dedicated partition file present at "ncs/v2.9.0/zephyr/dts/common/nordic" , was not aware of this change in nCS v2.9.0.

    2. Related to pm_static.yml definitions : turns out nCS v2.9.0 needs an explicit "pm_static.yml" defined and present at root directory, unlike earlier in nCS v2.6.0 i had my partition file named as : "pm_static_nrf52840dk_nrf52840.yml" & present at <prj_root_dir/boards/>. In nCS v2.9.0 build, it doesn't detect it at all.

    Happy to hear that and thank you for explaining what went wrong.

    Mohammed Ubaid said:
    But now I am getting a hardfault for the exact same code which was working on nCS v2.6.1. I think it has something to do with memory partitions itself. As in below, for nrf52840.

    Are you able to provide some device logs and state where the fault occurs? I.e is it in bootup, or application?

    Kind regards,
    Andreas

Children
No Data
Related