PlatformIO Community

First Firmwareupload on ESP32-Wroom-32D with JTAG

Hi all
I have a custom board with an ESP32-WROOM-32D module on it. It’s a single module and not the arduino one.
When I try to program the module for the first time (out of package) with the jtag port, it does not work. It can’t connect with the esp-idf command prompt.

I’ve bought the ESP32-DEVKITS-V1.1 to try out easier. After press the boot button, power the module on and try to connect with the esp-idf command prompt, it connects and it seems that I can upload the code via jtag. But when I try to debug it does not work and it does not start.

I have now the work around that I load the module first with a arduino blink code over the ESP32-DEVKITS-V1.1 and serial port. After this upload I can upload and debug the code with JTAG. After this I can solder the module on my custom board and update the firmware without any problem.

Is it possible to upload the code for the first time with JTAG and without loading the module with serial port first? How to do this? Are there any settings in SDK Configuration I have to set?

So you’re not usuing PlatformIO for this?

I don’t see how a firmware first has to be loaded to the module for it to be accessible via JTAG. JTAG is much more low-level.

What programmer have you connected in which exact way to the target chip, what commands are you using to attempt to upload the firmware to the chip?

So you’re not usuing PlatformIO for this?

No most time I use eclipse wich is suggested by espressif. But sometimes I think it’s buggy and I switch to platformio for little tests where I’m sure it’s not the settings or program wich is bad or corrupt. But platformio is sadly way to slow in compiling and debugging. Otherwise I would choose it as my main program interface.

But anyway I have the same problem with platformio. When I have a module out of the box and try to upload the blink example over jtag I get this:

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
none separate
adapter speed: 10000 kHz
Info : Configured 2 cores
esp32 interrupt mask on
Info : tcl server disabled
Info : telnet server disabled
Error: libusb_open() failed with LIBUSB_ERROR_NOT_SUPPORTED
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge   falling"
Info : clock speed 10000 kHz
Error: JTAG scan chain interrogation failed: all ones
Error: Check JTAG interface, timings, target power, etc.
Error: Trying to use configured scan chain anyway...
Error: esp32.cpu0: IR capture error; saw 0x1f not 0x01
Warn : Bypassing JTAG setup events due to errors
Info : accepting 'gdb' connection from pipe
Error: No symbols for FreeRTOS
Error: Target not examined yet


Error: Target not halted
Error: auto_probe failed
Error: Connect failed. Consider setting up a gdb-attach event for the target to prepare target for GDB    connect, or use 'gdb_memory_map disable'.
Error: attempted 'gdb' connection rejected
Error: error during select: Unknown error
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()
.pioinit:11: Error in sourced command file:
Remote communication error.  Target disconnected.: Success.

After uploading the blink example in the normal arduino ide outside of platformio with serial port it’s possible to upload and debug the code in platformio afterwards. This without touching a single wire.

Therefore I think the platformio.ini settings and the hardware setup are ok but it does not work with JTAG with new “empty” modules out of the box.

I use the esp-prog for debugging and upload my firmware.
The modules are these: ESP32-WROOM-32D (4MB)
https://www.digikey.ch/product-detail/de/espressif-systems/ESP32-WROOM-32D-4MB/1965-ESP32-WROOM-32D-4MB-CT-ND/9381732

Maybe you know a way to load the code directly with JTAG?

Where did you set the 10MHz? Can you lower it e.g. 1 MHz?

Where did you set the 10MHz? Can you lower it e.g. 1 MHz?

This is copyed out of the debug console from platformio. I don’t know where to set the clock there.
In the esp-idf I can set it to 1MHz. But this don’t change anything. I also tried 500kHz or 100kHz wich does not work either.

But 10MHz work for debugging and upload after first upload some code with the arduino ide and serial port. Therefore I assume that this is not the problem.

Ok found something on official espressif site here:

There is a point called:
JTAG and ESP32-WROOM-32 AT firmware Compatibility Issue

With this text:
The ESP32-WROOM series of modules come pre-flashed with AT firmware. This firmware configures the pins GPIO12 to GPIO15 as SPI slave interface, which makes using JTAG impossible.

To make JTAG available, build new firmware that is not using pins GPIO12 to GPIO15 dedicated to JTAG communication. After that, flash the firmware onto your module.

Seems that upload firmware over JTAG on new modules does not work and I have to do the workaround with the serial port.

1 Like

Wow that is one hell of a caveat. A module preflashed with a firmware that disallows JTAG flashes. :open_mouth:

Well but… maybe if RESET is held low all the time so that it doesn’t execute the firmware, those pins are JTAG accessible? And then one would have to manually release the reset line again? hm…

1 Like

Exact my thought. Maybe I’m missing something but it seems that this is really the problem and from the text above it seems that all the wroom modules have this preflashed firmware with disallowed JTAG.

For Arduino it’s no problem because arduino ide uses serial communication. But if you want to use JTAG it’s not that easy.

I tried to hold down EN and start the module. This does nothing.
If you hold down BOOT then it could connect but it seems that it’s not possible to flash correct. I was not able to flash correctly.

It seems also that there is no sequence with RST or TRST because if you see the pinout from esp-prog. There is not even a reset pin provided.

On this official espressif site you can find this text under point “Selecting JTAG Adapter”:

If you decide to use separate JTAG adapter, look for one that is compatible with both the voltage levels on the ESP32 as well as with the OpenOCD software. The JTAG port on the ESP32 is an industry-standard JTAG port which lacks (and does not need) the TRST pin. The JTAG I/O pins all are powered from the VDD_3P3_RTC pin (which normally would be powered by a 3.3 V rail) so the JTAG adapter needs to be able to work with JTAG pins in that voltage range.

Therefore I think it also has no sequence for reset or startup.
And I think that it’s impossible to activate JTAG without load a “dummy” firmware over serial port first.

After the JTAG was enabled it’s possible to overwrite the JTAG GPIO’s in the Firmware wich ends with no connection to the board. This could be solved with disconect the module from power, set GPIO 0 to GND and power the module again. In this state it’s possible to rewrite another firmware wich dont use the GPIO’s from JTAG. It does not work if the module is always powered. It really need to restart with GPIO 0 to GND and JTAG has to be enabled through other firmware before.

1 Like