Breaking change ESP32 file system

Breaking change ESP32 switch from default SPIFFS to default LittleFS file system loosing current (zigbee) files
This commit is contained in:
Theo Arends 2021-01-06 15:28:56 +01:00
parent 6b16745cf0
commit d6a24c6fe7
5 changed files with 79 additions and 6 deletions

View File

@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
## [Unreleased] - Development
## [9.2.0.3]
### Breaking Changed
- ESP32 switch from default SPIFFS to default LittleFS file system loosing current (zigbee) files
### Changed
- Force initial default state ``SetOption57 1`` to scan wifi network every 44 minutes for strongest signal (#10395)

View File

@ -79,6 +79,7 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota
- SPI display driver SSD1331 Color oled by Jeroen Vermeulen [#10376](https://github.com/arendst/Tasmota/issues/10376)
### Breaking Changed
- ESP32 switch from default SPIFFS to default LittleFS file system loosing current (zigbee) files
- Replaced MFRC522 13.56MHz rfid card reader GPIO selection from ``SPI CS`` by ``RC522 CS``
- Replaced NRF24L01 GPIO selection from ``SPI CS`` by ``NRF24 CS`` and ``SPI DC`` by ``NRF24 DC``
- Replaced ILI9341 GPIO selection from ``SPI CS`` by ``ILI9341 CS`` and ``SPI DC`` by ``ILI9341 DC``

View File

@ -107,7 +107,8 @@ String EthernetMacAddress(void);
#define ARDUINO_CORE_RELEASE ARDUINO_ESP32_RELEASE
#endif // ARDUINO_ESP32_RELEASE
#define USE_TFS
//#define USE_TFS
#define USE_UFILESYS
#ifdef USE_SCRIPT
#undef USE_TFS

View File

@ -306,6 +306,9 @@ void loadZigbeeDevices(bool dump_only = false) {
}
#ifdef USE_TFS
TfsLoadFile("/zb", spi_buffer, z_spi_len);
#endif
#ifdef USE_UFILESYS
UfsLoadFile("/zb", spi_buffer, z_spi_len);
#endif
z_dev_start = spi_buffer;
#endif // ESP32
@ -372,6 +375,9 @@ void saveZigbeeDevices(void) {
#ifdef USE_TFS
TfsLoadFile("/zb", spi_buffer, z_spi_len);
#endif
#ifdef USE_UFILESYS
UfsLoadFile("/zb", spi_buffer, z_spi_len);
#endif
#endif // ESP32
Z_Flashentry *flashdata = (Z_Flashentry*)(spi_buffer + z_block_offset);
@ -391,6 +397,9 @@ void saveZigbeeDevices(void) {
#ifdef ESP32
#ifdef USE_TFS
TfsSaveFile("/zb", spi_buffer, z_spi_len);
#endif
#ifdef USE_UFILESYS
UfsSaveFile("/zb", spi_buffer, z_spi_len);
#endif
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data saved in %s (%d bytes)"), PSTR("Flash"), buf_len);
#endif // ESP32
@ -427,6 +436,9 @@ void eraseZigbeeDevices(void) {
#ifdef ESP32
#ifdef USE_TFS
TfsEraseFile("/zb", z_block_len);
#endif
#ifdef USE_UFILESYS
UfsInitFile("/zb", z_block_len, 0xFF);
#endif
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_ZIGBEE "Zigbee Devices Data erased (%d bytes)"), z_block_len);
#endif // ESP32

View File

@ -19,9 +19,10 @@
#ifdef USE_UFILESYS
/*********************************************************************************************\
This driver adds universal file system support for ESP8266 (sd card or littlfs on > 1 M devices
with special linker file e.g. eagle.flash.4m2m.ld) (makes no sense on 1M devices without sd card)
and ESP32 (sd card or little fs or sfatfile system).
This driver adds universal file system support for
- ESP8266 (sd card or littlefs on > 1 M devices with special linker file e.g. eagle.flash.4m2m.ld)
(makes no sense on 1M devices without sd card)
- ESP32 (sd card or littlefs or sfatfile system).
The sd card chip select is the standard SDCARD_CS or when not found SDCARD_CS_PIN and initializes
the FS System Pointer ufsp which can be used by all standard file system calls.
@ -83,7 +84,7 @@ uint8_t ufs_type;
#define UFS_TFAT 2
#define UFS_TLFS 3
void UFSInit(void) {
void UfsInit(void) {
ufs_type = 0;
ffsp = 0;
// check for fs options,
@ -148,6 +149,61 @@ void UFSInit(void) {
return;
}
bool UfsFileExists(const char *fname){
if (!ufs_type) { return false; }
bool yes = ufsp->exists(fname);
if (!yes) {
AddLog_P(LOG_LEVEL_INFO, PSTR("UFS: File not found"));
}
return yes;
}
bool UfsSaveFile(const char *fname, const uint8_t *buf, uint32_t len) {
if (!ufs_type) { return false; }
File file = ufsp->open(fname, "w");
if (!file) {
AddLog_P(LOG_LEVEL_INFO, PSTR("UFS: Save failed"));
return false;
}
file.write(buf, len);
file.close();
return true;
}
bool UfsInitFile(const char *fname, uint32_t len, uint8_t init_value) {
if (!ufs_type) { return false; }
File file = ufsp->open(fname, "w");
if (!file) {
AddLog_P(LOG_LEVEL_INFO, PSTR("UFS: Erase failed"));
return false;
}
for (uint32_t i = 0; i < len; i++) {
file.write(&init_value, 1);
}
file.close();
return true;
}
bool UfsLoadFile(const char *fname, uint8_t *buf, uint32_t len) {
if (!ufs_type) { return false; }
if (!UfsFileExists(fname)) { return false; }
File file = ufsp->open(fname, "r");
if (!file) {
AddLog_P(LOG_LEVEL_INFO, PSTR("UFS: File not found"));
return false;
}
file.read(buf, len);
file.close();
return true;
}
uint32_t ufs_fsinfo(uint32_t sel) {
uint32_t result = 0;
@ -521,7 +577,7 @@ bool Xdrv50(uint8_t function) {
switch (function) {
case FUNC_PRE_INIT:
UFSInit();
UfsInit();
break;
case FUNC_COMMAND:
result = DecodeCommand(kUFSCommands, kUFSCommand);