Could not flash after flashing successfully the first time in VS Code

joshchen
Posts: 5
Joined: Mon Jul 05, 2021 1:07 am

Could not flash after flashing successfully the first time in VS Code

Postby joshchen » Mon Jul 05, 2021 1:12 am

Hi,

I was trying the blink example project with the Youtube video about the Espressif extensions using VS Code. I was able to build the project, selected the com port then flash with UART.

However, then second time I followed the exact same sequence, I got error saying "Failed to flash because of some unusual error". Here is the output:

> Executing task: C:\Users\.espressif\python_env\idf4.3_py3.8_env\Scripts\python.exe C:\Users\chenjo5\esp\esp-idf\components\esptool_py\esptool\esptool.py -p COM12 -b 460800 --before default_reset --after hard_reset --chip esp32 write_flash --flash_mode dio --flash_freq 40m --flash_size detect 0x10000 blink.bin 0x1000 bootloader/bootloader.bin 0x8000 partition_table/partition-table.bin <

esptool.py v3.1-dev
Serial port COM12
Traceback (most recent call last):
File "C:\Users\esp\esp-idf\components\esptool_py\esptool\esptool.py", line 4535, in <module>
_main()
File "C:\Users\esp\esp-idf\components\esptool_py\esptool\esptool.py", line 4528, in _main
main()
File "C:\Users\esp\esp-idf\components\esptool_py\esptool\esptool.py", line 4027, in main
esp = esp or get_default_connected_device(ser_list, port=args.port, connect_attempts=args.connect_attempts,
File "C:\Users\esp\esp-idf\components\esptool_py\esptool\esptool.py", line 120, in get_default_connected_device
_esp = chip_class(each_port, initial_baud, trace)
File "C:\Users\esp\esp-idf\components\esptool_py\esptool\esptool.py", line 310, in __init__
self._port = serial.serial_for_url(port)
File "C:\Users\.espressif\python_env\idf4.3_py3.8_env\lib\site-packages\serial\__init__.py", line 90, in serial_for_url
instance.open()
File "C:\Users\.espressif\python_env\idf4.3_py3.8_env\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 'COM12': PermissionError(13, 'Access is denied.', None, 5)
The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command C:\Users\.espressif\python_env\idf4.3_py3.8_env\Scripts\python.exe C:\Users\chenjo5\esp\esp-idf\components\esptool_py\esptool\esptool.py -p COM12 -b 460800 --before default_reset --after hard_reset --chip esp32 write_flash --flash_mode dio --flash_freq 40m --flash_size detect 0x10000 blink.bin 0x1000 bootloader/bootloader.bin 0x8000 partition_table/partition-table.bin" terminated with exit code: 1.


Can you help me to solve this problem?

If I close VS Code, open again and repeated the same sequence, it was ok to flash. But the second time still failed.

Thanks!

ESP_bignacio
Posts: 229
Joined: Wed May 02, 2018 12:12 pm

Re: Could not flash after flashing successfully the first time in VS Code

Postby ESP_bignacio » Mon Jul 05, 2021 6:33 am

Seems that the serial port is not accessible for the user, maybe another application is using it ?

Make sure ESP-IDF monitor is not running and you closed the terminal from previous flash task.

joshchen
Posts: 5
Joined: Mon Jul 05, 2021 1:07 am

Re: Could not flash after flashing successfully the first time in VS Code

Postby joshchen » Mon Jul 05, 2021 5:17 pm

ESP_bignacio wrote:
Mon Jul 05, 2021 6:33 am
Seems that the serial port is not accessible for the user, maybe another application is using it ?

Make sure ESP-IDF monitor is not running and you closed the terminal from previous flash task.
That solves the problem, thank you! Another question is when I tried to use JTAG to flash my ESP32-WROOM-32UE dev kit, it first asked "OpenOCD is not running, do you want to launch it?". I clicked on Yes, it shows the error below:

Open On-Chip Debugger v0.10.0-esp32-20210401 (2021-04-01-15:46)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 20000 kHz

WARNING: boards/esp32-wrover.cfg is deprecated, and may be removed in a future release.
If your board is ESP32-WROVER-KIT, use board/esp32-wrover-kit-1.8v.cfg instead.
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
❌ Error: no device found
Error: unable to open ftdi device with vid 0403, pid 6010, description '*', serial '*' at bus location '*'
❌ Error: no device found
Error: unable to open ftdi device with vid 0403, pid 6014, description '*', serial '*' at bus location '*'

Assertion failed!

Program: C:\Users\.espressif\tools\openocd-esp32\v0.10.0-esp32-20210401\openocd-esp32\bin\openocd.exe
File: ../src/jtag/core.c, Line 343

Expression: jtag_trst == 0
[Stopped] : OpenOCD Server


can you help?

Thanks!

jmporter34567
Posts: 8
Joined: Fri Jul 23, 2021 6:35 pm

Re: Could not flash after flashing successfully the first time in VS Code

Postby jmporter34567 » Sun Jul 25, 2021 8:48 pm

You didn't say which JTAG interface you're using, but some need you to use Zadig tool to install a WinUSB driver. Here's an example:
https://docs.espressif.com/projects/esp ... -jtag.html
Maybe you need to do that ? HTH

Who is online

Users browsing this forum: No registered users and 11 guests