How to debug code for the LPC1768

06 Jun 2012

What tools/software would I need to debug code written for the LPC1768?

I want to be able to set breakpoints, examine variable values, and set them on the fly to see how the code behaves.

The way I understand it is I need to use gdb and some sort of arm processor (cortex m3) emulator (is this software or some board I need to purhcase?). But I don't know where to begin...

06 Jun 2012

Out of the box, the mbed LPC1768 doesn't support debugging.

Currently there a few ways to get that kind of debugging support though:

  • One of the coolest but most difficult to pull off solutions is this one from Ilya I This link http://mbed.org/users/iva2k/notebook/jtag/ shows where a JTAG adapter was soldered onto the mbed board. Of course you would need to purchase a separate JTAG debugger pod to then connect to this newly added adapter.
  • The LPCXpresso board is very similar to the mbed device and it has JTAG debugging hardware built in. It uses a GCC based tool chain but it has limits on the size of the binaries it will produce and debug without you paying to unlock larger sizes.
  • I am currently working on a debug monitor that you compile into your code and allows you to use the GNU debugger, GDB, to debug your application. You can check out this forum post to learn more: http://mbed.org/forum/mbed/topic/2944/ I have released the sources for the alpha version of the MRI debug monitor on github at https://github.com/adamgreen/mri and I am currently updating my gcc4mbed project to integrate this debugging solution. I hope to release the gcc4mbed update in the next week or so. This update will allow you to use the command line version of GDB to debug your programs on the mbed. I hope to have another update in the near future which adds support for the Eclipse IDE so that you edit your code, build it, and debug it from a single application on Windows, OS X, or Linux.

All of the above solutions currently require the use of an offline compiler such as GCC so you would give up some of the convenience of the online compiler. However, if the mbed team was to support an export option which created a ZIP archive with sources and a compiled binary in ELF format then it should be possible to use the online compiler to produce binaries that would probably work with most of the above debugging solutions. It would be best if this export could generate binaries with the current optimization settings or an easier to debug optimization level (ie. no optimizations).