Stellaris/TiVa Toolchain for compiling Stellarap FIrmware

By | November 25, 2013

Recently, someone requested that I give some more details on how to compile the stellarap firmware.    In response, I have put together this post which includes detailed instructions for setting up a toolchain for compiling the stellarap firmware.    I have done this using a virgin Linux Mint 15 virtual machine, so you should be able to follow along on any fresh Linux system.   The only modifications I made to the virtual machine after installation were to install  GIT,  VIM and possibly a few other tools.

The first thing you will need to do is to download all of the required packages.    These are listed here with a brief description:

The latest GCC Arm Embedded compiler:      gcc-arm-none-eabi-4_7-2013q3-20130916-linux.tar.bz2  This is the GCC compiler for embedded ARM processors that is maintained by ARM Inc.   There are other compilers that you might try that should work fine, such as the code sourcery compiler.

Newlib library:  newlib-2.0.0.tar.gz

This is the library that provides convenient C functions such as stdio, strings (printf), and math.h functions.

TivaWare Software library:   SW-Tm4C-1.1.exe

This is the driver libraries provided by Texas Instruments that allow you to make use of specific functions such as the ADC, timers,  PWM,  etc.. inside the TiVa series microcontrollers.   This software is convenient since it saves us from having to re-invent the wheel, and also many of the functions are stored inside a ROM in the processor meaning that every call to a ROM provided library function is one less function that you need to store in program memory.

Finally, you will need the Stellarap firmware:   https://github.com/mroy/stellarap

Once you have all of these downloaded on your Linux (virtual) machine, you can begin to install them using the following commands assuming that you have placed all of these packages in ~/Downloads/

$ cd /opt
$ sudo tar -jxvf /home/user/Downloads/gcc-arm-none-eabi-4_7-2013q3-20130916-linux.tar.bz2
$ cd ~
$ echo  "export PATH=\$PATH:/opt/gcc-arm-none-eabi-4_7-2013q3/bin" >> ~/.bashrc
$ . ~/.bashrc
$ tar -zxvf ~/Downloads/newlib-2.0.0.tar.gz
$ cd newlib-2.0.0
$ ./configure --target=arm-none-eabi --disable-newlib-supplied-syscalls --enable-interwork --enable-multilib --disable-libssp --disable-nls
$ make
$ cd ~
$ mkdir stellarisware  && cd stellarisware
$ unzip ~/Downloads/SW-TM4C-1.1.exe
$ cd driverlib
$ make
$ cd ~
$ git clone https://github.com/mroy/stellarap
$ cd stellarap
$ make

Note that if you have difficulties compiling newlib, you may be able to get away with using the packaged version of libm and liba that comes with the compiler.  Just go into the stellarap makefile and uncomment the libm/liba library lines and comment the libm/liba lines for the compiled version.

Also, it may be useful for you to also build the USB debugger OpenOCD.  This allows you to use the built in debugger on the development board which is quite nice for debugging or even just programming the board.  I actually use this interface as the primary connection for my reprap and its been working great.   OpenOCD has recently been released with built in support for the Stellaris/TiVa  ICDI.

Get the latest OpenOCD with GIT:

$ cd ~  && git clone git://git.code.sf.net/p/openocd/code && mv code openocd

Build OpenOCD like this:

$ cd ~/openocd && ./bootstrap

If, like me, you get an error from this ./bootstrap about not being able to resolve the Git host for JimTcl, then execute the following to get JimTcl from the github mirror instead:

$ rm -rf jimtcl/
$ git clone https://github.com/msteveb/jimtcl

Then continue with the regular build process:

$ ./configure --enable-ti-icdi
$ make
$ sudo make install

This should install OpenOCD in /usr/local/

To run OpenOCD with the Launchpad, it needs a configuration script.   Copy paste the following script and save it as ~/stellarap/openocd.cfg


# 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 0x4000
set CHIPNAME lm4f120h5qr
source [find target/stellaris_icdi.cfg]

 Thats it!  To debug/run your newly compiled software,  connect your stellaris to the computer via USB and start openocd from the stellarap project directory:

$ sudo openocd

Now, in a new terminal, run the following:

$ arm-none-eabi-gdb main.axf

This starts the GDB debugger that comes with the compiler and tells it to use the compiled stellarap firmware.    Once GDB is started, run the following to get started programming your board:

$ target extended-remote :3333
$ monitor reset init
$ monitor reset halt
$ load
$ run

Stellarap should now be running on the device.  You should be able to start pronterface and connect to the Launchpad through  /dev/ttyACM0 or similar.

Cheers and good luck!

[edit] For anybody who is still having difficulties compiling/running the code, please see the binary files that are now included in the github page. The files are main.bin and main.axf. I have been using main.axf with arm-none-eabi-gdb to do debugging/programming, but have not tried flashing the .bin Results may vary.

9 thoughts on “Stellaris/TiVa Toolchain for compiling Stellarap FIrmware

  1. sapm

    Cypher,
    Thank you very much! Following this worked with a few additional steps with a fresh install of Mint 12 (following this tutorial http://theksmith.com/technology/linux-mint-12-virtual-machine/) for those still running into issues:

    1) Needed the tool texinfo:
    sudo apt-get install –reinstall texinfo
    2) Needed to install libusb-1.0-0-dev:
    sudo apt-get install libusb-1.0-0-dev

    With this it worked perfectly! Thanks again!

    Reply
  2. M.Hadi

    Completed all the prerequisites. working on Mint 15, everything is in the download folder. don’t seem to have much luck with the commands.

    hadi@hadi-virtual-machine ~ $ cd /opt
    hadi@hadi-virtual-machine /opt $ sudo tar -jzxvf /home/hadi/Downloads/gcc-arm-none-eabi-4_8-2014q2-20140609-linux.tar.bz2
    [sudo] password for hadi:
    tar: Conflicting compression options
    Try `tar –help’ or `tar –usage’ for more information.
    hadi@hadi-virtual-machine /opt $ cd ~
    hadi@hadi-virtual-machine ~ $ echo “export PATH=\$PATH:/opt/gcc-arm-none-eabi-4_7-2013q3/bin” >> ~/.bashrc
    hadi@hadi-virtual-machine ~ $ . ~/.bashrc
    “export: command not found
    “export: command not found
    “export: command not found
    hadi@hadi-virtual-machine ~ $

    Reply
  3. M.hadi

    Hey, i was just wondering if the code could be built on the code composer studio on windows if you have any ideas on that.

    Thanks.

    Reply
  4. M.Hadi

    Update on my errors. Sorry about this.

    Working on mint 17 now. had these same errors on mint 15 aswell
    $ sudo tar -jzxvf /home/user/Downloads/gcc-arm-none-eabi-4_7-2013q3-20130916-linux.tar.bz2
    (this command worked by removing the “z” from -jzxvf)
    $ echo “export PATH=\$PATH:/opt/gcc-arm-none-eabi-4_7-2013q3/bin” >> ~/.bashrc(nothing happens on this)
    $ . ~/.bashrc (“export: command not found)
    $ cd newlib-2.0.0.tar.gz (No such file or directory) . Used $ cd newlib-2.0.0 (worked fine)
    $ ./configure –target=arm-none-eabi –disable-newlib-supplied-syscalls –enable-interwork –enable-multilib –disable-libssp –disable-nls (configure: error: invalid variable name: `–target’)
    $ make ( make: *** No targets specified and no makefile found. Stop.)
    $ cd ~
    $ mkdir stellarisware && cd stellarisware
    $ unzip ~/Downloads/SW-TM4C-1.1.exe
    $ cd driverlib (worked fine till this)
    $ make ( CC adc.c
    make: arm-none-eabi-gcc: Command not found
    make: *** [gcc/adc.o] Error 127)

    going ahead from this would be unresaonable i think. Still trying to make this work, any help would be very much appreciated.

    Reply
    1. cypher Post author

      Hrm… it seems that WordPress may have altered some of my commands or I didnt copy them down exactly correct.
      The line which adds the export PATH to the .bashrc is fairly important. This is why the make is failing (arm-none-eabi-gcc not found).
      After you run that line, and you do an $ls -la in your home directory, do you see a newly created .bashrc file?

      I’ve updated the post a bit and used some code tags that removes a bunch of auto formatting that wordpress was doing. The main change is that before it would changing double hyphens to single hyphens. Give it a go again and see what happens.

      Reply
  5. M.Hadi

    Thank you for the reply!
    some progress.
    still getting (“export: command not found) on $ . ~/.bashrc . but yes i can see a .bashrc file in my home directory!
    $ ./configure –target=arm-none-eabi –disable-newlib-supplied-syscalls –enable-interwork –enable-multilib –disable-libssp –disable-nls (this command worked this time also added “sudo” before it to fix denied permission problem)
    $ sudo make (seemed to have started fine, errors at the end starting from
    /bin/bash: arm-none-eabi-cc: command not found
    make[5]: *** [lib_a-dummy.o] Error 127
    make[4]: *** [all-recursive] Error 1
    make[4]: Leaving directory `/home/hadi/newlib 2.0.0/ arm- one-eabi/newlib/libc’

    on make for the driverlib (adc.c:49:24: fatal error: inc/hw_adc.h: No such file or directory
    compilation terminated.)

    Reply
  6. Jordão

    Hello. Hope you’re still reading this.
    I have a Tiva TM4C1294 and a RAMPS 1.6. I would like to know if I need to modify your firmware to run everything ok on my Tiva, considering I’ll remap Tiva’s outputs to RAMPS inputs.

    Thanks for your time!

    Reply
    1. cypher Post author

      It’s been a long time since I have played with this software, but I don’t see any reason why it shouldn’t work. The only other issue you may run into is the fact that this code was written for the TM4C123G. You may need to make some changes if there are significant differences between peripherals and what not.

      Also, please be careful running this software for anything more than just an experiment, there aren’t a lot of safety features built in like there are in other firmwares. For example, thermal runaway is a real possibility if your temperature sensor breaks or looses connection.

      Anyways, good luck and feel free to post back here or fork the github if you like.

      Reply
      1. Jordão

        Hello again, cypher. Thanks for your reply.
        Don’t worry, I’m building this printer as a college project. I could even build the safety features, if I feel comfortable enough with your code. May I ask for your email or Discord? I would like to ask you some questions and talk some more.

        Thanks anyway!

        Reply

Leave a Reply to cypher Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.