In SDK 1.9.1 littlefs can not be assigned to external flash region

I think there were a few other cases that had a problem using external flash for littlefs, but I think I found out why it is not working in the latest SDK.

I configured all of the parameters for Partition manager, but the littlefs partition was always getting assigned to internal memory.

The problem is the pm.yml.file_system file does not contain a region: parameter and thus defaults to the internal flash.

I manually added "region: external_flash" and now it is working as expected, but this should be parameterized so that the user can configure the region from the application.

Could you please check and fix in the next release?

Here is the modified pm.yml.file_system file:

#include <autoconf.h>

#ifdef CONFIG_FILE_SYSTEM_LITTLEFS
littlefs_storage:
  region: external_flash
  placement: {before: [end]}
  size: CONFIG_PM_PARTITION_SIZE_LITTLEFS
#endif

Parents Reply Children
  • I have a solution that seemed to work, but had more important items and I was also waiting for a fix for 32bit SFlash addressing from upstream.  I'll post it here shortly if you want to take a look and try it.  But I have not had much time to work on a more generic fix that is required to get it working in the official SDK.

  • Here was the key change in the SDK, it seems by default there was no way to get the littlefs to goto external memory in the partition manager, but it should be selectable in a PR.

    There were a number of other changes that were needed as well to get it full configured.

    diff --git a/subsys/partition_manager/pm.yml.file_system b/subsys/partition_manager/pm.yml.file_system
    index 2b9907380..73008bbde 100644
    --- a/subsys/partition_manager/pm.yml.file_system
    +++ b/subsys/partition_manager/pm.yml.file_system
    @@ -2,6 +2,7 @@
     
     #ifdef CONFIG_FILE_SYSTEM_LITTLEFS
     littlefs_storage:
    +  region: external_flash
       placement: {before: [end]}
       size: CONFIG_PM_PARTITION_SIZE_LITTLEFS
     #endif
    

  • This looks great. Thanks for posting it. I took things a little farther to try to implement the configurability you mentioned. Here is what I have so far.:

    diff --git a/subsys/partition_manager/Kconfig b/subsys/partition_manager/Kconfig
    index b4fb5050c..721011146 100644
    --- a/subsys/partition_manager/Kconfig
    +++ b/subsys/partition_manager/Kconfig
    @@ -118,6 +118,18 @@ config PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY
     	  of the internal flash. This option should only be enabled by the user
     	  in the parent image.
     
    +config PM_EXTERNAL_FLASH_LITTLEFS
    +	bool "Place the LittleFS partition in external flash"
    +	depends on FILE_SYSTEM_LITTLEFS
    +	# Only depend on the chosen for the parent image. The value of this
    +	# option is propagated to the MCUboot child image automatically.
    +	depends on $(dt_chosen_enabled,$(DT_CHOSEN_EXT_FLASH))
    +	default n
    +	help
    +	  Place the partition for LittleFS in the external flash instead
    +	  of the internal flash. This option should only be enabled by the user
    +	  in the parent image.
    +
     config PM_IMAGE_NOT_BUILT_FROM_SOURCE
     	bool
     	help
    diff --git a/subsys/partition_manager/pm.yml.file_system b/subsys/partition_manager/pm.yml.file_system
    index 7c5462a87..3ff79a7bd 100644
    --- a/subsys/partition_manager/pm.yml.file_system
    +++ b/subsys/partition_manager/pm.yml.file_system
    @@ -2,6 +2,9 @@
     
     #ifdef CONFIG_FILE_SYSTEM_LITTLEFS
     littlefs_storage:
    +#if defined(CONFIG_PM_EXTERNAL_FLASH_LITTLEFS)
    +  region: external_flash
    +#endif
       placement: {before: [tfm_storage, end]}
       size: CONFIG_PM_PARTITION_SIZE_LITTLEFS
     #endif
    

    I will submit this as the starting point for a PR later today

  • Unfortunately, I got a little ahead of myself. Since I'm doing this "on company time" I am not able to sign the Contributor License Agreement so I will not be able to push the change through the PR process. Hopefully you, or someone from Nordic can take the patch above through the process.

Related