I just ask wether littlefs on waveshare_rp2040_pizero shall be configured or else, because when i do:
FSInfo *info;
LittleFS.info(*info);
The value at info->totalBytes is always default value=537140992
So, i am afraid i will end up writing ouside real area.
My board definition:
[env:pico_nodebug_16MB]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = waveshare_rp2040_pizero
framework = arduino
board_build.core = earlephilhower
board_build.filesystem_size = 5m
board_build.filesystem = littlefs
board_build.partitions = partitions.csv
build_flags = -O3
Thanks in advence, best regards.
LittleFS.info
takes a reference to a FSInfo
struct as parameter. See
return false;
}
int rc = lfs_rename(&_lfs, pathFrom, pathTo);
if (rc != 0) {
DEBUGV("lfs_rename: rc=%d, from=`%s`, to=`%s`\n", rc, pathFrom, pathTo);
return false;
}
return true;
}
bool info(FSInfo& info) override {
if (!_mounted) {
return false;
}
info.blockSize = _blockSize;
info.pageSize = _pageSize;
info.maxOpenFiles = _maxOpenFds;
info.maxPathLength = LFS_NAME_MAX;
info.totalBytes = _size;
info.usedBytes = _getUsedBlocks() * _blockSize;
return true;
Therefore the code must be
FSInfo info;
LittleFS.info(info);
A wonder why no crash happened.
2 Likes
If we want to be really pedantic we can also zero-init the struct first, use that as the FSInfo&
(“reference”, aka just a variable name) and compute the free (approximate) space, or rather the size of the unused blocks as:
FSInfo info {};
LittleFS.info(info);
Serial.println("LittleFS free bytes: " + String(info.totalBytes - info.usedBytes));
1 Like