mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 19:56:30 +00:00
scripter esp32 flash file ffat support
This commit is contained in:
parent
1733b4c772
commit
25c49e6211
6
esp32_partition_app1572k_ffat983k.csv
Normal file
6
esp32_partition_app1572k_ffat983k.csv
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# Name, Type, SubType, Offset, Size, Flags
|
||||||
|
nvs, data, nvs, 0x9000, 0x5000,
|
||||||
|
otadata, data, ota, 0xe000, 0x2000,
|
||||||
|
app0, app, ota_0, 0x10000, 0x180000,
|
||||||
|
app1, app, ota_1, 0x190000, 0x180000,
|
||||||
|
ffat, data, fat, 0x310000,0x0F0000,
|
|
6
esp32_partition_app1984k_ffat12M.csv
Normal file
6
esp32_partition_app1984k_ffat12M.csv
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# Name, Type, SubType, Offset, Size, Flags
|
||||||
|
nvs, data, nvs, 0x9000, 0x5000,
|
||||||
|
otadata, data, ota, 0xe000, 0x2000,
|
||||||
|
app0, app, ota_0, 0x10000, 0x1F0000,
|
||||||
|
app1, app, ota_1, 0x200000, 0x1F0000,
|
||||||
|
ffat, data, fat, 0x3F0000,0xC10000,
|
|
@ -43,6 +43,8 @@ keywords if then else endif, or, and are better readable for beginners (others m
|
|||||||
|
|
||||||
#define SCRIPT_DEBUG 0
|
#define SCRIPT_DEBUG 0
|
||||||
|
|
||||||
|
#define FORMAT_SPIFFS_IF_FAILED true
|
||||||
|
|
||||||
|
|
||||||
#ifndef MAXVARS
|
#ifndef MAXVARS
|
||||||
#define MAXVARS 50
|
#define MAXVARS 50
|
||||||
@ -78,11 +80,13 @@ uint32_t DecodeLightId(uint32_t hue_id);
|
|||||||
#undef EEP_SCRIPT_SIZE
|
#undef EEP_SCRIPT_SIZE
|
||||||
#undef USE_SCRIPT_COMPRESSION
|
#undef USE_SCRIPT_COMPRESSION
|
||||||
#if USE_SCRIPT_FATFS==-1
|
#if USE_SCRIPT_FATFS==-1
|
||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
#error "script fat file option -1 currently not supported for ESP32"
|
#pragma message "script fat file option -1 used"
|
||||||
#else
|
#else
|
||||||
#pragma message "script fat file option -1 used"
|
#pragma message "script fat file option -1 used"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#pragma message "script fat file SDC option used"
|
#pragma message "script fat file SDC option used"
|
||||||
#endif
|
#endif
|
||||||
@ -152,8 +156,12 @@ void Script_ticker4_end(void) {
|
|||||||
#if defined(LITTLEFS_SCRIPT_SIZE) || (USE_SCRIPT_FATFS==-1)
|
#if defined(LITTLEFS_SCRIPT_SIZE) || (USE_SCRIPT_FATFS==-1)
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
#include "FS.h"
|
#include "FS.h"
|
||||||
|
#ifdef LITTLEFS_SCRIPT_SIZE
|
||||||
#include "SPIFFS.h"
|
#include "SPIFFS.h"
|
||||||
#else
|
#else
|
||||||
|
#include "FFat.h"
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
#endif
|
#endif
|
||||||
FS *fsp;
|
FS *fsp;
|
||||||
@ -168,15 +176,15 @@ void SaveFile(const char *name,const uint8_t *buf,uint32_t len) {
|
|||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FORMAT_SPIFFS_IF_FAILED true
|
|
||||||
uint8_t fs_mounted=0;
|
uint8_t fs_mounted=0;
|
||||||
|
|
||||||
void LoadFile(const char *name,uint8_t *buf,uint32_t len) {
|
void LoadFile(const char *name,uint8_t *buf,uint32_t len) {
|
||||||
if (!fs_mounted) {
|
if (!fs_mounted) {
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
if(!SPIFFS.begin(FORMAT_SPIFFS_IF_FAILED)){
|
if (!SPIFFS.begin(FORMAT_SPIFFS_IF_FAILED)) {
|
||||||
#else
|
#else
|
||||||
if(!fsp->begin()){
|
if (!fsp->begin()) {
|
||||||
#endif
|
#endif
|
||||||
//Serial.println("SPIFFS Mount Failed");
|
//Serial.println("SPIFFS Mount Failed");
|
||||||
return;
|
return;
|
||||||
@ -776,11 +784,20 @@ char *script;
|
|||||||
if (!glob_script_mem.script_sd_found) {
|
if (!glob_script_mem.script_sd_found) {
|
||||||
|
|
||||||
#if USE_SCRIPT_FATFS>=0
|
#if USE_SCRIPT_FATFS>=0
|
||||||
|
// user sd card
|
||||||
fsp=&SD;
|
fsp=&SD;
|
||||||
if (SD.begin(USE_SCRIPT_FATFS)) {
|
if (SD.begin(USE_SCRIPT_FATFS)) {
|
||||||
|
#else
|
||||||
|
// use flash file
|
||||||
|
#ifdef ESP32
|
||||||
|
// if (SPIFFS.begin(FORMAT_SPIFFS_IF_FAILED)) {
|
||||||
|
if (FFat.begin(true)) {
|
||||||
#else
|
#else
|
||||||
if (fsp->begin()) {
|
if (fsp->begin()) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // USE_SCRIPT_FATFS>=0
|
||||||
|
|
||||||
glob_script_mem.script_sd_found=1;
|
glob_script_mem.script_sd_found=1;
|
||||||
} else {
|
} else {
|
||||||
glob_script_mem.script_sd_found=0;
|
glob_script_mem.script_sd_found=0;
|
||||||
@ -3590,7 +3607,22 @@ int16_t Run_script_sub(const char *type, int8_t tlen, JsonObject *jo) {
|
|||||||
// number precision
|
// number precision
|
||||||
glob_script_mem.script_dprec=atoi(lp);
|
glob_script_mem.script_dprec=atoi(lp);
|
||||||
goto next_line;
|
goto next_line;
|
||||||
} else if (!strncmp(lp,"delay(",6)) {
|
}
|
||||||
|
#ifdef USE_DISPLAY
|
||||||
|
else if (!strncmp(lp,"dt",2)) {
|
||||||
|
char dstbuf[256];
|
||||||
|
lp+=2;
|
||||||
|
SCRIPT_SKIP_SPACES
|
||||||
|
Replace_Cmd_Vars(lp,1,dstbuf,sizeof(dstbuf));
|
||||||
|
char *savptr = XdrvMailbox.data;
|
||||||
|
XdrvMailbox.data = dstbuf;
|
||||||
|
XdrvMailbox.data_len = 0;
|
||||||
|
DisplayText();
|
||||||
|
XdrvMailbox.data = savptr;
|
||||||
|
goto next_line;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else if (!strncmp(lp,"delay(",6)) {
|
||||||
lp+=5;
|
lp+=5;
|
||||||
// delay
|
// delay
|
||||||
lp=GetNumericResult(lp,OPER_EQU,&fvar,0);
|
lp=GetNumericResult(lp,OPER_EQU,&fvar,0);
|
||||||
@ -4415,6 +4447,7 @@ char path[48];
|
|||||||
|
|
||||||
void Script_FileUploadConfiguration(void) {
|
void Script_FileUploadConfiguration(void) {
|
||||||
uint8_t depth=0;
|
uint8_t depth=0;
|
||||||
|
|
||||||
strcpy(path,"/");
|
strcpy(path,"/");
|
||||||
|
|
||||||
if (!HttpCheckPriviledgedAccess()) { return; }
|
if (!HttpCheckPriviledgedAccess()) { return; }
|
||||||
@ -4464,7 +4497,12 @@ void script_upload(void) {
|
|||||||
HTTPUpload& upload = Webserver->upload();
|
HTTPUpload& upload = Webserver->upload();
|
||||||
if (upload.status == UPLOAD_FILE_START) {
|
if (upload.status == UPLOAD_FILE_START) {
|
||||||
char npath[48];
|
char npath[48];
|
||||||
|
#if defined(ESP32) && defined(USE_SCRIPT_FATFS) && USE_SCRIPT_FATFS==-1
|
||||||
|
//sprintf(npath,"/%s",upload.filename.c_str());
|
||||||
sprintf(npath,"%s/%s",path,upload.filename.c_str());
|
sprintf(npath,"%s/%s",path,upload.filename.c_str());
|
||||||
|
#else
|
||||||
|
sprintf(npath,"%s/%s",path,upload.filename.c_str());
|
||||||
|
#endif
|
||||||
fsp->remove(npath);
|
fsp->remove(npath);
|
||||||
upload_file=fsp->open(npath,FILE_WRITE);
|
upload_file=fsp->open(npath,FILE_WRITE);
|
||||||
if (!upload_file) Web.upload_error=1;
|
if (!upload_file) Web.upload_error=1;
|
||||||
@ -6754,14 +6792,22 @@ bool Xdrv10(uint8_t function)
|
|||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
fsp = &SD;
|
fsp = &SD;
|
||||||
if (SD.begin(USE_SCRIPT_FATFS)) {
|
if (SD.begin(USE_SCRIPT_FATFS)) {
|
||||||
|
#else
|
||||||
|
// flash file system
|
||||||
|
#ifdef ESP32
|
||||||
|
//fsp = &SPIFFS;
|
||||||
|
//if (SPIFFS.begin(FORMAT_SPIFFS_IF_FAILED)) {
|
||||||
|
fsp=&FFat;
|
||||||
|
if (FFat.begin(true)) {
|
||||||
#else
|
#else
|
||||||
// fs on flash
|
// fs on flash
|
||||||
fsp = &LittleFS;
|
fsp = &LittleFS;
|
||||||
if (fsp->begin()) {
|
if (fsp->begin()) {
|
||||||
|
#endif // ESP
|
||||||
|
|
||||||
#endif // USE_SCRIPT_FATFS>=0
|
#endif // USE_SCRIPT_FATFS>=0
|
||||||
|
AddLog_P(LOG_LEVEL_INFO,PSTR("FATFS mount OK!"));
|
||||||
//fsp->dateTimeCallback(dateTime);
|
//fsp->dateTimeCallback(dateTime);
|
||||||
|
|
||||||
glob_script_mem.script_sd_found=1;
|
glob_script_mem.script_sd_found=1;
|
||||||
char *script;
|
char *script;
|
||||||
script=(char*)calloc(FAT_SCRIPT_SIZE+4,1);
|
script=(char*)calloc(FAT_SCRIPT_SIZE+4,1);
|
||||||
@ -6781,6 +6827,7 @@ bool Xdrv10(uint8_t function)
|
|||||||
glob_script_mem.flags=1;
|
glob_script_mem.flags=1;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
AddLog_P(LOG_LEVEL_INFO,PSTR("FATFS mount failed!"));
|
||||||
glob_script_mem.script_sd_found=0;
|
glob_script_mem.script_sd_found=0;
|
||||||
}
|
}
|
||||||
#endif // USE_SCRIPT_FATFS
|
#endif // USE_SCRIPT_FATFS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user