Feature: RTT for debug output (was:3rd COM port)

PR #154 is now ready for final review.

./hacks/rtt_debugging.md provides sample steps to get this working under Ubuntu.

I default to outputting most “early boot” messages (of which I added many), as serial port output is not available during early boot, and USB connectivity can break if the device is broken into the debugger.

Future improvements may include compile-time or dynamic selection of output modality(ies): RTT, debug UART, both, etc. But for now, I’m just glad to have figured it out enough to integrate! :tada:

1 Like

Very impressive Henry. It looks like a well thought out and full featured debug system to me.

At this point it hasn’t touched much code in the actual firmware. Can we use this chance to make it a compile time option? I understand there to be debug levels, but it doesn’t look like it’s currently possible to disable it all together.

This is a pretty major update that will be applied to many places in the firmware. I’d like to have a dead stop option that disables it if we need to to triage at some point or test for strange bugs.

The NAND demo (iirc) did a clever trick where it wrapped the contents of the debug functions in #ifdef #endif, so they were optimized out without surrounding every use of the debug in the code.

1 Like

Glad it has your general approval. For the disabling … Of course! Can do this entirely in debug_rtt.h … and done.

Ensuring it’s easy to disable was actually an unstated goal of mine … As examples:

  • Redirect the macro to UART (but would lost the EARLY_BOOT category, which includes pre-UART setup messages)
  • Do both UART and RTT (but not clear why would do so)
  • Make the categories to be enabled / debug levels to be enabled a compile-time flag (this is on my todo list, but not high priority)
  • Disable entirely with compile-time flag

Thus, unless I hear otherwise, I’ll rebase/merge these changes within the next day. :tada:

4 Likes

Sounds great! Thank you so much, I’m glad that’s part of the design.

1 Like

I gave it a try with a picoprobe today. The default apt install of openocd on Ubuntu 22.04.4 wasn’t working for me, so I got the latest openocd from git (main branch). Built and installed and it worked just fine.

@henrygab - your instructions are great! No problems at all, once I built the latest openocd:

Thanks so much for the work you did on this!

Note: the issue with the packaged version of openocd is that it didn’t have the rp2040 flash driver and description config.

1 Like

Hookup of the picoprobe:

2 Likes