Skip to content

Commit

Permalink
Merge pull request #50 from LeoYan/main
Browse files Browse the repository at this point in the history
fixed ESP32-C3: "app image at 0x10000 has invalid magic byte" if the …
  • Loading branch information
adwait-esp committed Nov 10, 2022
2 parents 5d7cda0 + eb5ba6b commit 076af26
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion ESPLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,10 @@ class ESPLoader {
let image, address;
for (var i = 0; i < fileArray.length; i++) {
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;
console.log("Image Length " + image.length);
if (image.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion targets/esp32c3.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default class ESP32C3ROM {
static UART_DATE_REG_ADDR = 0x6000007c;

static FLASH_WRITE_SIZE = 0x400;
static BOOTLOADER_FLASH_OFFSET = 0x1000;
static BOOTLOADER_FLASH_OFFSET = 0;

static FLASH_SIZES = {
"1MB": 0x00,
Expand Down

0 comments on commit 076af26

Please sign in to comment.