mirror of
https://github.com/esphome/esphome.git
synced 2025-01-31 10:10:56 +00:00
Allow upload command to flash file via serial (#5274)
This commit is contained in:
parent
f2a6f18553
commit
72f29b1283
@ -218,14 +218,16 @@ def compile_program(args, config):
|
|||||||
return 0 if idedata is not None else 1
|
return 0 if idedata is not None else 1
|
||||||
|
|
||||||
|
|
||||||
def upload_using_esptool(config, port):
|
def upload_using_esptool(config, port, file):
|
||||||
from esphome import platformio_api
|
from esphome import platformio_api
|
||||||
|
|
||||||
first_baudrate = config[CONF_ESPHOME][CONF_PLATFORMIO_OPTIONS].get(
|
first_baudrate = config[CONF_ESPHOME][CONF_PLATFORMIO_OPTIONS].get(
|
||||||
"upload_speed", 460800
|
"upload_speed", 460800
|
||||||
)
|
)
|
||||||
|
|
||||||
def run_esptool(baud_rate):
|
if file is not None:
|
||||||
|
flash_images = [platformio_api.FlashImage(path=file, offset="0x0")]
|
||||||
|
else:
|
||||||
idedata = platformio_api.get_idedata(config)
|
idedata = platformio_api.get_idedata(config)
|
||||||
|
|
||||||
firmware_offset = "0x10000" if CORE.is_esp32 else "0x0"
|
firmware_offset = "0x10000" if CORE.is_esp32 else "0x0"
|
||||||
@ -236,12 +238,13 @@ def upload_using_esptool(config, port):
|
|||||||
*idedata.extra_flash_images,
|
*idedata.extra_flash_images,
|
||||||
]
|
]
|
||||||
|
|
||||||
mcu = "esp8266"
|
mcu = "esp8266"
|
||||||
if CORE.is_esp32:
|
if CORE.is_esp32:
|
||||||
from esphome.components.esp32 import get_esp32_variant
|
from esphome.components.esp32 import get_esp32_variant
|
||||||
|
|
||||||
mcu = get_esp32_variant().lower()
|
mcu = get_esp32_variant().lower()
|
||||||
|
|
||||||
|
def run_esptool(baud_rate):
|
||||||
cmd = [
|
cmd = [
|
||||||
"esptool.py",
|
"esptool.py",
|
||||||
"--before",
|
"--before",
|
||||||
@ -292,7 +295,8 @@ def upload_using_platformio(config, port):
|
|||||||
def upload_program(config, args, host):
|
def upload_program(config, args, host):
|
||||||
if get_port_type(host) == "SERIAL":
|
if get_port_type(host) == "SERIAL":
|
||||||
if CORE.target_platform in (PLATFORM_ESP32, PLATFORM_ESP8266):
|
if CORE.target_platform in (PLATFORM_ESP32, PLATFORM_ESP8266):
|
||||||
return upload_using_esptool(config, host)
|
file = getattr(args, "file", None)
|
||||||
|
return upload_using_esptool(config, host, file)
|
||||||
|
|
||||||
if CORE.target_platform in (PLATFORM_RP2040):
|
if CORE.target_platform in (PLATFORM_RP2040):
|
||||||
return upload_using_platformio(config, args.device)
|
return upload_using_platformio(config, args.device)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user