This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Building toolchain and OpenOCD for Stellaris on Linux

Other Parts Discussed in Thread: LM3S6965, DK-LM3S9B96, LM3S3748

 

I've been developing for Stellaris target on a Linux machine for several months now using GNU GCC and OpenOCD.   Due to an OS re-install this weekend,  I needed to get this all set-up again.  I thought I  would share the majority of steps it  took me to get things up and running on a fresh debian / stable install in hopes that it will help someone else out wanting to develop on Linux with the open / free tools.   Sorry if something similar has already been posted before.

Links

crosstool-ng  (building the toolchain made easy..  very nice!.)

http://ymorin.is-a-geek.org/projects/crosstool

OpenOCD project  (debugger / flashing).  Need the latest from GIT repository to get the interface and target definitions for the Stellaris parts.   This is done with git clone  (see below)

http://developer.berlios.de/projects/openocd

Open FTDI driver for accessing the FT2232 on the Stellaris boards

http://www.intra2net.com/en/developer/libftdi/download.php

#install crosstool-ng
bzip2 -d crosstool-ng-1.8.1.tar.bz2
tar -xf crosstool-ng-1.8.1.tar
cd crosstool-ng-1.8.1/
sudo apt-get install awk
sudo apt-get install gawk
sudo apt-get install bison
sudo apt-get install flex
sudo apt-get install automake
sudo apt-get install libtool
sudo apt-get install libncurses-dev
sudo apt-get install zlib1g-dev
./configure
make
sudo make install
mkdir /home/user1/arm-eabi/
cd /home/user1/arm-eabi/
#copy sample file for baremetal build to new directory
cp /home/user1/downloads/crosstool-ng-1.8.1/samples/arm-bare_newlib_cortex_m3_nommu-eabi/crosstool.config .config
#build the entire toolchain
ct-ng build

#install open FTDI drivers
tar -xzf libftdi-0.18.tar.gz
cd libftdi-0.18/
sudo apt-get install libusb-dev
./configure
make
sudo make install
ldconfig

#install latest OpenOCD
git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd openocd-git
cd openocd-git/
./bootstrap
./configure --enable-ft2232_libftdi
make
sudo make install

#add toolchain built by crosstool-ng to path
PATH="/home/user1/x-tools/arm-bare_newlib_cortex_m3_nommu-eabi/bin:${PATH}"
export PATH

#edit PREFIX in StellarisWare/makedefs to use new toolchain
PREFIX=arm-bare_newlib_cortex_m3_nommu-eabi

#build entire StellarisWare distribution
cd StellarisWare
make clean
make

#start openocd with stellaris configuration

#lm3s9b9x with external FTDI ICD board
#sudo openocd -f openocd-git/tcl/interface/luminary-icdi.cfg -f openocd-git/tcl/target/stellaris.cfg

#lm3s6965 with on-board FTDI
sudo openocd -f openocd-git/tcl/interface/luminary.cfg -f openocd-git/tcl/target/stellaris.cfg

#flash mcu with some code at address 0x00000 and execute
telnet localhost 4444
halt
flash write_image erase /tmp/main.bin 0
reset

  • Great Post! Thanks.  I have not got it fully working yet.  However I was hoping I could ask you a few questions:

     

    1.  Where are you getting the stellaris ware?  I downloaded it from TI but its in the form of an EXE did you just run it on windows then copy it to linux?

    2.  The flash mcu section at address 0x000000... How exactly is this accomplished?  

    3.  Once the tool chain is setup.  How does one go about "building" code?  Is there a way to configure Eclipse CDT to work off of this tool chain?  + Debug?

     

    Sorry for all the questions.  I think some of this should be apparent.  However I am just starting in ARM and struggling a bit to get started.  I purchased a Evalbot which TI does NOT support right now as a stand along dev board.  They want you to get the u3 RTOS book and go for there.  Which I choose not to do.

     

    Anyhow any help would be greatly appreciated! 

    Thanks,

    Riley Porter
    www.synthetos.com 

  • riley porter said:

    Yes, I just installed it on a Windows machine and then created a zip to transfer over to LInux.

    >1.  Where are you getting the stellaris ware?  I downloaded it from TI but its in the form of an EXE did you just run it on windows then copy it to linux?

     

    You define the origin of the code generated in the linker script.  In the TI examples,  the linker script for GCC is the name of the project with .ld suffix.  e.g.   blinky.ld

    >2.  The flash mcu section at address 0x000000... How exactly is this accomplished?  

     

    edit the makedefs file in the StellarisWare directory.  Change the PREFIX to the toolchain prefix.  

    e.g.   PREFIX=arm-bare_newlib_cortex_m3_nommu-eabi

    To build all the examples for all boards, from the StellarisWare directory type

    make clean

    make

    The output code and linked binary ends up in a gcc folder in each project directory.   e.g.  blinky/gcc/blinky.bin  is the binary

    to flash the device with openOCD,  I do the following

    telnet localhost 4444

    reset halt

    flash write_image erase /pathto/blinky.bin 0x0000

    reset

    >3.  Once the tool chain is setup.  How does one go about "building" code?  Is there a way to configure Eclipse CDT to work off of this tool chain?  + Debug?

     

     

  • Todd

    Again,  thanks for the reply.  I have not got to try that out yet as I am at work.  However for clarity.  There is not a way to get this to "play nice" with eclipse CDT?  Does GNU toolchain = command line only really?

     

    My email is rileyporter (a) gmail <dot> com  would you mind tossing me an email. 

     

    Thanks,

     

    Riley

  • This is really an excellent set of instructions, thanks for sharing!  I have the full chain running the example programs after using the steps above.  I have a small question though: which gdb do you use? I am not sure whether to compile my own or to use one from the code sourcery distribution.  My preference is for a gdb that doesn't require licences and can be built from source, but any will do really.

     

    Thanks again,

    Mike

  • Hi Todd,

    Thanks a lot for posting this , was looking for this from a lot of time and wasnt able to get things running on Ubuntu.

    Todd Elliott said:
    sudo apt-get install awk
    sudo apt-get install gawk
    sudo apt-get install bison
    sudo apt-get install flex
    sudo apt-get install automake
    sudo apt-get install libtool
    sudo apt-get install libncurses-dev
    sudo apt-get install zlib1g-dev

    instead of using this u could do sudo apt-get install gawk bison flex....and all other packages

    Regards,

    Karanpreet Singh

  • also u need to install a package

    sudo apt-get install texinfo

    for " makeinfo "  which was not there on ubuntu

  • Hi,

    I am using DK-LM3S9b96, the OpenOCD is not support this board, 

    I think I have to custom the script file under tcl/board, tcl/interface,  I tried to copy from ek-lm3s9b9x.cfg but not work.

    Please help. thank you.

    Best Regards,

    Leo

  • THANK YOU, THANK YOU, THANK YOU!

    This is something I wanted to do for a long time. Finally I am able to compile and debug from Linux.

    To compile openocd 0.5.0-rc2 from git repositoy I had to follow these steps:

    1) for ./bootstrap I had to change pkglibdir to pkgdatadir. This command I found does it for all Makefiles in current dir/ subdir:

    fgrep -rlZ pkglib_DATA --include Makefile.am . | xargs -0 sed -i 's/pkglib_DATA/pkgdata_DATA/g'    

    2) sudo apt-get install jimsh  -> because obviously jimsh was missing and is needed for ./configure

    3) ./configure --enable-maintainer-mode --enable-ft2232_libftdi

    finally -> make and sudo make install and it should build fine.

    compiled openocd binary is in /<your-checkedout-git-repository>/src/openocd

    Best Regards,

    cee

  • Hi all,

    thanks for this thread! crosstool-ng is just compiling the toolchain, but I'm confident that it will work.

    Anyway, if someone needs to get the StellarisWare sources, simply download the windows exe and extract it with some file extractor. I used file-roller (default tool of Ubuntu), but there are others which should work just as well.

    Regards,

    Philipp

  • Hi,

    I have found this quite useful. Thank you.

    I am using ubuntu and stellaris LM3S3748

    Just thought i should update these instructions though.

    http://crosstool-ng.org/ is the new website for cross tool

    download the latest stable ( i used 1.16.0 )

    The following is mostly copied from above

    bzip2 -d crosstool-ng-1.16.0.tar.bz2
    tar -xf crosstool-ng-1.16.0.tar
    cd crosstool-ng-1.16.0/
    sudo apt-get install awk gawk bison flex automake libtool libncurses-dev zlib1g-dev texinfo aria2 cvs
    ./configure
    make
    sudo make install
    mkdir /home/user1/arm-eabi/
    cd /home/user1/arm-eabi/
    #build the entire toolchain
    ct-ng menuconfig #note can change options here
    ct-ng build

    libftdi instructions are the same except 0.20 is latest

    can still git or download and run

    http://sourceforge.net/projects/openocd/  -- latest was 0.6

    bzip2 -d openocd-0.6.0-rc1.tar.bz2
    tar -xvf openocd-0.6.0-rc1.tar
    ./configure --enable-ft2232_libftdi
    make
    sudo make install

    same as 6965 above to run