Generate partitions path based on ESP32 model

To be able to support the ESP32-C3, a different partitioning scheme is
needed. Add a helper function to generate the URL to download the binary
partition table from, and use it when the user did not pass the
partitions argument.

Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
This commit is contained in:
Stijn Tintel 2022-03-05 16:02:23 +02:00
parent 70c74bba2f
commit e3b778d4da
2 changed files with 13 additions and 2 deletions

View File

@ -3,7 +3,10 @@ import struct
import esptool
from esphomeflasher.const import HTTP_REGEX
from esphomeflasher.const import (
ESP32_DEFAULT_PARTITIONS,
HTTP_REGEX,
)
from esphomeflasher.helpers import prevent_print
@ -186,6 +189,10 @@ def format_bootloader_path(path, model, flash_mode, flash_freq):
return path.replace("$MODEL$", model).replace("$FLASH_MODE$", flash_mode).replace("$FLASH_FREQ$", flash_freq)
def format_partitions_path(path, model):
return path.replace("$MODEL$", model)
def configure_write_flash_args(
info, firmware_path, flash_size, bootloader_path, partitions_path, otadata_path
):
@ -206,6 +213,10 @@ def configure_write_flash_args(
bootloader = open_downloadable_binary(
format_bootloader_path(bootloader_path, model, flash_mode, flash_freq)
)
if not partitions_path:
partitions_path = format_partitions_path(ESP32_DEFAULT_PARTITIONS, model)
partitions = open_downloadable_binary(partitions_path)
otadata = open_downloadable_binary(otadata_path)

View File

@ -8,7 +8,7 @@ ESP32_DEFAULT_BOOTLOADER_FORMAT = (
"2.0.2/tools/sdk/$MODEL$/bin/bootloader_$FLASH_MODE$_$FLASH_FREQ$.bin"
)
ESP32_DEFAULT_PARTITIONS = (
"https://raw.githubusercontent.com/esphome/esphomeflasher/main/partitions.esp32.bin"
"https://raw.githubusercontent.com/esphome/esphomeflasher/main/partitions.$MODEL$.bin"
)
# https://stackoverflow.com/a/3809435/8924614