nRF9160 SPI External Flash (mx25r6435f) - FATFS does not mount

Hello

I am using the nRF9160-DK and I would like to access the external flash memory (mx25r6435f), as a FAT format file system. To do that I have made a 'test project' to access the file system from the SHELL, as a starting point. 

I can access the flash memory successfully using the flash command in the shell, as you can see in the following picture. 

But when I try to mount the filesystem it gives me the error code -5, as you can see in the next picture.

The project code:

main.c

#define LOG_LEVEL CONFIG_LOG_DEFAULT_LEVEL
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(app);

int main(void)
{
	return 0;
}

prj.conf

CONFIG_FLASH=y

CONFIG_LOG=y
CONFIG_FS_LOG_LEVEL_DBG=y
CONFIG_FLASH_LOG_LEVEL_DBG=y

CONFIG_HEAP_MEM_POOL_SIZE=16384

CONFIG_SHELL=y
CONFIG_SHELL_LOG_LEVEL_INF=y

CONFIG_FILE_SYSTEM=y
CONFIG_FILE_SYSTEM_SHELL=y
CONFIG_FILE_SYSTEM_SHELL_TEST_COMMANDS=y

CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_FLASH_MAP=y
CONFIG_FLASH_PAGE_LAYOUT=y

CONFIG_MPU_ALLOW_FLASH_WRITE=y

CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y

nrf9160dk_nrf9160_ns.dts

/dts-v1/;
#include <nordic/nrf9160ns_sica.dtsi>
#include "nrf9160dk_nrf9160_common.dtsi"
#include "nrf9160dk_nrf9160_common_0_14_0.dtsi"

/delete-node/ &storage_partition;
&spi3 {
	cs-gpios = <&arduino_header 16 GPIO_ACTIVE_LOW>, /* D10 */
		   <&gpio0 25 GPIO_ACTIVE_LOW>;
	mx25r64: mx25r6435f@1 {
		compatible = "jedec,spi-nor";
		reg = <1>;
		status = "okay";
		spi-max-frequency = <8000000>;
		jedec-id = [c2 28 17];
		sfdp-bfp = [
			e5 20 f1 ff  ff ff ff 03  44 eb 08 6b  08 3b 04 bb
			ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
			10 d8 00 ff  23 72 f5 00  82 ed 04 cc  44 83 68 44
			30 b0 30 b0  f7 c4 d5 5c  00 be 29 ff  f0 d0 ff ff
		];
		size = <67108864>;
		mxicy,mx25r-power-mode = "high-performance";
	};
};

&mx25r64 {
	partitions {
		compatible = "fixed-partitions";
		#address-cells = <1>;
		#size-cells = <1>;

		storage_partition: partition@0 {
			label = "storage";
			reg = <0x00000000 0x08000000>;
		};
	};
};

/ {

	aliases {
		ext-flash = &mx25r64;
	};
	
	chosen {
		nordic,pm-ext-flash = &mx25r64;
		zephyr,flash = &flash0;
		zephyr,sram = &sram0_ns;
		zephyr,code-partition = &slot0_ns_partition;
	};

	msc_disk0 {
		compatible = "zephyr,flash-disk";
		partition = <&storage_partition>;
		disk-name = "NAND";
		cache-size = <4096>;
	};
	
};

/* Disable UART1, because it is used by default in TF-M */
&uart1 {
	status = "disabled";
};

nrf9160dk_nrf9160_ns.overlay

&mx25r64 {
    status = "okay";
};

CMakeLists.txt

cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})

project(flash_test)

target_sources(app PRIVATE src/main.c)

To build the project I am using the nrf9160dk_nrf9160_ns Board with the nRFConnect SDK v2.5.1

Is there something wrong in the configuration files? I can not figure out why it does not mount the device.

Thank you

Parents
  • Hi,

     

    The fs shell sample seems to be mainly targeted towards littlefs:

    https://docs.zephyrproject.org/latest/samples/subsys/shell/fs/README.html

     

    I am unable to get it to mount properly when running your code on my side, even with other boards (nrf52840 etc), so I suspect there's something strange with the shell fs backend

     

    Even if I took the zephyr/samples/subsys/fs/fat_fs sample, and then added SHELL=y / FILE_SYSTEM_SHELL=y, it did work, as the FS was mounted by the firmware running:

    *** Booting Zephyr OS build v3.3.99-ncs1-1 ***
    [00:00:00.250,335] <inf> flashdisk: Initialize device SD
    [00:00:00.250,366] <inf> flashdisk: offset d8000, sector size 512, page size 4096, volume size 163840
    [00:00:00.250,457] <inf> main: Block count 320
    Sector size 512
    Memory Size(MB) 0
    [00:00:00.250,579] <inf> flashdisk: Initialize device SD
    [00:00:00.250,579] <inf> flashdisk: offset d8000, sector size 512, page size 4096, volume size 163840
    Disk mounted.
    
    Listing dir /SD: ...
    [FILE] SOME.DAT (size = 0)
    [DIR ] SOME
    
    
    uart:~$ fs read /SD:/SOME.DAT
    File size: 0
    uart:~$ fs ls /SD:/
    SOME.DAT
    SOME/
    

    It looks like the firmware has to manually mount the volume first.

     

    PS: When using nrf9160dk_nrf9160_ns, you will invoke partition_manager, which uses pm_static.yml for static allocation of your partitions.

    You can then declare it similar to this (change addresses and sizes to your liking):

    storage_partition:
      address: 0x0
      end_address: 0x800000
      region: external_flash
      size: 0x800000

      

    Kind regards,

    Håkon

  • Hello Hakon

    I have made some progress since yesterday.
    The shell fs backend was not the problem as I had tried to mount using the fs_mount(&fs_mnt); function, that was returning the same error (-5).

    With some changes I managed to make it work, but only works using the SDK v2.4.2.

    The changes that I have made:

    prj.conf

    CONFIG_FLASH=y
    
    CONFIG_LOG=y
    CONFIG_FS_LOG_LEVEL_DBG=y
    CONFIG_FLASH_LOG_LEVEL_DBG=y
    
    CONFIG_HEAP_MEM_POOL_SIZE=16384
    
    CONFIG_SHELL=y
    CONFIG_SHELL_LOG_LEVEL_INF=y
    
    CONFIG_FILE_SYSTEM=y
    CONFIG_FILE_SYSTEM_SHELL=y
    CONFIG_FILE_SYSTEM_SHELL_TEST_COMMANDS=y
    
    CONFIG_DISK_DRIVERS=y
    CONFIG_DISK_DRIVER_FLASH=y
    CONFIG_DISK_ACCESS=y
    CONFIG_FAT_FILESYSTEM_ELM=y
    CONFIG_FILE_SYSTEM_LITTLEFS=n
    CONFIG_FLASH_MAP=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    
    CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y
    
    CONFIG_FILE_SYSTEM_MKFS=y
    
    
    CONFIG_SPI=y
    CONFIG_SPI_NOR=y
    CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
    
    # Memories
    CONFIG_MAIN_STACK_SIZE=4096
    CONFIG_SHELL_STACK_SIZE=4096
    

    overlay file

    #include <C:\ncs\v2.5.1\zephyr\boards\arm\nrf9160dk_nrf9160\nrf9160dk_nrf9160_common_0_14_0.dtsi>
    
    /delete-node/ &storage_partition;
    
    &mx25r64 {
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		storage_partition: partition@0 {
    			label = "storage";
    			reg = <0x00000000 0x0800000>;
    		};
    	};
    
    	status = "okay";
    };
    
    &uart1 {
    	status = "okay";
    };
    
    / {
    
    	aliases {
    		ext-flash = &mx25r64;
    	};
    	
    	chosen {
    		nordic,pm-ext-flash = &mx25r64;
    		zephyr,flash = &flash0;
    		zephyr,sram = &sram0_ns;
    		zephyr,code-partition = &slot0_ns_partition;
    	};
    
    	msc_disk0 {
    		compatible = "zephyr,flash-disk";
    		partition = <&storage_partition>;
    		disk-name = "NAND";
    		cache-size = <4096>;
    	};
    	
    };

    Using these changes on the SDK v2.4.2, it works. It successfully mounts, read and write the external flash.

    When I compile this code using the SDK v2.5.1 I get compiling errors. The error appear only when the 
    CONFIG_DISK_DRIVER_FLASH is enabled.

    But when CONFIG_DISK_DRIVER_FLASH is not enabled (was not included in my original post) the project compiles, but the disk would not mount. So it looks like to mount the disk it needs to enable CONFIG_DISK_DRIVER_FLASH.
     
    As I mention, on the SDK v2.5.1, when I enable CONFIG_DISK_DRIVER_FLASH I get the following compile error:
    FAILED: zephyr/drivers/disk/CMakeFiles/drivers__disk.dir/flashdisk.c.obj 
    C:\ncs\toolchains\c57af46cb7\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DKERNEL -DMBEDTLS_CONFIG_FILE=\"nrf-config.h\" -DMBEDTLS_USER_CONFIG_FILE=\"nrf-config-user.h\" -DNRF9160_XXAA -DNRF_SKIP_FICR_NS_COPY_TO_RAM -DNRF_TRUSTZONE_NONSECURE -DPICOLIBC_DOUBLE_PRINTF_SCANF -DUSE_PARTITION_MANAGER=1 -D_FORTIFY_SOURCE=1 -D_POSIX_C_SOURCE=200809 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR_SUPERVISOR__ -D__ZEPHYR__=1 -IC:/ncs/v2.5.1/zephyr/include -Izephyr/include/generated -IC:/ncs/v2.5.1/zephyr/soc/arm/nordic_nrf/nrf91 -IC:/ncs/v2.5.1/zephyr/lib/posix/getopt/. -IC:/ncs/v2.5.1/zephyr/soc/arm/nordic_nrf/common/. -IC:/ncs/v2.5.1/nrf/include -Itfm/install/interface/include -IC:/ncs/v2.5.1/nrf/include/tfm -IC:/ncs/v2.5.1/nrf/tests/include -Itfm/generated/interface/include -IC:/ncs/v2.5.1/modules/hal/cmsis/CMSIS/Core/Include -IC:/ncs/v2.5.1/zephyr/modules/cmsis/. -IC:/ncs/v2.5.1/modules/hal/nordic/nrfx -IC:/ncs/v2.5.1/modules/hal/nordic/nrfx/drivers/include -IC:/ncs/v2.5.1/modules/hal/nordic/nrfx/mdk -IC:/ncs/v2.5.1/zephyr/modules/hal_nordic/nrfx/. -IC:/ncs/v2.5.1/nrfxlib/nrf_modem/include -Imodules/nrf/subsys/nrf_security/src/include/generated -IC:/ncs/v2.5.1/nrf/subsys/nrf_security/include -IC:/ncs/v2.5.1/nrf/ext/oberon/psa/core/include -IC:/ncs/v2.5.1/nrf/ext/oberon/psa/core/library -IC:/ncs/v2.5.1/modules/crypto/mbedtls/include -IC:/ncs/v2.5.1/modules/crypto/mbedtls/library -IC:/ncs/v2.5.1/nrfxlib/crypto/nrf_oberon/include/mbedtls -IC:/ncs/v2.5.1/nrfxlib/crypto/nrf_oberon/include -Wshadow -fno-strict-aliasing -Os -imacros C:/Embedded_software/flash_test_new/build/zephyr/include/generated/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros C:/ncs/v2.5.1/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -ftls-model=local-exec -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=C:/Embedded_software/flash_test_new=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/ncs/v2.5.1/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/ncs/v2.5.1=WEST_TOPDIR -ffunction-sections -fdata-sections --specs=picolibc.specs -D_POSIX_THREADS -std=c99 -MD -MT zephyr/drivers/disk/CMakeFiles/drivers__disk.dir/flashdisk.c.obj -MF zephyr\drivers\disk\CMakeFiles\drivers__disk.dir\flashdisk.c.obj.d -o zephyr/drivers/disk/CMakeFiles/drivers__disk.dir/flashdisk.c.obj -c C:/ncs/v2.5.1/zephyr/drivers/disk/flashdisk.c
    C:/ncs/v2.5.1/zephyr/drivers/disk/flashdisk.c:484:1: error: return type defaults to 'int' [-Werror=implicit-int]
      484 | PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_CACHE)
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/drivers/disk/flashdisk.c: In function 'PM_FOREACH_AFFILIATED_TO_disk':
    C:/ncs/v2.5.1/zephyr/drivers/disk/flashdisk.c:523:30: error: storage class specified for parameter 'flash_disks'
      523 | static struct flashdisk_data flash_disks[] = {
          |                              ^~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/drivers/disk/flashdisk.c:523:15: error: parameter 'flash_disks' is initialized
      523 | static struct flashdisk_data flash_disks[] = {
          |               ^~~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/drivers/disk/flashdisk.c:524:39: error: 'DEFINE_FLASHDISKS_DEVICE' undeclared (first use in this function)
      524 |         PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_DEVICE)
          |                                       ^~~~~~~~~~~~~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/drivers/disk/flashdisk.c:524:39: note: each undeclared identifier is reported only once for each function it appears in
    C:/ncs/v2.5.1/zephyr/drivers/disk/flashdisk.c:533:1: error: expected declaration specifiers before 'PM_FOREACH_AFFILIATED_TO_disk'
      533 | PM_FOREACH_AFFILIATED_TO_disk(VERIFY_CACHE_SIZE_IS_NOT_ZERO_IF_NOT_READ_ONLY)
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from C:/ncs/v2.5.1/zephyr/include/zephyr/toolchain/gcc.h:92,
                     from C:/ncs/v2.5.1/zephyr/include/zephyr/toolchain.h:50,
                     from C:/ncs/v2.5.1/zephyr/include/zephyr/sys/__assert.h:11,
                     from C:/ncs/v2.5.1/zephyr/drivers/disk/flashdisk.c:10:
    C:/ncs/v2.5.1/zephyr/include/zephyr/init.h:125:44: error: storage class specified for parameter '__init_disk_flash_init'
      125 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
          |                                            ^~~~~~~
    Is this an error about the partition manager? I am a bit confused about this error and why it would not appear in the SDK v2.4.2 ?
    So, at this point I managed to make it work using SDK v2.4.2, but I would prefer to make it work on the latest SDK v2.5.1.
    Thank you for your support!
Reply
  • Hello Hakon

    I have made some progress since yesterday.
    The shell fs backend was not the problem as I had tried to mount using the fs_mount(&fs_mnt); function, that was returning the same error (-5).

    With some changes I managed to make it work, but only works using the SDK v2.4.2.

    The changes that I have made:

    prj.conf

    CONFIG_FLASH=y
    
    CONFIG_LOG=y
    CONFIG_FS_LOG_LEVEL_DBG=y
    CONFIG_FLASH_LOG_LEVEL_DBG=y
    
    CONFIG_HEAP_MEM_POOL_SIZE=16384
    
    CONFIG_SHELL=y
    CONFIG_SHELL_LOG_LEVEL_INF=y
    
    CONFIG_FILE_SYSTEM=y
    CONFIG_FILE_SYSTEM_SHELL=y
    CONFIG_FILE_SYSTEM_SHELL_TEST_COMMANDS=y
    
    CONFIG_DISK_DRIVERS=y
    CONFIG_DISK_DRIVER_FLASH=y
    CONFIG_DISK_ACCESS=y
    CONFIG_FAT_FILESYSTEM_ELM=y
    CONFIG_FILE_SYSTEM_LITTLEFS=n
    CONFIG_FLASH_MAP=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    
    CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y
    
    CONFIG_FILE_SYSTEM_MKFS=y
    
    
    CONFIG_SPI=y
    CONFIG_SPI_NOR=y
    CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
    
    # Memories
    CONFIG_MAIN_STACK_SIZE=4096
    CONFIG_SHELL_STACK_SIZE=4096
    

    overlay file

    #include <C:\ncs\v2.5.1\zephyr\boards\arm\nrf9160dk_nrf9160\nrf9160dk_nrf9160_common_0_14_0.dtsi>
    
    /delete-node/ &storage_partition;
    
    &mx25r64 {
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		storage_partition: partition@0 {
    			label = "storage";
    			reg = <0x00000000 0x0800000>;
    		};
    	};
    
    	status = "okay";
    };
    
    &uart1 {
    	status = "okay";
    };
    
    / {
    
    	aliases {
    		ext-flash = &mx25r64;
    	};
    	
    	chosen {
    		nordic,pm-ext-flash = &mx25r64;
    		zephyr,flash = &flash0;
    		zephyr,sram = &sram0_ns;
    		zephyr,code-partition = &slot0_ns_partition;
    	};
    
    	msc_disk0 {
    		compatible = "zephyr,flash-disk";
    		partition = <&storage_partition>;
    		disk-name = "NAND";
    		cache-size = <4096>;
    	};
    	
    };

    Using these changes on the SDK v2.4.2, it works. It successfully mounts, read and write the external flash.

    When I compile this code using the SDK v2.5.1 I get compiling errors. The error appear only when the 
    CONFIG_DISK_DRIVER_FLASH is enabled.

    But when CONFIG_DISK_DRIVER_FLASH is not enabled (was not included in my original post) the project compiles, but the disk would not mount. So it looks like to mount the disk it needs to enable CONFIG_DISK_DRIVER_FLASH.
     
    As I mention, on the SDK v2.5.1, when I enable CONFIG_DISK_DRIVER_FLASH I get the following compile error:
    FAILED: zephyr/drivers/disk/CMakeFiles/drivers__disk.dir/flashdisk.c.obj 
    C:\ncs\toolchains\c57af46cb7\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DKERNEL -DMBEDTLS_CONFIG_FILE=\"nrf-config.h\" -DMBEDTLS_USER_CONFIG_FILE=\"nrf-config-user.h\" -DNRF9160_XXAA -DNRF_SKIP_FICR_NS_COPY_TO_RAM -DNRF_TRUSTZONE_NONSECURE -DPICOLIBC_DOUBLE_PRINTF_SCANF -DUSE_PARTITION_MANAGER=1 -D_FORTIFY_SOURCE=1 -D_POSIX_C_SOURCE=200809 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR_SUPERVISOR__ -D__ZEPHYR__=1 -IC:/ncs/v2.5.1/zephyr/include -Izephyr/include/generated -IC:/ncs/v2.5.1/zephyr/soc/arm/nordic_nrf/nrf91 -IC:/ncs/v2.5.1/zephyr/lib/posix/getopt/. -IC:/ncs/v2.5.1/zephyr/soc/arm/nordic_nrf/common/. -IC:/ncs/v2.5.1/nrf/include -Itfm/install/interface/include -IC:/ncs/v2.5.1/nrf/include/tfm -IC:/ncs/v2.5.1/nrf/tests/include -Itfm/generated/interface/include -IC:/ncs/v2.5.1/modules/hal/cmsis/CMSIS/Core/Include -IC:/ncs/v2.5.1/zephyr/modules/cmsis/. -IC:/ncs/v2.5.1/modules/hal/nordic/nrfx -IC:/ncs/v2.5.1/modules/hal/nordic/nrfx/drivers/include -IC:/ncs/v2.5.1/modules/hal/nordic/nrfx/mdk -IC:/ncs/v2.5.1/zephyr/modules/hal_nordic/nrfx/. -IC:/ncs/v2.5.1/nrfxlib/nrf_modem/include -Imodules/nrf/subsys/nrf_security/src/include/generated -IC:/ncs/v2.5.1/nrf/subsys/nrf_security/include -IC:/ncs/v2.5.1/nrf/ext/oberon/psa/core/include -IC:/ncs/v2.5.1/nrf/ext/oberon/psa/core/library -IC:/ncs/v2.5.1/modules/crypto/mbedtls/include -IC:/ncs/v2.5.1/modules/crypto/mbedtls/library -IC:/ncs/v2.5.1/nrfxlib/crypto/nrf_oberon/include/mbedtls -IC:/ncs/v2.5.1/nrfxlib/crypto/nrf_oberon/include -Wshadow -fno-strict-aliasing -Os -imacros C:/Embedded_software/flash_test_new/build/zephyr/include/generated/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros C:/ncs/v2.5.1/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -ftls-model=local-exec -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=C:/Embedded_software/flash_test_new=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/ncs/v2.5.1/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/ncs/v2.5.1=WEST_TOPDIR -ffunction-sections -fdata-sections --specs=picolibc.specs -D_POSIX_THREADS -std=c99 -MD -MT zephyr/drivers/disk/CMakeFiles/drivers__disk.dir/flashdisk.c.obj -MF zephyr\drivers\disk\CMakeFiles\drivers__disk.dir\flashdisk.c.obj.d -o zephyr/drivers/disk/CMakeFiles/drivers__disk.dir/flashdisk.c.obj -c C:/ncs/v2.5.1/zephyr/drivers/disk/flashdisk.c
    C:/ncs/v2.5.1/zephyr/drivers/disk/flashdisk.c:484:1: error: return type defaults to 'int' [-Werror=implicit-int]
      484 | PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_CACHE)
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/drivers/disk/flashdisk.c: In function 'PM_FOREACH_AFFILIATED_TO_disk':
    C:/ncs/v2.5.1/zephyr/drivers/disk/flashdisk.c:523:30: error: storage class specified for parameter 'flash_disks'
      523 | static struct flashdisk_data flash_disks[] = {
          |                              ^~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/drivers/disk/flashdisk.c:523:15: error: parameter 'flash_disks' is initialized
      523 | static struct flashdisk_data flash_disks[] = {
          |               ^~~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/drivers/disk/flashdisk.c:524:39: error: 'DEFINE_FLASHDISKS_DEVICE' undeclared (first use in this function)
      524 |         PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_DEVICE)
          |                                       ^~~~~~~~~~~~~~~~~~~~~~~~
    C:/ncs/v2.5.1/zephyr/drivers/disk/flashdisk.c:524:39: note: each undeclared identifier is reported only once for each function it appears in
    C:/ncs/v2.5.1/zephyr/drivers/disk/flashdisk.c:533:1: error: expected declaration specifiers before 'PM_FOREACH_AFFILIATED_TO_disk'
      533 | PM_FOREACH_AFFILIATED_TO_disk(VERIFY_CACHE_SIZE_IS_NOT_ZERO_IF_NOT_READ_ONLY)
          | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In file included from C:/ncs/v2.5.1/zephyr/include/zephyr/toolchain/gcc.h:92,
                     from C:/ncs/v2.5.1/zephyr/include/zephyr/toolchain.h:50,
                     from C:/ncs/v2.5.1/zephyr/include/zephyr/sys/__assert.h:11,
                     from C:/ncs/v2.5.1/zephyr/drivers/disk/flashdisk.c:10:
    C:/ncs/v2.5.1/zephyr/include/zephyr/init.h:125:44: error: storage class specified for parameter '__init_disk_flash_init'
      125 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
          |                                            ^~~~~~~
    Is this an error about the partition manager? I am a bit confused about this error and why it would not appear in the SDK v2.4.2 ?
    So, at this point I managed to make it work using SDK v2.4.2, but I would prefer to make it work on the latest SDK v2.5.1.
    Thank you for your support!
Children
  • Hi,

    Avgerinos89 said:
    As I mention, on the SDK v2.5.1, when I enable CONFIG_DISK_DRIVER_FLASH I get the following compile error:

    My apologies for not seeing this.

     

    The pm_static.yml needs some extra parameters, similar to what is posted here:

     RE: Problem with flashdisk and partition_manager 

     

    Could you try this and see if it builds/runs properly afterwards? Note that you might need to delete your build folder and regenerate the project.

     

    Kind regards,

    Håkon

  • Hello Hakon

    Following your suggestion I managed to make it work using littlefs file system.

    I add the following pm_static.yml file:

    external_flash:
      address: 0x00000
      end_address: 0x7F0000
      region: external_flash
      size: 0x7F0000
    littlefs_storage:
      address: 0x00000
      device: MX25R64
      region: external_flash
      address: 0x0
      size: 0x7F0000

    Also I made a few changed to the prj.conf file to use littlefs
    prj.conf

    CONFIG_FLASH=y
    
    CONFIG_LOG=y
    CONFIG_FS_LOG_LEVEL_DBG=y
    CONFIG_FLASH_LOG_LEVEL_DBG=y
    
    CONFIG_HEAP_MEM_POOL_SIZE=16384
    
    CONFIG_SHELL=y
    CONFIG_SHELL_LOG_LEVEL_INF=y
    
    CONFIG_FILE_SYSTEM=y
    CONFIG_FILE_SYSTEM_SHELL=y
    CONFIG_FILE_SYSTEM_SHELL_TEST_COMMANDS=y
    
    CONFIG_FAT_FILESYSTEM_ELM=n
    CONFIG_FILE_SYSTEM_LITTLEFS=y
    CONFIG_FLASH_MAP=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    
    #CONFIG_MPU_ALLOW_FLASH_WRITE=y
    
    CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=n
    CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y
    
    CONFIG_SPI=y
    CONFIG_SPI_NOR=y
    CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
    
    # Memories
    CONFIG_MAIN_STACK_SIZE=4096
    CONFIG_SHELL_STACK_SIZE=4096

    At this moment I can use littlefs for my application so I will use littlefs as it is.

    Thank you for your help

  • I'm glad to hear that you got things running with littlefs.

    Let me know if there's anything else that pops up.

     

    Kind regards,

    Håkon

Related