Yesterday I mentioned I wasn’t able to get debugging going with JTAG and my STM32 dev board. I puzzled it out today, and it was a definite PEBKAC. Alas. In the hopes that it may help someone, I’ll share my results here.

The key is a “make it work” setting within CubeMX. By default, the JTAG pins are not configured! This is probably obvious to folks used to working with this platform. So obvious that nothing on Google pointed me in this direction. I happened on it accidentally. If you want to know more about that process, check out the video at the bottom of the post, where I break out the oscilloscope to chase a red herring and then eventually figure out the real cause.

Make it work!

See that setting under SYS? You gotta enable that. Once you do, JTAG works perfectly. Yay!

Next, to get things going with CLion (anything that supports remote GDB should work) configure a debug configuration like below.

CLion setup

Then you need only flash, reset the board, and connect with OpenOCD. It connect. To be able to debug, you then need to reset and wait for GDB to attach by entering reset halt in your OpenOCD telnet session.

If you run into trouble, check out the video below, where I show this stuff step by step, and give a quick demo. Have fun!