debugging SAM D21 with gdb / openocd

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm trying to debug the led_toggle demo program on a SAM D21 Xplained Pro board.  I was able to flash the program and run it just fine - the LED is toggling.  Next, I built openocd and tried to attach to the board.  Seems successful.

 

$ openocd -f ./openocd.cfg
Open On-Chip Debugger 0.10.0-dev-00117-ga652a4e (2015-11-21-13:20)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/b...
Info : only one transport option; autoselect 'swd'
none separate
adapter speed: 400 kHz
cortex_m reset_config sysresetreq
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : CMSIS-DAP: FW Version = 02.01.0157
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 400 kHz
Info : SWD IDCODE 0x0bc11477
Info : at91samd21j18.cpu: hardware has 4 breakpoints, 2 watchpoints
Info : accepting 'gdb' connection on tcp/3333
Info : SAMD MCU: SAMD21J18A (256KB Flash, 32KB RAM)

 

Then I tried to connect with gdb.  I can set breakpoints, but I have not found a way to be able to halt, reset, or restart the program.  Can anyone please give me some pointers on how to control a program that is already running from flash?

 

$ /opt/arm-cortex-gnu-toolchain-linux_x86_64/bin/arm-none-eabi-gdb led_toggle_flash.elf
GNU gdb (GNU Tools for ARM Embedded Processors) 7.8.0.20150604-cvs
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-linux-gnu --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/....
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/....
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from led_toggle_flash.elf...done.
(gdb) monitor halt reset
"monitor" command not supported by this target.
(gdb) load
You can't do that when your target is `exec'
(gdb)

 

Thanks,

 

Dallas

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think I've figured it out.  I gave gdb the "extended-remote" command instead of the "remote" command.  Now I am able to halt, run, step etc.

 

target extended-remote localhost:3333

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm able to set breakpoints and step with the led_toggle demo, but not the getting-started demo program.  When I start it with gdb, it seems to take over gdb.  It never returns to the gdb prompt.   I know the program is running - I can see stuff printed to the serial console.  I just can't enter any gdb commands while it's running.  Anyone know why?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm experiencing the same problem with OpenOCD and GDB on the Arduino CC Zero board, said to be compatible.

(gdb) file path/to/executable.elf
(gdb) monitor reset halt
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0xfffffffe msp: 0xfffffffc
(gdb) load
Loading section .text, size 0x2b24 lma 0x2000
Loading section .data, size 0x94 lma 0x4b24
Start address 0x2cbc, load size 11192
Transfer rate: 3 KB/sec, 5596 bytes/write.
(gdb) monitor reset init
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0xf1000000 pc: 0xfffffffe msp: 0xfffffffc
(gdb) continue
Continuing.
at91samd21g18.cpu -- clearing lockup after double fault
Program received signal SIGINT, Interrupt.
0xfffffffe in ?? ()

Registers sp and pc have strange values.

(gdb) info reg
r0             0xbfccefff	-1077088257
r1             0x56fffafa	1459616506
r2             0xfdeff3f7	-34606089
r3             0xfff9fdfc	-393732
r4             0xfdfe3b7e	-33670274
r5             0xdedcffba	-555941958
r6             0xff72f99f	-9242209
r7             0xfeee7e63	-17924509
r8             0xdbeefdfd	-605094403
r9             0xfdfbfd37	-33817289
r10            0xfcffb7fd	-50350083
r11            0xf9df7ff6	-102793226
r12            0xfdfd566f	-33728913
sp             0xffffffd8	0xffffffd8
lr             0xfffffff9	-7
pc             0xfffffffe	0xfffffffe
xPSR           0xf1000003	-251658237

Surprisingly, everything works fine on the Arduino ORG M0 Pro board, also said to be compatible.

 

Any clue?

Last Edited: Sat. Jan 30, 2016 - 04:46 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Looks like you are in a exception handler to me... What does 'bt' tell you?

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bt says

 

(gdb) bt
#0  0xfffffffe in ?? ()
#1  <signal handler called>
#2  0x00000000 in ?? ()
#3  0x00000000 in ?? ()