Hackuarium / esp32-c3

0 stars 1 forks source link

Create a logger system #1

Open lpatiny opened 2 years ago

lpatiny commented 2 years ago

Create a big binary file (1024 * 1024) on the spiffs partition

Try to have random access and create a logger

https://www.mischianti.org/2020/06/04/esp32-integrated-spiffs-filesystem-part-2/

lpatiny commented 2 years ago

Be inspired : https://github.com/Hackuarium/bioreactor-platformio/blob/master/BioMain/include/hack/SSTLogger.cpp

https://esp32.com/viewtopic.php?t=18164

We don't want to create a file !!!

andrescvargasr commented 2 years ago

We can use NVS instead of SPIFFS:

https://github.com/espressif/esp-idf/blob/01d014c42def8d0c19e1ce55c07de6761e092ffa/examples/storage/nvs_rw_value/main/nvs_value_example_main.c

First step, implement this code in ChibiOS.

lpatiny commented 2 years ago

No it is much more low level that this. We should I think use: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/storage/spi_flash.html#flash-partition-apis

We should use directly the instructions read, write, erase

https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/storage/spi_flash.html#_CPPv418esp_partition_readPK15esp_partition_t6size_tPv6size_t

Interestingly erase range is super similar to the flash we use in the bioreactor: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/storage/spi_flash.html#_CPPv418esp_partition_readPK15esp_partition_t6size_tPv6size_t

So I think copying the code of the logger and replace the corresponding instructions by those read, write and erase should work.

Please take care to setup a partition that is exactly 1024 * 1024 bytes for the logging system.

andrescvargasr commented 2 years ago

Preferences.h is the native solution in Platformio, from Spressif page:

"The Preferences library is unique to arduino-esp32. It should be considered as the replacement for the Arduino EEPROM library."

https://docs.espressif.com/projects/arduino-esp32/en/latest/api/preferences.html#

I will use this library for migration if you are agree.

lpatiny commented 1 year ago

We should really create our own partition scheme and directly access the memory like we do with the SST memory.

We should create a custom partition:

https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/partition-tables.html#type-field

We would like to directly write to the partition because it is faster and more compact. Will will also looks very similar to : https://github.com/Hackuarium/bioreactor-platformio/blob/master/BioMain/include/hack/SSTLogger.cpp

andrescvargasr commented 1 year ago

We have a branch for Logger in the project: Logger

We can try to use this version of Logger in Logger branch to check if everything runs well:

I will use the esp32-c3 that you bring me in November!