-
Notifications
You must be signed in to change notification settings - Fork 12
Debugging with openocd
Naoki Aizu edited this page May 13, 2013
·
4 revisions
- Installing Packages
$ sudo apt-get install libusb-1.0-0 libusb-dev libftdi1 libftdi-dev tcl libtool automake texinfo
- Downloading OpenOCD
$ git clone git://git.code.sf.net/p/openocd/code openocd
note: tested version is v0.7.0
- Compiling OpenOCD
$ cd openocd
$ git checkout -b v0.7.0 v0.7.0
$ ./bootstrap
$ ./configure --enable-maintainer-mode --enable-ft2232_libftdi
$ make
$ sudo make install
- Copy freertos-multicore/FreeRTOS/Demo/CORTEX_M3_PANDA/misc/omap4460.cfg to /usr/local/share/openocd/scripts/target/
See "Flyswatter2 Pandaboard How To"
$ sudo /usr/local/bin/openocd -s /usr/local/share/openocd/scripts/ -f interface/flyswatter2.cfg -f board/ti_pandaboard_es.cfg
- Running GDB
$ arm-none-linux-gnueabi-gdb vmlinux
- Connecting OpenOCD
(gdb) target remote localhost:3333
- Start target
(gdb) c
- Example
(gdb) target remote localhost:3333
Remote debugging using localhost:3333
0x00035f4a in ?? ()
(gdb) b start_kernel // set breakpoint on function that running on cpu core 0
Breakpoint 1 at 0xc069b6b0: file init/main.c, line 475.
(gdb) b secondary_start_kernel // set breakpoint on function that running on cpu core 1
Breakpoint 2 at 0xc04ec834: file arch/arm/kernel/smp.c, line 261.
(gdb) c
Continuing.
Breakpoint 1, start_kernel () at init/main.c:475
475 smp_setup_processor_id();
(gdb) monitor cortex_a smp_gdb // check current cpu core number
gdb coreid 0 -> -1 // current cpu core number is 0
(gdb) c
Continuing.
Breakpoint 2, secondary_start_kernel () at arch/arm/kernel/smp.c:261
261 atomic_inc(&mm->mm_count);
(gdb) monitor cortex_a smp_gdb // check current cpu core number
gdb coreid 1 -> -1 // current cpu core number is 1
(gdb)
- Running GDB and start target
$ arm-none-linux-gnueabi-gdb vmlinux
(gdb) target remote localhost:3333
Remote debugging using localhost:3333
0x00035f4a in ?? ()
(gdb) c
- Find the base address of kernel module on target
# cat /proc/modules
rpmsg_client_sample2 1850 0 - Live 0xbf023000 (O)
(the rest omitted)
- Halt target(Press Ctrl+C on GDB terminal)
Continuing.
^C
Program received signal SIGINT, Interrupt.
- Load symbol to GDB
(gdb) add-symbol-file rpmsg_client_sample2.ko 0xbf023000 -readnow
add symbol table from file "rpmsg_client_sample2.ko" at
.text_addr = 0xbf023000
(y or n) y
Reading symbols from /home/n-aizu/work/pandaes/rpmsg/rpmsg_client_sample2.ko...expanding to full symbols...done.
- Set breakpoint on kernel module code
(gdb) tb rpmsg_sample2_cb
Temporary breakpoint 1 at 0xbf023000
(gdb) c
Continuing.
Temporary breakpoint 1, rpmsg_sample2_cb (rpdev=0xebaf0a00, data=0xd9044810, len=4, priv=0x0, src=3955130188)
- Connecting OpenOCD with telnet
$ telnet localhost 4444
- Switch to Cortex-M3 core 0
> targets omap4460.m30
- Switch to Cortex-M3 core 1
> targets omap4460.m31
Warning
FreeRTOS Multicore check timeout on cpu core 0.
So if Cortex-M3 core 0 is halted, timeout event is never occured on Cortex-M3 core 1.
(vTaskDelay/vTaskDelayUntill are not working and queue APIs are never timeouted.)