Add LittleFS libs from ESP8266 project#189
Add LittleFS libs from ESP8266 project#189kolos wants to merge 6 commits intolibretiny-eu:masterfrom
Conversation
|
hello, |
|
Feel free to continue, It's tested on CB2S and WB2S. |
|
thanks a lot! i would appreciate if you could provide example linker script definitions you used for CB2S and WB2S, kind regards |
|
Create a libretiny platformio project, it will do the definitions for those constants. For example, here is my ; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:wb2s]
platform = libretiny
board = wb2s
framework = arduino
lib_deps = esphome/ESPAsyncWebServer-esphome@^3.1.0
upload_speed = 115200
monitor_speed = 115200
build_src_flags = -include Arduino.h
build_flags =
-DCONFIG_ASYNC_TCP_STACK_SIZE=4096
-DLT_LOGLEVEL=LT_LEVEL_NONE
-DLT_UART_SILENT_ALL=1
-DLT_USE_TIME=1
; -DconfigUSE_RECURSIVE_MUTEXES=1
-DUSE_ARDUINO
-DUSE_LIBRETUYA
-Wno-sign-compare
-Wno-unused-but-set-variable
-Wno-unused-variable
-Wno-unused-function
-fno-exceptions |
|
I'm using ESPAsyncWebserver like this: #include <ESPAsyncWebServer.h>
#include "LittleFS.h"
AsyncWebServer server(80);
void handleUpload(AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final) {
if (!index) {
request->_tempFile = LittleFS.open("/" + filename, "w");
}
if (len) {
request->_tempFile.write(data, len);
}
if (final) {
request->_tempFile.close();
request->redirect("/");
}
}
void setup_webserver() {
LittleFS.begin();
server.on("/upload", HTTP_POST, [](AsyncWebServerRequest *request) {
request->send(200);
}, handleUpload);
server.serveStatic("/", LittleFS, "/");
server.begin();
}and uploading files via curl: curl -F "file=@index.html.gz;filename=index.htm.gz" http://192.168.1.123/upload |
Thank you, but is it impossible to download with firmware? I mean, build a bin and flash it at ltchiptool. |
|
You can flash any binary image using ltchiptool, provided that you enter the correct starting offset. You will need to have a binary image of the LittleFS of the correct size. |
Is it possible to automate this in the script ~/.platformio/platforms/libretiny/builder/utils/ltchiptool-util.py or create a separate script using the FLASH_USERDATA_OFFSET and FLASH_USERDATA_LENGTH data from the board settings. |
|
I can probably use the mklittlefs tool from esp8266/esp32, and then ltchiptool and write everything in extra_scripts = pre:tools/fsbuildscript.py |
|
I wrote a script for the building file system by bk7231n. It works if you register it in platformio.ini Upload through the gui ltchiptool |
"User data" partition definitions needs to be moved from LittleFS.cpp to the boards definitions.
Currently hardcoded for my test board variant: CB2S