Jump to content
43oh

Using gdb and openOCD to remote debug Tiva/Stellaris on a Mac OS


Recommended Posts

I have been trying to learn how to program the Tiva/Stellaris using a Mac. Got Energia working-- version 0101E0010 has a bug where lm4flash doesn't work and needs to be replaced with a working version. Figuring out slowly how to use the Tiva driverlib. What was missing was debug capabilities. I wanted to share what I have learned so far and also solicit help from people who know more.

 

I installed openocd from macport. ti-icdi support is available on 0.7.0 but the build options need to be changed. This is somewhat of a kludge but it worked OK. Basically ad a ti-icdi variant to opened and then build it.

cd `port dir openocd`

#then append the following to the Portfile

variant ti description {TI-ICDI interface on Stellaris Launchpad} {
    configure.args-append --enable-ti-icdi
    depends_lib-append  port:libusb
}
#now install ti-icdi variant
sudo port install openocd +ti
Make a copy of the cfg file from /opt/local/share/openocd/scripts/board/ek-lm4f120xl.cfg  to the directory you want to work in. I changed 'set CHIPNAME lm4f120h5qr' to 'set CHIPNAME lm4f230h5qr'. I don't know if it actually changes anything but why not.  Start openocd
openocd ek-lm4f120xl.cfg 
Open another terminal window and start gdb. You can find the arm gdb in the Energia.app bundle so you don't have to build it yourself-- I added /Applications/Energia.app/Contents/Resources/Java/hardware/tools/lm4f/bin to my $PATH so that I could invoke gdb from anywhere.
 
One quirk of gdb: if you start gdb with a symbol file , you can't connect to the Stellaris. If you don't specify the symbol file, you can connect, but you can't do much because the symbols aren't loaded. To overcome this problem, load the symbol file AFTER connecting to the Stellaris.
 
So, write your program in Energia, compile and upload it. Go to the Compilation folder (Sketch->Show Compilation Folder). Go to this directory in a terminal window.
 
Look for the .elf file (should be program.cpp.elf). Start gdb:
arm-none-eabi-gdbtui
Connect to the remote target:
target extended :3333
Load the symbol file:
file progName.cpp.elf
You might need to reset the board to make openocd happy. You should see the source code in the top of the window. You can run, cont, stop the program. I am still trying to figure out the other parts of gdb right now.
 
Update: macports has added the ti variant to add icdi support. No need to edit the Portfile. You can now 'port install openocd +ti' after doing a 'port selfupdate'.
Link to post
Share on other sites
  • 3 weeks later...
  • 7 months later...
Debugging used to work with previous version of Energia but no longer works. 
 
I don't understand the Error: gdb requested a non-existing register message.
 
Configuration
 
  • LaunchPad LM4F120 and TM4C123
  • Energia 0101E0012
  • Sketch blink.ino
  • Open On-Chip Debugger 0.8.0
  • GNU gdb (GNU Tools for ARM Embedded Processors) 7.4.1
  • Mac OS X 10.9.3
  • Unchanged `ek_lm4f120xl.cfg` and `ek_lm4f120xl.xml` files
 
First window = openocd
$ openocd --file /Users/ReiVilo/Documents/Projets/Xcode/embed2/embed2/Utilities/ek_lm4f120xl.cfg
Open On-Chip Debugger 0.8.0 (2014-05-10-14:22)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : This adapter doesn't support configurable speed
Info : ICDI Firmware version: 9270
Info : lm4f120h5qr.cpu: hardware has 6 breakpoints, 4 watchpoints
Second window = arm-none-eabi-gdb
$ /Applications/Energia.app/Contents/Resources/Java/hardware/tools/lm4f/bin/arm-none-eabi-gdb
GNU gdb (GNU Tools for ARM Embedded Processors) 7.4.1.20130312-cvs
Copyright (C) 2012 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-apple-darwin10 --target=arm-none-eabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) 
 
Commands and answers
 
Commands on second window = arm-none-eabi-gdb
Answers from first window = openocd 

 

 

 
 
(gdb) file '/var/folders/5d/dky9xc691m32kztqnhkn8bhw0000gn/T/build667309560293890230.tmp/Blink.cpp.elf
(gdb) set tdesc filename /Users/ReiVilo/Documents/Projets/Xcode/embed2/embed2/Utilities/ek_lm4f120xl.xml
(gdb) set remotetimeout 2000
(gdb) target extended :3333
Info : accepting 'gdb' connection from 3333
undefined debug reason 7 - target needs reset
 
(gdb) monitor reset halt
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x000002b4 msp: 0x20008000
 

 

 

(gdb) load
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x000002b4 msp: 0x20008000
target state: halted
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x20000042 msp: 0x20008000
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x000002b4 msp: 0x20008000
Error: gdb requested a non-existing register
Info : dropped 'gdb' connection
 

 

 

(gdb) monitor reset init
 
ek_lm4f120xl.cfg` file
 
# TI Stellaris Launchpad ek-lm4f120xl Evaluation Kits
#
# http://www.ti.com/tool/ek-lm4f120xl
#
#
# NOTE: using the bundled ICDI interface is optional!
# This interface is not ftdi based as previous board were
#
#
source [find interface/ti-icdi.cfg]
set WORKAREASIZE 0x8000
#set WORKAREASIZE 0x4000
set CHIPNAME lm4f120h5qr
source [find target/stellaris_icdi.cfg]
 
ek_lm4f120xl.xml` file
 
<?xml version="1.0"?>
<!DOCTYPE target SYSTEM "gdb-target.dtd">
<target>
  <feature name="org.gnu.gdb.arm.core">
    <reg name="r0" bitsize="32" type="uint32"/>
    <reg name="r1" bitsize="32" type="uint32"/>
    <reg name="r2" bitsize="32" type="uint32"/>
    <reg name="r3" bitsize="32" type="uint32"/>
    <reg name="r4" bitsize="32" type="uint32"/>
    <reg name="r5" bitsize="32" type="uint32"/>
    <reg name="r6" bitsize="32" type="uint32"/>
    <reg name="r7" bitsize="32" type="uint32"/>
    <reg name="r8" bitsize="32" type="uint32"/>
    <reg name="r9" bitsize="32" type="uint32"/>
    <reg name="r10" bitsize="32" type="uint32"/>
    <reg name="r11" bitsize="32" type="uint32"/>
    <reg name="r12" bitsize="32" type="uint32"/>
    <reg name="sp" bitsize="32" type="data_ptr"/>
    <reg name="lr" bitsize="32"/>
    <reg name="pc" bitsize="32" type="code_ptr"/>
    <reg name="cpsr" bitsize="32" regnum="25"/>
  </feature>
  <feature name="org.gnu.gdb.arm.fpa">
    <reg name="f0" bitsize="96" type="arm_fpa_ext" regnum="16"/>
    <reg name="f1" bitsize="96" type="arm_fpa_ext"/>
    <reg name="f2" bitsize="96" type="arm_fpa_ext"/>
    <reg name="f3" bitsize="96" type="arm_fpa_ext"/>
    <reg name="f4" bitsize="96" type="arm_fpa_ext"/>
    <reg name="f5" bitsize="96" type="arm_fpa_ext"/>
    <reg name="f6" bitsize="96" type="arm_fpa_ext"/>
    <reg name="f7" bitsize="96" type="arm_fpa_ext"/>
    <reg name="fps" bitsize="32"/>
  </feature>
</target>

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...