I love the NRF9160 feather, and associated documentation. I’ve been working on getting the NRF9160 running with both networking and persistence. However, I’ve had issues getting networking and persistence to play nicely together.

Reproducing the error is simple. With an NRF9160 feather, flashing the “external_flash” example to the NRF feather works as expected, with the boot_count being displayed.

However, if one changes prj.conf of the example to add “CONFIG_NETWORKING=y”, things get wonky. The example will build cleanly. However, upon flashing, execution does not run as expected. I receive:

*** Booting Zephyr OS build v2.6.99-ncs1-1 ***
Area 1 at 0x0 on W25Q32JV for 4194304 bytes
[00:00:00.211,730] <inf> littlefs: LittleFS version 2.2, disk version 2.0
[00:00:00.220,520] <inf> littlefs: FS at W25Q32JV:0x0 is 1024 0x1000-byte blocks with 512 cycle
[00:00:00.230,438] <inf> littlefs: sizes: rd 16 ; pr 16 ; ca 64 ; la 32
[00:00:00.253,021] <inf> littlefs: /lfs mounted
/lfs mount: 0
/lfs: bsize = 16 ; frsize = 4096 ; blocks = 1024 ; bfree = 1019
/lfs/boot_count stat: 0
fn 'boot_count' siz 4
FAIL: open /lfs/boot_count: -16
[00:00:00.293,792] <inf> littlefs: /lfs unmounted
/lfs unmount: 0

I would love to know your thoughts on this - thanks so much for your help!

    WilliamRoyle hmm that’s what I would expect if you didn’t add anything else to the device.

    You may want to check out the tracker sample or many of the other nrf/samples/nrf9160 for controlling the modem using the lte_lc API.

    I hope that puts you in the right direction!

    Edit: I’ll add that the error is unexpected (should be counting up) but to add extra functionality like connecting to LTE requires more settings than just CONFIG_NETWORKING. Have you modified the sample at all? nrf/samples/nrf9160/mqtt_simple would be a good to look at for a very basic MQTT/LTE example.

    Jared,

    Thank you so much for taking the time to respond! I completely understand that enabling CONFIG_NETWORKING=y is not enough to set up LTE - I’ve been successfully working with LTE and MQTT. I’ve tried porting over the boot_count sample code and config to my functional LTE MQTT project, and run into the same issue - an fs_open crash

    Thinking about the boot_count sample again - I am confused as to the why simply setting CONFIG_NETWORKING=ycauses an issue in the boot_count sample - why should such a minimal change as CONFIG_NETWORKING=y result in fs_open crashing, after a successful mount? My intuition is that networking functionality should not significantly interfere with littleFS in most cases

    I use both all the time so it may not make sense to say CONFIG_NETWORKING is causing LFS to not find the above file.

    You may want to make sure you’re not erasing your flash before usage. You also need to create the file before reading from it.

    What thread are you executing filesystem stuff from? What version of NCS are you using?

    I agree - I am completely confused as to why CONFIG_NETWORKING=y is messing with LFS. I started by running the nfed/samples/boot_count sample with no modifications. The example builds & runs, giving expected output. I then added CONFIG_NETWORKING = y to the same boot_count sample, and then the example builds correctly , but results in the above error on execution. I am using v2.6.99-ncs1-1

    I suppose the best way to replicate this would be to add CONFIG_NETWORKING=y to the boot_count sample, and then build, flash and see if it runs correctly.

    Apologies for wasting your time with this - it is quite possible that I am overlooking something silly

    My suggestion is to add external flash to a working network/LTE sample rather than the other way around. There is a lot more config to do the other way around:

    Here is an example of two configurations (one board and one app level)

    #
    # Copyright (c) 2021 Circuit Dojo LLC
    #
    # SPDX-License-Identifier: LicenseRef-Circuit-Dojo-5-Clause
    #
    
    # Reboot!
    CONFIG_REBOOT=y
    
    # PWM for indication
    CONFIG_PWM=y
    
    # NEWLIB C
    CONFIG_NEWLIB_LIBC=y
    CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
    
    # Network
    CONFIG_NETWORKING=y
    CONFIG_NET_NATIVE=n
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_SOCKETS_OFFLOAD=y
    CONFIG_NET_SOCKETS_POSIX_NAMES=y
    
    # LTE link control
    CONFIG_LTE_LINK_CONTROL=y
    CONFIG_LTE_NETWORK_MODE_LTE_M=y
    CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
    
    # LTE PSM mode configuration parameters
    CONFIG_LTE_PSM_REQ_RPTAU="00000111" # 70 min
    CONFIG_LTE_PSM_REQ_RAT="00000011" # 6 sec active time
    
    # Modem library
    CONFIG_NRF_MODEM_LIB=y
    
    # Modem information
    CONFIG_MODEM_INFO=y
    
    # Date Time library
    CONFIG_DATE_TIME=y
    
    # Stacks and heaps
    CONFIG_MAIN_STACK_SIZE=8192
    CONFIG_HEAP_MEM_POOL_SIZE=8192
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    # Bootloader
    CONFIG_BOOTLOADER_MCUBOOT=y
    
    # Image manager
    CONFIG_IMG_MANAGER=y
    CONFIG_IMG_ERASE_PROGRESSIVELY=y
    CONFIG_DFU_TARGET=y
    
    # Enable flash operations.
    CONFIG_FLASH=y
    CONFIG_FLASH_MAP=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    
    # Enable the LittleFS file system.
    CONFIG_FILE_SYSTEM=y
    CONFIG_FILE_SYSTEM_LITTLEFS=y
    
    # Sensors
    CONFIG_I2C=y
    CONFIG_SENSOR=y
    CONFIG_LIS3MDL_CD=y
    CONFIG_LIS3MDL_TRIGGER_OWN_THREAD=y
    CONFIG_LIS3MDL_ODR="80"
    
    # ADC for battery measurement
    CONFIG_ADC=y
    
    # CJSON Library
    CONFIG_CJSON_LIB=y
    
    # OTA support
    CONFIG_FOTA_DOWNLOAD=y
    CONFIG_DOWNLOAD_CLIENT=y
    CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096
    
    # For saving settings
    CONFIG_SETTINGS=y
    CONFIG_SETTINGS_FS=y
    CONFIG_SETTINGS_FS_DIR="/lfs/settings"
    CONFIG_SETTINGS_FS_FILE="/lfs/settings/run"
    
    # Partition manager settings
    CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=n

    Board specific

    # Enable LIS2DH for board specific power savings
    CONFIG_LIS2DH=y
    CONFIG_LIS2DH_TRIGGER_NONE=y
    CONFIG_LIS2DH_OPER_MODE_LOW_POWER=y
    CONFIG_LIS2DH_ODR_RUNTIME=y
    
    # SPI Flash
    CONFIG_SPI=y
    CONFIG_SPI_NOR=y
    CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096

    Thanks for your help Jared - I suppose I was curious as to what was causing the error between the two. I’ll keep working with the Feather - it is a great little board

    Hi William,
    You may also want to check that you are not accessing the FLASH from multiple threads. I don’t believe the Zephyr file system is thread-safe.
    Neal

      Terms and Conditions | Privacy Policy