RAK4631 crashes at boot in LittleFS / Adafruit SPIFlash init
Hi,
I'm trying to set up a second RAK4631/WisBlock board as a standalone microReticulum transport node, but this board consistently crashes during boot while initializing the filesystem / SPI flash.
I already have another RAK4631 running microReticulum as a transport node on a rooftop, and that one works correctly. So I expected this second board to behave in the same way, but it does not.
The working RAK4631 boots normally and shows:
RNS is READY!
RNS transport mode is ENABLED
Frequency: 868000000 Hz
Bandwidth: 125000 Hz
TX Power: 14 dBm
Spreading Factor: 8
Coding Rate: 5
RNS Transport is READY!
On the second RAK4631, flashing appears to complete correctly, but the firmware crashes before it can respond to rnodeconf.
Hardware
- Board: RAK4631 / WisBlock
- MCU: nRF52840
- LoRa: SX1262
- External flash module: installed for the main test, but also tested without it
- Host: macOS / MacBook Air
- Serial port used:
/dev/cu.usbmodem101 - Device UID shown in serial log:
XXXXXXXXXXXX
I initially suspected the external flash module, but the same crash also happens when the external flash module is physically removed.
First test: flashing with rnodeconf
I installed the firmware using:
rnodeconf --clear-cache
rnodeconf --autoinstall --fw-url https://github.com/attermann/microReticulum_Firmware/releases/
The flashing process appears to complete:
Activating new firmware
Device programmed.
[09:22:44] Done flashing
[09:22:44] Waiting for NRF52 reset...
[09:22:50] Opening serial port /dev/cu.usbmodem101...
[09:22:53] Serial port opened, but RNode did not respond. Is a valid firmware installed?
Got invalid response while detecting device
Trying to configure TNC / transport mode gives the same result:
rnodeconf --tnc --freq 868000000 --bw 125000 --sf 8 --cr 5 --txp 14 /dev/cu.usbmodem101
Output:
[09:23:12] Opening serial port /dev/cu.usbmodem101...
[09:23:15] Serial port opened, but RNode did not respond. Is a valid firmware installed?
Got invalid response while detecting device
Serial output after reset
Opening the serial console with:
screen /dev/cu.usbmodem101 115200
and pressing reset shows this crash:
Total SRAM: 188612 bytes
Free SRAM: 43912 bytes
assertion "head >= 2 && head <= lfs->cfg->block_count" failed: file ".pio/libdeps/wiscore_rak4631/Adafruit SPIFlash/src/littlefs/lfs.c", line 1144, function: lfs_ctz_find
After a later PlatformIO test I also got:
Total SRAM: 188416 bytes
Free SRAM: 43720 bytes
Device UID: XXXXXXXXXXXX
assertion "head >= 2 && head <= lfs->cfg->block_count" failed: file ".pio/libdeps/wiscore_rak4631/Adafruit SPIFlash/src/littlefs/lfs.c", line 1144
Factory erase attempt
I also tried a factory erase before flashing again.
I used:
Meshtastic_nRF52_factory_erase_v3_S140_6.1.0.uf2
After the erase, I reflashed microReticulum, but the same LittleFS assertion still happens.
PlatformIO standard build test
I also tried building and uploading directly from PlatformIO, using the standard wiscore_rak4631 environment, with flash support enabled.
Repository state:
Branch: master
Commit: 8a8262e Updated nomad pages
Available local tag: 1.86
Environment: wiscore_rak4631
Platform: nordicnrf52
Board: rak4630
Variant: rak4631
Build/upload command:
~/.platformio/penv/bin/pio run -e wiscore_rak4631 -t upload --upload-port /dev/cu.usbmodem101 --jobs 1
The build/upload completed successfully:
Activating new firmware
Device programmed.
But the post-upload provisioning step failed because the device did not respond:
rnodeconf --product 10 --model 12 --hwrev 1 --rom /dev/cu.usbmodem101
[10:48:06] Opening serial port /dev/cu.usbmodem101...
[10:48:09] Serial port opened, but RNode did not respond. Is a valid firmware installed?
Got invalid response while detecting device
The firmware hash update also failed for the same reason:
rnodeconf --firmware-hash 94350aac6083ebe375511236d8778438b1e2576e11039beb7058262071e1bb6a /dev/cu.usbmodem101
[10:48:14] Opening serial port /dev/cu.usbmodem101...
[10:48:17] Serial port opened, but RNode did not respond. Is a valid firmware installed?
Got invalid response while detecting device
PlatformIO still reported the upload as successful:
Environment Status Duration
wiscore_rak4631 SUCCESS 00:02:51.677
After reset, the same LittleFS / Adafruit SPIFlash assertion appears on serial.
What seems strange to me
The same crash happens:
- after flashing with
rnodeconf --autoinstall; - after building and uploading the standard
wiscore_rak4631environment from PlatformIO; - after running the Meshtastic nRF52 factory erase UF2;
- with the external flash module installed;
- and also with the external flash module physically removed.
So I am not sure if this is:
- a corrupted filesystem state that is not erased by the factory erase UF2;
- a flash detection / fallback issue;
- a difference between my two RAK4631 boards;
- a bootloader or hardware revision difference;
- or an issue in the LittleFS / Adafruit SPIFlash initialization path.
I also noticed this section in RNode_Firmware.ino:
#if MCU_VARIANT == MCU_NRF52
// First attempt to initialize RAK15001 flash
TRACE("Looking for RAK15001 flash...");
static const SPIFlash_Device_t device_rak15001 = RAK15001;
filesystem = microStore::Adapters::FlashFSFileSystem(&device_rak15001);
It looks like the firmware tries to initialize the RAK15001 flash path on nRF52 before falling back, but in this case it seems to assert inside LittleFS before it can continue.
Questions
Is there a recommended way to completely erase or reformat the filesystem area used here by microReticulum on RAK4631?
Also, is there any known difference between RAK4631 boards, bootloaders, hardware revisions, or flash configurations that could explain why one RAK4631 works correctly as a transport node while this second one crashes during LittleFS initialization?
I can provide more logs or test a patch/build if useful.
I opened a related PR in RNode_Firmware_CE after debugging a RAK4631 / nRF52 EEPROM/LittleFS issue:
https://github.com/liberatedsystems/RNode_Firmware_CE/pull/114
Related issue:
https://github.com/liberatedsystems/RNode_Firmware_CE/issues/113
I am not sure this is the same bug as the Adafruit SPIFlash / LittleFS assertion reported here, since in this microReticulum issue the firmware crashes very early during filesystem / SPI flash initialization and does not respond to rnodeconf.
However, the RNode CE issue was also related to persistent storage handling on RAK4631/nRF52. In that case, direct LittleFS File access for the emulated EEPROM caused incomplete EEPROM persistence during rnodeconf --rom. The fix replaces direct global file access with a RAM-backed EEPROM buffer and flushes atomically when the ROM lock/config marker is written.
After that fix, on RAK4631 / RAK19007:
rnodeconf --rom --platform 70 --product 10 --model 12 --hwrev 1completes successfully- EEPROM checksum validates
- device signature validates
- after setting the manually flashed firmware hash,
rnsdbrings the RAK4631 interface online
Final Reticulum result:
RNodeInterface[RAK4631 RNode 868] is configured and powered up
I plan to test whether microReticulum_Firmware has inherited a similar nRF52 EEPROM/LittleFS path, or whether this issue is instead specific to the external SPI flash / RAK15001 initialization path. If useful, I can test a patch/build on my RAK4631 / RAK19007 hardware.
Hello,
I just bought my RAK4631 (RAK19003 Base Board) and I would like to make it work in standalone.
What do you suggest to do ? Is there a tutorial to get me started ?
Scratch my previous message, just did:
rnodeconf --eeprom-wipe /dev/ttyACM0
rnodeconf --autoinstall --fw-url https://github.com/attermann/microReticulum_Firmware/releases/
followed by:
rnodeconf --tnc --freq 869525000 --bw 250000 --sf 11 --cr 5 --txp 22 /dev/ttyACM1
And everything worked.
OS: NixOS
@massimilianopal A bug relating to flash init on NRF52 boards was fixed in the latest release (1.86.2) which I suspect shold address your issue. Let me know if you upgrade and are still having the same issue.
Thanks @attermann, I tested release 1.86.2 and I can confirm that the issue is fixed on my RAK4631.
The previous LittleFS / SPI flash init crash no longer occurs, and the board now boots and configures correctly.
Thanks for the quick fix!