mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
Parsed with restyle.sh. Compile with all errors.
This commit is contained in:
parent
d382a33c7d
commit
ee1481aa7c
@ -138,7 +138,7 @@ bool FSTools::moveFS(fs::FS & destinationFS)
|
|||||||
if (f) {
|
if (f) {
|
||||||
sourceFileCount++;
|
sourceFileCount++;
|
||||||
sourceByteTotal += f.size();
|
sourceByteTotal += f.size();
|
||||||
_dumpFileInfo(f);
|
//_dumpFileInfo(f);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -207,12 +207,12 @@ uint32_t FSTools::_getSize(const FST::layout & layout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FSTools::_dumpFileInfo(File & f)
|
// void FSTools::_dumpFileInfo(File & f)
|
||||||
{
|
// {
|
||||||
if (f) {
|
// if (f) {
|
||||||
//Serial.printf_P(PSTR(" File: %-30s [%8uB]\n"), f.fullName(), f.size() );
|
// Serial.printf_P(PSTR(" File: %-30s [%8uB]\n"), f.fullName(), f.size() );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
bool FSTools::_copyFS(FS & sourceFS, FS & destFS)
|
bool FSTools::_copyFS(FS & sourceFS, FS & destFS)
|
||||||
{
|
{
|
||||||
|
@ -55,7 +55,6 @@ extern const layout layout_8m7m;
|
|||||||
extern const layout layout_16m14m;
|
extern const layout layout_16m14m;
|
||||||
extern const layout layout_16m15m;
|
extern const layout layout_16m15m;
|
||||||
|
|
||||||
|
|
||||||
typedef std::function<void(File & f)> FileCb;
|
typedef std::function<void(File & f)> FileCb;
|
||||||
|
|
||||||
|
|
||||||
@ -63,15 +62,9 @@ typedef std::function<void(File & f)> FileCb;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//376884
|
|
||||||
//376452
|
|
||||||
|
|
||||||
|
|
||||||
class FSTools {
|
class FSTools {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FSTools();
|
FSTools();
|
||||||
~FSTools();
|
~FSTools();
|
||||||
bool attemptToMountFS(fs::FS & fs);
|
bool attemptToMountFS(fs::FS & fs);
|
||||||
@ -84,7 +77,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
uint32_t _getStartAddr(const FST::layout & layout);
|
uint32_t _getStartAddr(const FST::layout & layout);
|
||||||
uint32_t _getSize(const FST::layout & layout);
|
uint32_t _getSize(const FST::layout & layout);
|
||||||
void _dumpFileInfo(File & f);
|
// void _dumpFileInfo(File & f);
|
||||||
bool _copyFS(FS & sourceFS, FS & destFS);
|
bool _copyFS(FS & sourceFS, FS & destFS);
|
||||||
|
|
||||||
std::unique_ptr<fs::FS> _pFS;
|
std::unique_ptr<fs::FS> _pFS;
|
||||||
|
@ -2,19 +2,19 @@
|
|||||||
|
|
||||||
This sketch will convert SPIFFS partitions to LittleFS on ESP8266
|
This sketch will convert SPIFFS partitions to LittleFS on ESP8266
|
||||||
|
|
||||||
Change the `TARGET_FS_LAYOUT` to the partition layout that you want target
|
Change the `TARGET_FS_LAYOUT` to the partition layout that you want target
|
||||||
ie what you are trying to copy from.
|
ie what you are trying to copy from.
|
||||||
|
|
||||||
Include in the sketch whatever you want the destination to be, in this case LittleFS,
|
Include in the sketch whatever you want the destination to be, in this case LittleFS,
|
||||||
but it could be SPIFFS to convert back if need be.
|
but it could be SPIFFS to convert back if need be.
|
||||||
|
|
||||||
How it works: It creates a LittleFS partition between the end of the sketch and the
|
How it works: It creates a LittleFS partition between the end of the sketch and the
|
||||||
start of whatever filesystem you set as target. This has IMPORTANT implications for the
|
start of whatever filesystem you set as target. This has IMPORTANT implications for the
|
||||||
amount of data you can move!!! eg a 4Mb flash module with a 3Mb SPIFFS partition only leaves
|
amount of data you can move!!! eg a 4Mb flash module with a 3Mb SPIFFS partition only leaves
|
||||||
about 450k for the temp file system, so if you have more data than that on your 3Mb SPIFFS it
|
about 450k for the temp file system, so if you have more data than that on your 3Mb SPIFFS it
|
||||||
will fail.
|
will fail.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#define TARGET_FS_LAYOUT FST::layout_4m3m
|
#define TARGET_FS_LAYOUT FST::layout_4m3m
|
||||||
|
|
||||||
FSTools fstools;
|
FSTools fstools;
|
||||||
|
|
||||||
#ifndef STASSID
|
#ifndef STASSID
|
||||||
#define STASSID "xxxx"
|
#define STASSID "xxxx"
|
||||||
@ -39,27 +39,25 @@ const char* ssid = STASSID;
|
|||||||
const char* password = STAPSK;
|
const char* password = STAPSK;
|
||||||
|
|
||||||
|
|
||||||
bool migrateFS()
|
bool migrateFS() {
|
||||||
{
|
if (!fstools.attemptToMountFS(LittleFS)) { // Attempts to mount LittleFS without autoformat...
|
||||||
if (!fstools.attemptToMountFS(LittleFS)) { // Attempts to mount LittleFS without autoformat...
|
Serial.println(F("Default FS not found"));
|
||||||
Serial.println(F("Default FS not found"));
|
if (fstools.mountAlternativeFS(FST::SPIFFS /* FST::LITTLEFS */, TARGET_FS_LAYOUT, true)) {
|
||||||
if (fstools.mountAlternativeFS( FST::SPIFFS /* FST::LITTLEFS */ , TARGET_FS_LAYOUT , true )) {
|
Serial.println(F("Alternative found"));
|
||||||
Serial.println(F("Alternative found"));
|
if (fstools.moveFS(LittleFS)) {
|
||||||
if (fstools.moveFS(LittleFS)) {
|
|
||||||
Serial.println(F("FileSystem Moved New FS contents:"));
|
Serial.println(F("FileSystem Moved New FS contents:"));
|
||||||
fstools.fileListIterator(LittleFS, "/", [](File & f) {
|
fstools.fileListIterator(LittleFS, "/", [](File & f) {
|
||||||
Serial.printf_P(PSTR(" File: %-30s [%8uB]\n"), f.fullName(), f.size() );
|
Serial.printf_P(PSTR(" File: %-30s [%8uB]\n"), f.fullName(), f.size());
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void initWiFiOTA()
|
void initWiFiOTA() {
|
||||||
{
|
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
WiFi.begin(ssid, password);
|
WiFi.begin(ssid, password);
|
||||||
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
|
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
|
||||||
@ -107,20 +105,20 @@ void setup() {
|
|||||||
WiFi.persistent(false);
|
WiFi.persistent(false);
|
||||||
WiFi.disconnect(true);
|
WiFi.disconnect(true);
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.printf("SDK Version: %s\n", ESP.getSdkVersion() );
|
Serial.printf("SDK Version: %s\n", ESP.getSdkVersion());
|
||||||
Serial.println("Core Version: " + ESP.getCoreVersion() );
|
Serial.println("Core Version: " + ESP.getCoreVersion());
|
||||||
Serial.println("Full Version: " + ESP.getFullVersion() );
|
Serial.println("Full Version: " + ESP.getFullVersion());
|
||||||
|
|
||||||
Serial.printf("Sketch size: %u\n", ESP.getSketchSize());
|
Serial.printf("Sketch size: %u\n", ESP.getSketchSize());
|
||||||
Serial.printf("Free size: %u\n", ESP.getFreeSketchSpace());
|
Serial.printf("Free size: %u\n", ESP.getFreeSketchSpace());
|
||||||
|
|
||||||
Serial.println("Booting");
|
Serial.println("Booting");
|
||||||
|
|
||||||
migrateFS(); // MUST call this before calling your own begin();
|
migrateFS(); // MUST call this before calling your own begin();
|
||||||
|
|
||||||
initWiFiOTA();
|
initWiFiOTA();
|
||||||
|
|
||||||
Serial.println("Ready");
|
Serial.println("Ready");
|
||||||
Serial.print("IP address: ");
|
Serial.print("IP address: ");
|
||||||
|
@ -2,20 +2,20 @@
|
|||||||
|
|
||||||
This sketch will convert SPIFFS partitions to a custom FS on ESP8266
|
This sketch will convert SPIFFS partitions to a custom FS on ESP8266
|
||||||
|
|
||||||
Change the `TARGET_FS_LAYOUT` to the partition layout that you want target
|
Change the `TARGET_FS_LAYOUT` to the partition layout that you want target
|
||||||
ie what you are trying to copy from.
|
ie what you are trying to copy from.
|
||||||
|
|
||||||
This ksetch shows how to create a FS different to the one provided for by the sketch defaults.
|
This ksetch shows how to create a FS different to the one provided for by the sketch defaults.
|
||||||
This is useful if you need to use an intermediate sketch to move the FS but need to maintain the
|
This is useful if you need to use an intermediate sketch to move the FS but need to maintain the
|
||||||
sketch size limit of say 512kb.
|
sketch size limit of say 512kb.
|
||||||
|
|
||||||
How it works: It creates a LittleFS partition between the end of the sketch and the
|
How it works: It creates a LittleFS partition between the end of the sketch and the
|
||||||
start of whatever filesystem you set as target. This has IMPORTANT implications for the
|
start of whatever filesystem you set as target. This has IMPORTANT implications for the
|
||||||
amount of data you can move!!! eg a 4Mb flash module with a 3Mb SPIFFS partition only leaves
|
amount of data you can move!!! eg a 4Mb flash module with a 3Mb SPIFFS partition only leaves
|
||||||
about 450k for the temp file system, so if you have more data than that on your 3Mb SPIFFS it
|
about 450k for the temp file system, so if you have more data than that on your 3Mb SPIFFS it
|
||||||
will fail.
|
will fail.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -29,13 +29,13 @@
|
|||||||
|
|
||||||
#define TARGET_FS_LAYOUT FST::layout_4m3m
|
#define TARGET_FS_LAYOUT FST::layout_4m3m
|
||||||
|
|
||||||
const uint32_t startSector = FST::layout_4m1m.startAddr - 0x40200000;
|
const uint32_t startSector = FST::layout_4m1m.startAddr - 0x40200000;
|
||||||
const uint32_t tempFSsize = FST::layout_4m1m.endAddr - FST::layout_4m1m.startAddr;
|
const uint32_t tempFSsize = FST::layout_4m1m.endAddr - FST::layout_4m1m.startAddr;
|
||||||
|
|
||||||
fs::FS LittleFS_Different = FS(FSImplPtr(new littlefs_impl::LittleFSImpl(startSector, tempFSsize, FS_PHYS_PAGE, FS_PHYS_BLOCK, 5)));
|
fs::FS LittleFS_Different = FS(FSImplPtr(new littlefs_impl::LittleFSImpl(startSector, tempFSsize, FS_PHYS_PAGE, FS_PHYS_BLOCK, 5)));
|
||||||
|
|
||||||
|
|
||||||
FSTools fstools;
|
FSTools fstools;
|
||||||
|
|
||||||
#ifndef STASSID
|
#ifndef STASSID
|
||||||
#define STASSID "xxxx"
|
#define STASSID "xxxx"
|
||||||
@ -46,27 +46,25 @@ const char* ssid = STASSID;
|
|||||||
const char* password = STAPSK;
|
const char* password = STAPSK;
|
||||||
|
|
||||||
|
|
||||||
bool migrateFS()
|
bool migrateFS() {
|
||||||
{
|
if (!fstools.attemptToMountFS(LittleFS_Different)) { // Attempts to mount LittleFS without autoformat...
|
||||||
if (!fstools.attemptToMountFS(LittleFS_Different)) { // Attempts to mount LittleFS without autoformat...
|
Serial.println(F("Default FS not found"));
|
||||||
Serial.println(F("Default FS not found"));
|
if (fstools.mountAlternativeFS(FST::SPIFFS /* FST::LITTLEFS */, TARGET_FS_LAYOUT, true)) {
|
||||||
if (fstools.mountAlternativeFS( FST::SPIFFS /* FST::LITTLEFS */ , TARGET_FS_LAYOUT , true )) {
|
Serial.println(F("Alternative found"));
|
||||||
Serial.println(F("Alternative found"));
|
if (fstools.moveFS(LittleFS_Different)) {
|
||||||
if (fstools.moveFS(LittleFS_Different)) {
|
|
||||||
Serial.println(F("FileSystem Moved New FS contents:"));
|
Serial.println(F("FileSystem Moved New FS contents:"));
|
||||||
fstools.fileListIterator(LittleFS_Different, "/", [](File & f) {
|
fstools.fileListIterator(LittleFS_Different, "/", [](File & f) {
|
||||||
Serial.printf_P(PSTR(" File: %-30s [%8uB]\n"), f.fullName(), f.size() );
|
Serial.printf_P(PSTR(" File: %-30s [%8uB]\n"), f.fullName(), f.size());
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void initWiFiOTA()
|
void initWiFiOTA() {
|
||||||
{
|
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
WiFi.begin(ssid, password);
|
WiFi.begin(ssid, password);
|
||||||
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
|
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
|
||||||
@ -114,20 +112,20 @@ void setup() {
|
|||||||
WiFi.persistent(false);
|
WiFi.persistent(false);
|
||||||
WiFi.disconnect(true);
|
WiFi.disconnect(true);
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.printf("SDK Version: %s\n", ESP.getSdkVersion() );
|
Serial.printf("SDK Version: %s\n", ESP.getSdkVersion());
|
||||||
Serial.println("Core Version: " + ESP.getCoreVersion() );
|
Serial.println("Core Version: " + ESP.getCoreVersion());
|
||||||
Serial.println("Full Version: " + ESP.getFullVersion() );
|
Serial.println("Full Version: " + ESP.getFullVersion());
|
||||||
|
|
||||||
Serial.printf("Sketch size: %u\n", ESP.getSketchSize());
|
Serial.printf("Sketch size: %u\n", ESP.getSketchSize());
|
||||||
Serial.printf("Free size: %u\n", ESP.getFreeSketchSpace());
|
Serial.printf("Free size: %u\n", ESP.getFreeSketchSpace());
|
||||||
|
|
||||||
Serial.println("Booting");
|
Serial.println("Booting");
|
||||||
|
|
||||||
migrateFS(); // MUST call this before calling your own begin();
|
migrateFS(); // MUST call this before calling your own begin();
|
||||||
|
|
||||||
initWiFiOTA();
|
initWiFiOTA();
|
||||||
|
|
||||||
Serial.println("Ready");
|
Serial.println("Ready");
|
||||||
Serial.print("IP address: ");
|
Serial.print("IP address: ");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user