From 1fb780011036db1fd48c1f97bc524ca3e0f354f7 Mon Sep 17 00:00:00 2001 From: Andre Guedes Date: Wed, 1 Jul 2015 19:12:38 -0300 Subject: [PATCH] galileo: Add 'debug' rule This patch the 'debug' rule to simplify the debugging process. This new rule runs OpenOCD and gdb with the right parameters. OpenOCD runs in background and its output will be redirected to a log file in the application's path called LOG_OPENOCD. Once gdb client is detached, OpenOCD is terminated. The 'debug' rule is defined in Makefile.customrules-galileo file (create by this patch) which is included by the Contiki's buildsystem. So to debug a Contiki application for Galileo board, run the following command: $ make TARGET=galileo debug If you use a gdb front-end, you can define the "GDB" environment variable and your gdb front-end will be used instead of default gdb. For instance, if you want to use cgdb front-end, just run the command: $ make BOARD=galileo debug GDB=cgdb --- .gitignore | 3 ++- platform/galileo/Makefile.customrules-galileo | 8 ++++++++ platform/galileo/bsp/openocd-scripts/debug.cfg | 11 +++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 platform/galileo/Makefile.customrules-galileo create mode 100644 platform/galileo/bsp/openocd-scripts/debug.cfg diff --git a/.gitignore b/.gitignore index 02b314dfc..02e32989b 100644 --- a/.gitignore +++ b/.gitignore @@ -113,5 +113,6 @@ platform/galileo/bsp/libc/newlib-2.2.0-1* platform/galileo/bsp/grub/src/ platform/galileo/bsp/grub/bin/ -# galileo build artefacts +# galileo build and debug artefacts *.galileo +LOG_OPENOCD diff --git a/platform/galileo/Makefile.customrules-galileo b/platform/galileo/Makefile.customrules-galileo new file mode 100644 index 000000000..0ab0e662c --- /dev/null +++ b/platform/galileo/Makefile.customrules-galileo @@ -0,0 +1,8 @@ +GDB ?= gdb +OPENOCD_SCRIPTS = $(CONTIKI)/platform/galileo/bsp/openocd-scripts + +.PHONY: debug + +debug: $(CONTIKI_PROJECT).$(TARGET) + @openocd -s $(OPENOCD_SCRIPTS) -f debug.cfg &> $(shell pwd)/LOG_OPENOCD & + @$(GDB) $< -ex "target remote :3333" diff --git a/platform/galileo/bsp/openocd-scripts/debug.cfg b/platform/galileo/bsp/openocd-scripts/debug.cfg new file mode 100644 index 000000000..bbe8a5919 --- /dev/null +++ b/platform/galileo/bsp/openocd-scripts/debug.cfg @@ -0,0 +1,11 @@ +source [find interface/ftdi/flyswatter2.cfg]; +source [find board/quark_x10xx_board.cfg]; + +quark_x10xx.cpu configure -event gdb-attach { + halt +} + +quark_x10xx.cpu configure -event gdb-detach { + resume + shutdown +}