Unable to access mx25r64 partition using partition manager on sdk 2.9.0

I am trying to create a partition on mx25r64 using partition manager on my nrf52840dk.
Below is my overlay file

/{
	chosen {
		nordic,pm-ext-flash = &mx25r64;
	};
};

Below is my prj.conf file

CONFIG_FLASH=y 
CONFIG_FILE_SYSTEM=y  
CONFIG_FILE_SYSTEM_LITTLEFS=y 
CONFIG_FS_LITTLEFS_FMP_DEV=y 
CONFIG_FLASH_MAP=y 
CONFIG_PARTITION_MANAGER_ENABLED=y
CONFIG_PM_PARTITION_REGION_LITTLEFS_EXTERNAL=y

Below is my pm_static.yml file

external_flash:
  address: 0x00000000
  end_address: 0x007F0000
  region: external_flash
  size: 0x007F0000


littlefs_storage:
  address: 0x00000000
  device: mx25r64
  region: external_flash
  size: 0x007F0000

below is my main.c file. when i run it i keep getting the error storage device is null. meaning the flash cannot be located.

#define LFS_PARTITION FLASH_AREA_ID(littlefs_storage) 
#define LFS_STORAGE_DEV FLASH_AREA_DEVICE(LFS_PARTITION)

static struct fs_littlefs fs_config;
FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(fs_config);

static struct fs_mount_t lfs_mounted = {
    .type = FS_LITTLEFS,
    .mnt_point = "/lfs",            
    .fs_data = &fs_config,          
    .storage_dev = (void *)LFS_STORAGE_DEV, 
};

int main()
{
        const struct device *dev = lfs_mounted.storage_dev;
        if (!dev)
        {
                printk("Storage device is NULL\n");
                return -1;
        }

        printk("Device name: %s\n", dev->name);
}

Kindly assist me in identifying which configurations would i have missed that would be causing this issue.

Parents
  • Hello,

    As far as I can see you don't need the following in your static partitioning to set up the external flash

    external_flash:
      address: 0x00000000
      end_address: 0x007F0000
      region: external_flash
      size: 0x007F0000
    
    

    Your overlay file where you set the chosen external flash and in the board files handles this. CONFIG_PM_PARTITION_REGION_LITTLEFS_EXTERNAL sets up the littlefs partition on the external partition and you specify that it should be a static size by setting it up in your pm_static.yml

    littlefs_storage:
      address: 0x00000000
      device: mx25r64
      region: external_flash
      size: 0x007F0000

    Let me know if this works out for you,

    Kind regards,
    Andreas

  • I removed the external flash partition in the pm_static.yml file and retained only the littlefs_storage partition but I still get Storage device is NULL

  • Hi,

    There were one more thing missing:

    https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/scripts/partition_manager/partition_manager.html says that to use CONFIG_PM_PARTITION_REGION_LITTLEFS_EXTERNAL you  must add a chosen entry for nordic,pm-ext-flash in your devicetree.

    Here's a sample that showcases you this can be done as well as how I've configured the pm_static.yml. Alternatively to the pm_static.yml in the zip, you can also do the following if you wish to have the application and external flash statically configured:

    app:
      address: 0x0
      end_address: 0x100000
      region: flash_primary
      size: 0x100000
    external_flash:
      address: 0x20000
      end_address: 0x800000
      region: external_flash
      size: 0x7e0000
    littlefs_storage:
      address: 0x0
      device: DT_CHOSEN(nordic_pm_ext_flash)
      end_address: 0x20000
      placement:
        before:
        - tfm_storage
        - end
      region: external_flash
      size: 0x20000
    

    You can try this sample with your own pm_static.yml as well to compare.

    Resulting partition map:

    3583.littlefs_qspi_ext.zip

    Let me know if this works for you or if you're able to apply the changes I've made to the LittleFS sample to your own application

    Kind regards,
    Andreas

Reply
  • Hi,

    There were one more thing missing:

    https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/scripts/partition_manager/partition_manager.html says that to use CONFIG_PM_PARTITION_REGION_LITTLEFS_EXTERNAL you  must add a chosen entry for nordic,pm-ext-flash in your devicetree.

    Here's a sample that showcases you this can be done as well as how I've configured the pm_static.yml. Alternatively to the pm_static.yml in the zip, you can also do the following if you wish to have the application and external flash statically configured:

    app:
      address: 0x0
      end_address: 0x100000
      region: flash_primary
      size: 0x100000
    external_flash:
      address: 0x20000
      end_address: 0x800000
      region: external_flash
      size: 0x7e0000
    littlefs_storage:
      address: 0x0
      device: DT_CHOSEN(nordic_pm_ext_flash)
      end_address: 0x20000
      placement:
        before:
        - tfm_storage
        - end
      region: external_flash
      size: 0x20000
    

    You can try this sample with your own pm_static.yml as well to compare.

    Resulting partition map:

    3583.littlefs_qspi_ext.zip

    Let me know if this works for you or if you're able to apply the changes I've made to the LittleFS sample to your own application

    Kind regards,
    Andreas

Children
No Data
Related