8 months, 3 weeks ago.

LittleFS assert with "Assertion failed: block < lfs->cfg->block_count"

We have several instance of LittleFS assertion on SD card, using UBLOX_C030_U201 device, and happened with different SD cards from different vendors.

After we clone the SD card to new card, the new SD will have the same issue. We narrow down to a particular file, when we try to read the file, it got the following error.

My guess is, the file uses several SD blocks to store the data, one of the block value is corrupted and point to a location beyond the capacity of the SD card.

One instance seems relate to we power cycle the device and run into this issue, another instance happened during normal operation.

Question is: 1. What information we should collect to further help investigation, is there any log or debug we could turn on? 2. We changed the assert to an error message and return, which end up an infinite loop of the error message. Is there a way to return an error when the read failed or run into a bad block?

The error message is

++ MbedOS Error Info ++ Error Status: 0x80FF0144 Code: 324 Module: 255 Error Message: Assertion failed: block < lfs->cfg->block_count Location: 0x0 File: .\mbed-os\features\storage\filesystem\littlefs\littlefs\lfs.c+18 Error Value: 0x0 Current Thread: main Id: 0x2000D430 Entry: 0x8023E09 StackSize: 0x1000 StackMem: 0x2000D490 SP: 0x2000DF18 For more info, visit: https://armmbed.github.io/mbedos-error/?error=0x80FF0144

Many thanks,

created a issue in github https://github.com/ARMmbed/mbed-os/issues/11704

posted by Jianping Shen 17 Oct 2019

1 Answer

8 months, 3 weeks ago.

Hi Jianping,

LittleFS has 4 levels of debug logging. By default, all logging is enabled except for enable_debug. Setting enable_debug to true makes the log output very verbose, and the output is useful for bug reports.

Please refer here.


Regards, Desmond

I turned on all the 4 levels of debug,


#define MBED_LFS_ENABLE_ASSERT                                                1                                                                                                // set by library:littlefs
#define MBED_LFS_ENABLE_DEBUG                                                 1                                                                                                // set by application[*]
#define MBED_LFS_ENABLE_ERROR                                                 1                                                                                                // set by library:littlefs
#define MBED_LFS_ENABLE_INFO                                                  1                                                                                                // set by library:littlefs
#define MBED_LFS_ENABLE_WARN                                                  1                                                                                                // set by library:littlefs

When read the file, i got this

$ cat temp1909280234.tmp h
lfs info:413: file_open(0, "00170d3314aa/00170d5acf2a/temp1909280234.tmp", 0x0)
lfs info:415: file_open -> 0
lfs info:441: file_read(20008520, 20008778, 512)
C:\software\git\conmet_test_automation\mbed-os\features\storage\filesystem\littlefs\littlefs\lfs.c:1144 test -- assertion failed

++ MbedOS Fault Handler ++
FaultType: HardFault

R0   : 00000018
R1   : 00020026
R2   : 20002AF0
R3   : 00000000
R4   : 20008544
R5   : 20008548
R6   : 00000001
R7   : 00000000
R8   : 200033A8
R9   : 00000000
R10  : 0800282C
R11  : 00000001
R12  : 08008047
SP   : 20002AF8
LR   : 080015B5
PC   : 08007B3C
xPSR : 01000000
PSP  : 20002A90
MSP  : 20005E00
CPUID: 410FC241
HFSR : 80000000
MMFSR: 00000000
BFSR : 00000000
UFSR : 00000000
DFSR : 0000000A
AFSR : 00000000
Mode : Thread
Priv : Privileged
Stack: PSP
++ MbedOS Error Info ++
Error Status: 0x80FF013D Code: 317 Module: 255
Error Message: Fault exception
Location: 0x0
Error Value: 0x8007B3C
Current Thread: main  Id: 0x20001C58 Entry: 0x800C671 StackSize: 0x1000 StackMem: 0x20001CB8 SP: 0x20005DA0

If i change the MBED_LFS_ENABLE_ASSERT in mbed_config.h to 0, it gets infinity loop as below.

lfs info:443: file_read -> -5003
ffffffff lfs info:441: file_read(20008520, 20008778, 512)
lfs info:443: file_read -> -5003
ffffffff lfs info:441: file_read(20008520, 20008778, 512)
lfs info:443: file_read -> -5003
ffffffff lfs info:441: file_read(20008520, 20008778, 512)
posted by Jianping Shen 15 Oct 2019

Hi Jianping,

It seems a issue, would you raise a GitHub issue here? Thanks.


posted by Desmond Chen 16 Oct 2019