I have been trying to run (under windows 11 )one of the examples that came with my ESP32-S3 ETH board from waveshare. It works fine under the Arduino IDE but produces the following error under Platformio:
“A serial exception error occurred: Cannot configure port, something went wrong. Original message: OSError(22, ‘The I/O operation has been aborted because of either a thread exit or an application request.’, None, 995)
Note: This error originates from pySerial. It is likely not a problem with esptool, but with the hardware connection or drivers.”
This message comes after what appears to be a successful writing of the code.
What does this even mean? What does pySerial have to do with anything?
Please try the following:
- Upload the sketch
- Restart the ESP manually (or disconnect and reconnect the ESP)
- Open the serial monitor
I tried that. Here is what I get:
- Executing task: C:\Users\BigBill.platformio\penv\Scripts\platformio.exe device monitor --port COM4
UserSideException: could not open port ‘COM4’: FileNotFoundError(2, ‘The system cannot find the file specified.’, None, 2)
- The terminal process “C:\Users\BigBill.platformio\penv\Scripts\platformio.exe ‘device’, ‘monitor’, ‘–port’, ‘COM4’” terminated with exit code: 1.
- Terminal will be reused by tasks, press any key to close it.
Is there a document somewhere that explains these “OSError”s and how pySerial is involved?
Don’t use a fixed port! Set the port to “AUTO”
Your board does not have an external UART to USB chip but is using the builtin USB functionality of the ESP32. That means, if the ESP32 reboots, the USB connection will be interrupted. Your PC has to reenumerate the USB devices and will probably end up again with a Serial port for your ESP. But this take some time and the COM port may change!
Changing the port to Auto definitely made things different. Now the error message has changed. It is:
“Retrieving maximum program size .pio\build\esp32-s3-devkitc-1\firmware.elf
Checking size .pio\build\esp32-s3-devkitc-1\firmware.elf
Advanced Memory Usage is available via “PlatformIO Home > Project Inspect”
RAM: [== ] 24.2% (used 79304 bytes from 327680 bytes)
Flash: [== ] 17.4% (used 1138048 bytes from 6553600 bytes)
Configuring upload protocol…
AVAILABLE: cmsis-dap, esp-bridge, esp-builtin, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esptool
Looking for upload port…
Auto-detected: COM5
Uploading .pio\build\esp32-s3-devkitc-1\firmware.bin
esptool.py v4.8.5
Serial port COM5
Connecting…
A fatal error occurred: Failed to connect to ESP32-S3: Invalid head of packet (0x5B): Possible serial noise or corruption.”
In particular, I never got that “Connecting….” part. And the error mesage is different. No more PySerial.
I thought I had seen a screen that suggested that I might be trying to communicate at 4800 baud. I think the ESP32 wants 115200. Could this be a baud rate issue? How do i set or check the baud rate for communicating with the serial monitor?
Any ideas?
Now I am getting something on the serial terminal:
Executing task: C:\Users\BigBill.platformio\penv\Scripts\platformio.exe device monitor
— Terminal on COM5 | 9600 8-N-1
— Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
— More details at Redirecting...
— Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
I think the ESP32 is supposed to use 115200 instead of 9600 baud. How do I change that?
To answer my own question…
Add “monitor_speed = 115200” to the platformio.ini file.
This matches my call to “Serial.begin(115200);“ in the code.
Unfortunately, this does not solve my problem. The output in the serial monitor looks the same except for the baud rate:
Executing task: C:\Users\BigBill.platformio\penv\Scripts\platformio.exe device monitor
— Terminal on COM5 | 115200 8-N-1
— Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
— More details at Redirecting...
— Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
I am open to suggestions
I think the main issue, that your sketch does not upload correctly.
Put the ESP32-S3 in upload-mode manually: Press and hold the BOOT
button, then shortly press the RESET
button and release the BOOT
button.
(This also disconnect the serial connection and the port may change again.)
Upload the sketch and watch the log for errors.
Then manually reset the ESP again and open the Serial monitor.
If any error happens, please post the full log here.
(Please use pre-formatted text when posting logs, code and file content)
Now it works! Even though I get the error when uploading:
Writing at 0x000f19da... (82 %)
Writing at 0x000f6fe9... (84 %)
Writing at 0x000fd851... (86 %)
Writing at 0x00107c11... (88 %)
Writing at 0x0010d506... (91 %)
Writing at 0x0011288c... (93 %)
Writing at 0x00118335... (95 %)
Writing at 0x0011df57... (97 %)
Writing at 0x00123eea... (100 %)
Wrote 1138416 bytes (725577 compressed) at 0x00010000 in 10.0 seconds (effective 909.0 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: PermissionError(13, 'A device attached to the system is not functioning.', None, 31)
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
*** [upload] Error 1
============================================= [FAILED] Took 22.89 seconds =============================================
But when I switch to the serial monitor, I can now see the output of my program.
Thank you very much for your help.
When I started this thread, my image uploaded correctly without my having to press the boot and reset buttons. Why is that now required? Why is that not required under the Arduino IDE?
Because you probably use different settings in the ArduinoIDE we don’t know.