Files
2026-09-20 18:55:16 +02:00

19 lines
892 B
Python

# Flash the ESP32-C3 with the ROM loader instead of esptool's RAM stub.
#
# Over the C3's native USB-Serial-JTAG the stub loads and starts, then the
# transfer stalls with "Packet content transfer stopped (received 0 bytes)" —
# reproducibly so through a USB hub. The ROM loader has no such trouble and is
# no slower here, because the link runs at USB speed regardless of the nominal
# baud rate.
#
# PlatformIO exposes --before/--after through board_upload.*, but not --no-stub,
# so it gets spliced into the argument list ahead of the write_flash subcommand
# (esptool requires global options to precede it).
Import("env")
flags = list(env.get("UPLOADERFLAGS", []))
if "write_flash" in flags and "--no-stub" not in flags:
flags.insert(flags.index("write_flash"), "--no-stub")
env.Replace(UPLOADERFLAGS=flags)
print("no_stub.py: using the ROM loader (--no-stub) for upload")