Notifications
Clear all

VSCode debugging on ESP32 with ESP-Prog JTAG debugger.

5 Posts
2 Users
4 Likes
4,610 Views
(@jfabernathy)
Member
Joined: 3 years ago
Posts: 141
Topic starter  

I've spent some time playing with my new $12 ESP-Prog JTAG debugger for the ESP32. I've found some things that are useful, so I thought I'd document them for reference.

There are a number of videos and blogs to get you started, but it's always the missing pieces that slow you down. 

You need VSCode with PlatformIO to use the debugger and that installation is standard and fairly simple on Linux. Bill has a good video on that, platformIO. Hooking up the JTAG ESP-Prog requires using 4 pins that can't be used for anything else during the debugging. DON'T CONNECT THE VCC. You can use Windows 10 but I didn't try that. Though I used a Windows 10 YouTube video as reference. Linux was less steps; less 3rd party code to install.

However, beside editing the Platformio.ini file with the 2 debug statements everyone tells you about, you also need some additional packages for Ubuntu or similar Linux.

The debugger requires that some libraries are preinstalled on the system.  

sudo apt install libncurses5?

You  might also need

sudo apt-get install libncurses5-dev libncursesw5-dev.

Also needed:


sudo apt install libpython2.7-dev

Some references I used:

https://www.instructables.com/How-to-Use-a-Debugger-on-an-ESP32/   for Windows and photos of JTAG port connections.

 

https://docs.platformio.org/en/latest/tutorials/espressif32/arduino_debugging_unit_testing.html

If your code won't compile, have another glass of bourbon. Eventual the problem will be solved.


   
Centari and YurkshireLad reacted
Quote
noweare
(@noweare)
Member
Joined: 4 years ago
Posts: 110
 

Thanks for this. I will be using this post as a reference when I get back to using esp32's more frequently. I am sure it will save me some time.


   
Centari reacted
ReplyQuote
(@jfabernathy)
Member
Joined: 3 years ago
Posts: 141
Topic starter  

Just want to point out that the use of ESP-Prog is a little finicky.  I find that about half the time I have to unplug the USB cable between my computer running VSCode and PlatformIO and the ESP-Prog while uploading code to the ESP32 board via it's USB Cable.

So you might have to play with that to see what works for you. 

If your code won't compile, have another glass of bourbon. Eventual the problem will be solved.


   
ReplyQuote
(@jfabernathy)
Member
Joined: 3 years ago
Posts: 141
Topic starter  

I got the ESP-Prog debugger to work a little more reliably by following a procedure.

Since I like to have the USB Serial console as an output for high-level debug messages, and I have to power the ESP32 board I have that board’s USB connected to the PC. I do this first. Then I open VSCode and build and upload the code with an .ini file that reads:

[env:featheresp32]
platform = espressif32
board = featheresp32
framework = arduino
monitor_speed = 115200
build_type = debug
debug_tool = esp-prog
debug_init_break = tbreak setup

After the code has uploaded I connect the ESP-Prog USB cable and start debug. At this point, I usually can stop debug, edit the program, recompile and upload without removing the ESP-Prog USB cable.

I did get it working reliably using the ESP-Prog USB cable only by putting in the

upload_protocol = esp-prog

statement into the platformio.ini file, but you lose the USB port for printf and you still have to power the board with USB anyway via a power brick.

If your code won't compile, have another glass of bourbon. Eventual the problem will be solved.


   
ReplyQuote
(@jfabernathy)
Member
Joined: 3 years ago
Posts: 141
Topic starter  

I got some help on the PlatformIO forum and it made me look at the ESP-Prog JTAG debugger in more detail.  It has a lot of capabilities.  Depending on the ESP32 board under test you can even connect a UART from the ESP32 to the USB Serial on the ESP-Prog.  You can jumper the ESP-Prog to power the ESP32 board with either 5v or 3.3v, but at the end on the day.  I still have my best results with both USB Cables connected to my PC, one going to the ESP32 board and one going to the ESP-Prog. 

If you figure out more, please post it here. This JTAG method is a lot more flaky that what we use to use back on the Intel P6 generation processors, but those JTAG debuggers were entire PCI boards and cost thousands of dollars.

 

If your code won't compile, have another glass of bourbon. Eventual the problem will be solved.


   
Dazza reacted
ReplyQuote