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

nRF9160 DK: Logging to external memory

Hey,

I noticed that in the SDK v1.6.0 a Kconfig option CONFIG_LOG_BACKEND_FS was added. However, I cannot find any information on how to use it.

I would like to be able to store the logs on an SD-card/memory chip on the nRF9160 DK (v.1.0.2). I tried simply adding the config and it's requirements to the Zephyr littlefs sample but I couldn't get it to work. Is there some additional things I need to change? Or a sample that is easy to try it on?

Also the Kconfig help states that it uses LittleFS, but is it possible to use another filesystem such as FAT? It would be easier to export the data to a Windows machine for analyzing. On this Zephyr PR it is stated that it will support any FS that is supported by VFS API. So I assume it could be possible. If it is possible, does it automatically use the FS that was configured, despite the Kconfig information only mentioning LittleFS?

Thanks in advance!

Parents Reply Children
  • Update on this:

    I realised I have to route the flash chip to the nRF9160. I followed this thread to do so. I also realised there is an overlay for newer DK's so I removed the spi3 configurations from the "nrf9160dk_nrf9160ns.overlay" file, because I get them when I build it for the new revision.

    However, I am still not able to get it to work.

    I also tested Zephyr's littlefs sample, and it fails to mount the flash as well:

    *** Booting Zephyr OS build v2.6.0-rc1-ncs1  ***
    Area 0 at 0x0 on MX25R64 for 65536 bytes
    FAIL: mount id 0 at /lfs1: -19
    [00:00:00.252,563] [1B][0m<inf> littlefs: littlefs partition at /lfs1[1B][0m
    [00:00:00.260,620] [1B][0m<inf> littlefs: LittleFS version 2.2, disk version 2.0[1B][0m
    [00:00:00.260,620] [1B][1;31m<err> littlefs: can't get flash device: MX25R64[1B][0m
    [00:00:00.260,650] [1B][1;31m<err> fs: fs mount error (-19)[1B][0m
    

  • I will try to get a hold of an nRF9160 DK v1.0 with external memory and try to get it working.

  • A quick comment. I saw the following message: 

    <err> littlefs: can't get flash device: MX25R64

    This means that these lines failed:

    The call to device_get_binding() can fail due to two reasons

    1. If the label ("MX25R64") it's looking for is not in the generated DTS (which is translated into header files readable to .c files)
    2. If the associated init function failed.

    Regarding 1, can you check the file zephyr/samples/subsys/fs/littlefs/<build folder>/zephyr/zephyr.dts and search for "MX25R64"?

    Regarding 2, to find the associated init function you can look at the compatible field used for the mx25r64, which is "jedec,spi-nor". Then, after searching through NCS for "jedec_spi_nor", I found that the driver zephyr/drivers/flash/spi_nor.c used that compatible field, which contains the init function spi_nor_init(). Can you look into (either through debugging, or adding printk()'s and open a terminal like Termite) spi_nor_init()-->spi_nor_configure() and see if it fails (should return null if succesful)? This is a function run by the kernel before main.c

    Best regards,

    Simon

  • Regarding 1, can you check the file zephyr/samples/subsys/fs/littlefs/<build folder>/zephyr/zephyr.dts and search for "MX25R64"?

    It is mentioned under spi3:

    			spi3: spi@b000 {
    				#address-cells = < 0x1 >;
    				#size-cells = < 0x0 >;
    				reg = < 0xb000 0x1000 >;
    				interrupts = < 0xb 0x1 >;
    				status = "okay";
    				label = "SPI_3";
    				compatible = "nordic,nrf-spim";
    				sck-pin = < 0xd >;
    				mosi-pin = < 0xb >;
    				miso-pin = < 0xc >;
    				cs-gpios = < &gpio0 0x19 0x1 >;
    				mx25r64: mx25r6435f@0 {
    					compatible = "jedec,spi-nor";
    					reg = < 0x0 >;
    					spi-max-frequency = < 0x7a1200 >;
    					label = "MX25R64";
    					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 = < 0x4000000 >;
    					has-dpd;
    					t-enter-dpd = < 0x2710 >;
    					t-exit-dpd = < 0x88b8 >;
    					partitions {
    						compatible = "fixed-partitions";
    						#address-cells = < 0x1 >;
    						#size-cells = < 0x1 >;
    						lfs1_part: partition@0 {
    							label = "storage";
    							reg = < 0x0 0x10000 >;
    							phandle = < 0x5 >;
    						};
    					};
    				};
    			};

    Does this seem correct to you?

    Can you debug spi_nor_init() and see if it fails

    I will try debugging tomorrow.

    I also tried attaching an oscilloscope to the SCK-pin (P0.13) but it didn't seem to have any signal on it.

    Thanks for your response Slight smile

  • Oette said:
    I will try debugging tomorrow.

     Sounds good. Let me know if the init function fails or not.

Related