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!

  • It does not seem like there are any samples that demonstrates how to use this feature. However, it's made a test for it here: https://github.com/nrfconnect/sdk-zephyr/tree/0944459b5b622048a08ad1f8cf8a044c135fd0d3/tests/subsys/logging/log_backend_fs

    This should give you an idea how to enable LittleFS backend logging in your sample

    Don't overlook these files:

    Add similar files for your board (nrf9160dk_nrf9160ns I guess?) in your sample as well

    If you don't get it to work, please let me know and I will try to get it working myself.

    Best regards,

    Simon

  • Hey Simon,

    I tried the test, but I couldn't get it to work. I am able to build and run it but mounting the filesystem fails:

    *** Booting Zephyr OS build v2.6.0-rc1-ncs1  ***
    Running test suite test_log_backend_fs
    ===================================================================
    START - test_fs_nonexist
     Assertion failed at ../src/log_fs_test.c:47: test_fs_nonexist: (rc not equal to 0)
     Can not mount FS.
     FAIL - test_fs_nonexist in 0.10 seconds
     ===================================================================
     START - test_wipe_fs_logs
     PASS - test_wipe_fs_logs in 0.1 seconds
     ===================================================================
     START - test_log_fs_file_content
     Assertion failed at ../src/log_fs_test.c:103: test_log_fs_file_content: (fs_open(&file, fname, FS_O_READ) not equal to 0)
     Can not open log file.
     FAIL - test_log_fs_file_content in 0.14 seconds
     ===================================================================
     START - test_log_fs_file_size
     Assertion failed at ../src/log_fs_test.c:145: test_log_fs_file_size: (fs_stat(fname, &entry) not equal to 0)
     Can not get file info. 
     FAIL - test_log_fs_file_size in 0.13 seconds
     ===================================================================
     START - test_log_fs_files_max
     Assertion failed at ../src/log_fs_test.c:212: test_log_fs_files_max: (rc not equal to 0)
     Can not open directory. 
     FAIL - test_log_fs_files_max in 0.12 seconds
     ===================================================================
     Test suite test_log_backend_fs failed.
     ===================================================================
    PROJECT EXECUTION FAILED

    I made .conf and .overlay files for nrf9160dk: nrf9160dk_nrf9160ns.conf, 4743.nrf9160dk_nrf9160ns.overlay

    Is there something wrong with these? Or is there something I need to change in the code? I needed to add the MX25R64 in the overlay because it is not included in the common.dts file.

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

Related