Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Commit

Permalink
Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob committed Mar 23, 2022
1 parent 365e452 commit ae42132
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
18 changes: 9 additions & 9 deletions src/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const ESP32_FLASH_SIZES = {
"16MB": 0x40,
"32MB": 0x50,
"64MB": 0x60,
"128MB": 0x70
"128MB": 0x70,
};

export const DETECTED_FLASH_SIZES = {
Expand All @@ -52,8 +52,8 @@ export const ESP32_BOOTLOADER_FLASH_OFFSET = 0x1000;
export const BOOTLOADER_FLASH_OFFSET = 0x0;

export const ESP8266_SPI_REG_BASE = 0x60000200;
export const ESP8266_BASEFUSEADDR = 0x3FF00050;
export const ESP8266_MACFUSEADDR = 0x3FF00050;
export const ESP8266_BASEFUSEADDR = 0x3ff00050;
export const ESP8266_MACFUSEADDR = 0x3ff00050;
export const ESP8266_SPI_USR_OFFS = 0x1c;
export const ESP8266_SPI_USR1_OFFS = 0x20;
export const ESP8266_SPI_USR2_OFFS = 0x24;
Expand All @@ -63,8 +63,8 @@ export const ESP8266_SPI_W0_OFFS = 0x40;
export const ESP8266_UART_DATE_REG_ADDR = 0x60000078;

export const ESP32_SPI_REG_BASE = 0x3ff42000;
export const ESP32_BASEFUSEADDR = 0x3FF5A000;
export const ESP32_MACFUSEADDR = 0x3FF5A000;
export const ESP32_BASEFUSEADDR = 0x3ff5a000;
export const ESP32_MACFUSEADDR = 0x3ff5a000;
export const ESP32_SPI_USR_OFFS = 0x1c;
export const ESP32_SPI_USR1_OFFS = 0x20;
export const ESP32_SPI_USR2_OFFS = 0x24;
Expand All @@ -74,8 +74,8 @@ export const ESP32_SPI_W0_OFFS = 0x80;
export const ESP32_UART_DATE_REG_ADDR = 0x60000078;

export const ESP32S2_SPI_REG_BASE = 0x3f402000;
export const ESP32S2_BASEFUSEADDR = 0x3f41A000;
export const ESP32S2_MACFUSEADDR = 0x3f41A044;
export const ESP32S2_BASEFUSEADDR = 0x3f41a000;
export const ESP32S2_MACFUSEADDR = 0x3f41a044;
export const ESP32S2_SPI_USR_OFFS = 0x18;
export const ESP32S2_SPI_USR1_OFFS = 0x1c;
export const ESP32S2_SPI_USR2_OFFS = 0x20;
Expand Down Expand Up @@ -128,8 +128,8 @@ export const CHIP_FAMILY_ESP8266 = 0x8266;
export const CHIP_FAMILY_ESP32 = 0x32;
export const CHIP_FAMILY_ESP32S2 = 0x3252;
export const CHIP_FAMILY_ESP32S3 = 0x3253;
export const CHIP_FAMILY_ESP32C3 = 0x32C3;
export const CHIP_FAMILY_ESP32C6 = 0x32C6;
export const CHIP_FAMILY_ESP32C3 = 0x32c3;
export const CHIP_FAMILY_ESP32C6 = 0x32c6;
export const CHIP_FAMILY_ESP32H2 = 0x3272;
export type ChipFamily =
| typeof CHIP_FAMILY_ESP8266
Expand Down
31 changes: 22 additions & 9 deletions src/esp_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,17 @@ export class ESPLoader extends EventTarget {
macAddr[3] = (mac1 >> 16) & 0xff;
macAddr[4] = (mac1 >> 8) & 0xff;
macAddr[5] = mac1 & 0xff;
} else if (this.chipFamily == CHIP_FAMILY_ESP32S2 || this.chipFamily == CHIP_FAMILY_ESP32S3 || this.chipFamily == CHIP_FAMILY_ESP32C3) {
macAddr[0] = (mac1 >> 8) & 0xFF;
macAddr[1] = mac1 & 0xFF;
macAddr[2] = (mac0 >> 24) & 0xFF;
macAddr[3] = (mac0 >> 16) & 0xFF;
macAddr[4] = (mac0 >> 8) & 0xFF;
macAddr[5] = mac0 & 0xFF;
} else if (
this.chipFamily == CHIP_FAMILY_ESP32S2 ||
this.chipFamily == CHIP_FAMILY_ESP32S3 ||
this.chipFamily == CHIP_FAMILY_ESP32C3
) {
macAddr[0] = (mac1 >> 8) & 0xff;
macAddr[1] = mac1 & 0xff;
macAddr[2] = (mac0 >> 24) & 0xff;
macAddr[3] = (mac0 >> 16) & 0xff;
macAddr[4] = (mac0 >> 8) & 0xff;
macAddr[5] = mac0 & 0xff;
} else {
throw new Error("Unknown chip family");
}
Expand Down Expand Up @@ -243,7 +247,12 @@ export class ESPLoader extends EventTarget {
if (this.IS_STUB || this.chipFamily == CHIP_FAMILY_ESP8266) {
statusLen = 2;
} else if (
[CHIP_FAMILY_ESP32, CHIP_FAMILY_ESP32S2, CHIP_FAMILY_ESP32S3, CHIP_FAMILY_ESP32C3].includes(this.chipFamily)
[
CHIP_FAMILY_ESP32,
CHIP_FAMILY_ESP32S2,
CHIP_FAMILY_ESP32S3,
CHIP_FAMILY_ESP32C3,
].includes(this.chipFamily)
) {
statusLen = 4;
} else {
Expand Down Expand Up @@ -684,7 +693,11 @@ export class ESPLoader extends EventTarget {

let stamp = Date.now();
buffer = pack("<IIII", eraseSize, numBlocks, flashWriteSize, offset);
if (this.chipFamily == CHIP_FAMILY_ESP32S2 || this.chipFamily == CHIP_FAMILY_ESP32S3 || this.chipFamily == CHIP_FAMILY_ESP32C3) {
if (
this.chipFamily == CHIP_FAMILY_ESP32S2 ||
this.chipFamily == CHIP_FAMILY_ESP32S3 ||
this.chipFamily == CHIP_FAMILY_ESP32C3
) {
buffer = buffer.concat(pack("<I", encrypted ? 1 : 0));
}
this.logger.log(
Expand Down

0 comments on commit ae42132

Please sign in to comment.