Xinyuan-LilyGO / T-QT

MIT License
94 stars 31 forks source link

esptool, Linux #33

Open PSLLSP opened 7 months ago

PSLLSP commented 7 months ago

I am new to ESP32. I cannot use esptool with T-QT device. I am not sure if this is a bug in the T-QT device or esptool. I use Linux Mint 20.3.

$ esptool version
esptool.py v2.8
2.8
$ esptool flash_id
esptool.py v2.8
Found 1 serial ports
Serial port /dev/ttyACM0
Connecting...
/dev/ttyACM0 failed to connect: Write timeout

A fatal error occurred: Could not connect to an Espressif device on any of the 1 available serial ports.

Connection to the device timeouts. When I reset the device with button on the side, serial port /dev/ttyACM0 disappears for a second and esptool crashes:

$ esptool flash_id
esptool.py v2.8
Found 1 serial ports
Serial port /dev/ttyACM0
Connecting....
Traceback (most recent call last):
  File "/usr/bin/esptool", line 3101, in <module>
    _main()
  File "/usr/bin/esptool", line 3094, in _main
    main()
  File "/usr/bin/esptool", line 2885, in main
    esp = ESPLoader.detect_chip(each_port, initial_baud, args.before, args.trace)
  File "/usr/bin/esptool", line 274, in detect_chip
    detect_port.connect(connect_mode)
  File "/usr/bin/esptool", line 475, in connect
    last_error = self._connect_attempt(mode=mode, esp32r0_delay=False)
  File "/usr/bin/esptool", line 453, in _connect_attempt
    self.flush_input()
  File "/usr/bin/esptool", line 389, in flush_input
    self._port.flushInput()
  File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 584, in flushInput
    self.reset_input_buffer()
  File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 595, in reset_input_buffer
    termios.tcflush(self.fd, termios.TCIFLUSH)
termios.error: (5, 'Input/output error')
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 153, in apport_excepthook
    with os.fdopen(os.open(pr_filename,
FileNotFoundError: [Errno 2] No such file or directory: '/var/crash/_usr_share_esptool_esptool.py.1000.crash'

....

When I use the same procedure on some older devices with UART chip, there is no such issue because that UART is not disconnected during device reset; in most cases it is /dev/ttyUSB0 and even esptool can reset device with RST signal...

Any advice? Do I miss something? Can I use esptool utility with T-QT device?

PSLLSP commented 7 months ago

I think, I know the answer. My esptool is too old. I updated esptool to the newer version and it works:

$ pip3 install esptool
...

$ python3 -m esptool version
esptool.py v4.6.2
4.6.2

$ python3 -m esptool flash_id
esptool.py v4.6.2
Found 1 serial ports
Serial port /dev/ttyACM0
Connecting...
Detecting chip type... ESP32-S3
Chip is ESP32-S3 (revision v0.1)
Features: WiFi, BLE
Crystal is 40MHz
MAC: f4:12:fa:99:99:99
Uploading stub...
Running stub...
Stub running...
Manufacturer: c8
Device: 4017
Detected flash size: 8MB
Flash type set in eFuse: quad (4 data lines)
Hard resetting via RTS pin...