khoih-prog / LittleFS_Mbed_RP2040

Wrapper of LittleFS for Arduino MBED RP2040 boards. This library facilitates your usage of LittleFS for the onboard flash. LittleFS supports power fail safety and high performance
GNU General Public License v3.0
22 stars 4 forks source link

MBED crash - RP2040 rebooting #1

Closed Gerriko closed 3 years ago

Gerriko commented 3 years ago

This is the output from Serial (it happens with both examples): Start LittleFS_Counting on RaspberryPi Pico LittleFS_Mbed_RP2040 v1.0.0 [LFS] LittleFS size (KB) = 256 [LFS] LittleFS Mount Fail [LFS] Formatting...

You then see the standard LED blink (5 short and some long blinks) which is associated with an MBED failure.

If you then open up a separate Serial output on Serial1 you get the mbed debug info:

++ MbedOS Fault Handler ++

FaultType: HardFault

Context: R0 : 20041F00 R1 : 2000BEEC R2 : 100183E0 R3 : 4B32B500 R4 : 20041F00 R5 : FFFFFF76 R6 : 2000D630 R7 : 10016ED1 R8 : 00000000 R9 : 00000000 R10 : 00000000 R11 : 00000000 R12 : 00000004 SP : 2000B8E8 LR : 1000069F PC : 1000480C xPSR : 01000000 PSP : 2000B8C8 MSP : 2003FFC0 CPUID: 410CC601 Mode : Thread Priv : Privileged Stack: PSP

-- MbedOS Fault Handler --

++ MbedOS Error Info ++ Error Status: 0x80FF013D Code: 317 Module: 255 Error Message: Fault exception Location: 0x1000480C Error Value: 0x2000CF8C Current Thread: main Id: 0x2000D144 Entry: 0x100040C5 StackSize: 0x8000 StackMem: 0x20003998 SP: 0x2000B8E8 For more info, visit: https://mbed.com/s/error?error=0x80FF013D&osver=61300&core=0x410CC601&comp=2&ver=110100&tgt=RASPBERRY_PI...

-- MbedOS Error Info --

khoih-prog commented 3 years ago

Strange. There must be some breaking change from core v2.1.0 (I tested and created the library then).

Can you try with core v2.1.0? I'll spend time later to find out why and fix the issue.

khoih-prog commented 3 years ago

Confirmed. Got the same crash as you did with core v2.4.1 now.

khoih-prog commented 3 years ago

Try smaller flash size => OK.

So might be the code size is much bigger now => 256K LittleFS can't be used. Or might be using new address for flash start. I'll see. Please change :

#define RP2040_FS_SIZE_KB       64    //256
Start LittleFS_Test on RaspberryPi Pico
LittleFS_Mbed_RP2040 v1.0.0
[LFS] LittleFS size (KB) = 64
[LFS] LittleFS Mount OK
====================================================
Writing file: /littlefs/hello1.txt => Open OK
* Writing OK
====================================================
Reading file: /littlefs/hello1.txt => Open OK
Hello from RaspberryPi Pico
====================================================
Appending file: /littlefs/hello1.txt => Open OK
* Appending OK
====================================================
Reading file: /littlefs/hello1.txt => Open OK
Hello from RaspberryPi Pico
Hello from RaspberryPi Pico
====================================================
Renaming file: /littlefs/hello1.txt to: /littlefs/hello2.txt => OK
====================================================
readCharsFromFile: /littlefs/hello2.txt => Open OK
Hello from RaspberryPi Pico
Hello from RaspberryPi Pico
====================================================
Deleting file: /littlefs/hello2.txt => OK
====================================================
Reading file: /littlefs/hello2.txt => Open Failed
====================================================
Testing file I/O with: /littlefs/hello1.txt => Open OK
- writing

16 Kbytes written in (ms) 238
====================================================
- reading

16 Kbytes read in (ms) 5
====================================================
Testing file I/O with: /littlefs/hello2.txt => Open OK
- writing
Write result = 0
Write error, i = 1

0 Kbytes written in (ms) 3
====================================================
- reading
Read result = 0
Read error, i = 0

0 Kbytes read in (ms) 1
====================================================
Deleting file: /littlefs/hello1.txt => OK
====================================================
Deleting file: /littlefs/hello2.txt => OK
====================================================

Test complete
khoih-prog commented 3 years ago

Try 128K still crashing. So please use 64K from now on until the issue found and fixed.

khoih-prog commented 3 years ago

Testing again with 256K LittleFS

  1. Core v2.1.0 => OK
  2. Core v2.2.0 => OK
  3. Core v2.3.1 => OK
  4. Core v2.4.1 => OK now !!! After installing v2.1.0, ..., then back to v2.4.1.

Very strange, possibly some flags is not written correctly. Will see.

In the mean time, please try with v2.1.0, then v2.4.1 to see if OK.

Start LittleFS_Test on RaspberryPi Pico
LittleFS_Mbed_RP2040 v1.0.0
[LFS] LittleFS size (KB) = 256
[LFS] LittleFS Mount OK
====================================================
Writing file: /littlefs/hello1.txt => Open OK
* Writing OK
====================================================
Reading file: /littlefs/hello1.txt => Open OK
Hello from RaspberryPi Pico
====================================================
Appending file: /littlefs/hello1.txt => Open OK
* Appending OK
====================================================
Reading file: /littlefs/hello1.txt => Open OK
Hello from RaspberryPi Pico
Hello from RaspberryPi Pico
====================================================
Renaming file: /littlefs/hello1.txt to: /littlefs/hello2.txt => OK
====================================================
readCharsFromFile: /littlefs/hello2.txt => Open OK
Hello from RaspberryPi Pico
Hello from RaspberryPi Pico
====================================================
Deleting file: /littlefs/hello2.txt => OK
====================================================
Reading file: /littlefs/hello2.txt => Open Failed
====================================================
Testing file I/O with: /littlefs/hello1.txt => Open OK
- writing

64 Kbytes written in (ms) 784
====================================================
- reading

64 Kbytes read in (ms) 18
====================================================
Testing file I/O with: /littlefs/hello2.txt => Open OK
- writing

64 Kbytes written in (ms) 780
====================================================
- reading

64 Kbytes read in (ms) 19
====================================================
Deleting file: /littlefs/hello1.txt => OK
====================================================
Deleting file: /littlefs/hello2.txt => OK
====================================================

Test complete
khoih-prog commented 3 years ago

Don't have issue with another RP2040 board with core v2.4.1 at the beginning. So it's somehow board dependent !!! This is difficult to find out where the issue is.

Any idea???

khoih-prog commented 3 years ago

The other example LittleFS_Counting => still OK with 256KB

Start LittleFS_Counting on RaspberryPi Pico
LittleFS_Mbed_RP2040 v1.0.0
[LFS] LittleFS size (KB) = 256
[LFS] LittleFS Mount OK
Times have been run = 1
 => Open to write OK

Start LittleFS_Counting on RaspberryPi Pico
LittleFS_Mbed_RP2040 v1.0.0
[LFS] LittleFS size (KB) = 256
[LFS] LittleFS Mount OK
 => Open to read OK
Times have been run = 2
 => Open to write OK

Start LittleFS_Counting on RaspberryPi Pico
LittleFS_Mbed_RP2040 v1.0.0
[LFS] LittleFS size (KB) = 256
[LFS] LittleFS Mount OK
 => Open to read OK
Times have been run = 3
 => Open to write OK

Start LittleFS_Counting on RaspberryPi Pico
LittleFS_Mbed_RP2040 v1.0.0
[LFS] LittleFS size (KB) = 256
[LFS] LittleFS Mount OK
 => Open to read OK
Times have been run = 4
 => Open to write OK
khoih-prog commented 3 years ago

I'm closing the issue now as it seems this is not a bug of the library.

Gerriko commented 3 years ago

Agree. It seems to be board related. Have it working.