restoring QT Py ESP32-S2

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jessemf
 
Posts: 5
Joined: Fri Dec 31, 2021 4:16 pm

restoring QT Py ESP32-S2

Post by jessemf »

I have a QT Py ESP32-S2 board that I was able to program a couple of times, then something happened and I can't seem to get it to work. I believe that I have wiped the boot loader, when it starts up without holding the boot button, I see no serial port come up.
I have tried the factory reset guide guide https://learn.adafruit.com/adafruit-qt- ... tory-reset, but I can't get it to work. When I try the WebSerial way, it refuses to connect. With the esp tool way I run into an error when trying the first step (getting chip ID). I get the following:

Code: Select all

$ esptool.py --port /dev/ttyACM0 chip_id
esptool.py v4.3
Serial port /dev/ttyACM0
Connecting........
Traceback (most recent call last):
  File "/usr/bin/esptool.py", line 34, in <module>
    esptool._main()
  File "/usr/lib/python3.10/site-packages/esptool/__init__.py", line 1022, in _main
    main()
  File "/usr/lib/python3.10/site-packages/esptool/__init__.py", line 664, in main
    esp = esp or get_default_connected_device(
  File "/usr/lib/python3.10/site-packages/esptool/__init__.py", line 907, in get_default_connected_device
    _esp = detect_chip(
  File "/usr/lib/python3.10/site-packages/esptool/cmds.py", line 93, in detect_chip
    detect_port.connect(connect_mode, connect_attempts, detecting=True)
  File "/usr/lib/python3.10/site-packages/esptool/loader.py", line 632, in connect
    last_error = self._connect_attempt(
  File "/usr/lib/python3.10/site-packages/esptool/loader.py", line 556, in _connect_attempt
    self.bootloader_reset(usb_jtag_serial, extra_delay)
  File "/usr/lib/python3.10/site-packages/esptool/loader.py", line 537, in bootloader_reset
    self._setDTR(False)  # IO0=HIGH, done
  File "/usr/lib/python3.10/site-packages/esptool/loader.py", line 450, in _setDTR
    self._port.setDTR(state)
  File "/usr/lib/python3.10/site-packages/serial/serialutil.py", line 603, in setDTR
    self.dtr = value
  File "/usr/lib/python3.10/site-packages/serial/serialutil.py", line 473, in dtr
    self._update_dtr_state()
  File "/usr/lib/python3.10/site-packages/serial/serialposix.py", line 715, in _update_dtr_state
    fcntl.ioctl(self.fd, TIOCMBIC, TIOCM_DTR_str)
BrokenPipeError: [Errno 32] Broken pipe
some googling suggested that I might not be in the right group, so I checked:

Code: Select all

$ ls -l /dev/ttyACM0
crw-rw---- 1 root uucp 166, 0 Nov 12 20:46 /dev/ttyACM0
I am indeed a member of the uucp group

This is on an Arch Linux system relevant versions:
Linux version : Linux 6.0.7-arch1-1 x86_64
Python version : 3.10.8
esptool : v4.3

what can I do to restore the boot loader and program this board?

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: restoring QT Py ESP32-S2

Post by mikeysklar »

Are you able to query board with esptool when you try to enter bootloader using the boot + reset tap?

To enter the bootloader:

Press and hold the BOOT/DFU button down. Don't let go of it yet!
Press and release the Reset button. You should still have the BOOT/DFU button pressed while you do this.
Now you can release the BOOT/DFU button.

User avatar
jessemf
 
Posts: 5
Joined: Fri Dec 31, 2021 4:16 pm

Re: restoring QT Py ESP32-S2

Post by jessemf »

huh, I thought I did that step before, but I was able to load the boot loader this time.
However, I'm still having trouble programing it with the Arduino IDE. I get the following error when trying to upload the sketch:

Code: Select all

Sketch uses 236098 bytes (16%) of program storage space. Maximum is 1441792 bytes.
Global variables use 18752 bytes (5%) of dynamic memory, leaving 308928 bytes for local variables. Maximum is 327680 bytes.
esptool.py v4.2.1
Serial port /dev/ttyACM0
Traceback (most recent call last):
  File "/home/jesse/.arduino15/packages/esp32/tools/esptool_py/4.2.1/esptool.py", line 34, in <module>
    esptool._main()
  File "/home/jesse/.arduino15/packages/esp32/tools/esptool_py/4.2.1/esptool/__init__.py", line 1004, in _main
    main()
  File "/home/jesse/.arduino15/packages/esp32/tools/esptool_py/4.2.1/esptool/__init__.py", line 646, in main
    esp = esp or get_default_connected_device(
  File "/home/jesse/.arduino15/packages/esp32/tools/esptool_py/4.2.1/esptool/__init__.py", line 895, in get_default_connected_device
    _esp.connect(before, connect_attempts)
  File "/home/jesse/.arduino15/packages/esp32/tools/esptool_py/4.2.1/esptool/loader.py", line 631, in connect
    last_error = self._connect_attempt(
  File "/home/jesse/.arduino15/packages/esp32/tools/esptool_py/4.2.1/esptool/loader.py", line 555, in _connect_attempt
    self.bootloader_reset(usb_jtag_serial, extra_delay)
  File "/home/jesse/.arduino15/packages/esp32/tools/esptool_py/4.2.1/esptool/loader.py", line 530, in bootloader_reset
    self._setDTR(False)  # IO0=HIGH
  File "/home/jesse/.arduino15/packages/esp32/tools/esptool_py/4.2.1/esptool/loader.py", line 449, in _setDTR
    self._port.setDTR(state)
  File "/usr/lib/python3.10/site-packages/serial/serialutil.py", line 603, in setDTR
    self.dtr = value
  File "/usr/lib/python3.10/site-packages/serial/serialutil.py", line 473, in dtr
    self._update_dtr_state()
  File "/usr/lib/python3.10/site-packages/serial/serialposix.py", line 715, in _update_dtr_state
    fcntl.ioctl(self.fd, TIOCMBIC, TIOCM_DTR_str)
BrokenPipeError: [Errno 32] Broken pipe
BrokenPipeError: [Errno 32] Broken pipe


User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: restoring QT Py ESP32-S2

Post by mikeysklar »

Something is up with serial communication based on this line:
File "/usr/lib/python3.10/site-packages/serial/serialposix.py", line 715, in _update_dtr_state
fcntl.ioctl(self.fd, TIOCMBIC, TIOCM_DTR_str)
Are you switching into bootloader mode before programming (holding BOOT and tapping RESET)?

You had mentioned using esptool.py v4.3 manually. The Arduino IDE output is showing v4.2.1 being used. Can you update the version to v4.3 that the Arduino IDE is using? What version of the Arduino IDE are you running?

User avatar
jessemf
 
Posts: 5
Joined: Fri Dec 31, 2021 4:16 pm

Re: restoring QT Py ESP32-S2

Post by jessemf »

When programing through the Arduino IDE I was not switching to bootloader mode (This is the way it should be, right?). Trying in bootloader mode didn't help.

I have the Arduino IDE (version 1.8.19) and esptool installed through the system package manager. The version that the Arduino IDE uses is, presumably, installed with the board manager and is not in the system path. I don't know how one would upgrade it (it's already up to date, I think) without going in and messing with the files that are part of the package.

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: restoring QT Py ESP32-S2

Post by mikeysklar »

Bootloader mode is required when issues come up. It is not uncommon for todays native USB chips do get confused.
Native USB and manual bootloading

Historically, microcontroller boards contained two chips: the main micro chip (say, ATmega328 or ESP8266 or ESP32) and a separate chip for USB interface that would be used for bootloading (a CH430, FT232, CP210x, etc). With these older designs, the microcontroller is put into a bootloading state for uploading code by the separate chip. It allows for easier uploading but is more expensive as two chips are needed, and also the microcontroller can't act like a keyboard or disk drive.

Modern chips often have 'native' USB - that means that there is no separate chip for USB interface. It's all in one! Great for cost savings, simplicity of design, reduced size and more control. However, it means the chip must be self-aware enough to be able to put itself into bootload/upload mode on its own. That's fine 99% of the time but is very likely you will at some point get the board into an odd state that makes it too confused to bootload.
A lot of beginners have a little freakout the first time this happens, they think the board is ruined or 'bricked' - it's almost certainly not, it is just crashed and/or confused. You may need to perform a little trick to get the board back into a good state, at which point you won't need to manually bootload again.
https://learn.adafruit.com/adafruit-qt- ... ng-3108162

The esp32 board manager is currently at stable v2.0.5 which includes esptool.py 4.2.1 so lets just stay with those.

User avatar
jessemf
 
Posts: 5
Joined: Fri Dec 31, 2021 4:16 pm

Re: restoring QT Py ESP32-S2

Post by jessemf »

yea, I read that before. The problem I had before is that it seemed to get confused every time I tried to program it. Now it doesn't seem to want to program no mater what I do...

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: restoring QT Py ESP32-S2

Post by mikeysklar »

There is a ROM bootloader to protect this board from really getting stuck.

When you a Enter the ROM bootloader mode there will just be a serial device to upload to (not USB drive). Are you able to push up the bin file still?

(using your COM port and appropriate bin file)

Code: Select all

esptool.py --port /dev/ttyACM0 write_flash 0x0 combined.bin
The bottom right link will get you the zip file with the combined.bin file:

https://circuitpython.org/board/adafruit_qtpy_esp32s2/

User avatar
jessemf
 
Posts: 5
Joined: Fri Dec 31, 2021 4:16 pm

Re: restoring QT Py ESP32-S2

Post by jessemf »

well, now I don't know what happened! I'm getting the same error in _update_dtr_state I'm not sure what happened, why is this soooo flakey??

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: restoring QT Py ESP32-S2

Post by mikeysklar »

The steps should be:

* Get into DFU mode (hold down the boot button and tap reset)
* run the 4.3 esptool.py utility:

Code: Select all

esptool.py --port /dev/ttyACM0 write_flash 0x0 combined.bin
If you have another machine to try the same thing on that would be a good data point.

User avatar
Caducation
 
Posts: 16
Joined: Tue Mar 02, 2021 7:09 pm

Re: restoring QT Py ESP32-S2

Post by Caducation »

jessemf wrote: Thu Nov 17, 2022 12:57 am well, now I don't know what happened! I'm getting the same error in _update_dtr_state I'm not sure what happened, why is this soooo flakey??
I know this is a little old but I came across this post when searching for something else.

I had an issue with my QTPY esp32-s2 similar to yours. I used it programmed a few times and then it just seemed to stop working(with the new Arduino IDE). What I found was that I had to close the serial monitor. Whenever this seemed to happen it was dealing with a program that connected to the serial monitor and would appear like the port wasn't listed and I couldn't program the board. At one point I did go back and reload the .Uf2 bootloader but really the issue was the serial monitor(for me). This didn't happen in the old IDE for me. It came up when I installed 2.0.3.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”