I want to put my .bin file in to the server and update SPIFFS with OTA I use "ESP32httpUpdate.h" library and get the 'spiffs Update Faild Error (-100): To less space' the partition.csv and the SPIFFS size is 1441792 bytes, the spiffs .bin file is 1,441,792 I've changed partition csv file (default.csv) and increase SPIFSS to 2M and then Platformio / Arduino IDE generated the 2MB Spiffs file. I know the SPIFFS.bin will be exactly same as partition.csv and I just put 2KB text file in the data folder. I've added the SPIFFS.format() but I get the same error. Thanks.
OUTPUT:
Connected to ****
IP address: 192.168.0.104
Flash chip size: 4194304
Partiton table:
0 - 10 - 10000 - 140000 - app0 - 0
0 - 11 - 150000 - 140000 - app1 - 0
1 - 2 - 9000 - 5000 - nvs - 0
1 - 0 - e000 - 2000 - otadata - 0
1 - 82 - 290000 - 160000 - spiffs - 0
1 - 3 - 3f0000 - 10000 - coredump - 0
Listing directory: /
=====================
SPIFFS Partition Info:
Total space: 1318001 bytes
Used space: 0 bytes
FreeSpace=1318001---------------------------------
Partition Label: nvs
Partition Type: 1
Partition Subtype: 2
Partition Size: 20480 bytes
Partition Address: 0x9000
---------------------------------
---------------------------------
Partition Label: otadata
Partition Type: 1
Partition Subtype: 0
Partition Size: 8192 bytes
Partition Address: 0xE000
---------------------------------
---------------------------------
Partition Label: app0
Partition Type: 0
Partition Subtype: 16
Partition Size: 1310720 bytes
Partition Address: 0x10000
---------------------------------
---------------------------------
Partition Label: app1
Partition Type: 0
Partition Subtype: 17
Partition Size: 1310720 bytes
Partition Address: 0x150000
---------------------------------
---------------------------------
Partition Label: spiffs
Partition Type: 1
Partition Subtype: 130
Partition Size: 1441792 bytes
Partition Address: 0x290000
---------------------------------
---------------------------------
Partition Label: coredump
Partition Type: 1
Partition Subtype: 3
Partition Size: 65536 bytes
Partition Address: 0x3F0000
---------------------------------
spiffs Update Faild Error (-100): To less space
MY CODE:
#include <Arduino.h>
//#include "FS.h"
#include "SPIFFS.h"
#include "ESP32httpUpdate.h"
#include <WiFi.h>
//#include "HttpsOTAUpdate.h"
const char* modem_ssid = "********";
const char* modem_pass = "**********";
String Update_URL = "http://192.168.0.241/folder/LPT1000.spiffs.bin";
String spiffs_ver = "LPT1000_1.1";
void listDir(fs::FS &fs, const char * dirname, uint8_t levels){
Serial.printf("Listing directory: %s\r\n", dirname);
File root = fs.open(dirname);
if(!root){
Serial.println("- failed to open directory");
return;
}
if(!root.isDirectory()){
Serial.println(" - not a directory");
return;
}
File file = root.openNextFile();
while(file){
if(file.isDirectory()){
Serial.print(" DIR : ");
Serial.println(file.name());
if(levels){
listDir(fs, file.path(), levels -1);
}
} else {
Serial.print(" FILE: ");
Serial.print(file.name());
Serial.print("\tSIZE: ");
Serial.println(file.size());
}
file = root.openNextFile();
}
}
void update_spiffs(){
SPIFFS.format();
//ESPhttpUpdate.rebootOnUpdate(true);
t_httpUpdate_return ret1 = ESPhttpUpdate.updateSpiffs(Update_URL, spiffs_ver);
switch(ret1){
case HTTP_UPDATE_FAILED:
Serial.printf("spiffs Update Faild Error (%d): %s", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
break;
case HTTP_UPDATE_NO_UPDATES:
Serial.println("spiffs No Update");
break;
case HTTP_UPDATE_OK:
Serial.println("spiffs Update OK");
break;
}
}
void setup() {
Serial.begin(115200);
if (!SPIFFS.begin(true)) { //begin SPIFFS
Serial.println("An Error has occurred while mounting SPIFFS");
return;
}
WiFi.begin(modem_ssid, modem_pass);
Serial.println("");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(modem_ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
delay(100);
// ====================
size_t ul;
esp_partition_iterator_t _mypartiterator;
const esp_partition_t *_mypart;
ul = spi_flash_get_chip_size(); Serial.print("Flash chip size: "); Serial.println(ul);
Serial.println("Partiton table:");
_mypartiterator = esp_partition_find(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_ANY, NULL);
if (_mypartiterator) {
do {
_mypart = esp_partition_get(_mypartiterator);
printf("%x - %x - %x - %x - %s - %i\r\n", _mypart->type, _mypart->subtype, _mypart->address, _mypart->size, _mypart->label, _mypart->encrypted);
} while (_mypartiterator = esp_partition_next(_mypartiterator));
}
esp_partition_iterator_release(_mypartiterator);
_mypartiterator = esp_partition_find(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, NULL);
if (_mypartiterator) {
do {
_mypart = esp_partition_get(_mypartiterator);
printf("%x - %x - %x - %x - %s - %i\r\n", _mypart->type, _mypart->subtype, _mypart->address, _mypart->size, _mypart->label, _mypart->encrypted);
} while (_mypartiterator = esp_partition_next(_mypartiterator));
}
esp_partition_iterator_release(_mypartiterator);
// ====================
delay(500);
listDir(SPIFFS, "/", 0);
Serial.println("=====================");
size_t totalBytes = SPIFFS.totalBytes();
size_t usedBytes = SPIFFS.usedBytes();
Serial.println("SPIFFS Partition Info:");
Serial.print("Total space: ");
Serial.print(totalBytes);
Serial.println(" bytes");
Serial.print("Used space: ");
Serial.print(usedBytes);
Serial.println(" bytes");
Serial.print(" FreeSpace=");
Serial.print(SPIFFS.totalBytes()-SPIFFS.usedBytes());
//======================================================
esp_partition_iterator_t it = esp_partition_find(ESP_PARTITION_TYPE_ANY, ESP_PARTITION_SUBTYPE_ANY, NULL);
if (it != NULL) {
while (true) {
const esp_partition_t* partition = esp_partition_get(it);
if (partition == NULL) break;
Serial.println("---------------------------------");
Serial.print("Partition Label: ");
Serial.println(partition->label);
Serial.print("Partition Type: ");
Serial.println(partition->type);
Serial.print("Partition Subtype: ");
Serial.println(partition->subtype);
Serial.print("Partition Size: ");
Serial.print(partition->size);
Serial.println(" bytes");
Serial.print("Partition Address: 0x");
Serial.println(partition->address, HEX);
Serial.println("---------------------------------");
it = esp_partition_next(it);
if (it == NULL) break;
}
} else {
Serial.println("Failed to get partition table");
}
//======================================================
delay(100);
update_spiffs();
}
void loop() {
}