Hello. On ESP8266 and ESP32, you can make file system partitions (SPIFFS or LITTLEFS) of different sizes. Part of this volume can be allocated for FTP. I only know of a way to find out the size of a file uploaded to the file system. But I do not know how to find out the size that is allocated for the section. I would like to know in addition the total memory size (sometimes up to 32 MB), and how much is allocated for the sketch and for the file system and for ftp. Perhaps I started the topic in the wrong section of the form. If so, I hope the moderators will move the topic to the correct section of the forum.
Arduino+Espressif ESP32
Portioning in the IDE:
Partition Table — Arduino-ESP32 2.0.6 documentation (readthedocs-hosted.com)
To create a memory layout at link time:
ESP32 Arduino: Creating a Memory Map file – EverythingESP
Remember: Espressif is a 3rd party core, thus the IDE scheme/options are not from the Official Arduino team.
FTP libraries such as
GitHub - jlemaire06/ESP32-ftp: ftp server on ESP32 board
programmatically deal with memory allocation.
The Spiffs library include two functions. That will return totalBytes(), and usedBytes() from that
you can deduct available bytes in the SPIFFS partition.
size_t SPIFFSFS::totalBytes()
size_t SPIFFSFS::usedBytes()
I did not check for littlefs.
in esp.h the function uint32_t getSketchSize(); will return your sketch size.
check esp.h for other useful functions that have to do with memory
Yes, I understand, but I did not think of where else to ask this question.
What does it give? Is this size dynamic? Does it change constantly? Is it possible to somehow calculate the size of the allocated memory?
At the moment, I'm only trying to deal with esp8266. If I understand correctly, then for him I should look at the FS.h library. There's a mention there:
// Backwards compatible, <4GB filesystem usage
struct FSInfo {
size_t totalBytes;
size_t usedBytes;
size_t blockSize;
size_t pageSize;
size_t maxOpenFiles;
size_t maxPathLength;
};
But so far I haven't figured out how to use it.
I also tried to use this one from the SPIFFS library:
bool info(FSInfo& info) override
{
info.blockSize = _blockSize;
info.pageSize = _pageSize;
info.maxOpenFiles = _maxOpenFds;
info.maxPathLength = SPIFFS_OBJ_NAME_LEN;
uint32_t totalBytes, usedBytes;
auto rc = SPIFFS_info(&_fs, &totalBytes, &usedBytes);
if (rc != SPIFFS_OK) {
DEBUGV("SPIFFS_info: rc=%d, err=%d\r\n", rc, _fs.err_code);
return false;
}
info.totalBytes = totalBytes;
info.usedBytes = usedBytes;
return true;
}
The Espressif portioning scheme is well documented:
Filesystem — ESP8266 Arduino Core 3.1.1-26-g734defb8 documentation (arduino-esp8266.readthedocs.io)
Unfortunately, I don't understand everything there. But there is exactly the moment that I mentioned above:
FSInfo fs_info;
SPIFFS.info(fs_info);
or LittleFS.info(fs_info);
Can you suggest how to use it correctly?
Yes, it was with this library that I began to get acquainted with the work of the file system. json is used there. I couldn't do it without him.
For example, I'm trying to get the total size:
FSInfo fs_info;
LittleFS.info(fs_info);
Serial.println(fs_info.totalBytes);
I get a bunch of errors:
error: 'FSInfo' does not name a type
FSInfo fs_info;
^~~~~~
In function 'void setup()':
error: 'class fs::LittleFSFS' has no member named 'info'
LittleFS.info(fs_info);
^~~~
error: 'fs_info' was not declared in this scope
LittleFS.info(fs_info);
^~~~~~~
note: suggested alternative: 'isinff'
LittleFS.info(fs_info);
^~~~~~~
isinff
exit status 1
'FSInfo' does not name a type
Although at the beginning of the sketch I wrote:
#include <FS.h>
#include <LittleFS.h>
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.