workflow: update SPIFFS binary creation to include minimal header and adjust update validation logic

This commit is contained in:
Manuel Weiser 2025-02-22 12:21:33 +01:00
parent 04a7c2cce3
commit 698abbd669
3 changed files with 8 additions and 16 deletions

View File

@ -40,8 +40,8 @@ jobs:
# Copy firmware binary # Copy firmware binary
cp .pio/build/esp32dev/firmware.bin .pio/build/esp32dev/upgrade_filaman_firmware_v${VERSION}.bin cp .pio/build/esp32dev/firmware.bin .pio/build/esp32dev/upgrade_filaman_firmware_v${VERSION}.bin
# Create SPIFFS binary (without header) # Create SPIFFS binary with minimal header
cp .pio/build/esp32dev/spiffs.bin .pio/build/esp32dev/upgrade_filaman_website_v${VERSION}.bin ( printf '\xe9\x01\x00\x00' && cat .pio/build/esp32dev/spiffs.bin ) > .pio/build/esp32dev/upgrade_filaman_website_v${VERSION}.bin
# Create full binary # Create full binary
(cd .pio/build/esp32dev && (cd .pio/build/esp32dev &&

View File

@ -47,8 +47,8 @@ jobs:
# Copy firmware binary # Copy firmware binary
cp .pio/build/esp32dev/firmware.bin .pio/build/esp32dev/upgrade_filaman_firmware_v${VERSION}.bin cp .pio/build/esp32dev/firmware.bin .pio/build/esp32dev/upgrade_filaman_firmware_v${VERSION}.bin
# Create SPIFFS binary (without header) # Create SPIFFS binary with minimal header
cp .pio/build/esp32dev/spiffs.bin .pio/build/esp32dev/upgrade_filaman_website_v${VERSION}.bin ( printf '\xe9\x01\x00\x00' && cat .pio/build/esp32dev/spiffs.bin ) > .pio/build/esp32dev/upgrade_filaman_website_v${VERSION}.bin
# Create full binary (always) # Create full binary (always)
(cd .pio/build/esp32dev && (cd .pio/build/esp32dev &&

View File

@ -397,27 +397,20 @@ void setupWebserver(AsyncWebServer &server) {
command = (filename.indexOf("spiffs") > -1) ? U_SPIFFS : U_FLASH; command = (filename.indexOf("spiffs") > -1) ? U_SPIFFS : U_FLASH;
Serial.printf("Update Start: %s\nSize: %u\nCommand: %d\n", filename.c_str(), updateSize, command); Serial.printf("Update Start: %s\nSize: %u\nCommand: %d\n", filename.c_str(), updateSize, command);
// Überprüfe die SPIFFS-Größe
if (command == U_SPIFFS && updateSize > 0x30000) {
String errorMsg = "SPIFFS update too large. Maximum size is 192KB";
Serial.println(errorMsg);
request->send(400, "application/json", "{\"success\":false,\"message\":\"" + errorMsg + "\"}");
return;
}
if (command == U_SPIFFS) { if (command == U_SPIFFS) {
Serial.println("Backup JSON configs..."); Serial.println("Backup JSON configs...");
backupJsonConfigs(); backupJsonConfigs();
if (!Update.begin(updateSize, command, false)) { // Deaktiviere alle Validierungen für SPIFFS-Updates
if (!Update.begin(UPDATE_SIZE_UNKNOWN, command)) {
Serial.printf("Update Begin Error: %s\n", Update.errorString()); Serial.printf("Update Begin Error: %s\n", Update.errorString());
Serial.println("Restoring JSON configs...");
restoreJsonConfigs(); restoreJsonConfigs();
String errorMsg = String("Update begin failed: ") + Update.errorString(); String errorMsg = String("Update begin failed: ") + Update.errorString();
request->send(400, "application/json", "{\"success\":false,\"message\":\"" + errorMsg + "\"}"); request->send(400, "application/json", "{\"success\":false,\"message\":\"" + errorMsg + "\"}");
return; return;
} }
} else { } else {
// Normale Validierung für Firmware-Updates
if (!Update.begin(updateSize, command)) { if (!Update.begin(updateSize, command)) {
Serial.printf("Update Begin Error: %s\n", Update.errorString()); Serial.printf("Update Begin Error: %s\n", Update.errorString());
String errorMsg = String("Update begin failed: ") + Update.errorString(); String errorMsg = String("Update begin failed: ") + Update.errorString();
@ -431,7 +424,6 @@ void setupWebserver(AsyncWebServer &server) {
if (Update.write(data, len) != len) { if (Update.write(data, len) != len) {
Serial.printf("Update Write Error: %s\n", Update.errorString()); Serial.printf("Update Write Error: %s\n", Update.errorString());
if (command == U_SPIFFS) { if (command == U_SPIFFS) {
Serial.println("Restoring JSON configs...");
restoreJsonConfigs(); restoreJsonConfigs();
} }
String errorMsg = String("Write failed: ") + Update.errorString(); String errorMsg = String("Write failed: ") + Update.errorString();
@ -439,7 +431,7 @@ void setupWebserver(AsyncWebServer &server) {
return; return;
} }
Serial.printf("Progress: %u/%u\n", index + len, updateSize); // Sende den Fortschritt als JSON
String progress = "{\"progress\":" + String((index + len) * 100 / updateSize) + "}"; String progress = "{\"progress\":" + String((index + len) * 100 / updateSize) + "}";
request->send(200, "application/json", progress); request->send(200, "application/json", progress);
} }