Skip to content

Commit

Permalink
refactor(stub_flasher): Cleanup, make adding new targets easier
Browse files Browse the repository at this point in the history
  • Loading branch information
radimkarnis committed Nov 1, 2023
1 parent d266645 commit fb7f4db
Show file tree
Hide file tree
Showing 32 changed files with 80 additions and 282 deletions.
4 changes: 1 addition & 3 deletions esptool/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ class ESPLoader(object):
CHIP_NAME = "Espressif device"
IS_STUB = False

FPGA_SLOW_BOOT = False

DEFAULT_PORT = "/dev/ttyUSB0"

USES_RFC2217 = False
Expand Down Expand Up @@ -628,7 +626,7 @@ def _construct_reset_strategy_sequence(self, mode):

# This FPGA delay is for Espressif internal use
if (
self.FPGA_SLOW_BOOT
self.CHIP_NAME == "ESP32"
and os.environ.get("ESPTOOL_ENV_FPGA", "").strip() == "1"
):
delay = extra_delay = 7
Expand Down
2 changes: 0 additions & 2 deletions esptool/targets/esp32.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class ESP32ROM(ESPLoader):
IMAGE_CHIP_ID = 0
IS_STUB = False

FPGA_SLOW_BOOT = True

CHIP_DETECT_MAGIC_VALUE = [0x00F01D83]

IROM_MAP_START = 0x400D0000
Expand Down
2 changes: 0 additions & 2 deletions esptool/targets/esp32c3.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ class ESP32C3ROM(ESP32ROM):
CHIP_NAME = "ESP32-C3"
IMAGE_CHIP_ID = 5

FPGA_SLOW_BOOT = False

IROM_MAP_START = 0x42000000
IROM_MAP_END = 0x42800000
DROM_MAP_START = 0x3C000000
Expand Down
2 changes: 0 additions & 2 deletions esptool/targets/esp32c6.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ class ESP32C6ROM(ESP32C3ROM):
CHIP_NAME = "ESP32-C6"
IMAGE_CHIP_ID = 13

FPGA_SLOW_BOOT = False

IROM_MAP_START = 0x42000000
IROM_MAP_END = 0x42800000
DROM_MAP_START = 0x42800000
Expand Down
2 changes: 0 additions & 2 deletions esptool/targets/esp32p4.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ class ESP32P4ROM(ESP32ROM):
CHIP_NAME = "ESP32-P4"
IMAGE_CHIP_ID = 18

FPGA_SLOW_BOOT = False

IROM_MAP_START = 0x40000000
IROM_MAP_END = 0x44000000
DROM_MAP_START = 0x40000000
Expand Down
2 changes: 0 additions & 2 deletions esptool/targets/esp32s2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class ESP32S2ROM(ESP32ROM):
CHIP_NAME = "ESP32-S2"
IMAGE_CHIP_ID = 2

FPGA_SLOW_BOOT = False

IROM_MAP_START = 0x40080000
IROM_MAP_END = 0x40B80000
DROM_MAP_START = 0x3F000000
Expand Down
2 changes: 0 additions & 2 deletions esptool/targets/esp32s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class ESP32S3ROM(ESP32ROM):

CHIP_DETECT_MAGIC_VALUE = [0x9]

FPGA_SLOW_BOOT = False

IROM_MAP_START = 0x42000000
IROM_MAP_END = 0x44000000
DROM_MAP_START = 0x3C000000
Expand Down
47 changes: 31 additions & 16 deletions flasher_stub/include/soc_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,16 @@
#endif // ESP32P4

// Increase CPU freq to speed up read/write operations over USB
// Temporarily disabled on the S3 due to stability issues, will be fixed in the next minor release
// Disabled on the S3 due to stability issues, would require dbias adjustment.
// https://github.com/espressif/esptool/issues/832, https://github.com/espressif/esptool/issues/808
#define USE_MAX_CPU_FREQ ((WITH_USB_JTAG_SERIAL || WITH_USB_OTG) && !ESP32S3)

// Later chips don't support ets_efuse_get_spiconfig.
#define SUPPORT_CONFIG_SPI (ESP32 || ESP32S2 || ESP32S3 || ESP32S3BETA2 || ESP32C3 || ESP32H2BETA1 || ESP32H2BETA2 || ESP32C6BETA)

/**********************************************************
* Per-SOC based peripheral register base addresses
* Sync with reg_base.h in ESP-IDF
*/
#ifdef ESP8266
#define UART_BASE_REG 0x60000000 /* UART0 */
Expand Down Expand Up @@ -380,21 +385,6 @@
* SYSTEM registers
*/

#ifdef ESP32S3
#define SYSTEM_CPU_PER_CONF_REG (SYSTEM_BASE_REG + 0x010)
#define SYSTEM_CPUPERIOD_SEL_M ((SYSTEM_CPUPERIOD_SEL_V)<<(SYSTEM_CPUPERIOD_SEL_S))
#define SYSTEM_CPUPERIOD_SEL_V 0x3
#define SYSTEM_CPUPERIOD_SEL_S 0
#define SYSTEM_CPUPERIOD_MAX 1 // CPU_CLK frequency is 160 MHz - not actually max possible frequency,
// see https://github.com/espressif/esptool/issues/832 and https://github.com/espressif/esptool/issues/808

#define SYSTEM_SYSCLK_CONF_REG (SYSTEM_BASE_REG + 0x060)
#define SYSTEM_SOC_CLK_SEL_M ((SYSTEM_SOC_CLK_SEL_V)<<(SYSTEM_SOC_CLK_SEL_S))
#define SYSTEM_SOC_CLK_SEL_V 0x3
#define SYSTEM_SOC_CLK_SEL_S 10
#define SYSTEM_SOC_CLK_MAX 1
#endif // ESP32S3

#ifdef ESP32C3
#define SYSTEM_CPU_PER_CONF_REG (SYSTEM_BASE_REG + 0x008)
#define SYSTEM_CPUPERIOD_SEL_M ((SYSTEM_CPUPERIOD_SEL_V)<<(SYSTEM_CPUPERIOD_SEL_S))
Expand Down Expand Up @@ -450,3 +440,28 @@
#if ESP32S3_OR_LATER
#define SECURITY_INFO_BYTES 20
#endif // ESP32S3_OR_LATER

/**********************************************************
* Per-SOC address of the rom_spiflash_legacy_funcs symbol in ROM
* Can be retrieved with gdb: "info address rom_spiflash_legacy_funcs"
*/

#if ESP32 || ESP32S2 || ESP32S3
#define ROM_SPIFLASH_LEGACY 0x3ffae270
#endif // ESP32 || ESP32S2 || ESP32S3

#if ESP32C3 || ESP32C6BETA || ESP32C2 || ESP32C6
#define ROM_SPIFLASH_LEGACY 0x3fcdfff4
#endif // ESP32C3 || ESP32C6BETA || ESP32C2 || ESP32C6

#if ESP32H2BETA1 || ESP32H2BETA2
#define ROM_SPIFLASH_LEGACY 0x3fcdfff0
#endif // ESP32H2BETA1 || ESP32H2BETA2

#if ESP32H2
#define ROM_SPIFLASH_LEGACY 0x4084fff0
#endif // ESP32H2

#if ESP32P4
#define ROM_SPIFLASH_LEGACY 0x4ff3ffec
#endif // ESP32P4
7 changes: 1 addition & 6 deletions flasher_stub/ld/rom_32h2.ld
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* ROM function interface esp32h2.rom.ld for esp32h2
*
*
Expand All @@ -22,7 +17,7 @@ PROVIDE ( SPI_read_status_high = esp_rom_spiflash_read_statushigh);
PROVIDE ( SPI_write_status = esp_rom_spiflash_write_status);
PROVIDE ( SPIRead = esp_rom_spiflash_read);
PROVIDE ( SPIParamCfg = esp_rom_spiflash_config_param);
PROVIDE ( SPIEraseChip = esp_rom_spiflash_erase_chip);
PROVIDE ( SPIEraseChip = esp_rom_spiflash_erase_chip);
PROVIDE ( SPIEraseSector = esp_rom_spiflash_erase_sector);
PROVIDE ( SPIEraseBlock = esp_rom_spiflash_erase_block);
PROVIDE ( SPI_Write_Encrypt_Enable = esp_rom_spiflash_write_encrypted_enable);
Expand Down
17 changes: 0 additions & 17 deletions flasher_stub/ld/stub_32.ld
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
/*
* Copyright (c) 2016 Cesanta Software Limited
* All rights reserved
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

/* Note: stub is deliberately loaded close to the very top
of available RAM, to reduce change of colliding with anything
else... */
Expand Down
6 changes: 0 additions & 6 deletions flasher_stub/ld/stub_32c3.ld
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/*
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/

MEMORY {
iram : org = 0x40380000, len = 0x4000
dram : org = 0x3FC84000, len = 0x18000
Expand Down
17 changes: 0 additions & 17 deletions flasher_stub/ld/stub_32c6.ld
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
/*
* Copyright (c) 2022 Espressif Systems (Shanghai) PTE LTD
* All rights reserved
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

MEMORY {
iram : org = 0x40800000, len = 0x4000
dram : org = 0x40840000, len = 0x18000
Expand Down
6 changes: 0 additions & 6 deletions flasher_stub/ld/stub_32c6_beta.ld
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/*
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/

MEMORY {
iram : org = 0x40380000, len = 0x4000
dram : org = 0x3FC84000, len = 0x18000
Expand Down
6 changes: 0 additions & 6 deletions flasher_stub/ld/stub_32h2.ld
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/

MEMORY {
iram : org = 0x40800000, len = 0x4000
dram : org = 0x40830000, len = 0x18000
Expand Down
6 changes: 0 additions & 6 deletions flasher_stub/ld/stub_32h2_beta_1.ld
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/*
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/

MEMORY {
iram : org = 0x40380000, len = 0x4000
dram : org = 0x3FC84000, len = 0x18000
Expand Down
6 changes: 0 additions & 6 deletions flasher_stub/ld/stub_32h2_beta_2.ld
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/*
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/

MEMORY {
iram : org = 0x40380000, len = 0x4000
dram : org = 0x3FC84000, len = 0x18000
Expand Down
17 changes: 0 additions & 17 deletions flasher_stub/ld/stub_32p4.ld
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
/*
* Copyright (c) 2023 Espressif Systems (Shanghai) PTE LTD
* All rights reserved
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

MEMORY {
iram : org = 0x4FF10000, len = 0x4000
dram : org = 0x4FF50000, len = 0x18000
Expand Down
6 changes: 0 additions & 6 deletions flasher_stub/ld/stub_32s2.ld
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/*
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/

MEMORY {
iram : org = 0x40028000, len = 0x18000
dram : org = 0x3FFD0000, len = 0x28000
Expand Down
6 changes: 0 additions & 6 deletions flasher_stub/ld/stub_32s3.ld
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/*
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/

MEMORY {
iram : org = 0x40378000, len = 0x18000
dram : org = 0x3FCA0000, len = 0x28000
Expand Down
6 changes: 0 additions & 6 deletions flasher_stub/ld/stub_32s3_beta_2.ld
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/*
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/

MEMORY {
iram : org = 0x40378000, len = 0x18000
dram : org = 0x3FCA0000, len = 0x28000
Expand Down
17 changes: 0 additions & 17 deletions flasher_stub/ld/stub_8266.ld
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
/*
* Copyright (c) 2016 Cesanta Software Limited
* All rights reserved
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
* Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

/* Note: stub is deliberately loaded close to the very top
of available RAM, to reduce change of colliding with anything
else... */
Expand Down
Loading

0 comments on commit fb7f4db

Please sign in to comment.