This is one of the more expensive channels :-) Just made an order of 1 esp-prog. Not being able to do in-circuit debugging has always been a show stopper me doing more advanced programs on ESP and ATMEL micros.
You can use Atmel Studio and ICE with Atmel micros. only real issue: I've bricked a few micros for the same silly reason. :( you need a high voltage programmer to unbrick them.
I have my lovely AVR Dragon. Old but good also support atmel debugwire (ATTiny series) :) Also nice to have is msp launchpad (new version support usb 3.0 controllers) and stm discovery board
Thank you Andreas & everyone who is involved in making this possible! Got my first ESP32 last week. I know I'm late but Arduino & ESP8266 & TI Launchpad was enough before. But now I'm hooked on the ESP32 drug! =) And there's sooo many boards to try! Thank you once again. =)
I will second that. I just got some code debugged and it felt great. People in the education business will have plenty of reasons now to use the ESP32 and have their students' stuff debugged at the source level.
Great video, yes, want one. Also you could use the "static" keyword to keep your local variable in its associated function without making it a global. It will then keep its value between calls.
Beat me to the thing I wanted to point out. I don't know why, but I have an aversion to global variables and much rather keep things with the associated function that is using them when possible.
I used to be confused with something like : *static int var=0;* In the beginning of a function because I thought when the function runs again the var gets set back to *0* :)
Also "volatile" to make sure the compiler doesn't compile out variables that don't actually do anything (useful to count the number of times you've hit a function).
Indeed, just added PIO to my VSCode and I must say I like the compile feedback far more than the dark side of the moon affair with the Arduino builds :-)
OMG Andreas! This is HUGE! I've tried doing this before with a different debugger with limited success. Thank you for sharing your success path! Ten thumbs ups!!
This is one of the best videos done Andreas. We really hope you could go into much more details about this topic in future. We learnt a lot from this video. Thanks a lot. Bless you.
Inline debugging and preliminary ULP support for ESP32 in pio: like xmas and easter at the same time! Thanks platformio for making that possible and thanks Andreas for paving the way!
Andreas, as an influencer, the more you promote useful tools like this one, more available and cheap they will become. Thank you so much for this, and keep trying new stuff! Also I am waiting for your video on unit testing for Arduino and ESP.
I was able to do inline debugging for ESP32 about 1 year ago but only using Espressif WROVER kit and ESP-IDF framework. But your Arduino framework is SO much easier.
Absolutely awesome and already placed the order at Aliexpress. Until now I was excepting that debugging these microcontollers is just out range and will never work. Will stay on Patreon, because these are the videos with really big value.
You demystified JTAG debugging for me, so much so FedEx dropped off my Olimex ARM-USB-TINY-H yesterday. Following this video I was running and debugging in less than an hour. Great video as always!
A great feature to have especially for the price you pay for the ESP-PROG. Andreas many thanks for this great video. It makes life so much easier to learn this way. Keep up the good work.
Wow, this is a game changer for sure. I hope I can get some time to try this out. I've been hesitating about working with the ESP32 (as I have a bunch of other Arduinos and compatibles already) but if I can get this working there's no excuse now. I would really love to see you come back to this from time to time with updates as you continue to work with this system and figure other things out, and perhaps as PIO addresses any issues you've run into.
@@AndreasSpiess Yes. I would , think you would only want revisit this if you find something really significantly interesting (as you have done with a few other videos) but of course that also assumes you continue with it yourself. Looking at the comments there seems to be a lot of people very interested in this, so I guess you'd want to consider that as well. I really hope I have time for this myself soon. The library of information you are building on this channel is really amazing.
Dear Andreas, thanks for another very nice video on a Sunday morning. Another alternative for a JTAG adapter is named „Mini USB Blaster“ (a white and blue enclosure) for around 2-3€ on AliExpress. I‘ve used it for quite some time together with Eclipse, but it should work with PIO as well.
I gave it a short try, but there does not seem to be a config option for the Altera USB Blaster (yet). My few experiments didn‘t yield any usable results...
Since I‘ll be away from my playthings for 1-3 months (work-related) I cannot follow up on this in the next weeks. I have put it on my list, though, for later experimentation
It took way longer than expected, but there is now a better description of how to use the Altera USB Blaster and its problems. So actually I would not suggest to buy it. Here is the link: www.esp32.com/viewtopic.php?t=9901
Thanks mate. This is the one thing that has really held me back - not just useful for debugging, but also a great way to learn and experiment. I hope you're getting a commission - I just bought one.
Unbelievably cool and informative video man! Well done! Exactly what I have been looking for, for years! Just in time. Love your clear, direct, and still detailed style! Long lives your channel and you!
@@AndreasSpiess helped?? Are you kidding me! Already ordered the ESP prog gears for debugging! Hats off! You rock! I am going to try it with Visual Studio + visual micro combination, as I am not too certain about platform io. Have it a try few years ago, and ended up in lots of grief and frustration. Is it much better now? Also, can it be added straight on visual studio together with visual micro, asking cause I can see you are using visual studio. Cheers
@@AndreasSpiess you are natural, wise and very knowledgeable yet down to earth simple in approach, detailed and hard core, yet no fluff, straight to the point! Very rare combination. Well done man, I mean it. 👍👍
Many of my viewers use plaformio and are happy with it. I use VisualMicro because it is more Ardhuino IDE compatible and my "Channel IDE" remains the Arduino IDE.
YES! Andreas, You're absolutely right : this will be a true life changer for me as well. I'm used to work with debuggers in the programming languages I use on a dayly basis and and always found it more than tedious to do my arduino programming without. Especially as I am not as safe and sound in C++ as I am inmy other languages. -When it comes to referencing and dereferencing of pointers I sometimes have to enter the area of guesswork or trial and error. - Optimizing code by testing different variants and approaches is very time consuming.When it comes to debuging. - Debugging data types via the serial monitor is not always working as expected, as it does its own conversions or requires manual conversion prior display, which sometimes covers up the problem. - Stupid errors like expecting a float value froma division of two integers without conversion - .... I actually knew about the inline debugging capabilites of platformio, but at the time I read about it, it was available in the commerical version only and was no option for the projects I did at that time. So I did not pay attention, when You made this video back then. Just when I accidentally heard about the esp-prog a few days ago, I looked into it again and remembered that You had done a video on that subject. Now I find it hard to wait until I get the debugger. I've not directly found a source that delivers from within Germany. So it seems, I'll have to get it from China and be patient. Despite the fact, that on an esp8266 only a few usable pins remain,I still think,it will be a huge support even for these boards. Especially,when it is about conceptual / structural debugging. Excelent, as always! Thanks and regards Frank
Hey, I used an "Intel Blue Box" just like that one in my first job at age 17, writing PL/M code on our custom 8085 audio spectrum analyzer board. The debugger hardware was two large Intel circuit boards that would just get flaky after a while - we would pull the boards, rub the back with aluminum foil, stick them back in and keep working. Now we're both here 40 years later playing with ESP32 hardware debuggers!
Thanks a million! You just changed the way I deal with the ESP32 once and for all. I followed your tutorial and I can assure everybody that it works perfectly! Do not forget to replace the drivers using the Zadig driver installer. I did and it did not work. I had to go and watch the video a second time and it worked once I replaced the drivers. Interestingly enough, the code always goes to the FreeRTOS when debugging at the source code level. It makes it even more obvious that FreeRTOS is an integral part of the ESP32 Arduino libraries. Debugging will lead you there no matter what. I simply stepped out of the FreeRTOS stuff because I was more interested in my code than any RTOS kernel stuff. On a different note: Who are the morons who disliked this video? Do they even know what they were looking at when they watched your video?
@@AndreasSpiess You know what? To hell with these idiots. It's because of RUclipsrs like you that knowledge is spreading quickly. Thanks a million and please continue to make and share more videos. You have a loyal subscriber to your channel now.
Although I'm familiar with inline debugging from other platforms, it's rather complicated to use for ESP32 until the board manufacturers will use a standardised connector. My standard way of debugging, 99% ESP8266, is to use MQTT. In this way I can both "print" messages and also input data if I want to. I can do similar things as conditional breakpoints or logging, or conditional input controlled by MQTT. My first upload with a new project is always a simple standard sketch that replaces serial load with OTA over Wifi and has some standard topics for debug and reporting when a devices boots or restarts. In this way it is really fast to make changes to the code for debugging purposes. I never use the serial terminal since I'm used to making continuous improvements to my sketches with the devices long away from my computer. OTA and MQTT makes it possible to make changes and corrections without having the device connected physically. "JTAG" over Wifi supported by the chipset itself would however be very useful, with even having to use a JTAG physical connector...
@@bollie9752 No. It's basically just having a debug topic for outgoing messages instead of Serial.print and then listening to this topic in a shell or by logging to a file. If you want to change the program flow in some way you can have incoming debug topics for values or triggers. A trigger can just set a variable or a simple if statement in the code can do something that affects the program flow e.g. by assigning some variables, skipping a section of the code or whatever. I only do this when something is not working as intended but I also have a standard topic for all my clients and a listener on my server that logs this to a text file. I use this to check when a device has rebooted and to which IP/mac-address, the RSSI dB value, name and version of the sketch etc. Like this (one row in the log file): 19-06-23 11:43: NeoPixelAlertIndicator1 BOOT 192.168.0.154 60:01:94:39:72:85 RSSI(dBm):-54 NeoPixelAlertIndicator 1.4 2018-08-25 Hans Palm
Nice! I know EXACTLY what you mean when you say, "...and I know what I'm talking about", (Lol, Good job explaining those traps for new players!) Thank you.
Also, using the serial port, even just invoking it and not using it, consumes more electrical power. Important if you are zoned into low power devices.
I didn't see this issue you are referencing. Everything worked fine for me the first time around. The only annoying thing I dealt with was having to step through some FreeRTOS code. Other than that, it was an absolute delight to step through my code any way I wanted. The assembled code was also listed and you can debug through it if that's your thing.
I just started to use PlatformIO with VScode (Arduino Platform). A bit of a learning curve, but I love it. On to my comment about debugging. I already had a J-Link, so I hooked it up to an ESP32_Devkitc_V4 that I just bought. I had to use Zadig to install the WinUSB driver, just as you did for the FTDI debugger. Then I set "debug_tool = jlink". PlatformIO recognized the J-Link, but when running the debugger, I got an error, and the debugger stopped. A Google search told me that I needed to hook up pin 1 (VT) on the J-Link to 3.3 V on the ESP32. Now it works well. Thanks for the excellent (as always) video.
Great subject and the ESP Debugger is already on order😁 sweet✅ Thank you Andreas on this very important subject. 🏴 I hope to see another video delving deeper and it’s applications 😁🏴
Greutzi Andreas, thank you for this video, most helpful. I liked and subscribed. I'm glad you were excited by your first debugger - as excited as the Moon landing! One small nit about your video, Astronaut Neil Armstrong was so excited he forgot to say "a man" and instead said "That's one small step for man, one giant leap for mankind." :-) I just received my ESP-prog board. Can't wait for the missing 'a' in learning how to use it! -Frank
@@AndreasSpiess I followed your videos' instructions to get the ESP Dev board wired to an esp32 wroom board. It was about 1:00 a.m. when realized the second USB micro cable I have is one of those stupid stupid power only cables. I threw my head back and yelled up to the USB cable God.... 'no!' hehehe. The USB cable shop opens here in about 2 hours. Jtag debugging shall be mine today! 😃
Instead of the Espressif or Olimex adapter, I've successfully used FT232H boards (CJMCU FT232H). They are about USD 7.00 on Aliexpress. The pin mapping is: TDI -> AD1; TDO -> AD2; TCK -> AD0; TMS -> AD3. I've used a Mac with OpenOCD however and don't know if it works with Zadig.
Maybe you try it in this config? It would be beneficial if we get an even cheaper adapter. The problem I see is not Zadig, it is to choose the right definition file in platformIO.ini (and if one is available)
@@AndreasSpiess It turns out that FT2232HL (such as the CJMCU FT2232HL) boards are even better. They are a drop-in replacement for ESP-PROG board. With exactly the same configuration in PlatformIO, on Windows (Zadig) and MacOS (sudo kextunload -b com.FTDI.driver.FTDIUSBSerialDriver) it just work. That's no surprise as the ESP-PROG board is in fact at FT2232HL board. And it uses OpenOCD in the background. The CJMCU FT2232HL is about USD 9 on Ebay and Aliexpress. The slightly cheaper CJMCU FT232H board (USD 7) can also be used. But it requires some fiddling in the OpenOCD configuration files as the USB product ID is 0x6014 (as opposed to 0x6010); otherwise the device is not found.
Thank you for your info! Could you give us a little more info on which file to change, where to find the product ID etc.? There are quite a few cheap FTDI boards on Aliexpress and with your help, we maybe could make them run...
If you have the JTAG adapter connected, you can upload the program via the debugger, at 20 MBit/s. Just add “upload_protocol = esp-prog” to platform.ini. You can then disconnect the USB cable to the dev board and replace it with 3.3V supply from the adapter to the dev board.
So far I thought you need the second channel to do that and you have to connect this channel also to the chip. I did not know it runs on the JTAG wires.
@@AndreasSpiess Here it says 142 units on 02-jul-19, but sometimes they don't respect this. 7 weeks is the factory lead time. At least in my country they offer free shipping above 50€. I forgot to mention the value is without VAT.
Great video. Thanks. Another purchase is on it's way. One thing to watch is that the more highly integrated esp32 boards often use the jtag pins for their other functions, so it may be necessary to debug libraries on another board before including in final target. I use Ttgo T4 for some quick project as it has a lot of functions but has assigned all jtag pinsvto other functions. Perhaps future designs will leave jtag free if it becomes more popular.
Thankyou Andreas for this great tutorial once again. I've known about inline debugging for quite a while since my university days, but to see it explained in the most modern of IDE (VSCode) and HW (ESP32) is a fresh reminder that the more things change the more they stay the same.
Wow, wow, wow it's quite incredible how how you can keep coming up with so useful and instructive videos. I was wondering what you have for breakfast because I could do with some of that brilliance.
I'd subscribe to your channel twice if I could! Your content is very interesting, entertaining and useful to me. You are an awesome and inspiring man Andreas. Love and hugs from Chile to the guy with the Swiss accent :)
Maybe a silly question, but why move localVariable to make it global? You can keep it local but just define it as "static int localVariable;". This preserves it as a local variable bit prevents the redeclation and this prevents it being reset.
Great video Andreas! ... This remember's me to my first job (long long ago) where we created a (expensive) hardware for JTAG debugging support for the pentium processor. The main focus was to enable conditional breakpoints (as you showed) very fast. You always have to stop the processor put in some serial bitstream into the pins to get the needed values out ... on a pentium this was ~1KBit ... For that we created a special ASIC (25 years ago!) to achieve this very fast. My job was the software ... I miss these days ;-)
Btw. If somebody is interested how JTAG debugging works: The processor get's stopped .. all important registers of the CPU get copied into 'shadow' registers and this shadow registers can be 'clocked' out serial using a special protocol through the connected lines. Also memory can be read and written that way. Sometimes CPUs have special debug registers that can be adressed also ... btw. many chips support a JTAG interface .... the cool thing is that you can chain them together if you have a larger circuit, but then it get's a real serial mess ;-)
Thanks for the details. Dave J. did one a video where he also mentioned the "serialization". But it was less for processors and more for "boundary checks" of ordinary HW. For processors, I would assume you would spend the money for a second adapter to reduce the complexity of the software.
@@northshorepx All STM32 chips support remote debugging using their SWD interface, which is exposed as pins on the blue pill / maple boards for example. The Nucleo dev boards from ST have an STLink-V2 included on the board, which is identical to the cheap standalone STLink-V2 USB devices you can find online for a few dollars. A J-Link can achieve the same thing. You can program and debug through this interface.
The ARM boards use the ST-Link style interface, which is logically similar to JTAG, but a different wire-protocol (SWD - Serial Wire Debug). I'm pretty sure that the ESP32 microprocessor cores do not implement the ARM debugger port in their hardware. Thus the need for a JTAG physical interface. The adapters referenced (including ST-Link style) translate higher level GDB primitives (read/write memory, examine/set CPU registers, etc.) into specific debugging register accesses, via some physical protocol (SWD or JTAG, depending on the CPU and debugger interface.)
Andreas, first thaks for everything! I got a Segger J-link, it's what i could get here in Brazil in a fast pace, and it helped me a lot. I got it working better in Linux than Windows. on Windows sometimes the debugger didn`t work at all. openOCD couldn`t find it. So i`m working on Ubuntu and it runs fine, and by the way, compilation seems faster =)
LOL - I was building systems back in 70s to 90s - I remember using those Intel MDS-80 development stations with the 8 inch floppies. Recently been looking to get back in for some hobby projects. Funny part is in the videos I saw there seemed to be no In-line debugger or emulator; I was very Puzzled,... CERTAINLY NO ONE WOULD BE DEVELOPING CODE WITHOUT ONE!! LOL - Thankyou for the video - definitely adding this to the list !!!!
This sure would have helped last summer with debugging the tank communications problems. That brings up another situation where serial debugging does not work well Debugging a crash. The serial writes are cached; so, the messages go out after a delay - and sometimes not at all when a crash occurs. This can mislead you regarding where the code is crashing.
The Espressif IDE has a possibility to invoke the debugger after a crash to find out the last steps before. Maybe this is also available in PIO/Arduino framework. I do not know.
Today I got my esp-prog board to work on my mac with help of this video (which inspired me to buy the esp-prog in the first place). I now am able to both program (upload), monitor and debug the ESP32 (I tried the SBC-NODEMCU-ESP32 from JOY-IT) over a single USB connection. I did run into some small problems. My advice is to install the official FTDI VCP driver for the MAC OS you are running (I'm at a beta of 10.15.5 currently). Then LEAVE THE PORT SETTING FOR THE DEBUG PORT EMPTY, but use the 'xxx01' port for the upload and the monitor port. Still I don't like the VS Code environtment that much. Maybe after some time I will learn to appreciate it. But even if I don't like it for programming, I still can use it to debug the ESP32 projects now. Next on my list is to create a jig to easily cable up the NodeMCU to the ESP-prog. I'm thinking about designing a PCB with feed-through header pins or so.
I have a few development boards laying around which I use to start every project. Only after the code is already working I change to the target. You could add such a Jig to such development boards...
For your information you could of declared "localVariable" as static like :- static int localVariable = 0; With the static keyword the variable will not be destroyed when out of scope (exiting the loop routine) It will retain its value the next time loop is called unlike your dynamic variable that gets created each time you call loop. The "= 0" (assignment of zero) only gets called once during creation. The reason why this may be a better choice is because no other routine can see or more importantly change the contents of "localVariable" Which may be a better choice that making "localVariable" accessible to everyone (all routines) in some cases. Depends whether you want other routines to see the variable. Welcome to the world of debugging. 😃
Great video :) It would be awesome, if you did a video on using the second serial port on the esp-prog. For the newbee like me, it would be worth mentioning (in addition) to just connect one usb cable to programmer (es-prog in my case) and that the programming happens thru the jtag. I learn that the hard way.
@@AndreasSpiess Please also show how to use Serial port with ESP-PROG. That would really save connecting both (esp32 as well as esp-prog) to the power supply. Atleast you say the setting in the platform.ini file for the serial via esp-prog. please
I remember "poor man's debugging" in C using printf statements. I then made a debug_print macro that was a printf embedded inside a "#ifdef _debug". That way I could recompile with or without _debug defined. This totally confused me. When I compiled and ran the program without debug, it misbehaved. When I recompiled with debug, the problem went away! This had me scratching my head. Veteran coders probably have figured out why running with debug turned on "fixed" the problem. Yep, the problem was timing dependant. The printf statements slowed down execution just enough that the timing worked!
BTW, ATmega328 contains debugging hardware named debugWire. Inly uses one pin and has not many HW-breakpoints, but in general it works. But yeah, I never had a „probe“ for it, while with ARM it was just a 8€ usb dongle.
i was gonna say a JTAG adapter is too expensive just for a bit of debugging...but that ESP-Prog is just the right price!..Thanks Andreas :) nice to hear Neil Armstrong quoted correctly too!..
@@AndreasSpiess we dont all do this for a living tho..nothing i make is made commercial..and im not making money from youtube vids!...for the price of the "full blown" JTAG id rather eat for 2 weeks! :P
I stopped to optimize only money. At my age, "Life quality" has to be optimized. And eating a little less would also enhance my "life quality" if you know what I mean ;-)
Great video. Inline debugging is the biggest thing I miss, with arduino and esp chips. Spending hrs trying to find a simple bug which would have taken minutes with a debugger. Why I liked using pic's. Watch out ESP32 here I come, well I will be after the Ali Express 1 month wait.
IIRC the Atmega32 has JTAG too, which messes with some pins in factory-new controllers. I remember having to disable it via the fuse-bits before programming. It is an old chip, probably as old as the Atmega8.
Great, but I am not sure about the poweriing of the ESP-prog... Do you connect ESP-VDD somewhere to the ESP32 ? or do you have 2 USB cables to the PC ? A wiring diagram could help, Thanks a lot, Alain
This is fabulous. It makes the esp32 a “professional” processor, at a ridiculous price. What a find. Thank you Andreas. I was a bit confused by your use of “step over” though. I have always thought that meant skip the next line of code, and step into was to execute the next line of code. Is this debugger unable to skip a line of code? I am quite impressed with your entire library of videos available and grateful to you for them.
As for now, it's not necessary to use PlatformIO; actually, it makes things more complicated. Right now it's better to use Espressif's ESP-IDF VS Code Extension. As a JTAG adapter one can use an FT232H (or FT2232H) based board. They can serve even more than just JTAG.
You are right. But I decided to use the Arduino Framework on this channel because it also can be used for Atmel and STM32 chips. And it is supported with many libraries. That is why we use PlatformIO. If I remember right, the Espressif board in the video uses an FT2232H chip.
@@AndreasSpiess I see; for multiplatform Arduino, PlatformIO sounds like a good choice. About the board I don't know, just at 12:25 you're showing (for many hobbyists) relatively expensive JTAG adapter. And I'd say it's enough to grab some board with one of those FTDI chips. ESP-PROG (for about 15€ on Ali) for example, is nothing but a FT2232H based board which uses two channels from the chip; one for JTAG, one for UART programming. But it's fine to just get one channel version with FT232H (for about 8€ on Ali). It can do both, just to the target module needs to be connected either to UART or JTAG pins. And it's not even uncommon that users program target chips over JTAG (right before debugging session starts), so that whole UART thing might be dropped, IMHO.
@@victoriamotion7980 Thats a comment I only understood AFTER I received my ESP-PROG board and noticed that its not much more than a dual channel USB-Serial adaptor with some interface connectors. Its ok though. Thanks for writing it.
I've done a lot of embedded and system programming with only a serial and/or LCD interface for debugging (at best). Worst case was an x86 project where my assembly polling code kept freezing up. I later found out that another programmer made changes to an interrupt routine and his PUSHA/POPA guard instructions needed to be upgraded to PUSHAD/POPAD. Lost several days of work over that one. Inline debugging is the best.
Good luck getting that working. I have an atmel ice, but couldn't get debugging working with an uno. I think a fuse needs to be set and that requires a "high voltage" programmer, which the ice is not.
I'm late to the game, pardon me. But I have to add that Atmel sold the "ATMega Xplained Mini" for the 328P and 328PB that came with a debugger on board. Perhaps these are still available - they were $8.88, I remember. At the time I was using Atmel Studio to conduct the debuging. The super cool part was that the registers were available and one could tweek bits while debugging if they wanted to.
One, not just "newer AVR's" support jtag. Just going one step above 328's also adds JTAG. I know I've seen the pinouts on the 644/1284 datasheet. So you can even pick up JTAG with a chip supported by Arduino that also comes in a DIL package. Second, you made my inner Tux cringe with that Windoze IDE thingy. Will this work with Atom and Platform IO? Lastly, while I have watched it at least twice, and still haven't tried it, LadyAda did a live stream a few years ago showing how Adafruit uses OpenOCD with a raspberry π. I think that has similar functionality. I saved that upload in a publicly listed playlist with OpenOCD in the name if you haven't seen it or are interested but can't find it. Thanks for the upload. -Jake
I will try it once I get the new Arduino Nanos. And these inline debuggers are very similar. Not complicated at the surface, but quite complex in the background
If you have armel icd like avr dragon or avr ice you can debug smaller chips. I used dragon for debugging attiny2313 with debugwire :) Debugwire uses reset pin so you can use normal spi programming interface to debug. eg ATMega328 supports debugwire that arduino nano have. I haven't check does MPLAB Snap support debugwire but that's new debugger for AVR, ARM and PIC from Microchip. This is bare card and under 20 usd
Nice explanation of inline debugging. Thank you. Only one note and some "provocative" questions. There are lot of reasons why inline debugging is not so popular like in the past, for example in the time of 8080 processor (1985). The reasons are multithreading and thousands of external events per second from wifi, i2c, spi, one wire sensors, interrupts, buttons... External events is hard to stop. When you stop processor you lose real time, connection to the sever, external events and many more... Ofcourse for very simple applications like debugging of blinking led it is possible. But for simple application do we need it? Is it posible to replace "stupid" real time logging via serial interface with inline debugger? What is main task of inline debugging?
You are right with your comments. But since we do small projects with our MCUs it still can help. I would not recommend it for a server ;-) Maybe you can set the breakpoints at particular areas where you can stop the CPU without hurting the functioning. Or you debug your sketch without WiFi at the beginning... Just ideas. Debugging real-time systems always was tricky, even back then.
@@AndreasSpiess is it possible to catch "kernel panic" with inline debugger? I mean, for example, stack corruption, heap corruption or unwanted memory overwriting? What posibilities have breakpoints? Can we see stack dump of all threads when processor stops?
Very valuable info. Now to order the Expresive JTAG board. But because of the CoronoVirus restictions (03.31.20), it may be summer time before I can play with these new toys! AARG..... Thanks Andreas for this great info and explanation. You do great work........
Inline debugging is one of the biggest reason why I prefer STM platform. Nice to hear that, it can also be accessed on ESP platform. But, I feel even that Chinese JTAG hardware is quite expensive at $15. In STM world, Chinese debugging hardware for STM (STLink) only cost $3 - $4. I can hope that, the prices for ESP debugger might change if it become more and more popular.
Just keep in mind that you can use a lot of other devices to debug ESP32, and not only the two shown in the video. For example, one can use an FTDI Chip: docs.platformio.org/en/latest/plus/debugging.html#debugging-tools
This is one of the more expensive channels :-) Just made an order of 1 esp-prog.
Not being able to do in-circuit debugging has always been a show stopper me doing more advanced programs on ESP and ATMEL micros.
You can use Atmel Studio and ICE with Atmel micros. only real issue: I've bricked a few micros for the same silly reason. :(
you need a high voltage programmer to unbrick them.
@@Chris-rg6nm could you give some details?
Reminds me of the latest ESP32: www.crowdsupply.com/thomas-mckahan/obsidian-esp32
Perhaps too quick, it seems that I could have used my Segger JLink, does anyone have some experience with that?
I have my lovely AVR Dragon. Old but good also support atmel debugwire (ATTiny series) :)
Also nice to have is msp launchpad (new version support usb 3.0 controllers) and stm discovery board
Possibly the most important video you've made so far. This will release thousands from the 'irons' of the current environment.
I also liked to produce this one...
I always your videos to the very end.... my whole family loves the "BYE" at the end.
Thank you. And greetings to your family!
Ah the 'bleeding edge' and despite the warnings I know I'm going to fall down the same holes as you. Concise and inspiring as ever, thanks Andreas.
Now you were #1 ;-)
This is not a hole, this is a highlight in my opinion!
Hello Richard😁🏴 looking forward to your next video 👍
@@deangreenhough3479 Thanks Dean but you should not mention my pathetic offerings on our God's channel! :)
Thank you Andreas & everyone who is involved in making this possible!
Got my first ESP32 last week.
I know I'm late but Arduino & ESP8266 & TI Launchpad was enough before.
But now I'm hooked on the ESP32 drug! =)
And there's sooo many boards to try!
Thank you once again. =)
You are welcome. I am sure you will like the ESP32
My life just changed significantly. Thanks!!!
Glad to read that!
I will second that. I just got some code debugged and it felt great. People in the education business will have plenty of reasons now to use the ESP32 and have their students' stuff debugged at the source level.
Great video, yes, want one. Also you could use the "static" keyword to keep your local variable in its associated function without making it a global. It will then keep its value between calls.
Thanks for the hint!
Beat me to the thing I wanted to point out. I don't know why, but I have an aversion to global variables and much rather keep things with the associated function that is using them when possible.
Great advice
I used to be confused with something like :
*static int var=0;*
In the beginning of a function because I thought when the function runs again the var gets set back to *0* :)
Also "volatile" to make sure the compiler doesn't compile out variables that don't actually do anything (useful to count the number of times you've hit a function).
Your videos and all the work you put in are so valuable to us Andreas! I save a ton of time with your shared experience. Thanks a lot.
You are welcome!
Excellent, exactly the same editor and way of working through my C# code windows program in Studio 2017.
Wow! Thanks Andreas, always wondered about this stuff, time to go shopping! (Big thanks to the platformIO team too.... )
Enjoy!
Thanks Andreas! Nice to know that PIO debugger is become free!
PS: 14-15 September there will be CERN Open Days and they are really worth a trip!
I put it into my calendar. Maybe...
Big thank you! -- this is will take me from the Arduino side over to PlatformIO
Same here ;-)
Indeed, just added PIO to my VSCode and I must say I like the compile feedback far more than the dark side of the moon affair with the Arduino builds :-)
OMG Andreas! This is HUGE! I've tried doing this before with a different debugger with limited success. Thank you for sharing your success path! Ten thumbs ups!!
Thank you. I think, many of us like the news...
This is one of the best videos done Andreas. We really hope you could go into much more details about this topic in future. We learnt a lot from this video. Thanks a lot. Bless you.
I think everybody has to use it and learn from now. I am not sure if I will dig much deeper here, at least not on video.
@@AndreasSpiess Thats allright. You directed a lot of people in the right direction.
Inline debugging and preliminary ULP support for ESP32 in pio: like xmas and easter at the same time! Thanks platformio for making that possible and thanks Andreas for paving the way!
You are welcome!
@@AndreasSpiess it works on my linux box! Coool! :)
Incredible level of debugging control! And it did not cost much at all. THANK YOU! Rekindled my interest in working with ESP32. Fabulous video! :)
Indeed, a very useful feature!
Thanks for making this video.
It's so hard to explain how easy debugging can be.
Showing how it works was the only way I found...
Andreas, as an influencer, the more you promote useful tools like this one, more available and cheap they will become.
Thank you so much for this, and keep trying new stuff!
Also I am waiting for your video on unit testing for Arduino and ESP.
I have no plans for the unit testing so far. But you never know...
I was able to do inline debugging for ESP32 about 1 year ago but only using Espressif WROVER kit and ESP-IDF framework. But your Arduino framework is SO much easier.
I used PIO also for the WROVER. It worked, too
@@AndreasSpiess Hello Andreas, when using the WROVER kit do I (still) need to use the ESP-prog device? thanks.
If you use the (50$) kit, JTAG is built-in. You just have to add all the jumpers on the JTAG pins (according to the description)
Absolutely awesome and already placed the order at Aliexpress. Until now I was excepting that debugging these microcontollers is just out range and will never work. Will stay on Patreon, because these are the videos with really big value.
Thank you for your support! I really liked to create this video, because I always wanted this feature...
You demystified JTAG debugging for me, so much so FedEx dropped off my Olimex ARM-USB-TINY-H yesterday.
Following this video I was running and debugging in less than an hour. Great video as always!
Good to know the that the video was useful for you.
This is over my head. I was studying electronic assembly 38 years ago.
The same here before I learned it ;-) My age is 65.
Always finding new interesting videos on your channel - a "swiss mountain" of information it is
Glad you like the channel!
A great feature to have especially for the price you pay for the ESP-PROG. Andreas many thanks for this great video. It makes life so much easier to learn this way. Keep up the good work.
Glad it was helpful!
Thank you Andreas. A real breakthrough in ESP32 programming. Debugging was the thing we were waiting for.
You are welcome!
Wow, this is a game changer for sure. I hope I can get some time to try this out. I've been hesitating about working with the ESP32 (as I have a bunch of other Arduinos and compatibles already) but if I can get this working there's no excuse now.
I would really love to see you come back to this from time to time with updates as you continue to work with this system and figure other things out, and perhaps as PIO addresses any issues you've run into.
We will see. I have many topics to cover, so usually I only come back for substantial changes
@@AndreasSpiess Yes. I would , think you would only want revisit this if you find something really significantly interesting (as you have done with a few other videos) but of course that also assumes you continue with it yourself. Looking at the comments there seems to be a lot of people very interested in this, so I guess you'd want to consider that as well. I really hope I have time for this myself soon. The library of information you are building on this channel is really amazing.
Dear Andreas, thanks for another very nice video on a Sunday morning. Another alternative for a JTAG adapter is named „Mini USB Blaster“ (a white and blue enclosure) for around 2-3€ on AliExpress. I‘ve used it for quite some time together with Eclipse, but it should work with PIO as well.
Maybe you try it with this setup? It would be beneficial for my viewers if they can buy an even cheaper adapter.
I gave it a short try, but there does not seem to be a config option for the Altera USB Blaster (yet). My few experiments didn‘t yield any usable results...
Since I‘ll be away from my playthings for 1-3 months (work-related) I cannot follow up on this in the next weeks. I have put it on my list, though, for later experimentation
It took way longer than expected, but there is now a better description of how to use the Altera USB Blaster and its problems. So actually I would not suggest to buy it. Here is the link: www.esp32.com/viewtopic.php?t=9901
Thanks mate. This is the one thing that has really held me back - not just useful for debugging, but also a great way to learn and experiment. I hope you're getting a commission - I just bought one.
And I Hope you get one. The supplier is maybe overwhelmed!
Unbelievably cool and informative video man! Well done! Exactly what I have been looking for, for years! Just in time. Love your clear, direct, and still detailed style! Long lives your channel and you!
Glad it helped! And thank you for your nice words.
@@AndreasSpiess helped?? Are you kidding me! Already ordered the ESP prog gears for debugging! Hats off! You rock! I am going to try it with Visual Studio + visual micro combination, as I am not too certain about platform io. Have it a try few years ago, and ended up in lots of grief and frustration. Is it much better now? Also, can it be added straight on visual studio together with visual micro, asking cause I can see you are using visual studio. Cheers
@@AndreasSpiess you are natural, wise and very knowledgeable yet down to earth simple in approach, detailed and hard core, yet no fluff, straight to the point! Very rare combination. Well done man, I mean it. 👍👍
Many of my viewers use plaformio and are happy with it. I use VisualMicro because it is more Ardhuino IDE compatible and my "Channel IDE" remains the Arduino IDE.
Thank you for the video. Makers owe you a lot!
You are welcome!
YES! Andreas, You're absolutely right : this will be a true life changer for me as well. I'm used to work with debuggers in the programming languages I use on a dayly basis and and always found it more than tedious to do my arduino programming without. Especially as I am not as safe and sound in C++ as I am inmy other languages.
-When it comes to referencing and dereferencing of pointers I sometimes have to enter the area of guesswork or trial and error.
- Optimizing code by testing different variants and approaches is very time consuming.When it comes to debuging.
- Debugging data types via the serial monitor is not always working as expected, as it does its own conversions or requires manual conversion prior display, which sometimes covers up the problem.
- Stupid errors like expecting a float value froma division of two integers without conversion
- ....
I actually knew about the inline debugging capabilites of platformio, but at the time I read about it, it was available in the commerical version only and was no option for the projects I did at that time. So I did not pay attention, when You made this video back then.
Just when I accidentally heard about the esp-prog a few days ago, I looked into it again and remembered that You had done a video on that subject. Now I find it hard to wait until I get the debugger. I've not directly found a source that delivers from within Germany. So it seems, I'll have to get it from China and be patient.
Despite the fact, that on an esp8266 only a few usable pins remain,I still think,it will be a huge support even for these boards. Especially,when it is about conceptual / structural debugging.
Excelent, as always!
Thanks and regards
Frank
I hope the "ship" from China is fast ;-)
@@AndreasSpiess it seems, they are using a rowboad :-) ... I've waited so long, I'll get through this as well.
been waiting for this for a while - thanks for doing such a great video and making life easier for ALL makers
I hope so...
Hey, I used an "Intel Blue Box" just like that one in my first job at age 17, writing PL/M code on our custom 8085 audio spectrum analyzer board. The debugger hardware was two large Intel circuit boards that would just get flaky after a while - we would pull the boards, rub the back with aluminum foil, stick them back in and keep working.
Now we're both here 40 years later playing with ESP32 hardware debuggers!
I also started with this rack in the 1970s...
Thanks a million! You just changed the way I deal with the ESP32 once and for all. I followed your tutorial and I can assure everybody that it works perfectly! Do not forget to replace the drivers using the Zadig driver installer. I did and it did not work. I had to go and watch the video a second time and it worked once I replaced the drivers.
Interestingly enough, the code always goes to the FreeRTOS when debugging at the source code level. It makes it even more obvious that FreeRTOS is an integral part of the ESP32 Arduino libraries. Debugging will lead you there no matter what. I simply stepped out of the FreeRTOS stuff because I was more interested in my code than any RTOS kernel stuff.
On a different note: Who are the morons who disliked this video? Do they even know what they were looking at when they watched your video?
Thank you for sharing your experience! I always get a fer buttons down. Some of them quite fast. They are maybe even subscribers for that reason...
@@AndreasSpiess You know what? To hell with these idiots. It's because of RUclipsrs like you that knowledge is spreading quickly.
Thanks a million and please continue to make and share more videos.
You have a loyal subscriber to your channel now.
Thanks so much for this Andreas! Saved me a heap of time getting up and running with this little debug module. Such great content!
Glad it helped! PlatformIO is really a good tool.
Although I'm familiar with inline debugging from other platforms, it's rather complicated to use for ESP32 until the board manufacturers will use a standardised connector. My standard way of debugging, 99% ESP8266, is to use MQTT. In this way I can both "print" messages and also input data if I want to. I can do similar things as conditional breakpoints or logging, or conditional input controlled by MQTT. My first upload with a new project is always a simple standard sketch that replaces serial load with OTA over Wifi and has some standard topics for debug and reporting when a devices boots or restarts. In this way it is really fast to make changes to the code for debugging purposes. I never use the serial terminal since I'm used to making continuous improvements to my sketches with the devices long away from my computer. OTA and MQTT makes it possible to make changes and corrections without having the device connected physically. "JTAG" over Wifi supported by the chipset itself would however be very useful, with even having to use a JTAG physical connector...
hanpa Home Automation Do you have a github repo on this or links to an article?
Interesting idea...
@@bollie9752 No. It's basically just having a debug topic for outgoing messages instead of Serial.print and then listening to this topic in a shell or by logging to a file. If you want to change the program flow in some way you can have incoming debug topics for values or triggers. A trigger can just set a variable or a simple if statement in the code can do something that affects the program flow e.g. by assigning some variables, skipping a section of the code or whatever. I only do this when something is not working as intended but I also have a standard topic for all my clients and a listener on my server that logs this to a text file. I use this to check when a device has rebooted and to which IP/mac-address, the RSSI dB value, name and version of the sketch etc. Like this (one row in the log file):
19-06-23 11:43: NeoPixelAlertIndicator1 BOOT 192.168.0.154 60:01:94:39:72:85 RSSI(dBm):-54 NeoPixelAlertIndicator 1.4 2018-08-25 Hans Palm
Nice! I know EXACTLY what you mean when you say, "...and I know what I'm talking about",
(Lol, Good job explaining those traps for new players!) Thank you.
You are welcome!
1:58 - Also, using the serial port to debug doesn't work at all if the serial port is used by the sketch for something else.
Also, using the serial port, even just invoking it and not using it, consumes more electrical power. Important if you are zoned into low power devices.
I didn't see this issue you are referencing. Everything worked fine for me the first time around. The only annoying thing I dealt with was having to step through some FreeRTOS code. Other than that, it was an absolute delight to step through my code any way I wanted. The assembled code was also listed and you can debug through it if that's your thing.
Thanks Andreas, already got the board a few week ago, finally got some time to install and test.
Just got the the debugger running.
Good! I am glad it works.
Super video. Thank you so much. You really helped me get up to speed with ESP32. I just bought the ESP PROG and it works really nicely.
👍👍👍
Glad it helped
I just started to use PlatformIO with VScode (Arduino Platform). A bit of a learning curve, but I love it.
On to my comment about debugging. I already had a J-Link, so I hooked it up to an ESP32_Devkitc_V4 that I just bought. I had to use Zadig to install the WinUSB driver, just as you did for the FTDI debugger. Then I set "debug_tool = jlink".
PlatformIO recognized the J-Link, but when running the debugger, I got an error, and the debugger stopped. A Google search told me that I needed to hook up pin 1 (VT) on the J-Link to 3.3 V on the ESP32. Now it works well.
Thanks for the excellent (as always) video.
RTFM helps sometimes ;-)
Good job. You are on top of this stuff!
Thank you!
Thanks for the video - I ordered one and can't wait to start using the debugger. Nice work ;)
Hope you enjoy it!
Greetings from your favourite fan in Zimbabwe
Greetings back from Switzerland
Thanks for all the great video's Andreas!
Thank you for your support!
Great subject and the ESP Debugger is already on order😁 sweet✅ Thank you Andreas on this very important subject. 🏴 I hope to see another video delving deeper and it’s applications 😁🏴
I am not sure if deeper will be mainstream ;-) But I am sure you will be able to dig as deep as you want if you have it running...
Greutzi Andreas, thank you for this video, most helpful. I liked and subscribed. I'm glad you were excited by your first debugger - as excited as the Moon landing! One small nit about your video, Astronaut Neil Armstrong was so excited he forgot to say "a man" and instead said "That's one small step for man, one giant leap for mankind." :-) I just received my ESP-prog board. Can't wait for the missing 'a' in learning how to use it! -Frank
Thank you for the addition. So I was a little less excited and added the "a" ,-)
@@AndreasSpiess I followed your videos' instructions to get the ESP Dev board wired to an esp32 wroom board. It was about 1:00 a.m. when realized the second USB micro cable I have is one of those stupid stupid power only cables. I threw my head back and yelled up to the USB cable God.... 'no!' hehehe. The USB cable shop opens here in about 2 hours. Jtag debugging shall be mine today! 😃
Hi Andreas, great video! Good to see this in action. Thank you for your time and effort!
You are welcome!
Instead of the Espressif or Olimex adapter, I've successfully used FT232H boards (CJMCU FT232H). They are about USD 7.00 on Aliexpress. The pin mapping is: TDI -> AD1; TDO -> AD2; TCK -> AD0; TMS -> AD3. I've used a Mac with OpenOCD however and don't know if it works with Zadig.
Maybe you try it in this config? It would be beneficial if we get an even cheaper adapter. The problem I see is not Zadig, it is to choose the right definition file in platformIO.ini (and if one is available)
@@AndreasSpiess It turns out that FT2232HL (such as the CJMCU FT2232HL) boards are even better. They are a drop-in replacement for ESP-PROG board. With exactly the same configuration in PlatformIO, on Windows (Zadig) and MacOS (sudo kextunload -b com.FTDI.driver.FTDIUSBSerialDriver) it just work. That's no surprise as the ESP-PROG board is in fact at FT2232HL board. And it uses OpenOCD in the background. The CJMCU FT2232HL is about USD 9 on Ebay and Aliexpress. The slightly cheaper CJMCU FT232H board (USD 7) can also be used. But it requires some fiddling in the OpenOCD configuration files as the USB product ID is 0x6014 (as opposed to 0x6010); otherwise the device is not found.
Thank you for your info! Could you give us a little more info on which file to change, where to find the product ID etc.? There are quite a few cheap FTDI boards on Aliexpress and with your help, we maybe could make them run...
@@AndreasSpiess The details can be found in these instructions: medium.com/@manuel.bl/low-cost-esp32-in-circuit-debugging-dbbee39e508b
How about the drivers for Linux? Could you please help me with this.
If you have the JTAG adapter connected, you can upload the program via the debugger, at 20 MBit/s. Just add “upload_protocol = esp-prog” to platform.ini. You can then disconnect the USB cable to the dev board and replace it with 3.3V supply from the adapter to the dev board.
So far I thought you need the second channel to do that and you have to connect this channel also to the chip. I did not know it runs on the JTAG wires.
Mouser is selling the ESP-PROG for 11,35€! Much cheaper than the Chinese suppliers. It is out of stock now but restock is planned for next week.
Here it says 7 weeks :-( And postage is around 10$.
@@AndreasSpiess Here it says 142 units on 02-jul-19, but sometimes they don't respect this. 7 weeks is the factory lead time. At least in my country they offer free shipping above 50€. I forgot to mention the value is without VAT.
Great video. Thanks. Another purchase is on it's way. One thing to watch is that the more highly integrated esp32 boards often use the jtag pins for their other functions, so it may be necessary to debug libraries on another board before including in final target. I use Ttgo T4 for some quick project as it has a lot of functions but has assigned all jtag pinsvto other functions. Perhaps future designs will leave jtag free if it becomes more popular.
You are right. Maybe suppliers will include a jtag connector after this video ;-)
Thankyou Andreas for this great tutorial once again. I've known about inline debugging for quite a while since my university days, but to see it explained in the most modern of IDE (VSCode) and HW (ESP32) is a fresh reminder that the more things change the more they stay the same.
You are right. But now we can use it free of charge. This is probably new ;-)
Wow, wow, wow it's quite incredible how how you can keep coming up with so useful and instructive videos.
I was wondering what you have for breakfast because I could do with some of that brilliance.
I particularly liked the making of this video because it fulfilled a longtime wish of me...
I'd subscribe to your channel twice if I could! Your content is very interesting, entertaining and useful to me. You are an awesome and inspiring man Andreas. Love and hugs from Chile to the guy with the Swiss accent :)
Thank you for your nice words!
Great ! I was waiting for this. You are too. Keep it good job Andreas.
Thanks, will do!
Maybe a silly question, but why move localVariable to make it global?
You can keep it local but just define it as "static int localVariable;". This preserves it as a local variable bit prevents the redeclation and this prevents it being reset.
You are right.
And you can even initialise it, which will happen once, when the program is started: static int i=0;
Bravissimo!!!
From the guy with the austrian accent......
I have still one incuircit emulater from Keil, but for the 8031.
Regards and THANKS
Time to change ;-)
Great video Andreas! ... This remember's me to my first job (long long ago) where we created a (expensive) hardware for JTAG debugging support for the pentium processor. The main focus was to enable conditional breakpoints (as you showed) very fast. You always have to stop the processor put in some serial bitstream into the pins to get the needed values out ... on a pentium this was ~1KBit ... For that we created a special ASIC (25 years ago!) to achieve this very fast. My job was the software ... I miss these days ;-)
And now we have it inside our 5$ chips ;-)
Btw. If somebody is interested how JTAG debugging works: The processor get's stopped .. all important registers of the CPU get copied into 'shadow' registers and this shadow registers can be 'clocked' out serial using a special protocol through the connected lines.
Also memory can be read and written that way. Sometimes CPUs have special debug registers that can be adressed also ... btw. many chips support a JTAG interface .... the cool thing is that you can chain them together if you have a larger circuit, but then it get's a real serial mess ;-)
Thanks for the details. Dave J. did one a video where he also mentioned the "serialization". But it was less for processors and more for "boundary checks" of ordinary HW. For processors, I would assume you would spend the money for a second adapter to reduce the complexity of the software.
By the way there is stm32 boards called NUCLEO which include debugger on board, prices starting from 10€. And this is ARM
Do you have a link please?
@@northshorepx All STM32 chips support remote debugging using their SWD interface, which is exposed as pins on the blue pill / maple boards for example. The Nucleo dev boards from ST have an STLink-V2 included on the board, which is identical to the cheap standalone STLink-V2 USB devices you can find online for a few dollars. A J-Link can achieve the same thing.
You can program and debug through this interface.
The ARM boards use the ST-Link style interface, which is logically similar to JTAG, but a different wire-protocol (SWD - Serial Wire Debug). I'm pretty sure that the ESP32 microprocessor cores do not implement the ARM debugger port in their hardware. Thus the need for a JTAG physical interface. The adapters referenced (including ST-Link style) translate higher level GDB primitives (read/write memory, examine/set CPU registers, etc.) into specific debugging register accesses, via some physical protocol (SWD or JTAG, depending on the CPU and debugger interface.)
Andreas, first thaks for everything!
I got a Segger J-link, it's what i could get here in Brazil in a fast pace, and it helped me a lot. I got it working better in Linux than Windows. on Windows sometimes the debugger didn`t work at all. openOCD couldn`t find it.
So i`m working on Ubuntu and it runs fine, and by the way, compilation seems faster =)
Thank you for sharing your experience. Linux still is the platform of choice for many projects.
Thank's Andreas, Once again you make my day! (not for my wallet) You've got great content! Time to order one and the data analyser too :)
You are welcome!
Interesting... got love all the Arduino developments...
LOL - I was building systems back in 70s to 90s - I remember using those Intel MDS-80 development stations with the 8 inch floppies.
Recently been looking to get back in for some hobby projects.
Funny part is in the videos I saw there seemed to be no In-line debugger or emulator; I was very Puzzled,... CERTAINLY NO ONE WOULD BE DEVELOPING CODE WITHOUT ONE!! LOL - Thankyou for the video - definitely adding this to the list !!!!
Same as me. Now we do no more need emulators. We use the chip itself.
Klasse und Grüezi in die Schweiz!
Danke!
This sure would have helped last summer with debugging the tank communications problems.
That brings up another situation where serial debugging does not work well
Debugging a crash. The serial writes are cached; so, the messages go out after a delay - and sometimes not at all when a crash occurs.
This can mislead you regarding where the code is crashing.
The Espressif IDE has a possibility to invoke the debugger after a crash to find out the last steps before. Maybe this is also available in PIO/Arduino framework. I do not know.
Today I got my esp-prog board to work on my mac with help of this video (which inspired me to buy the esp-prog in the first place). I now am able to both program (upload), monitor and debug the ESP32 (I tried the SBC-NODEMCU-ESP32 from JOY-IT) over a single USB connection. I did run into some small problems. My advice is to install the official FTDI VCP driver for the MAC OS you are running (I'm at a beta of 10.15.5 currently). Then LEAVE THE PORT SETTING FOR THE DEBUG PORT EMPTY, but use the 'xxx01' port for the upload and the monitor port.
Still I don't like the VS Code environtment that much. Maybe after some time I will learn to appreciate it. But even if I don't like it for programming, I still can use it to debug the ESP32 projects now.
Next on my list is to create a jig to easily cable up the NodeMCU to the ESP-prog. I'm thinking about designing a PCB with feed-through header pins or so.
I have a few development boards laying around which I use to start every project. Only after the code is already working I change to the target. You could add such a Jig to such development boards...
For your information you could of declared "localVariable" as static like :-
static int localVariable = 0;
With the static keyword the variable will not be destroyed when out of scope (exiting the loop routine)
It will retain its value the next time loop is called unlike your dynamic variable that gets created each time you call loop.
The "= 0" (assignment of zero) only gets called once during creation.
The reason why this may be a better choice is because no other routine can see or more importantly change the contents of "localVariable"
Which may be a better choice that making "localVariable" accessible to everyone (all routines) in some cases.
Depends whether you want other routines to see the variable.
Welcome to the world of debugging. 😃
I agree. But my choice was better for my video ;-) Plus, I am unsure why I would prefer static variables over global ones.
This is a game-changer!
I think so, too.
Great video :) It would be awesome, if you did a video on using the second serial port on the esp-prog.
For the newbee like me, it would be worth mentioning (in addition) to just connect one usb cable to programmer (es-prog in my case) and that the programming happens thru the jtag.
I learn that the hard way.
Sorry for forgetting to mention that fact!
@@AndreasSpiess Please also show how to use Serial port with ESP-PROG. That would really save connecting both (esp32 as well as esp-prog) to the power supply. Atleast you say the setting in the platform.ini file for the serial via esp-prog. please
I remember "poor man's debugging" in C using printf statements. I then made a debug_print macro that was a printf embedded inside a "#ifdef _debug". That way I could recompile with or without _debug defined.
This totally confused me. When I compiled and ran the program without debug, it misbehaved. When I recompiled with debug, the problem went away!
This had me scratching my head. Veteran coders probably have figured out why running with debug turned on "fixed" the problem.
Yep, the problem was timing dependant. The printf statements slowed down execution just enough that the timing worked!
This happens sometimes. More often it happens to me that the SW does not work properly with debugging on becasue of too slow speed...
Another video with ZERO dislikes 👏
Up till now ;-)
AVRs have something called "Debug Wire". I have used it with Atmel Studio about 10 years ago.
Yes, but AFAIK it was never integrated into Arduino
BTW, ATmega328 contains debugging hardware named debugWire. Inly uses one pin and has not many HW-breakpoints, but in general it works.
But yeah, I never had a „probe“ for it, while with ARM it was just a 8€ usb dongle.
Unfortunately, DebugWire only works with the proprietary IDE (AFAIK)
i was gonna say a JTAG adapter is too expensive just for a bit of debugging...but that ESP-Prog is just the right price!..Thanks Andreas :)
nice to hear Neil Armstrong quoted correctly too!..
For me, the JTAG adapter is an investment, not an expense. I expect quite some return of it...
@@AndreasSpiess we dont all do this for a living tho..nothing i make is made commercial..and im not making money from youtube vids!...for the price of the "full blown" JTAG id rather eat for 2 weeks! :P
I stopped to optimize only money. At my age, "Life quality" has to be optimized. And eating a little less would also enhance my "life quality" if you know what I mean ;-)
@@AndreasSpiess JTAG can be more expensive as it has a lot of not well-known features. Please have a look at EEVblog #499 what JTAG is capable of.
Great video. Inline debugging is the biggest thing I miss, with arduino and esp chips. Spending hrs trying to find a simple bug which would have taken minutes with a debugger. Why I liked using pic's. Watch out ESP32 here I come, well I will be after the Ali Express 1 month wait.
Hopefully it arrives faster ;-)
Another super video - thanks for making!
My pleasure!
IIRC the Atmega32 has JTAG too, which messes with some pins in factory-new controllers. I remember having to disable it via the fuse-bits before programming. It is an old chip, probably as old as the Atmega8.
As mentioned, the new bunch of Arduinos also uses processors which should support JTAG. We will see... The new Nanos are ordered...
@@AndreasSpiess Looking forward to it. The Atmega32 is quite different from the Atmega328 used on the Nanos.
The new Nanos use a ATMega4809 chip...
Bravo, as usual!
Thank you!
Thank You for the work! I have got also the Email, and had no time to test. Now you have done the work, which helps very much!
Great, but I am not sure about the poweriing of the ESP-prog...
Do you connect ESP-VDD somewhere to the ESP32 ?
or do you have 2 USB cables to the PC ?
A wiring diagram could help,
Thanks a lot,
Alain
So far I used two cables (JTAG in addition to the normal .cable But I read that you can load the sketch also through the JTAG connection.
@@AndreasSpiess
It is what I did, and, thanks God and Andreas, it works (from to day...). It is a tremendous progress in the IDE world.
Excellent video. Glad I found it. Even if I was late to the party.
It is never too late to start with inline debugging ;-)
@@AndreasSpiess got my debugger coming from Banggood. Thanks again :)
This is fabulous. It makes the esp32 a “professional” processor, at a ridiculous price. What a find. Thank you Andreas.
I was a bit confused by your use of “step over” though. I have always thought that meant skip the next line of code, and step into was to execute the next line of code. Is this debugger unable to skip a line of code?
I am quite impressed with your entire library of videos available and grateful to you for them.
Step-over means here that you do not step in... I do not find a button to skip a line. Would also not be very important for me.
Thank you
As for now, it's not necessary to use PlatformIO; actually, it makes things more complicated. Right now it's better to use Espressif's ESP-IDF VS Code Extension. As a JTAG adapter one can use an FT232H (or FT2232H) based board. They can serve even more than just JTAG.
You are right. But I decided to use the Arduino Framework on this channel because it also can be used for Atmel and STM32 chips. And it is supported with many libraries. That is why we use PlatformIO. If I remember right, the Espressif board in the video uses an FT2232H chip.
@@AndreasSpiess I see; for multiplatform Arduino, PlatformIO sounds like a good choice. About the board I don't know, just at 12:25 you're showing (for many hobbyists) relatively expensive JTAG adapter. And I'd say it's enough to grab some board with one of those FTDI chips. ESP-PROG (for about 15€ on Ali) for example, is nothing but a FT2232H based board which uses two channels from the chip; one for JTAG, one for UART programming. But it's fine to just get one channel version with FT232H (for about 8€ on Ali). It can do both, just to the target module needs to be connected either to UART or JTAG pins. And it's not even uncommon that users program target chips over JTAG (right before debugging session starts), so that whole UART thing might be dropped, IMHO.
@@victoriamotion7980 Thats a comment I only understood AFTER I received my ESP-PROG board and noticed that its not much more than a dual channel USB-Serial adaptor with some interface connectors.
Its ok though.
Thanks for writing it.
I've done a lot of embedded and system programming with only a serial and/or LCD interface for debugging (at best). Worst case was an x86 project where my assembly polling code kept freezing up. I later found out that another programmer made changes to an interrupt routine and his PUSHA/POPA guard instructions needed to be upgraded to PUSHAD/POPAD. Lost several days of work over that one. Inline debugging is the best.
Definitively. But so far it was not cheap for a Maker like me...
just for the record: "older" AVRs can be debugged similar, they just don't use JTAG, but debugWire - which only uses one pin, instead of four...
I knew it. But I never saw a tool for Arduino which used it.
Good luck getting that working. I have an atmel ice, but couldn't get debugging working with an uno. I think a fuse needs to be set and that requires a "high voltage" programmer, which the ice is not.
I'm late to the game, pardon me. But I have to add that Atmel sold the "ATMega Xplained Mini" for the 328P and 328PB that came with a debugger on board. Perhaps these are still available - they were $8.88, I remember. At the time I was using Atmel Studio to conduct the debuging. The super cool part was that the registers were available and one could tweek bits while debugging if they wanted to.
Essential information. Many thanks!
You are welcome!
Super 👍
Thank you!
One, not just "newer AVR's" support jtag. Just going one step above 328's also adds JTAG. I know I've seen the pinouts on the 644/1284 datasheet. So you can even pick up JTAG with a chip supported by Arduino that also comes in a DIL package.
Second, you made my inner Tux cringe with that Windoze IDE thingy. Will this work with Atom and Platform IO?
Lastly, while I have watched it at least twice, and still haven't tried it, LadyAda did a live stream a few years ago showing how Adafruit uses OpenOCD with a raspberry π. I think that has similar functionality. I saved that upload in a publicly listed playlist with OpenOCD in the name if you haven't seen it or are interested but can't find it.
Thanks for the upload.
-Jake
I will try it once I get the new Arduino Nanos. And these inline debuggers are very similar. Not complicated at the surface, but quite complex in the background
If you have armel icd like avr dragon or avr ice you can debug smaller chips. I used dragon for debugging attiny2313 with debugwire :)
Debugwire uses reset pin so you can use normal spi programming interface to debug. eg ATMega328 supports debugwire that arduino nano have.
I haven't check does MPLAB Snap support debugwire but that's new debugger for AVR, ARM and PIC from Microchip. This is bare card and under 20 usd
Hey Andres, the Arduino Micro runs on the Atmega32u4 chip which has a built in JTAG Debugger. The JTAG pin out can be found in the 32u4 data sheet.
Thank you for your information!
Nice explanation of inline debugging. Thank you. Only one note and some "provocative" questions. There are lot of reasons why inline debugging is not so popular like in the past, for example in the time of 8080 processor (1985). The reasons are multithreading and thousands of external events per second from wifi, i2c, spi, one wire sensors, interrupts, buttons... External events is hard to stop. When you stop processor you lose real time, connection to the sever, external events and many more... Ofcourse for very simple applications like debugging of blinking led it is possible. But for simple application do we need it? Is it posible to replace "stupid" real time logging via serial interface with inline debugger? What is main task of inline debugging?
You are right with your comments. But since we do small projects with our MCUs it still can help. I would not recommend it for a server ;-)
Maybe you can set the breakpoints at particular areas where you can stop the CPU without hurting the functioning. Or you debug your sketch without WiFi at the beginning... Just ideas. Debugging real-time systems always was tricky, even back then.
@@AndreasSpiess is it possible to catch "kernel panic" with inline debugger? I mean, for example, stack corruption, heap corruption or unwanted memory overwriting? What posibilities have breakpoints? Can we see stack dump of all threads when processor stops?
You see the registers and all memory locations as well as processor flags. Also, all variables used by the "infrastructure"
I promised myself that I wouldn't be spending money. But I'm just going to need this.
I am sure this can be considered as an investment, not a spend ;-)
Option #2: Just make the local variable static. Then it stays in the local function scope, but the value persists across calls.
Youi are right!
Very valuable info. Now to order the Expresive JTAG board. But because of the CoronoVirus restictions (03.31.20), it may be summer time before I can play with these new toys! AARG.....
Thanks Andreas for this great info and explanation. You do great work........
Inline debugging is one of the biggest reason why I prefer STM platform. Nice to hear that, it can also be accessed on ESP platform. But, I feel even that Chinese JTAG hardware is quite expensive at $15. In STM world, Chinese debugging hardware for STM (STLink) only cost $3 - $4.
I can hope that, the prices for ESP debugger might change if it become more and more popular.
Maybe also other JTAG hardware is or will become supported. I do not know. The topic is too new for me...
If you only need to buy one debugger, do we really care if the price is $5 or $20? 😃
Can we use same hardware to debug arduino boards uno,nano etc?
No. They use a different standard and you need to use the Atmel software to do it.
@@AndreasSpiess Ok thanks
Great video. Thank you Andreas
Glad you liked it!
So is Platform IO now your programing IDE? I'm thinking of making the move. This video might have been what I needed.
I think so. I still have to use Arduino IDE for the videos, I think.
Great work Andreas!
Thank you!
Just keep in mind that you can use a lot of other devices to debug ESP32, and not only the two shown in the video.
For example, one can use an FTDI Chip: docs.platformio.org/en/latest/plus/debugging.html#debugging-tools
You are right. But I did not test them.