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

FIXED_PARTITION_ID macro unable to identify flash partition from overlay

I'll preface this by saying I am new to developing on the nRF and the Zephyr OS. 

I am just trying to set up a flash read/write module on my nRF52DK PCA100040 model. From my readings, it seems I need to first set up a flash partition which is done in an overlay file. In my VSCode config, I added the .overlay file as an "Extra Device Tree Overlay". 

The contents of my .overlay file is:

&flash0 {
    partitions {
        compatible = "fixed-partitions";
        #address-cells = <1>;
        #size-cells = <1>;
   
        rolling_buffer: partition@7F000 {
            label = "rolling_buffer";
            reg = <0x7F000 0x1000>; /* 32b for log storage */
            compatible = "fixed-partition";
        };
    };
};
And my initFlash() function is just:
void initFlash()
{    
    int rc;
    rc = flash_area_open(FIXED_PARTITION_ID(rolling_buffer), &fa);
    if (rc) {
        printk("Failed to open flash partition (%d)\n", rc);
        // return;
    }
}


And when I compile I get the error:
C:/ncs/v3.1.0/nrf/include/flash_map_pm.h:47:22: error: 'PM_rolling_buffer_ID' undeclared (first use in this function)
   47 | #define PM_ID(label) PM_##label##_ID
My prj.conf file:
CONFIG_GPIO=y
CONFIG_SENSOR=y
CONFIG_ADC=y
CONFIG_PRINTK=y
CONFIG_CBPRINTF_FP_SUPPORT=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_FCB=y
CONFIG_LOG=y
build command:
west build --build-dir C:/logger/build C:/logger/build --pristine --board nrf52dk/nrf52832 --sysbuild -- -DCONF_FILE="prj.conf" -DEXTRA_DTC_OVERLAY_FILE=nrf52832dk_nrf52832.overlay -DCONFIG_DEBUG_OPTIMIZATIONS=y -DCONFIG_DEBUG_THREAD_INFO=y
What's  going on here? I feel like I have tried almost everything I can within my current understanding, but can't seem to get this to work. I am using SDK and Toolchain v3.1.0.
Parents Reply
  • Hi,

     

    You will need to align on a flash page, ie. 0x1000 bytes.

    gabagool said:
    How does the compiler know of the pm_static.yaml file, and do I need to add the partition to the .yaml file as well as the .overlay file?

    if pm_static.yml exists, the build system will pick it up and use that for static partitioning, as described in the former link, ie. the documentation for the partition manager.

    gabagool said:

    If I have what I have in my  .overlay file, then do I need the following in my pm_static.yaml file?

    partitions in overlay will not be picked up by the partition manager, they will need to be declared in the pm_static.yml file.

     

    Kind regards,

    Håkon

Children
No Data
Related