Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
bmorcelli committed Jul 1, 2024
1 parent 37db948 commit a4a300e
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 28 deletions.
Binary file modified Launcher/Launcher_2.0_C.bin
Binary file not shown.
Binary file modified Launcher/Launcher_2.0_Cardputer.bin
Binary file not shown.
Binary file modified Launcher/Launcher_2.0_core2.bin
Binary file not shown.
Binary file modified Launcher/Launcher_2.0_core_16Mb.bin
Binary file not shown.
Binary file modified Launcher/Launcher_2.0_cplus1_1.bin
Binary file not shown.
Binary file modified Launcher/Launcher_2.0_cplus2.bin
Binary file not shown.
15 changes: 12 additions & 3 deletions custom_8Mb.csv
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# Name, Type, SubType, Offset, Size, Flags
#nvs, data, nvs, 0x9000, 0x5000,
#otadata, data, ota, 0xe000, 0x2000,
#app0, app, test, 0x10000, 0x180000,
#app1, app, ota_0, 0x190000, 0x4E0000,
#vfs, data, fat, 0x670000, 0x80000,
#spiffs, data, spiffs, 0x6F0000, 0x100000,
#coredump, data, coredump,0x7F0000, 0x10000,
#
#
nvs, data, nvs, 0x9000, 0x5000,
otadata, data, ota, 0xe000, 0x2000,
app0, app, test, 0x10000, 0x180000,
app1, app, ota_0, 0x190000, 0x4E0000,
vfs, data, FAT, 0x670000, 0x80000,
spiffs, data, spiffs, 0x6F0000, 0x100000,
app1, app, ota_0, 0x190000, 0x450000,
sys, data, fat, 0x5F0000, 0x100000,
vfs, data, fat, 0x6F0000, 0x100000,
coredump, data, coredump,0x7F0000, 0x10000,
2 changes: 1 addition & 1 deletion merge_files.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
esptool --chip esp32s3 merge_bin --output Launcher/Launcher_2.0_Cardputer.bin 0x0 .pio/build/m5stack-cardputer/bootloader.bin 0x8000 .pio/build/m5stack-cardputer/partitions.bin 0x10000 .pio/build/m5stack-cardputer/firmware.bin
esptool --chip esp32 merge_bin --output Launcher/Launcher_2.0_cplus2.bin 0x1000 .pio/build/m5stack-cplus2/bootloader.bin 0x8000 .pio/build/m5stack-cplus2/partitions.bin 0x10000 .pio/build/m5stack-cplus2/firmware.bin
esptool --chip esp32 merge_bin --output Launcher/Launcher_2.0_cplus1_1.bin 0x1000 .pio/build/m5stack-cplus1_1/bootloader.bin 0x8000 .pio/build/m5stack-cplus1_1/partitions.bin 0x10000 .pio/build/m5stack-cplus1_1/firmware.bin
esptool --chip esp32 merge_bin --output Launcher/Launcher_2.0_C.bin 0x1000 .pio/build/m5stack-c/support_files/bootloader.bin 0x8000 .pio/build/m5stack-c/partitions.bin 0x10000 .pio/build/m5stack-c/firmware.bin
esptool --chip esp32 merge_bin --output Launcher/Launcher_2.0_C.bin 0x1000 .pio/build/m5stack-c/bootloader.bin 0x8000 .pio/build/m5stack-c/partitions.bin 0x10000 .pio/build/m5stack-c/firmware.bin
esptool --chip esp32 merge_bin --output Launcher/Launcher_2.0_core2.bin 0x1000 .pio/build/m5stack-core2/bootloader.bin 0x8000 .pio/build/m5stack-core2/partitions.bin 0x10000 .pio/build/m5stack-core2/firmware.bin
esptool --chip esp32 merge_bin --output Launcher/Launcher_2.0_core_16Mb.bin 0x1000 .pio/build/m5stack-core/bootloader.bin 0x8000 .pio/build/m5stack-core/partitions.bin 0x10000 .pio/build/m5stack-core/firmware.bin
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ default_envs =
[common]
build_flags =
;-D LAUNCHER_VERSION="2.0b"
-DLAUNCHER='"2.1.0"'
-DLAUNCHER='"2.1.1"'
-DMAXFILES=256
-DEEPROMSIZE=64 ;512
-DLH=8
Expand Down
10 changes: 6 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ void setup() {
esp_app_desc_t ota_desc;
esp_err_t err = esp_ota_get_partition_description(esp_ota_get_next_update_partition(NULL), &ota_desc);


tft.init();
// Setup GPIOs and stuff
#if defined(STICK_C_PLUS2)
pinMode(UP_BTN, INPUT);
Expand All @@ -295,7 +295,7 @@ void setup() {

rotation = gsetRotation();
tft.setRotation(rotation);
tft.init();

resetTftDisplay();
initDisplay(true);
askSpiffs=gsetAskSpiffs();
Expand Down Expand Up @@ -484,9 +484,11 @@ void loop() {
options.push_back({"Clear FAT", [=]() { eraseFAT(); }});
#endif
if(MAX_SPIFFS>0) options.push_back({"Bkp SPIFFS", [=]() { dumpPartition("spiffs", "/bkp/spiffs.bin"); }});
if(MAX_FAT_sys>0) options.push_back({"Bkp FAT sys", [=]() { dumpPartition("sys", "/bkp/FAT_sys.bin"); }});
if(MAX_FAT_vfs>0) options.push_back({"Bkp FAT vfs", [=]() { dumpPartition("vfs", "/bkp/FAT_vfs.bin"); }});
if(MAX_SPIFFS>0) options.push_back({ "Restore SPIFFS", [=]() { restorePartition("spiffs"); }});
if(MAX_FAT_vfs>0) options.push_back({"Restore FAT FS", [=]() { restorePartition("vfs"); }});
if(MAX_SPIFFS>0) options.push_back({ "Rest SPIFFS", [=]() { restorePartition("spiffs"); }});
if(MAX_FAT_vfs>0) options.push_back({"Rest FAT Vfs", [=]() { restorePartition("vfs"); }});
if(MAX_FAT_vfs>0) options.push_back({"Rest FAT Sys", [=]() { restorePartition("sys"); }});

options.push_back({"Restart", [=]() { ESP.restart(); }});

Expand Down
4 changes: 2 additions & 2 deletions src/onlineLauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void installFirmware(String file, uint32_t app_size, bool spiffs, uint32_t spiff

#ifndef STICK_C_PLUS
//Erase FAT partition
eraseFAT();
//eraseFAT();
#endif

#ifndef STICK_C
Expand Down Expand Up @@ -286,7 +286,7 @@ void installFirmware(String file, uint32_t app_size, bool spiffs, uint32_t spiff

#if !defined(STICK_C_PLUS)
if(fat) {
eraseFAT();
//eraseFAT();
int FAT=U_FAT_vfs;
if(fat_size[1]>0) FAT = U_FAT_sys;
for(int i=0; i<2; i++) {
Expand Down
40 changes: 24 additions & 16 deletions src/sd_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ bool eraseFAT() {
}

// erase all FAT partition
err = esp_partition_erase_range(partition, 0, partition->size);
err = spi_flash_erase_range(partition->address, partition->size);
if (err != ESP_OK) {
//log_e("Failed to erase partition: %s", esp_err_to_name(err));
return false;
Expand All @@ -40,7 +40,7 @@ bool eraseFAT() {
}

// erase all FAT partition
err = esp_partition_erase_range(partition, 0, partition->size);
err = spi_flash_erase_range(partition->address, partition->size);
if (err != ESP_OK) {
return false;
}
Expand Down Expand Up @@ -520,7 +520,7 @@ void performUpdate(Stream &updateSource, size_t updateSize, int command) {

#ifndef STICK_C_PLUS
//Erase FAT partition
eraseFAT();
//eraseFAT();
#endif

prog_handler = 0; // Install flash update
Expand Down Expand Up @@ -655,19 +655,23 @@ void updateFromSD(String path) {
}

if (fat) {
if (fat_size_sys > 0 && fat_size_vfs > 0) {
if (fat_size_sys > 0) {
if (!file.seek(fat_offset_sys)) goto Exit;
if (!performFATUpdate(file, fat_size_sys + fat_size_vfs, "sys")) log_i("FAIL updating FAT sys");
if (!performFATUpdate(file, fat_size_sys, "sys")) log_i("FAIL updating FAT sys");
else displayRedStripe("sys FAT complete");
} else if (fat_size_sys == 0 && fat_size_vfs > 0) {
}

if (fat_size_vfs > 0) {
if (!file.seek(fat_offset_vfs)) goto Exit;
if (!performFATUpdate(file, fat_size_vfs, "vfs")) log_i("FAIL updating FAT vfs");
else displayRedStripe("vfs FAT complete");
}


}
ESP.restart();
//ESP.restart();
displayRedStripe("Complete");
delay(2000);
}
Exit:
displayRedStripe("Error on updating.");
Expand All @@ -679,17 +683,23 @@ void updateFromSD(String path) {
** Function name: performFATUpdate
** Description: this function performs the update
***************************************************************************************/
uint8_t DRAM_ATTR buffer[1024];
uint8_t buffer2[1024];

bool performFATUpdate(Stream &updateSource, size_t updateSize, const char *label) {
// Preencher o buffer com 0xFF
memset(buffer, 0xFF, sizeof(buffer));
memset(buffer2, 0x00, sizeof(buffer2));
const esp_partition_t* partition;
esp_err_t error;
size_t paroffset = 0;
int written = 0;
int bytesRead = 0;

error = esp_flash_set_chip_write_protect(NULL, false);

if (error != ESP_OK) {
log_i("Protection error: %d", error);
//return false;
}

partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_FAT, label);
if (!partition) {
error = UPDATE_ERROR_NO_PARTITION;
Expand All @@ -698,7 +708,7 @@ bool performFATUpdate(Stream &updateSource, size_t updateSize, const char *label

log_i("Start updating: %s", partition->label);
paroffset = partition->address;
log_i("Erasing updating: %s from: %d with size: %d", label, paroffset, partition->size);
log_i("Erasing updating: %s from: %d with size: %d", label, paroffset, updateSize);

error = spi_flash_erase_range(partition->address, updateSize);
if (error != ESP_OK) {
Expand All @@ -711,15 +721,13 @@ bool performFATUpdate(Stream &updateSource, size_t updateSize, const char *label
log_i("Updating updating: %s", label);

while (written < updateSize) { //updateSource.available() &&
bytesRead = updateSource.readBytes(buffer, sizeof(buffer));
if (bytesRead == 0) break; // Evitar loop infinito se não houver bytes para ler

error = spi_flash_write(paroffset, buffer, bytesRead);
bytesRead = updateSource.readBytes(buffer2, sizeof(buffer2));
error = spi_flash_write(paroffset, buffer2, bytesRead);
if (error != ESP_OK) {
log_i("[FLASH] Failed to write to flash (0x%x)", error);
return false;
}

if (bytesRead == 0) break; // Evitar loop infinito se não houver bytes para ler
paroffset += bytesRead;
written += bytesRead;
progressHandler(written, updateSize);
Expand Down
2 changes: 1 addition & 1 deletion src/webInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void handleUpload(AsyncWebServerRequest *request, String filename, size_t index,
else prog_handler = 1;
#ifndef STICK_C_PLUS
//Erase FAT partition
eraseFAT();
//eraseFAT();
#endif
progressHandler(0, 500);
Update.onProgress(progressHandler);
Expand Down

0 comments on commit a4a300e

Please sign in to comment.