Skip to content

Serial exception after successful upload: OSError 22 #11482

@maciejmatczak

Description

@maciejmatczak

Board

Xiao ESP32-S3

Device Description

Xiao ESP32-S3.

Hardware Configuration

Just a Xiao esp32s3 board.

Version

v3.2.0

IDE Name

Arduino

Operating System

Windows 11

Flash frequency

240 Mhz

PSRAM enabled

no

Upload speed

115200, 921600

Description

Googling "arduino serial oserror esp32s3" shows some number of similar issues.

On my side: windows 11, esp32s3, standard settings, reproducible with blink example.

After successful upload, user receives an error:

Hash of data verified.

Leaving...
Hard resetting with RTC WDT...

A serial exception error occurred: Cannot configure port, something went wrong. Original message: OSError(22, 'A device which does not exist was specified.', None, 433)
Note: This error originates from pySerial. It is likely not a problem with esptool, but with the hardware connection or drivers.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html

After device resets, it reconnects to the OS, but it seems something tries to still use it. Looks like race/someone not being patient. I started to dig a bit.

Current Arduino core, version v3.2.0, uses esptool of version 4.9.dev3, not 4.8.1 as many people seem to think.

This is the version that the tool itself reports during usage in Arduino. It seems to me a version info is not updated per dev releases, but dev releases are used in production.

4.9.dev3 builds as:

"C:\Users\...\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\4.9.dev3/esptool.exe" --chip esp32s3 --port "COM3" --baud 921600  --before default_reset --after hard_reset write_flash  -z --flash_mode keep --flash_freq keep --flash_size keep 0x0 "C:\Users\...\AppData\Local\arduino\sketches\6F1BA3D6987F9E875A195D03E8455185/Example_01_PrintString.ino.bootloader.bin" 0x8000 "C:\Users\...\AppData\Local\arduino\sketches\6F1BA3D6987F9E875A195D03E8455185/Example_01_PrintString.ino.partitions.bin" 0xe000 "C:\Users\...\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0/tools/partitions/boot_app0.bin" 0x10000 "C:\Users\...\AppData\Local\arduino\sketches\6F1BA3D6987F9E875A195D03E8455185/Example_01_PrintString.ino.bin"
esptool.py v4.8.1
Serial port COM3
Connecting...
Chip is ESP32-S3 (QFN56) (revision v0.2)
Features: WiFi, BLE, Embedded PSRAM 8MB (AP_3v3)
Crystal is 40MHz
MAC: d8:3b:da:46:e9:9c
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00004fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x0005efff...
Compressed 20208 bytes to 13058...
Wrote 20208 bytes (13058 compressed) at 0x00000000 in 0.4 seconds (effective 370.7 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 146...
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.1 seconds (effective 231.0 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 451.9 kbit/s)...
Hash of data verified.
Compressed 322608 bytes to 173750...
Wrote 322608 bytes (173750 compressed) at 0x00010000 in 2.9 seconds (effective 884.4 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting with RTC WDT...

A serial exception error occurred: Cannot configure port, something went wrong. Original message: OSError(22, 'Określono nieistniejące urządzenie.', None, 433)
Note: This error originates from pySerial. It is likely not a problem with esptool, but with the hardware connection or drivers.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html

Later, comparing esptool tags, we can see some sleep() here and there:

espressif/esptool@v4.9.dev3...v5.0.dev1#diff-cb25ea9381c2f7a537ecf1516335d3a9e8a711a9dbf3d1eff78453a611072103

Especially here: espressif/esptool@v4.9.dev3...v5.0.dev1#diff-cb25ea9381c2f7a537ecf1516335d3a9e8a711a9dbf3d1eff78453a611072103R360

Either way, when I tried the same .bin files with v5.0.dev1, it seems that resets occurs with RTS, and the exception is not raised:

> venv\Scripts\esptool.exe --chip esp32s3 --port "COM3" --baud 921600  --before default-reset --after hard-reset write-flash  -z --flash-mode keep --flash-freq keep --flash-size keep 0x0 "C:\Users\...\AppData\Local\arduino\sketches\6F1BA3D6987F9E875A195D03E8455185/Example_01_PrintString.ino.bootloader.bin" 0x8000 "C:\Users\...\AppData\Local\arduino\sketches\6F1BA3D6987F9E875A195D03E8455185/Example_01_PrintString.ino.partitions.bin" 0xe000 "C:\Users\...\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0/tools/partitions/boot_app0.bin" 0x10000 "C:\Users\...\AppData\Local\arduino\sketches\6F1BA3D6987F9E875A195D03E8455185/Example_01_PrintString.ino.bin"
esptool.py v4.8.1
Serial port COM3:
Connecting...
Connected to ESP32-S3 on COM3:
Chip type:          ESP32-S3 (QFN56) (revision v0.2)
Features:           Wi-Fi, BT 5 (LE), Dual Core + LP Core, 240MHz, Embedded PSRAM 8MB (AP_3v3)
Crystal frequency:  40MHz
USB mode:           USB-Serial/JTAG
MAC:                d8:3b:da:46:e9:9c

Uploading stub flasher...
Running stub flasher...
Stub flasher running.
Changing baud rate to 921600...
Changed.

Configuring flash size...
Flash will be erased from 0x00000000 to 0x00004fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x0005efff...
Compressed 20208 bytes to 13058...
Writing at 0x00000000 [                              ]   0.0% 0/13058 bytes...
Writing at 0x00004ef0 [==============================] 100.0% 13058/13058 bytes...
Wrote 20208 bytes (13058 compressed) at 0x00000000 in 0.4 seconds (371.6 kbit/s).
Hash of data verified.
Compressed 3072 bytes to 146...
Writing at 0x00008000 [                              ]   0.0% 0/146 bytes...
Writing at 0x00008c00 [==============================] 100.0% 146/146 bytes...
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.1 seconds (229.7 kbit/s).
Hash of data verified.
Compressed 8192 bytes to 47...
Writing at 0x0000e000 [                              ]   0.0% 0/47 bytes...
Writing at 0x00010000 [==============================] 100.0% 47/47 bytes...
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (455.0 kbit/s).
Hash of data verified.
Compressed 322608 bytes to 173750...
Writing at 0x00010000 [                              ]   0.0% 0/173750 bytes...
Writing at 0x0001bd91 [=>                            ]   9.4% 16384/173750 bytes...
Writing at 0x00028b52 [====>                         ]  18.9% 32768/173750 bytes...
Writing at 0x0002e256 [=======>                      ]  28.3% 49152/173750 bytes...
Writing at 0x0003407d [==========>                   ]  37.7% 65536/173750 bytes...
Writing at 0x00039a03 [=============>                ]  47.1% 81920/173750 bytes...
Writing at 0x0003f10d [===============>              ]  56.6% 98304/173750 bytes...
Writing at 0x00044b6b [==================>           ]  66.0% 114688/173750 bytes...
Writing at 0x0004a5dd [=====================>        ]  75.4% 131072/173750 bytes...
Writing at 0x000551fc [========================>     ]  84.9% 147456/173750 bytes...
Writing at 0x0005b0df [===========================>  ]  94.3% 163840/173750 bytes...
Writing at 0x0005ec30 [==============================] 100.0% 173750/173750 bytes...
Wrote 322608 bytes (173750 compressed) at 0x00010000 in 3.0 seconds (870.7 kbit/s).
Hash of data verified.

Hard resetting via RTS pin...

> 

My kind request would be:

  • current esptool v5.0.dev1 works for xiao esp32s3 upload well - can we please incorporate it into this arduino core?
  • can we use official version of esptool in this core to not confuse people about which esptool version they use?

Sketch

blink

Debug Message

added above

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions