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!

  • 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.

  • Hey, I was able to get it mounted. I just needed to add these configs and remove the qspi configs that I had copied from the nrf52840 config:

    CONFIG_SPI=y
    CONFIG_SPI_NOR=y
    CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
    CONFIG_PM_EXTERNAL_FLASH=y
    CONFIG_PM_EXTERNAL_FLASH_DEV_NAME="MX25R64"
    CONFIG_PM_EXTERNAL_FLASH_BASE=0
    CONFIG_PM_EXTERNAL_FLASH_SIZE=0x4000000
    

    Now I just need to get it working with the logs Smiley. I will ask for help if I have trouble with it

  • Ah, I should have seen that earlier. The nRF52840 DK uses QSPI, while the nRF9160 DK uses SPI

    Yes, don't hesitate to ask if you encounter new issues.

Related