Skip to content

Commit

Permalink
Merge branch 'bugfix/wrong_flash_size_at_bin_start' into 'release/v2.…
Browse files Browse the repository at this point in the history
…2.0.0_esp8266'

fix: Fixed an issue that flash size is set incorrectly on esp8266

See merge request application/esp-at!1467
  • Loading branch information
xcguang committed Nov 17, 2023
2 parents c964081 + 48d3e7c commit f0436d7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tools/esp_at_factory_bin_combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import argparse

ESP_FLASH_MODE = {"QIO": 0, "QOUT": 1, "DIO": 2, "DOUT": 3, "FAST_READ": 4, "SLOW_READ": 5}
ESP_FLASH_SIZE = {"1MB": 0, "2MB": 1, "4MB": 2, "8MB": 3, "16MB": 4}
ESP_FLASH_SIZE = {"ESP8266": {"1MB": 2, "2MB": 3, "4MB": 4, "8MB": 8, "16MB": 9}, "DEFAULT": {"1MB": 0, "2MB": 1, "4MB": 2, "8MB": 3, "16MB": 4}}
ESP_BIN_SIZE = {"1MB": 1024*1024, "2MB": 2*1024*1024, "4MB": 4*1024*1024, "8MB": 8*1024*1024, "16MB": 16*1024*1024}
ESP_FLASH_SPEED = {"40M": 0, "26M": 1, "20M": 2, "80M": 0x0F}

Expand All @@ -52,7 +52,12 @@ def esp32_at_combine_bin(module, flash_mode, flash_size, flash_speed, build_dir,
bootloader_addr = bin_list['bootloader.bin']
bin_data[bootloader_addr + 2] = ESP_FLASH_MODE[flash_mode] # Flash mode DIO
# 0x20 Flash size 4MB, speed 40MHz
bin_data[bootloader_addr + 3] = (ESP_FLASH_SIZE[flash_size] << 4) | ESP_FLASH_SPEED[flash_speed]

idf_target = os.environ.get('ESP_AT_PROJECT_PLATFORM').split('_', 1)[1].upper()
if idf_target == 'ESP8266':
bin_data[bootloader_addr + 3] = (ESP_FLASH_SIZE['ESP8266'][flash_size] << 4) | ESP_FLASH_SPEED[flash_speed]
else:
bin_data[bootloader_addr + 3] = (ESP_FLASH_SIZE['DEFAULT'][flash_size] << 4) | ESP_FLASH_SPEED[flash_speed]

if parameter_file != None:
with open(parameter_file) as f:
Expand Down

0 comments on commit f0436d7

Please sign in to comment.