EspoTek / Labrador

EspoTek Labrador is a USB device that transforms your PC or smartphone into a fully-featured electronics lab. This repo holds all of the source code!
http://espotek.com
1.1k stars 116 forks source link

Debugging the firmware #257

Closed mmehari closed 6 months ago

mmehari commented 6 months ago

Hi,

My question is more of an understanding to the internals of the project rather than finding and fixing a bug, but I would expect you used debugging tools during the time you build the firmware.

I would guess it will be through the PDI interface (PDI_CLK and PDI_DATA) already integrated in the espotek hardware but I don't know further details on its operation.

If you had the experience, would you be kind to share me the information?

EspoTek commented 6 months ago

Yep, your guess is bang on the money.

I debugged on Windows using Atmel Studio 7 and a PDI debugger.

In terms of hardware, I used the ATMEL JTAG-ICE here: https://au.element14.com/microchip/atatmel-ice-pcba/debugger-atmel-arm-avr-pcba-kit/dp/2407171

I wouldn't recommend that exact bit of hardware, though. You can get much cheaper PDI debuggers these days from AliExpress, Sparkfun etc. and it looks like the price has tripled for the official kit since I bought mine!

In terms of how to debug in Atmel Studio, there's a little "Play button" at the top of the IDE that launches it in debugging mode. You can set breakpoints just like you would in Visual Studio. I can't remember exactly how to bring it up, but there's also a little window that lets you read the state of every single hardware register while execution is suspended. Just make sure to set your PDI clock to the max or you're going to have a bad time!