You are here
Home > embedded >

ARM Cortex-M4 HOWTO Debug Under Ubuntu

With SAME54 board and using OpenOCD will debug the LED Flasher example. This post assumes that basic setup is ready using GNU-ARM Embedded Tool chain and OpenOCD.

Basic gdb with OpenOCD

To Begin with connect the SAME54 explained pro board and start the OpenOCD server using telnet

telnet localhost 444

>reset halt

Then it is time for gdb to use GDB via openocd there are couple of options like, gdb, ddd, insight and kdgb. Will start with gbd

$arm-none-eabi-gdb --eval-command="target remote localhost:3333" AtmelStart.elf

This will start gdb with remote debugging and you can see following message

Type "apropos word" to search for commands related to "word"…
Reading symbols from AtmelStart.elf…
Remote debugging using localhost:3333
main () at ../led_switcher_main.c:55
55 delay_ms(100);
(gdb) list

Add breakpoint and continue “cont” execution

This time you may see following error, if you are running it for first time.

> same54.cpu : clearing lockup after double fault

If you happen to get this error, that means, Your CPU was in locked state. That means it could not run its “Hard Fault” Interrupt Handler (maybe there is a 0 in its Vector).
Simple solution to this is – you can either reset your board or execute openocd with “gdb_memory_map enable option”

$sudo openocd -f tcl/board/microchip_same54_xplained_pro.cfg -c "gdb_memory_map enable"  

OpenOCD with DDD debugger

DDD is quite nice little gdb front end.

$ddd --eval-command="target remote localhost:3333" --debugger arm-none-eabi-gdb AtmelStart.elf 

OpenOCD with Kdbg

This is another nice front end for gdb and one of my favorite. Before you start using it first edit Settings->global Options and change the option “How to invoke GDB” to “arm-none-eabi-gdb –fullname -nx”

Then you close and reopen with kdbg in command line as

$kdbg -r localhost:3333 AtmelStart.elf 

Put breakpoint in main and start debugging your program. Happy debugging.

Leave a Reply

Top
%d bloggers like this: