This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Flash filing system for nRF Connect SDK

Hi there,

Our team is developing an application based on the nRF5340-DK - we are developing on the DK while our hardware is in transit.  Our schematic largely follows the reference design for all necessary peripherals.  Notably, we've used the same QSPI NOR flash series as the MX25R6435F specified in the PCA10095 schematic (albeit larger).  Our intention is to use this external flash as a general filing system to store sensor data

I've scoured the nRF Connect SDK examples and there doesn't seem to be any reference as to how one uses the external flash as a general filing system. I'd very much appreciate it if someone could please provide some guidance as to the simplest way to achieve this.  Thanks!

BR,

Z

Parents
  • I think you should be able to use the NVS filesystem with external flash and QSPI. The NVS driver uses the api flash.h, and the underlying hardware interface can be choosen between the drivers located in zephyr/drivers/flash and there is indeed one for qspi: zephyr/drivers/flash/nrf_qspi_nor.c.

    Please tell me if the NVS filesystem satisfies your needs, and I'll help you implement it. But I think the way to go about it is to use the sample zephyr/samples/subsys/nvs, and add some configs to the prj.conf (check how it's done in e.g. the spi_flash sample or the littlefs sample), in addition I think you need to an an overlay file to configure the hardware.

    As seen in the link above it seems like LittleFs also has support for external flash through QSPI, just use the board files for the nRF52840dk as a reference

    Regarding FatFS, it does not seem like it's supported out-of the box if you're using external flash with QSPI. This ticket may be helpful: https://devzone.nordicsemi.com/f/nordic-q-a/71566/use-nrfx-qspi-with-zephyr-filesystem 

    In general I would no recommend you an advanceded file system, like littleFS or FatFs, if the intention is only to use it internally on the chip, that might be an overkill. One usecase might be if you're using USB and are going to emulate a USB Stick. 

    Of course you could use the sample SPI Flash sample where you access the flash directly, and structure the data the way you like.

    Please tell me what kind of File System you would like to implement and I'll assist you

    Best regards,

    Simon

  • Thanks for the detailed list of options, Simon.

    I've had a review of the various file systems outlined in your response; NVS, being a basic key:value store, looks like a good fit for this application.  I'll start looking into implementation based on the guidance you've already provided, however would appreciate if you could also outline implementation steps.  Thank you.

    BR,
    Zyrus

  • Hi Simon,

    I had a cursory look, but nothing meaningful.  Figured that I'd wait for (i.e. rely on) the official guidance and so focussed on some other activities to make more efficient use of my time - i.e. nothing at all (sorry!).

    Appreciate your assistance.

    BR,
    Zyrus

  • I tried to look into this, but it wasn't that straightforward. I'll put off some time the next days and see if I can make this work.

  • I was able to make it work.

    Could you test this application with NCS v1.5.0 and the board nrf5340dk_nrf5340_cpuapp:

    3603.nvs_external_flash.zip

    Also you have to make CONFIG_NORDIC_QSPI_NOR select CONFIG_FLASH_HAS_PAGE_LAYOUT in zephyr/drivers/flash/Kconfig.nordic_qspi_nor. See code snippet below:

    menuconfig NORDIC_QSPI_NOR
    	bool "QSPI NOR Flash"
    	select FLASH_HAS_DRIVER_ENABLED
    	select NRFX_QSPI
    	select FLASH_JESD216
    	select FLASH_HAS_PAGE_LAYOUT
    	depends on HAS_HW_NRF_QSPI
    	help
    	  Enable support for nrfx QSPI driver with EasyDMA.

    The Kconfig CONFIG_FLASH_HAS_PAGE_LAYOUT does not have a prompt, so it's not possible to set it directly in the prj.conf file.

    Best regards,

    Simon

  • Great - thanks Simon. Will give it a go first thing in the morning - it's 9pm here ATM.

    BR,

    Zyrus

  • Hi Simon,

    Have tested and confirm that it works (at this stage).  I'm using a custom board with the Macronix MX66L1G45G (1-Gbit flash); I made the necessary changes in the zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340_cpuapp_common.dts as below:

    &qspi {
    	status = "okay";
    	sck-pin = <17>;
    	io-pins = <13>, <14>, <15>, <16>;
    	csn-pins = <18>;
    	mx66l1g: mx66l1g45g@0 {
    		compatible = "nordic,qspi-nor";
    		reg = <0>;
    		/* MX66L1G supports only pp and pp4io */
    		writeoc = "pp4io";
    		/* MX66L1G supports all readoc options */
    		readoc = "read4io";
    		sck-frequency = <8000000>;
    		label = "MX66L1G";
    		jedec-id = [c2 20 1b];
    		sfdp-bfp = [
    			e5 20 fb ff  ff ff ff 3f  44 eb 08 6b  08 3b 04 bb
    			fe ff ff ff  ff ff 00 ff  ff ff 44 eb  0c 20 0f 52
    			10 d8 00 ff  d6 49 c5 00  82 df 04 e3  44 03 67 38
    			30 b0 30 b0  f7 bd d5 5c  4a 9e 29 ff  f0 50 f9 85
    		];
    		size = <1073741824>;
    	};
    };
    

    4k page size is fine, but had to also modify the number of pages to be able to access the full memory.

    Thanks for your help.

    BR,
    Zyrus

Reply
  • Hi Simon,

    Have tested and confirm that it works (at this stage).  I'm using a custom board with the Macronix MX66L1G45G (1-Gbit flash); I made the necessary changes in the zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340_cpuapp_common.dts as below:

    &qspi {
    	status = "okay";
    	sck-pin = <17>;
    	io-pins = <13>, <14>, <15>, <16>;
    	csn-pins = <18>;
    	mx66l1g: mx66l1g45g@0 {
    		compatible = "nordic,qspi-nor";
    		reg = <0>;
    		/* MX66L1G supports only pp and pp4io */
    		writeoc = "pp4io";
    		/* MX66L1G supports all readoc options */
    		readoc = "read4io";
    		sck-frequency = <8000000>;
    		label = "MX66L1G";
    		jedec-id = [c2 20 1b];
    		sfdp-bfp = [
    			e5 20 fb ff  ff ff ff 3f  44 eb 08 6b  08 3b 04 bb
    			fe ff ff ff  ff ff 00 ff  ff ff 44 eb  0c 20 0f 52
    			10 d8 00 ff  d6 49 c5 00  82 df 04 e3  44 03 67 38
    			30 b0 30 b0  f7 bd d5 5c  4a 9e 29 ff  f0 50 f9 85
    		];
    		size = <1073741824>;
    	};
    };
    

    4k page size is fine, but had to also modify the number of pages to be able to access the full memory.

    Thanks for your help.

    BR,
    Zyrus

Children
No Data
Related