Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Friday, 15 October 2010

Cross-Compiler for ARM Based Embedded System

Installing a cross-compiler for ARM

For an embeded Debian3 operating system, Emdebian4, on an Armel5 (ARM/ATMEL) processor. The cross-compiler toolchain will be installed on a Linux box running Ubuntu 10.04 (Lucid Lynx).

Adding Embedian repositories to the aptitude install system

sudo gedit /etc/apt/sources.list

Add the following lines to that file:

#
# -- Emdebian cross toolchains
#
deb http://buildd.emdebian.org/debian/ lenny main
deb-src http://buildd.emdebian.org/debian/ lenny main

NOTE: Since late 2010, the repository location has been changed to:

# deb http://www.emdebian.org/debian/ unstable main
# deb http://www.emdebian.org/debian/ testing main
deb http://www.emdebian.org/debian/ lenny main
deb-src http://www.emdebian.org/debian/ lenny main

In order to verify and be able to use the repositories they have to be authenticated via GPG.

The simple way to do this is:

sudo apt-get install emdebian-archive-keyring

If you want to do it manually, please check http://www.emdebian.org/packages/keys.html.


Installing the tool-chain via aptitude

sudo apt-cache search armel
sudo apt-get install linux-libc-dev-armel-cross
sudo apt-get install libc6-armel-cross libc6-dev-armel-cross
sudo apt-get install binutils-arm-linux-gnueabi
sudo apt-get install gcc-4.3-arm-linux-gnueabi
sudo apt-get install g++-4.3-arm-linux-gnueabi

In the case of library version conflicts the following might help:

sudo apt-get autoremove


Installing the cross-tools own aptitude and dpkg

The embedian tool-chain comes along with it's own package management, that will allow you to install pre-compiled versions of essential basic libraries that will make it easier to get going.

sudo apt-get install apt-cross dpkg-cross

Update the list of available software and list/install packages using:

sudo apt-cross -a armel -u
sudo apt-cross -a armel -l
sudo apt-cross -a armel -i


Using the Embedian cross-compiler

In order to compile code using the cross-compiler, you need to tell your PC explicitly to use it.

NOTE that the binaries created do NOT run on your PC as they are compiled to run on an ARM architecture! You can check for which platform etc. a file is by displaying it's ELF header:

readelf -h


Custom Makefile

Make sure that the following variables are set in your Makefile/environment:

CC = arm-linux-gnueabi-gcc (or arm-linux-gnueabi-g++)
CXX = arm-linux-gnueabi-g++

If you want to link static libraries, which can be helpful in the case of embedded systems where not necessarily all libraries are available as dynamically linked versions on the target system, use:

CFLAGS += -static


Software that uses the "configure" workflow (usually the case!)

./configure --prefix=/usr/arm-linux-gnueabi --host=arm-linux-gnueabi

Tuesday, 6 July 2010

Ubuntu Linux: Which Version am I Running?

If you are running Linux on your machine, in particular Ubuntu, it can be tedious if you just quickly want to find out the version of the Kernel you are running and which Ubuntu release you are running (including it's nickname/codename!).

So here are two quick ways of getting the information from the command line:

lsb_release -a

... will give you a good idea of which version you are running, e.g.:

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 9.10
Release: 9.10
Codename: karmic

... and if you want to find out more about the kernel version, this can be done via typing

uname -a

Wednesday, 2 June 2010

Nexys2 - Configure Via USB

The Nexys2 is a low-cost FPGA development board from Digilent. It features a Xilinx Spartan-3E FPGA (500K or 1200K gate version), 16 MByte Flash/SDRAM, USB and an RS232.

The board can be powered via USB, which makes it quite convenient to use. The board can be configured in two different ways:

1.) Using a Xilinx Platform Cable

- attach cable (separade leads) to J5.
- pins 1 to 6: TMS, TDI, TDO, TCK, GND, VREF

Using the platform cable provides convenient access to the FPGA + attached SPI flash as well as the platform flash (PROM) using the impact tool from the Xilinx suite.

2.) Configuring via USB

... which does not require the expensive platform cable!

In case you run Windows, just download the Digilent Adept tool from the digilent website.

In case you run Linux you are fine thanks to the guy who wrote a nice tool called nexys2prog. It is fairly straight forward to set it up and works like a charm (example for Ubuntu / Debian):

apt-get install fxload
apt-get install libftdi
download UrJTAG and install it via:
./configure
make
make install

Now you should be ready to run the nexys2prog configuration script

nexys2prog myfile.bit

It will detect and configure the Nexys2 board when it is connected to the USB port. In order to do so, custom firmware is loaded into the board's USB controller. Unplug and replug the board in order to restore the original configuration, which is required to use Digilent Adept.