6 years, 4 months ago.

LittleFS crashes with a K64F

I got the LittleFS example to compile, but I get a runtime error: The RED LED flashes and the following is displayed on the console:

Ãmbed assertation failed: (int)obj->spi.instance != NC, file: .\mbed-os\targets\TARGET_Freescale\TARGET_MCUXpresso_MCUS\TARGET_MSuÿt/]^ðd|5 ÿt

When I add LittleFS to my normal application (replacing FATFileSystem), I get this runtime error:

assertion "block < lfs->cfg->block_count" failed: file ".\mbed-os\features\filesystem\littlefs\littlefs\lfs.c", line 31, function: lfs_cache_read

...kevin

Question relating to:

1 Answer

6 years, 3 months ago.

Hi Kevin,

Out of curiosity, which block device are you using?

Quote:

I got the LittleFS example to compile, but I get a runtime error: The RED LED flashes and the following is displayed on the console:

By default, the filesystem example uses external SPI flash. If your board doesn't have external flash, you will need to change the block device in the main.cpp file:
https://github.com/armmbed/mbed-os-example-filesystem#changing-the-block-device

Quote:

When I add LittleFS to my normal application (replacing FATFileSystem), I get this runtime error:

I know of one bug that made it into the release. There's a patch up here that may solve your issue:
https://github.com/ARMmbed/mbed-os/pull/5761

This bug is an issue on small block devices (< 64 blocks) that are not a power of 2 in size. This is common for internal flash.

If that's not the issue, do you have more info on the geometry of your block device? (read size, prog size, erase size, total size).

Accepted Answer

Hello Christopher,

I tried the SDBlockDevice and the SPIFBlockDevice, same result. I have been using FATFileSystem with SDBlockDevice without any issues. The SDFlash device am using is a 4GB chip.

posted by Kevin Braun 27 Dec 2017

Hi Kevin,

Do you have a code snippet that shows the issue or could you link to the repo where this issue happens?

posted by Christopher Haster 27 Dec 2017

Is it possible the SD card hasn't been formatted with LittleFS? If the SD was formatted with FAT it would need to be reformatted before it can be used with LittleFS.

You can add this block of code to your application to make LittleFS automatically reformat if it doesn't detect a LittleFS filesystem:

BlockDevice bd;
LittleFileSystem fs("fs");

int err = fs.mount(&bd);
if (err) {
    fs.reformat(&bd);
}
// fs is now mounted
posted by Christopher Haster 27 Dec 2017