Debian "bare metal" compiler and Stellaris/TIVA-C launchpad.

Posted at 2014-10-28.

More testing for the Debian "bare metal" compiler with Tiva-C launchpad.

(Previous at 2014-01-03 entry).

I came across this post today. I've been thinking I could try the TI stuff to see how it works for a while now. I've even been tempted by the idea of using the midikeys project as a guinea pig for something like this. Either way, I decided to poke around a bit for a start.

There seemed to be no need to build any of the tools by hand. I installed Debian packages with these versions:

There's also some (outdated) guides on the chibios site.

Test the board and flash util

I fetched SW-EK-TM4C123GXL-2.0.1.11577.exe and used unzip to unpack it. Beware that it's a tarbomb, so have an empty directory handy. Plugging in the EK-TM4C123GXL board (Tiva version), /dev/ttyACM0 appears and is group writable by plugdev, so no need to change udev config.

$ cd examples/boards/ek-tm4c123gxl/blinky/gcc
$ lm4flash blinky.bin 
Found ICDI device with serial: 0E200046
ICDI version: 9270

And it blinks!

Test the debugger and compiler

With a helping peek at TI wiki since I've forgotten the syntax again, I could try the debugger:

$ openocd -f interface/ti-icdi.cfg -f target/stellaris_icdi.cfg
Open On-Chip Debugger 0.7.0 (2013-08-04-09:35)
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 : lm3s.cpu: hardware has 6 breakpoints, 4 watchpoints

Switching to another window for gcc. The openocd process may produce output in its window so you see what it's doing. You can also conveniently kill it with ^C there. I'm not sure if those are the ideal configs, but they seem to work out of the box. I should have a look at other ones to compare details.

$ arm-none-eabi-gdb 
GNU gdb (7.7.1+dfsg-1+6) 7.7.1
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/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) target remote :3333
Remote debugging using :3333
0x00000000 in ?? ()
(gdb) monitor reset halt
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x000002d8 msp: 0x20000100
(gdb) load blinky.axf 
Loading section .text, size 0x324 lma 0x0
Start address 0x2d8, load size 804
Transfer rate: 4 KB/sec, 804 bytes/write.
(gdb) monitor reset init
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x000002d8 msp: 0x20000100
(gdb) cont
Continuing.
^C
Program received signal SIGINT, Interrupt.
0x000002ac in ?? ()
(gdb)

Yay! Run, halt, flash(?), continue/start and break on ^C. There doesn't seem to be debug info in the default binary, though, so cd .. and rebuild. There didn't seem to be any need for configuration for using the Makefiles with this gcc.

$ make DEBUG=1
  CC    blinky.c
  CC    startup_gcc.c
  LD    gcc/blinky.axf 
$ arm-none-eabi-gdb gcc/blinky.axf 
GNU gdb (7.7.1+dfsg-1+6) 7.7.1
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/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from gcc/blinky.axf...done.
(gdb) target remote :3333
Remote debugging using :3333
0x000002a8 in main () at blinky.c:78
78              for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++)
(gdb) monitor reset halt
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x000002d0 msp: 0x20000100
(gdb) load
Loading section .text, size 0x360 lma 0x0
Start address 0x2e0, load size 864
Transfer rate: 4 KB/sec, 864 bytes/write.
(gdb) monitor reset init
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x000002e0 msp: 0x20000100
(gdb) break main
Breakpoint 1 at 0x272: file blinky.c, line 51.
(gdb) cont
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.

Breakpoint 1, main () at blinky.c:51
51          SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOF;
(gdb) bt
#0  main () at blinky.c:51
(gdb) break 73
Breakpoint 1 at 0x28a: file blinky.c, line 73.
(gdb) list 73
68          while(1)
69          {
70              //
71              // Turn on the LED.
72              //
73              GPIO_PORTF_DATA_R |= 0x08;
74
75              //
76              // Delay for a bit.
77              //
(gdb) cont
Continuing.
Note: automatically using hardware breakpoints for read-only addresses.

Breakpoint 1, main () at blinky.c:73
73              GPIO_PORTF_DATA_R |= 0x08;
(gdb) step
78              for(ui32Loop = 0; ui32Loop < 200000; ui32Loop++)

I looked up the line and set a breakpoint just before the LED lights and indeed step command lights the LED. Neat!

Conclusion

Over all, this setup seems to be very easy to use if you're familiar with basic (g)cc, gdb and make. OpenOCD doesn't provide too much diversion at this level either.