I'm trying to flash an ESP32-S3 within my python program. using esptool (4.8.1) I can successfully flash using the command line version of esptool.py:
Code: Select all
esptool.py -p /dev/ttyACM0 write_flash 0x10000 firmware.bin
Failed to enter Flash download mode. Only got 2 byte status response.
Code: Select all
from esptool.cmds import detect_chip
try_port = "/dev/ttyACM0"
filename = "./firmware.bin"
def progress_callback(current, total):
percent = current / total * 100
print(f"percent {percent}")
with detect_chip(try_port) as esp:
print(str(type(esp)))
esp.connect()
esp.change_baud(115200)
chip_desc = esp.get_chip_description()
features = esp.get_chip_features()
print(f"Detected bootloader on port {try_port} : {chip_desc}")
print(f"Features {features}")
port = try_port
esp.run_stub()
with open(filename, 'rb') as firmware:
firmware_data = firmware.read()
print(f"{len(firmware_data)}")
esp.flash_begin(len(firmware_data), 0x10000)
esp.flash_data(firmware_data, progress_callback=progress_callback)
esp.flash_finish()
Code: Select all
python f.py
Connecting...
Detecting chip type... ESP32-S3
<class 'esptool.targets.esp32s3.ESP32S3ROM'>
Connecting...
Changing baud rate to 115200
Changed.
Detected bootloader on port /dev/ttyACM0 : ESP32-S3 (QFN56) (revision v0.2)
Features ['WiFi', 'BLE', 'Embedded PSRAM 2MB (AP_3v3)']
Uploading stub...
Running stub...
Stub running...
1562064
Traceback (most recent call last):
File "/home/brent/git-projects/RC_app_private/f.py", line 19, in <module>
esp.flash_begin(len(firmware_data), 0x10000)
File "/home/brent/.pyenv/versions/r_c/lib/python3.11/site-packages/esptool/loader.py", line 916, in flash_begin
self.check_command(
File "/home/brent/.pyenv/versions/r_c/lib/python3.11/site-packages/esptool/loader.py", line 516, in check_command
raise FatalError(
esptool.util.FatalError: Failed to enter Flash download mode. Only got 2 byte status response.