Serial Toolchain under Ubuntu 10.04

We have choosen to write this for Ubuntu because it seems to be the choice for people starting with Linux today (and we use it) and we have chosen to use 10.04 because it is a long term support (LTS) version. The steps should be able to be used on most systems with the package management steps changed appropriately.

  1. Setup your Serial Hardware
  2. Download and install Latest Codesourcery G++ lite EABI
  3. Download and install StellarisWare Packages
  4. Install other utilities
  5. Download examples, modify the makefile and compile
  6. Download, install and configure editor/IDE

This guide is used across our development boards any place you see <boardName> please replace it with the name of your board. IE Eridani, Cygni, Procyon, etc.

Setup your Serial hardware

Hardware under Linux is one of those things, it tends to either work automatically or be very hard to make work.

For this we assume you have an FT232 which we call FTDI Basic for the rest of the guide but you may use any serial port that gives 3.3V or 5V I/O. If you are using something else just read FTDI Basic as serial com device. You may need to configure your board to be powered differently later in the guide also if you don't use FTDI Basic or similar.

Whatever you use, when you use the board you will attach the COM port to A0/A1 or the FTDI Basic pinout that repeats A0/A1 with power and GND pins.

lsusb will give a listing of the usb devices attached to your computer. The first part of the ID string is the vendor ID the second part is the product ID.

On Ubuntu these FTDI based serial devices can only be accessed with sudo unless you create special rules for them.

Open a terminal and goto:

cd /etc/udev/rules.d/

open your favorite text editor and make a new file:

sudo gedit 82-ftdiusb.rules

the file contents should be something like this:

BUS!="usb", ACTION!="add", SUBSYSTEM!=="usb_device", GOTO="kcontrol_rules_end"

# Just an extra serial port (Sparkfun FT232R)
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE="664", GROUP="plugdev"

# Olimex ARM-USB-OCD-TINY
ATTRS{idVendor}=="15ba", ATTRS{idProduct}=="0004", MODE="664", GROUP="plugdev"

# Bus Blaster 2
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6010", MODE="664", GROUP="plugdev"

# TI/Luminary Stellaris Evaluation Board (several)
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="bcd9", MODE="664", GROUP="plugdev"

# TI/Luminary Stellaris In-Circuit Debug Interface (ICDI) Board
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="bcda", MODE="664", GROUP="plugdev"

LABEL="kcontrol_rules_end"

You basically just need to add:

ATTRS{idVendor}=="XXXX", ATTRS{idProduct}=="YYYY", MODE="664", GROUP="plugdev"

for each FTDI device you want to use in user space (without sudo). This code lets members of plugdev use the device. The default Ubuntu account should be a member of this group. If the device isn't there nothing bad will happen.

Use lsusb to find XXXX and YYYY for your JTAG.

These rules aren't in effect yet, the easiest way to have them active is just to reboot (I don't know a special command).

Download and install Latest Codesourcery G++ lite EABI

You may download the latest version of G++ EABI from here. The version at the time of writing was 2010.09-51.

G++ EABI is a cross compiler for ARM programs running without an OS.

To install successfully you need to change a few things:

sudo dpkg-reconfigure -plow dash -- > Answer **NO**

This changes the shell to bash.

Check that it is the default shell:

ls -lh /bin/sh

This should result in something like:

lrwxrwxrwx 1 root root 4 2011-01-23 11:09 /bin/sh -> bash

Now we can run the installer:

/bin/sh arm-YOURVERSIONNUMBER-arm-none-eabi.bin 

For this guide we accepted all of the defaults on install. It should be the default but be sure in the path step that the path is added for the user you wish to complete your development with.

The path is added to .profile for which is executed on startup, you can either rerun that whole script or add the path for this boot by hand:

PATH="/home/YOUR USER NAME/CodeSourcery/Sourcery_G++_Lite/bin:${PATH}"
export PATH

Check that everything is setup correctly:

arm-none-eabi-gcc

It should say:

arm-none-eabi-gcc: no input files

Download and install StellarisWare Packages

Go to Ti's site and get the complete StellarisWare here.

The most recent version we have used is SW-LM3S-8264, but newer versions should be fine as well. If the complete package is too large you can get most of functionality with StellarisWare Driver Library standalone package.

Create a folder called “Development” in your home directory.

Although this file is an .exe it actually contains a ZIP of all the examples and codes, just double click on it and the archiver will open. Extract the files to:

/Development/StellarisWare

Create a directory called <boardName> in your Development directory when you are done installing the StellarisWare software.

Install other utilities

For the make files to run we need perl installed, it should be installed with Ubuntu. If you don't have a serial terminal emulator gtkterm is a good one to have.

To install gtkterm just run:

sudo apt-get install gtkterm

Ubtuntu doesn't come with make by default in some flavors if you don't have it you will need it:

sudo apt-get install make

Download examples, modify the makefile and flash the board

First you need to download and unzip the examples for your board. For this guide we will assume they are in Development/<boardNameExamples>.

In the example zip there are files to support this toolchain as well as other toolchains. This toolchain assumes you have the bootloader that came with your board. If for some reason you don't and have used another toolchain and overwritten it you will need to put it back. A copy of the bootloader binary is included in the examples archive in extras directory.

The first thing we need to do is copy sflash from the extra/sflash directory to some directory in your path.

I choose to put it in CodeSourcery's bin directory even though it isn't part of CodeSourcery. You could add a special directory to your path or just copy it as I suggest.

To see what directories are in your path:

echo $PATH

Once it is somewhere in your path try:

sflash -h

At the prompt if it gives you help everything is okay. If not make sure it is in a path directory. If it fails the binary might not work on your system. In that case go get the source for it and rebuild it for your system. The source is on Luminary Micro's download page under “application note source”, it is SW01242-680.

Open the “makefilesettings” in the root of the example directory in your favorite text editor.

This file is included (added to) all the other make files, this lets us update one file to change the build settings across all our example programs. The MAKEFILE tells a program called make how to create our program. It specifies all sorts of information. If you would like to know more about the MAKEFILE you can read about it here. For now we just need to change a few lines in makefilesettings.

COMPORT = /dev/ttyUSBx where x is some number (or any tty device you want to use)
SERIALPROG = 1
WINDOWS = 0
DIR_STELLARISWARE = the directory you installed StellarisWare to

Open a command prompt and change to the blinky directory.

Run:

make

If everything is setup right now you will get no errors.

If you get an error you have made a mistake in the guide. Please review it again.

This toolchain uses a bootloader. The bootloader works by checking if a pin is low on reset. If it is, then the bootloader waits for the proper commands over UART0 (A1/A2) to update the flash. If it is not it runs your program from 0x1000 in flash. You may use any means you wish to have the pin low if you wish to force an update.

The pin checked is (check pin):

Board Pin
Eridani B4
Cygni B3
Procyon B4

Please read the documentations/manuals for your board if you have not already. To proceed we will use assume you are using a 5V FTDI Basic, BasicUART, or other compatible UART board.

Attach jumpers between User LED and the blink pin in the blinky example, and User Switch and check pin. Set the jumper board jumpers to take power from the UART interface.

If your UART does not supply a 5V rail power set the board up to take power from another source.

The pin used for blinking the LED in blinky is:

Board Pin
Eridani D0
Cygni B0
Procyon B5

Attach the UART board so that the GND Pin is aligned with the labels on the board.

The POWER led should now be lit. If it is not the jumpers are set wrong or the UART board is not supplying 5V.

While holding the User Switch press RESET.

Your board should now be in the bootloader waiting for input.

At the command prompt:

make flash

The User LED should start blinking. And the command prompt should look like this:

Congratulations everything is working nicely. Go ahead and look at the blinky.c file, change the blink rate and reprogram your board or try flashing some of the other examples.

Download, install and configure editor/IDE

There are many editors which you could use. In Linux the field is wide open. For something simple gedit will due. It is really up to your taste. Goodluck and enjoy!

toolchain/seriallin.txt · Last modified: 2014/08/01 20:14 (external edit)
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki