matth-x / MicroOcpp

OCPP 1.6 client for microcontrollers
MIT License
334 stars 145 forks source link

Trouble with internal file system of ESP "no more free space" #256

Closed kevincsouto closed 7 months ago

kevincsouto commented 8 months ago

I'm working with 4 connectors in the same station, and it's working well, I use the build flag for num connectors and increase de buffer tx data for more connectors, but this message appears in the serial monitor:

"E (921139) esp_littlefs: ./components/esp_littlefs/src/littlefs/lfs.c:673:error: No more free space 56

[MO] info (StopTransaction.cpp:50): StopTransaction initiated [MO] info (StatusNotification.cpp:50): New status: Available (connectorId 3) [MO] info (StopTransaction.cpp:197): Request has been accepted!"

Three hour later, I delete the flash memory, the problem disapear until it's appears later like this:

"[MO] info (Authorize.cpp:37): Request has been accepted [main] idTag accepted by the Central System: Starting transaction! [MO] info (Authorize.cpp:37): Request has been accepted [MO] info (Connector.cpp:240): Session mngt: trigger StartTransaction E (620579) esp_littlefs: ./components/esp_littlefs/src/littlefs/lfs.c:673:error: No more free space 47

[MO] info (StartTransaction.cpp:48): StartTransaction initiated [main] Selected Connector: 3 [MO] info (StatusNotification.cpp:50): New status: Charging (connectorId 2) [MO] info (StatusNotification.cpp:50): New status: Preparing (connectorId 3) [MO] info (StartTransaction.cpp:142): Request has been accepted [MO] info (Authorize.cpp:37): Request has been accepted"

It's appears when I starts and end a lot of connections. The configuration in platformio.ini is like this:

[env:esp32doit-devkit-v1] platform = espressif32 board = esp32doit-devkit-v1 framework = arduino board_build.partitions = min_spiffs.csv monitor_speed = 115200 monitor_filters = esp32_exception_decoder lib_deps = matth-x/MicroOcpp@^1.0.0 miguelbalboa/MFRC522 @ ^1.4.10 mandulaj/PZEM-004T-v30 @ ^1.1.2 me-no-dev/ESP Async WebServer@^1.2.3 build_flags = -std=gnu++17 -D CHARGEBOX='"EMMA"' -D WIFISSID='"XXXX"'
-D PASSWORD='"xxxx"'
-D OCPPURL='"ws://localhost:8180/steve/websocket/CentralSystemService/"' -D MO_NUMCONNECTORS=5 -D MO_TXRECORD_SIZE=16 build_unflags = -std=gnu++11

How I resolve this?

matth-x commented 8 months ago

Hi @kevincsouto, the error message is right here, unfortunately. MO keeps a transaction journal to reliably transmit all operations to the server, even over offline periods and power outages. The storage format on flash is basically many tiny JSON documents, and one files per document. I decided for this for more convenient debugging of the library*, but it turns out that it really comes at the cost of a bad net utilization of the file system. One solution is to decrease the size limit of the tx journal, to test it and decide if there's enough headroom left.

The build flag MO_TXRECORD_SIZE (as you already found) defines the size of the tx journal per connector. With four connectors, the total size is MO_NUMCONNECTORS-1 MO_TXRECORD_SIZE = 4 16 = 64, which is probably too large. I would recommend to define the record size to be 1 or 2.

Btw. ClearCache also clears the transaction "cache" in this OCPP implementation, which might come handy in such situations.

*) If you want to see how MO works with these JSON files, try the Simulator on Ubuntu (https://github.com/matth-x/MicroOcppSimulator) and check out the .jsn files in the mo_store folder