PIO Esptool.py Fails to program ESP 8266 via CH340 - Yet Arduino IDE will?

I am just try to get going with ‘Hello World’ working on the ESP-01S with a CH340 USB/Serial Programmer board.

I have made some mods so I can short IO0 to GND to get into programming mode after a quick short of the RST to GND.

But with PIO and VScode it fails, it looks like esptool.py is having issues. Why might this be ??

AVAILABLE: espota, esptool
CURRENT: upload_protocol = esptool
MethodWrapper([“upload”], [“.pio\build\esp01_1m\firmware.bin”])
Using manually specified: COM5
“C:\Users\neil.platformio\penv\Scripts\python.exe” “C:\Users\neil.platformio\packages\tool-esptoolpy@1.30000.201119\esptool.py” --before no_reset --after soft_reset --chip esp8266 –
port “COM5” --baud 115200 write_flash 0x0 .pio\build\esp01_1m\firmware.bin
esptool.py v3.0
Serial port COM5
Traceback (most recent call last):
File “C:\Users\neil.platformio\packages\tool-esptoolpy@1.30000.201119\esptool.py”, line 3969, in
_main()
File “C:\Users\neil.platformio\packages\tool-esptoolpy@1.30000.201119\esptool.py”, line 3962, in _main
main()
File “C:\Users\neil.platformio\packages\tool-esptoolpy@1.30000.201119\esptool.py”, line 3551, in main
esp = chip_class(each_port, initial_baud, args.trace)
File “C:\Users\neil.platformio\packages\tool-esptoolpy@1.30000.201119\esptool.py”, line 271, in init
self.port = serial.serial_for_url(port)
File "C:\Users\neil.platformio\penv\lib\site-packages\serial_init
.py", line 90, in serial_for_url
instance.open()
File “C:\Users\neil.platformio\penv\lib\site-packages\serial\serialwin32.py”, line 64, in open
raise SerialException(“could not open port {!r}: {!r}”.format(self.portstr, ctypes.WinError()))
serial.serialutil.SerialException: could not open port ‘COM5’: PermissionError(13, ‘Access is denied.’, None, 5)
*** [upload] Error 1

This is my INI file

[env:esp01_1m]
platform = espressif8266
board = esp01_1m
;board = esp12e
framework = arduino
upload_protocol = esptool
upload_port = COM5
;upload_speed = 115200

However with the Arduino IDE 2.2.1, exactly the same hardware, same serial port, I can program the board no trouble with its esptool.py !

Blockquote
esptool.py v3.0
Serial port COM5
Connecting…
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: bc:ff:4d:35:b3:5c
Uploading stub…
Running stub…
Stub running…
Configuring flash size…
Auto-detected Flash size: 1MB
Compressed 269696 bytes to 198411…
Writing at 0x00000000… (7 %)
Writing at 0x00004000… (15 %)
Writing at 0x00008000… (23 %)
Writing at 0x0000c000… (30 %)
Writing at 0x00010000… (38 %)
Writing at 0x00014000… (46 %)
Writing at 0x00018000… (53 %)
Writing at 0x0001c000… (61 %)
Writing at 0x00020000… (69 %)
Writing at 0x00024000… (76 %)
Writing at 0x00028000… (84 %)
Writing at 0x0002c000… (92 %)
Writing at 0x00030000… (100 %)
Wrote 269696 bytes (198411 compressed) at 0x00000000 in 17.5 seconds (effective 123.3 kbit/s)…
Hash of data verified.

Leaving…
Hard resetting via RTS pin…

You usually get access denied when there’s some other serial program (like the Arduino Serial Monitor) still open and holding onto the port.

Alsop check that you’re using the same reset method.

:+1: Thanks, it take a genius to spot the obvious sometime…
Shutting down the Arduino IDE did