fixed ESP32-C3: "app image at 0x10000 has invalid magic byte" if the app image flashed at first #48

This commit is contained in:
LeoYan 2022-11-03 08:53:21 +08:00
parent a3e77fb2ec
commit eb5ba6b0e6
2 changed files with 5 additions and 2 deletions

View File

@ -777,7 +777,10 @@ class ESPLoader {
let image, address; let image, address;
for (var i = 0; i < fileArray.length; i++) { for (var i = 0; i < fileArray.length; i++) {
console.log("Data Length " + fileArray[i].data.length); console.log("Data Length " + fileArray[i].data.length);
image = fileArray[i].data + '\xff\xff\xff\xff'.substring(0, 4 - fileArray[i].data.length % 4);
image = fileArray[i].data;
const reminder = fileArray[i].data.length % 4;
if (reminder > 0) image += '\xff\xff\xff\xff'.substring(4 - reminder);
address = fileArray[i].address; address = fileArray[i].address;
console.log("Image Length " + image.length); console.log("Image Length " + image.length);
if (image.length === 0) { if (image.length === 0) {

View File

@ -8,7 +8,7 @@ export default class ESP32C3ROM {
static UART_DATE_REG_ADDR = 0x6000007c; static UART_DATE_REG_ADDR = 0x6000007c;
static FLASH_WRITE_SIZE = 0x400; static FLASH_WRITE_SIZE = 0x400;
static BOOTLOADER_FLASH_OFFSET = 0x1000; static BOOTLOADER_FLASH_OFFSET = 0;
static FLASH_SIZES = { static FLASH_SIZES = {
"1MB": 0x00, "1MB": 0x00,