How do I upload arduino code to esp32 using ESP-Prog

I added the following to the platformio.ini file and tried to upload but get the error message below:

[env:esp32dev]
platform = espressif32
board = esp32dev
debug_tool = esp-prog
upload_protocol = esp-prog
framework = arduino

monitor_speed = 115200
> Executing task in folder 190722-124508-esp32dev: C:\Users\johnw\.platformio\penv\Scripts\platformio.exe run --target upload <

Processing esp32dev (framework: arduino; platform: espressif32; board: esp32dev)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PackageManager: Installing tool-openocd-esp32 @ ~1.1000.20181026
Error: Detected unknown package 'tool-openocd-esp32'
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

Well but it’s right there

What pio --version do you have? Updated all platforms?

PS C:\Users\johnw\Documents\PlatformIO\Projects\190722-124508-esp32dev> platformio upgrade
You're up-to-date!
PlatformIO 4.0.0 is currently the newest version available.
PS C:\Users\johnw\Documents\PlatformIO\Projects\190722-124508-esp32dev> platformio update
Updating tool-scons                      @ 2.20501.7      [Up-to-date]
Updating tool-unity                      @ 1.20403.0      [Up-to-date]
Updating contrib-pysite                  @ 2.27.190418    [Up-to-date]
Updating contrib-piohome                 @ 2.2.0          [Up-to-date]
Updating tool-pioplus                    @ 2.5.2          [Up-to-date]

Platform Manager
================
Platform Atmel AVR
--------
Updating atmelavr                        @ 1.15.0         [Up-to-date]
Updating toolchain-atmelavr              @ 1.50400.190710 [Up-to-date]
Updating framework-arduinoavr            @ 4.1.1          [Up-to-date]

Platform Espressif 32
--------
Updating espressif32                     @ 1.9.0          [Up-to-date]
Updating tool-esptoolpy                  @ 1.20600.0      [Up-to-date]
Updating toolchain-xtensa32              @ 2.50200.80     [Up-to-date]
Updating framework-arduinoespressif32    @ 2.10002.190628 [Up-to-date]
Updating tool-mkspiffs                   @ 2.230.0        [Up-to-date]


Library Manager
===============
Library Storage: C:\Users\johnw\.platformio\lib
PS C:\Users\johnw\Documents\PlatformIO\Projects\190722-124508-esp32dev>

Do I need to do something special after updating the platformio.ini file? I just saved it and tried uploading. Twice.

Weird - I tried again and it got further, but now failing here:

Building .pio\build\esp32dev\firmware.bin
esptool.py v2.6
Memory Usage -> http://bit.ly/pio-memory-usage
DATA:    [          ]   4.1% (used 13540 bytes from 327680 bytes)
PROGRAM: [==        ]  15.5% (used 203472 bytes from 1310720 bytes)
Configuring upload protocol...
AVAILABLE: 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 = esp-prog
Uploading .pio\build\esp32dev\firmware.bin
Open On-Chip Debugger  v0.10.0-esp32-20190708 (2019-07-08-11:04)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 1
none separate
adapter speed: 20000 kHz
esp32 interrupt mask on
Error: libusb_open() failed with LIBUSB_ERROR_NOT_FOUND
Error: no device found
Error: unable to open ftdi device with vid 0403, pid 6010, description '*', serial '*' at bus location '*'
** OpenOCD init failed **
shutdown command invoked

Warn : Flash driver of esp32.flash does not support free_driver_priv()
Warn : Flash driver of irom does not support free_driver_priv()
Warn : Flash driver of drom does not support free_driver_priv()
*** [upload] Error 1
====================================================================== [ERROR] Took 26.67 seconds ======================================================================
The terminal process terminated with exit code: 1

Uhh well that’s nice that the package install error is suddenly gone… oO?

You’ll need Zadig to change the driver to WinUSB, see here and here

I thought that was only for debugging - I’m just trying to upload. There are 2 USB/Serial ports - is one for uploading and one for JTAG? How do I configure the upload side?

I followed the instructions because I want to do JTAG debugging at some point. I tried the upload again and got this:

Configuring upload protocol...
AVAILABLE: 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 = esp-prog
Uploading .pio\build\esp32dev\firmware.bin
Open On-Chip Debugger  v0.10.0-esp32-20190708 (2019-07-08-11:04)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 1
none separate
adapter speed: 20000 kHz
esp32 interrupt mask on
Error: JTAG scan chain interrogation failed: all zeroes
Error: Check JTAG interface, timings, target power, etc.
Error: Trying to use configured scan chain anyway...
Error: esp32.cpu0: IR capture error; saw 0x00 not 0x01
Warn : Bypassing JTAG setup events due to errors
Error: JTAG scan chain interrogation failed: all zeroes
Error: Check JTAG interface, timings, target power, etc.
Error: Trying to use configured scan chain anyway...
Error: esp32.cpu0: IR capture error; saw 0x00 not 0x01
Warn : Bypassing JTAG setup events due to errors
*** [upload] Error 253
====================================================================== [ERROR] Took 5.09 seconds ======================================================================
The terminal process terminated with exit code: 1

JTAG is not connected atm - just upload. Do I need to follow the same WinUSB procedure for channel 1 to get upload working? Just don’t want to screw anything up that will take hours to unwind…

I connected JTAG and I"m getting the same error…

No only 1 of the 2 channels of the adapter is connected to the JTAG interface anyways. The second is UART.

The JTAG should also be able to upload the firmware. Given that saw 0x00 not 0x01 you should double-check all wires to make sure they go to their correct JTAG pin on the ESP32. What exact target ESP32 board do you have?

It’s a custom board but wired as esp dev kit. At this point I don’t care as much about jtag debugging - that is a nice to have but the programming is a must-have. How can I skip the jtag side and just upload?

Yeah just remove upload_tool = .. and it will default back to flashing via UART. You need to put back one of the interfaces in UART mode so that the PC sees a COM adapter, connect the wires for UART RX,TX, IO0 and EN as seen in https://github.com/espressif/esp-iot-solution/blob/master/documents/evaluation_boards/ESP-Prog_guide_en.md?utm_source=platformio&utm_medium=docs and it should flash it.

Phew. That works :slight_smile: THANK YOU!

Back to jtag, though since we’re here… My jtag pins are connected like this:

What else could the problem be?

I think platformIO is possessed… After posting that, reconnecting JTAG and retrying it works :confused:
But anyway, it works!!! Thanks for your help!!!

Does it work every time after that? Intermittent connections sound like a bad cable or a too-high frequency signal going through it.

This drives the cable at 20MHz, crappy breadboard cables might not like that. You can decrease the frequency in <home folder>\.platformio\packages\tool-openocd-esp32\share\openocd\scripts\board\esp-wroom-32.cfg at the adapter_khz line if needed.

1 Like

OK I’ll keep that in mind.

Hi Maximillian, I am trying to upload (no debug) using the ESP_PROG, like Daemach did. My ESP32 is not responding, and I suspect I need to “put back one of the interfaces in UART mode so that the PC sees a COM adapter” as you suggested. I am on Ubuntu and see 2 ports, ttyUSB0 and ttyUSB1. How do I set the port as a COM adapter on LInux?

Another difficulty is that I do not have easy access to the EN pin right now. Is this necessary for uploading?

Any help appreciated, Thanks, Kevin