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

Changing Flash parameters in overlay file

My project is using nRF52840.   Early software development used an nRF52840-DK to develop most of the software.   Software is based on Zephyr using nRF Connect version 1.6.1.     I'm using the "littlefs" file system.   I got most things working using the nRF52840-DK.     I now have my custom board and it uses a slightly different (and larger) qspi-nor flash device.   

I'm still using the nRF52840-DK board file, but "modify" some of the parameters using an overlay file.    I know I need to change some of the parameters w.r.t. the flash.    I was able to modify the jedec-id for the new device, but am looking for some documentation that defines the parameters (keywords) in the board definition file (what some of them mean and format of values)   

Can you point me to these definitions (so I don't have to read through a lot of code :-))?

Thanks!

  • Hi

    It's been a while, so just to make sure we're on the same page. You're still using an nRF52840, the S25FL external flash, and you're still having error -5 (I/O error) when trying to mount the external board. Is that correct? 

    This could be due to the mount process already being in progress when this is called somehow. You can try waiting for the SD card to be detected before starting the mount process. You can also check out this case where my colleague Torbjørn provided a possible fix to a mount error like this.

    Best regards,

    Simon

  • Hi Simon,

    Yes...    

    Still using nRF52840 and S25FL external flash connected via QSPI, so it is not an SD card (your referenced case deals with SD cards).

    I've also moved to NCS 2.0.2 (the latest released version of NCS).

    I've had trouble finding any detailed documentation on the structure/internals of littleFS.    But I've traced through the code and the error appears to occur when the CRCs are being checked during the formatting process.     I saw one post that implied that the config statement "CONFIG_APP_WIPE_STORAGE=y" should be included in prj.conf, but if I do so, the build process fails, indicating that this configuration variable was not found.

    I assume the physical interface to the chip works since it reads the jedec-id (I had to change the listed on in the .dts file to expect the one in the S25FL device.).    As I mentioned earlier, I had the software running on the -DK board, but am struggling to get it working on my custom board with a different (larger) QSPI device.

    Thanks...

  • Hi

    Can you upload the overlay (.dts) file where your QSPI (pins, size, etc.) are set up of how it looks now so we can take a look? I'm afraid I'm not familiar with an error in this line in lfs.c, but it seems like the dir pair is corrupted at some point when trying to fetch a matching dir...

    Best regards,

    Simon

  • Hi 

    Here is the file:

    /*
     * Copyright (c) 2017 Linaro Limited
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    /dts-v1/;
    #include <nordic/nrf52840_qiaa.dtsi>
    
    / {
    	model = "Nordic nRF52840 ModelRocket";
    	compatible = "nordic,nrf52840-dk-nrf52840";
    
    	chosen {
    
    #if 1
                    zephyr,gps-uart = &uart0;
    #endif
    		zephyr,sram = &sram0;
    		zephyr,flash = &flash0;
    		zephyr,code-partition = &slot0_partition;
    	};
    
    
    
    
    	nrf_radio_fem: ble_pa {
    	   compatible = "skyworks,sky66112-11", "generic-fem-two-ctrl-pins";
    	   ctx-gpios = <&gpio1 2 GPIO_ACTIVE_HIGH>;
    	   crx-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>;
        };
    
    	fstab {
    		compatible = "zephyr,fstab";
    		lfs2: lfs2 {
    			compatible = "zephyr,fstab,littlefs";
    			mount-point = "/lfs2";
    			partition = <&lfs2_part>;
    /*
    			automount;
    */
    			read-size = <16>;
    			prog-size = <16>;
    			cache-size = <64>;
    			lookahead-size = <32>;
    			block-cycles = <512>;
    		};
    	};
    
    
    };
    
    
    &adc {
    	status = "okay";
    };
    
    &gpiote {
    	status = "okay";
    };
    
    &gpio0 {
    	status = "okay";
    };
    
    &gpio1 {
    	status = "okay";
    };
    
    &uart0 {
    	compatible = "nordic,nrf-uarte";
    	status = "okay";
    	current-speed = <115200>;
    	tx-pin = <12>;
    	rx-pin = <41>;
            /delete-property/ rts-pin;
            /delete-property/ cts-pin;
    };
    
    &uart1 {
            compatible = "nordic,nrf-uarte";
    	status = "disabled";
    	current-speed = <115200>;
            /* Unused pins */
    	rx-pin = <33>;
    	tx-pin = <25>;
    };
    
    &i2c0 {
    	compatible = "nordic,nrf-twim";
            /* Cannot be used together with spi0 */
    	status = "okay";
    	sda-pin = <26>;
    	scl-pin = <27>;
    };
    
    &i2c1 {
    	compatible = "nordic,nrf-twim";
    	/* Cannot be used together with spi1. */
    	status = "okay";
    	sda-pin = <11>;
    	scl-pin = <13>;
    };
    
    &pwm0 {
    	status = "disabled";
    	ch0-pin = <14>;
    	ch0-inverted;
    };
    
    &spi0 {
    	compatible = "nordic,nrf-spi";
    	/* Cannot be used together with i2c0. */
    	status = "disabled";
    	sck-pin = <27>;
    	mosi-pin = <26>;
    	miso-pin = <29>;
    };
    
    &spi1 {
    	compatible = "nordic,nrf-spi";
            /* Cannot be used together with i2c1 */
    	status = "disabled";
    	sck-pin = <31>;
    	mosi-pin = <30>;
    	miso-pin = <40>;
    };
    
    &spi2 {
    	compatible = "nordic,nrf-spi";
    	status = "disabled";
    	sck-pin = <19>;
    	mosi-pin = <20>;
    	miso-pin = <21>;
    };
    
    &spi3 {
    	compatible = "nordic,nrf-spi";
    	status = "disabled";
    	sck-pin = <47>;
    	mosi-pin = <46>;
    	miso-pin = <45>;
    };
    
    &qspi {
    	status = "okay";
    	sck-pin = <19>;
    	io-pins = <20>, <21>, <22>, <23>;
    	csn-pins = <17>;
    	mx25r64: mx25r6435f@0 {
    		compatible = "nordic,qspi-nor";
    		reg = <0>;
    		/* MX25R64 supports only pp and pp4io */
    		writeoc = "pp4io";
    		/* MX25R64 supports all readoc options */
    		readoc = "read4io";
    		sck-frequency = <8000000>;
    		label = "MX25R64";
    
    		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
    		];
    
    		has-dpd;
    		t-enter-dpd = <10000>;
    		t-exit-dpd = <35000>;
    
    #if 0
    		jedec-id = [c2 28 17];
    		size = <67108864>;
    #endif
    		jedec-id = [01 20 18];
            size = <134217728>;
    		partitions {
    			compatible = "fixed-partitions";
    			#address-cells = <1>;
    			#size-cells = <1>;
    
    			lfs2_part: partition@0 {
    				label = "main_storage";
    				reg = <0x00000000 0x02000000>;
    			};
    			
    		};
    		/* End from overlay */
    	};
    };
    
    &flash0 {
    
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		boot_partition: partition@0 {
    			label = "mcuboot";
    			reg = <0x000000000 0x0000C000>;
    		};
    		slot0_partition: partition@c000 {
    			label = "image-0";
    			reg = <0x0000C000 0x00067000>;
    		};
    		slot1_partition: partition@73000 {
    			label = "image-1";
    			reg = <0x00073000 0x00067000>;
    		};
    		scratch_partition: partition@da000 {
    			label = "image-scratch";
    			reg = <0x000da000 0x0001e000>;
    		};
    
    		/*
    		 * The flash starting at 0x000f8000 and ending at
    		 * 0x000fffff is reserved for use by the application.
    		 */
    
    		/*
    		 * Storage partition will be used by FCB/LittleFS/NVS
    		 * if enabled.
    		 */
    		storage_partition: partition@f8000 {
    			label = "storage";
    			reg = <0x000f8000 0x00008000>;
    		};
    	};
    };
    
    zephyr_udc0: &usbd {
    	compatible = "nordic,nrf-usbd";
    	status = "okay";
    };
    

    Note that I started with the nRF52840-DK file and edited it to reflect my board.    Also, I have two file systems.   "/lfs1" mounts the on-chip storage partition, while "/lfs2" is for the external flash device attached to the QSPI bus.      Also note that I didn't change the "name" of the flash device, but rather changed the important parameters.

    Thanks!

  • Hi

    From this .dts file it seems like the QSPI is defined as the MX25 flash chip that is onboard the nRF52840. You need to configure it for the S25FL that you're using. Make sure that the size and write/read permissions fits that board.

    Best regards,

    Simon

Related