HowTo: Develop on the TI Tiva LaunchPad using Linux

For years I’ve almost exclusively used Atmel’s AVR series of 8-bit microcontrollers in projects. AVRs get along quite nicely with Linux, which I primarily development on. But I’ve been hearing great things about TI’s line of inexpensive development boards and their toolchain. So I took the plunge and ordered a dev board.

Well as it turns out I ordered the wrong board. Woops! Instead of the $10 MSP-EXP430G2 Launchpad (featuring their MSP430 8 16-bit microcontroller) development board I accidentally ordered the $13 Tiva C series TM4C123GXL Launchpad. Oh well, there are worse things than mistakenly getting an ARM dev board for a few bucks.

So what’s the toolchain even like on this thing? Will I need to download some massive IDE? After some quick searching I was happy to find that building, flashing, and debugging can all be done with command line Linux tools.

The following setup instructions were taken from the Tiva Template project and the Recursive Labs Blog, along with a few of my own notes and helpful tidbits. I’ll be working in a folder named Embedded in my home directory, on a computer running Ubuntu 13.10 Saucy Salamander.

Dependencies

This section only needs to be performed once to get your development computer setup.

  1. Let’s create a working directory to hold our projects and toolchain.
    1
    2
    mkdir ~/Embedded
    cd ~/Embedded
  2. Install some dependencies using the commands below. This step should hopefully work for both 32- and 64-bit systems now (thanks Mayank!) And if you happen to be an Arch Linux user and are following along be sure to check out Vivek’s advice in the comments for further 64-bit instructions.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    # For 64-bit systems:
    sudo dpkg –add-architecture i386
     
    # For everybody:
    sudo apt-get update
    sudo apt-get install flex bison libgmp3-dev libmpfr-dev \
        libncurses5-dev libmpc-dev autoconf texinfo build-essential \
        libftdi-dev python-yaml zlib1g-dev libtool
     
    # For 64-bit systems yet again:
    sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
     
    # I needed these as well flashing over USB:
    sudo apt-get install libusb-1.0-0 libusb-1.0-0-dev
  3. Go to the GNU Tools for ARM Embedded Processors page and download the most recent tarball for Linux. Then extract it (including the top-level “gcc-arm-none-eabi-…” folder) into ~/Embedded.
    1
    tar -xvf gcc-arm-none-eabi-4_8-2014q2-20140609-linux.tar.bz2 -C ~/Embedded
  4. Add the extracted directory’s bin folder to your user’s path.
    1
    export PATH=$PATH:$HOME/Embedded/gcc-arm-none-eabi-4_8-2014q1/bin

    This will only last for as long as you’re logged in however, and will need to be rerun each time you want to do development. For a more permanent solution you can:

    • copy the contents of gcc-arm-none-eabi-4_8-2014q1/bin to one of the directories in your path (not recommended)
    • create/modify your .bashrc file so it performs the above command at the beginning of every login. To do this open/create ~/.bashrc and add the above command (at the bottom or wherever appropriate).
  5. Download the “TivaWare for Tiva C Series” package from TI’s Tiva C Series Software section. You will be asked to create a login after clicking the download link in order to get the file. The current version was SW-TM4C-2.1.0.12573.exe when I downloaded it.
  6. Extract the exe file to a new tivaware folder in Embedded using the commands below.
    1
    2
    3
    4
    5
    6
    cd ~/Embedded
    mkdir tivaware
    cd tivaware/
    # Go download exe from link above, and place it in the tivaware folder
    mv ~/Downloads/SW-TM4C-2.1.0.12573.exe . #Don't miss the dot
    unzip SW-TM4C-2.1.0.12573.exe
  7. Compile with make
    1
    make
  8. The Tiva Template project has the stuff we need for compiling, as well as some example code. Go grab it off of GitHub with the commands below.
    1
    2
    cd ~/Embedded
    git clone git@github.com:uctools/tiva-template
  9. lm4flash is the utility we’ll be using to flash our target board. Grab it from GitHub and compile the source.
    1
    2
    3
    4
    cd ~/Embedded
    cd lm4tools/lm4flash/
    make
  10. lm4flash will work out of the box, but will require sudo to talk to the board through USB. You have the option of fixing this by setting up a udev rule for the device and adding your user to the dialout group with the following commands. After that unplug the board, logout, login, and reconnect the board.
    1
    2
    3
    cd /etc/udev/rules.d
    echo "SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"1cbe\", ATTRS{idProduct}==\"00fd\", MODE=\"0660\"" | sudo tee 99-tiva-launchpad.rules
    # Remember to unplug and logout
  11. We even have debugging capabilities. OpenOCD, the Open On-Chip Debugger, now supports this board. Grab and compile.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    cd ~/Embedded
    cd openocd
    git fetch http://openocd.zylin.com/openocd refs/changes/63/2063/1
    git checkout FETCH_HEAD
    git submodule init
    git submodule update
    ./bootstrap
    ./configure --enable-ti-icdi --prefix=`pwd`/..
    make -j3
    make install

Building Firmware

We’ll be building a simple blinking LED app using the example source code and makefile included in the Tiva Template.

  1. Go look at Embedded/tiva-template-master/src/main.c to see the blinky goodness.
  2. Configure our project’s Makefile in Embedded/tiva-template-master as follows:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    #######################################
    # user configuration:
    #######################################
    # TARGET: name of the output file
    TARGET = main
    # MCU: part number to build for
    MCU = TM4C123GH6PM
    # SOURCES: list of input source sources
    SOURCES = main.c startup_gcc.c
    # INCLUDES: list of includes, by default, use Includes directory
    INCLUDES = -IInclude
    # OUTDIR: directory to use for output
    OUTDIR = build
    # TIVAWARE_PATH: path to tivaware folder
    TIVAWARE_PATH = $(HOME)/Embedded/tivaware
  3. Run make to build the app.
    1
    2
    cd ~/Embedded/tiva-template-master
    make
  4. This should hopefully build and place our output files in build.

Flashing

  1. Run this to flash over USB. Remember to run with sudo if you did not follow the udev and group instructions in step 10 under Dependencies.
    1
    2
    cd ~/Embedded/lm4tools/lm4flash/
    ./lm4flash ~/Embedded/tiva-template-master/build/main.bin
  2. Woohoo! Hopefully the RGB LED under the reset button is blinking red. Now go play with the delay time and colors in main.c.

References

25 thoughts on “HowTo: Develop on the TI Tiva LaunchPad using Linux

  1. @Chris, Thank you for developing this how-to. Have you tried develop software for TIVA using eclipse.

    • Hi Mahendra,

      I’m glad to hear it was helpful for you. I’ve used Eclipse a few times but not for the Tiva yet. Maybe that should be my next post. In the mean time Google returns a few tutorials on the subject although their build environments may have been setup slightly different from mine.

      Thanks for the comment!

    • Code Composer is eclipse…
      Just not a do it your self from scratch eclipse c/c++ set up.
      I wish it was.

  2. Thanks for the well written guide. However, I have never used OpenOCD and I can’t seem to be making it function correctly. I get a message that indicates that OpenOCD is not installed. Should I just install it with apt-get?

  3. Hi Chris, thanks a lot for this guide! I have so far been able to install all the packages. May I simply add that building openocd requires to have libtool installed? Just add it to the apt-get install command at the start of the procedure. Cheers!

    • Hi Luis. Glad to hear the guide was helpful for you! And thanks for the tip! I added it to the dependencies.

  4. Hello Chris Miller,

    Thanks for a great tutorial :). Found it very interesting. But unfortunately I am stuck on a problem. After I unzip the TivaWare for Tiva C Series and I write the command “make” it give me an error that says “arm-none-eabi-gcc: Command not found”. Any suggestions?

    J. Pantelis

    • Hi Jim,

      It sounds like something went wrong with step 3 or 4 in the Dependencies section. The ARM GCC binary either wasn’t extracted properly or, more likely, isn’t accessible via your system path.

      1) Make sure you are doing all of this from a folder named “Embedded” inside your user’s home directory. You of course don’t absolutely need to do this, but if you choose not to and aren’t careful then this is the spot where you may start having problems.
      2) Make sure you’re running these commands with the actual file names. They’ve most likely changed since I wrote this.
      3) Check that step 3 was successful. There should be a “gcc-arm-blah-blah/bin” folder with stuff in it. Delete the gcc-arm-blah-blah folder and rerun this step if necessary.
      4) Check your system path. Run “echo $PATH” and make sure that your gcc-arm-blah-blah/bin folder is in there (should be near the end after the last colon). Copy this out and make sure it’s a valid path by cd-ing into it from the terminal. If it’s missing or isn’t valid then re-run step 4 with the correct path. And don’t overlook the bottom part of that step.

      I hope this was helpful. I don’t actually have this setup anymore but I’ll try to be of help if you have any other questions.

  5. Hi Chris,

    I’m getting no enumeration of the Tiva-C Launchpad when it’s connected via USB to Ubuntu 14.04. I also don’t see it with ‘lsusb’.
    Everything else works fine, but without the board being recognized it’s a bit of a problem.
    Do you have any advice? Even ‘dmesg’ doesn’t move and shake when it’s plugged and unplugged.

    Thanks!

  6. Hi Chris,

    If you are on a 64bit distro, you might need to install the 32bit libraries. on arch linux I had to add multilib option and install lib32-gcc-libs for the step to work

    • Thanks Vivek! Sorry it took so long to respond. I appreciate the feedback. Hopefully your comment will be of help to other Arch users!

  7. Nice job. I would like to correct you on something small, as it is only for the introduction of your article and not for its main goal :). MSP430 is 16 bit RISC, not 8 bit. Despite that, it is a very informative article on working on TIVA C series using the powerful command line of Linux. This is turn means that you can easily configure other GUI’s (for graphical fans) to use these tools.

    Thank you for your effort and congratulations

  8. Chris,

    Thanks a ton for this material, this was exactly what I was looking for.

    I had been able to set up the CCS environment on Windows and had got the Hello-World thingies running. My next task was to make the process fully on command-line in Linux. You just saved me tens of hours of my life !!!

    Once again, can’t thank you enough !!!!

  9. Really good tutorial! 😀 Thanks for this. Since I’m running this on a 64-bit system and the tivaware exe contains 32 bit files, the only step I had to change was do this before step 7:

    sudo dpkg –add-architecture i386
    sudo apt-get update
    sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386

  10. Hi Chris

    Thank you for the tutorial. It was very helpful =).
    I was able to tests some of the examples with my tiva C launchpad.
    However after that i wanted to do some modifications so i copied the ~/Embedded/tivaware/examples/boards/ek-tm4c123gxl/qs-rgb folder to another directory ~/Embedded/my_tests . But now (still without changing the code) i cant compile my code inside my_tests folder. I already changed the Makefile inside the ~/Embedded/my_tests/qs-rgb folder to match the includes and makedefs and driverlib folders.
    Could someone help me?

    EG

  11. It might also be a good idea to install pkg-config before trying to build lm4flash, or it will fail with the confusing message that “libusb.h” could not be found. Some setups don’t include it by default anymore.

  12. Thanks alot, that worked nicely. I cheated and used the gcc-arm anf lm4flash from the software center but it still worked.

  13. Hi,
    i am new to ubuntu n I am first time dealing with this Tiva c tm4c129xl MC.
    after following above steps …my PC able to detect usb connected to tiva…..but i am unable to burn any programm in tiva…n i want to try some ready codes in python for tiva…….plzzzzz sugesste me in step by step manner …cosidering i am new user….plzz help.

  14. I thank your for such a nice sharing.
    Here is my suggestions which worked for my Ubuntu 14.04 machine.

    At step 3, GNU tool for ARM Embedded Processor can be installed by this terminal command,
    sudo apt-get install gcc-arm-none-eabi

    There is no need for step 4, if one used the above command.

    At step 10, I used the following script to write the udev rules.

    # For Tiva Lunchpad permissions.
    SUBSYSTEM==”usb”,\
    ENV{DEVTYPE}==”usb_device”,\
    ATTR{idVendor}==”1cbe”,\
    ATTR{idProduct}==”00fd”,\
    MODE=”0666″,\
    NAME=”bus/usb/$env{BUSNUM}/$env{DEVNUM}”,\
    RUN+=”/bin/chmod 0666 %c”

    After that, I used the following command to reload udev.
    sudo udevadm control

    After that I unplugged and logged out and then logged in and plugged the board again.

    After the above procedure, I was able to program and debug the launchpad by using the CCS compiler built in Stellaris in circuit debugger with CCS IDE Interface, with out any need for other debuggers.

  15. WooHoo! Thanks so much for this tutorial. I had been struggling for a while going through the Tiva course material, but this is *exactly* what I needed. Thanks for sharing this! Much appreciated.

Comments are closed.