Mbed littlefs mount failure on Seeed Xiao Sense with nrf52840

X_Yang
Mon, 27 Mar 2023 15:12:38 +0000
Electronics and hardware

Hello I’m trying to mount the mbed littlefs to the qspi blockdevice on Seeed Xiao Sense (nrf52840).
I’m using Arduino IDE 2.0.4 on Windows. I installed “seeed nRF52 mbed-enabled Boards” through Arduino board manager. Then I updated the library files according to the commit attached here. So the qspi blockdevice will work on this board.

github.com/Seeed-Studio/ArduinoCore-mbed

upload the new libmbed.a which opened the QSPI interface with onboard flash

committed 02:59AM - 15 Feb 22 UTC

bigbearishappy

+38 -7

The qspi blockdevice functionality including read/prog/erase is OK, but when I was trying to mount the littlefs to the qspi blockdevice it failed. The format error code is -4005, which is “Erase command not on sector aligned addresses or exceeds device size” defined on line 32 of QSPIFBlockDevice.h. The mount error code is -138, which I didn’t find the definition. In addition, the qspi blockdevice read size is 4, program size is 4, erase size is 256.
I also tested the littlefs on heap blockdevice, and it worked just fine.
Attached below is my Arduino code. Thanks a lot!

#include “mbed.h”
#include “BlockDevice.h”
#include “QSPIFBlockDevice.h”
#include “LittleFileSystem.h”

#include “HeapBlockDevice.h”

//QSPIFBlockDevice bd(QSPI_FLASH1_IO0, QSPI_FLASH1_IO1, QSPI_FLASH1_IO2, QSPI_FLASH1_IO3, QSPI_FLASH1_SCK, QSPI_FLASH1_CSN, QSPIF_POLARITY_MODE_1, MBED_CONF_QSPIF_QSPI_FREQ);

//mbed::BlockDevice *bd = new mbed::HeapBlockDevice(2048, 1, 1, 512);
//heap blockdevice works fiine

mbed::BlockDevice *bd = new QSPIFBlockDevice(QSPI_FLASH1_IO0, QSPI_FLASH1_IO1, QSPI_FLASH1_IO2, QSPI_FLASH1_IO3, QSPI_FLASH1_SCK, QSPI_FLASH1_CSN, QSPIF_POLARITY_MODE_1, MBED_CONF_QSPIF_QSPI_FREQ);

mbed::LittleFileSystem fs(“fs”);

void setup() {
Serial.begin(115200);
while (!Serial);

Serial.println(“init the blockdevice…”);
int err = bd->init();
if(err) {
Serial.print(“init error. err code=”);
Serial.println(err);
}

Serial.print("bd read size = ");
Serial.println(bd->get_read_size());
Serial.print("bd program size = ");
Serial.println(bd->get_program_size());
Serial.print("bd erase size = ");
Serial.println(bd->get_erase_size());
Serial.print("bd erase value at addr 0 = ");
Serial.println(bd->get_erase_size(0));

int force_format = 1;
if (force_format) {
err = fs.format(bd);
if (err) {
Serial.print("format err = ");
Serial.println(err);
}
}

err = fs.mount(bd);
if (err) {
Serial.print("mount err = ");
Serial.println(err);
}

bd->deinit();
}

void loop() {
Serial.println(“testing done”);
delay(10000);
}

4 posts - 2 participants