Monthly Archives: februarie 2014

Downloading images to TI Tiva C Launchpad from Keil in Wine

Posted by on februarie 07, 2014
Fără categorie / 2 Comments

I needed to run some programs on my Tiva C Launchpad board from Linux. Normally this is very simple, as shown in a previous post. However, I needed to use the ARM Keil IDE, in order to get credit for my work.

Keil runs fine under Wine, but Wine is not that good with unknown USB devices. However, I managed to find a way around that and download the image using lm4tools instead of the default flasher. The instructions were tested using Tiva C, but work just as well on Stellaris Launchpad.

1. First, we gotta be sure we can run it:

git clone https://github.com/utzig/lm4tools.git
cd lm4tools/lm4flash
make
sudo make install
echo 'ATTRS{idVendor}=="1cbe", ATTRS{idProduct}=="00fd", GROUP="users", MODE="0660"' | \
  sudo tee /etc/udev/rules.d/99-tiva-launchpad.rules

The last command is optional and ensures the command can be used as a regular user. The Vendor and Product id are obtained by running:

lsusb | grep Luminary

and are the same on Stellaris Launchpad and Tiva C

2. Then, we have to make the script callable from wine. This can be done by creating a shortcut in the fake C:\ drive used by wine:

ln -s /usr/bin/lm4flash ~/.wine/drive_c/windows/system/lm4flash.exe

To check if it works, just start cmd from wine:

$ wine cmd
c:> c:\windows\system\lm4flash.exe

3. lm4flash needs a bin file and Keil ony generates an axf file. To get the bin file, go to project options, user tab and paste the following in the „Run programs after Build/Rebuild” section:

C:\Keil\ARM\ARMCC\bin\fromelf.exe  --bin HelloLaunchPad.axf --output HelloLaunchPad.bin

Ofcourse, you need to customize the paths.

4. The final step is to use lm4flash to download the image. Go to the project options, Utilities tab and select the „Use External tool for Flash programming” radio button from the „Configure Flash Menu Command” section.

Command: C:\windows\system\lm4flash.exe
Argument: HelloLaunchPad.bin
Run Independent checked (this is so the IDE won’t block if the script fails for some reason)

5. That’s it, make a small change to the code (so you know if the new code is active) and click on Flash->Download. Hope this helps someone 🙂

IDEs for developing for the Tiva C board.

Posted by on februarie 05, 2014
Fără categorie / No Comments

Now that we have a working environment for the Tiva C, we might as well install some IDEs and make it easy to develop complex programs. The main options on Linux are:

  1. TI’s own Code Composer (an Eclipse IDE with some changes); it can also be installed within an existing Eclipse instance, but it only works with versions 3.8 to 4.0.
  2. Eclipse itself can be configured so it works with the Linux tools
  3. If for some reason you want to use Keil, the IDE from ARM itself, you will need to use Wine, as there is no Linux version.

In this post we will talk about the first to IDEs and leave Keil for another day, as the configuration is a little bit more complex in its case. If you want a step-by-step guide for Keil (and Code Composer), I recommend this excellent article.

Code Composer

Code Composer conveniently offers a dependency script the one can use to determine if all necessary packets are installed. I strongly suggest to run it first, as debugging afterwards can be difficult. You can find the full instructions below

#precheck
wget http://software-dl.ti.com/dsps/dsps_public_sw/sdo_ccstudio/scratchpad/depends_0.2.tar.gz
mkdir ticheck
cd ticheck
tar -xzvf ../depends_0.2.tar.gz
./check_depends.sh
#install anything needed
#download the CCS
./ccs_setup_5.5.0.00077.bin

You will need to choose the following options: Custom-> Tiva C Series ARM MCUs -> Select All -> Select All

If you could not install the drivers from the installer, you need to run another script: sudo /opt/ti/ccsv5/install_scripts/install_drivers.sh

You are now ready to start Code Composer. If you are familiar with Eclipse development, you should have no problem compiling, downloading and debugging code for the Tiva board.

Eclipse

In order to use Eclipse itself, you need to configure it to use the arm compiler and OpenOcd debugger. You can find an excellent tutorial on this page, so I won’t go into further details here.

Similar approaches can be taken with other IDEs, like Netbeans. If you are using another IDEs, do leave a comment and let us know how it’s been working for you.

Programming for the Tiva C Launchpad on Linux

Posted by on februarie 04, 2014
Fără categorie / 3 Comments

I’ve recently acquired a Tiva C launchpad from Texas Instruments, that I plan to use to complete an online course much like PM was during my faculty years. However, unlike 7 years ago, my only OS is now openSUSE, which meant having an additional (although small) challenge in creating a development environment.

Below is a checklist of what you will need. Prerequisites include being able to download and compile programs from source code (but you probably know that if you’re trying to program an embedded board, right?).

1. First and foremost, you will need a toolchain for compiling the code you write. Tiva C has an ARM Cotex-M processor, making it relatively easy to find a great number of toolchains.

Many people on the internet recommend Summon-arm, but this toolchain is no longer maintained. Instead, the author recommends GNU Tools For ARM Embedded Processors (AKA GCC ARM Embedded), so I went with that one. You can download either a precompiled archive, or the sources and do the compiling yourself. As my computer is fairly old, I decided on the binary archive:

wget https://launchpad.net/gcc-arm-embedded/4.8/4.8-2013-q4-major/+download/gcc-arm-none-eabi-4_8-2013q4-20131204-linux.tar.bz2
tar -xvf gcc-arm-none-eabi-4_8-2013q4-20131204-linux.tar.bz2
sudo cp -r * /usr

2. Then, you need the Texas Instruments libraries and headers. You will not find any Linux kit on the TI website, but fear not: the Windows installer is just a zip file that contains a working Makefile. The kit can be downloaded from this page (or direct link). You will need a TI account to download – the same one used to order the Launchpad. Compiling it is also a breeze:

mkdir tilib
cd tilib
unzip ../SW-EK-TM4C123GXL-2.0.1.11577.exe
make

3. You will also need something to download the binaries on the device. lm4flash is the recommended way of doing this on Linux. This is also compiled easily and quickly:

git clone https://github.com/utzig/lm4tools.git
cd lm4tools/lm4flash
make
sudo make install

echo 'ATTRS{idVendor}=="1cbe", ATTRS{idProduct}=="00fd", GROUP="users", MODE="0660"' | \
sudo tee /etc/udev/rules.d/99-stellaris-launchpad.rules

The last command is optional and ensures the lm4flash command can be used as a regular user. The Vendor and Product id are obtained by running:

lsusb | grep Luminary

and are the same on Stellaris Launchpad and Tiva C

You can check that lm4flash works by downloding one of the examples included in the TI archive (see step 2). After a successful download, the link should blick while the color varies.

cd tilib/examples/boards/ek-tm4c123gxl/blinky/sourcerygxx
lm4flash blinky.bin

4. Debugger – a must if you write more than very simple programs for the Tiva C. The OpenOcd package is the way to go.

If you want to fetch the source on a Deb-based Linux (Debian, Ubuntu etc.) using git, here is what you must do:

sudo apt-get install git-core libtool autoconf texinfo libusb-dev libusb-1.0 screen
git clone http://git.code.sf.net/p/openocd/cod

On my openSUSE, I prefered to download the tarball:

sudo zypper in git-core libtool autoconf texinfo libusb-dev libusb-1_0-0 libusb-1_0-devel
wget http://downloads.sourceforge.net/project/openocd/openocd/0.7.0/openocd-0.7.0.tar.bz2

In both cases, compiling is the same:

./configure –enable-maintainer-mode –enable-ti-icdi
make
sudo make install

5. While TI offers its own startup libraries, some people prefer a totally free (as in FLOSS) linker. Instructions on installing such a linker on the Stellaris Launchpad (the forerunner of Tiva C) can be found on this page. I have not tried it, as for my requirements the TI libraries are enough, but due to la similarities between the platforms, this should also work just fine on the Tiva.

This is it, you can now compile and download your own programs on your new board. However, if you’re not a vim-or-emacs person, you might want to install an IDE.