Difference between revisions of "IMote2 Compiler"

From TinyOS Wiki
Jump to: navigation, search
(Using Newer Toolchain)
Line 126: Line 126:
 
I've run a few of the things in the test directory for fun:
 
I've run a few of the things in the test directory for fun:
  
* apps/tests/LplBroadcastCountToLeds (needs to add TARGET_INTELMOTE2 to the list of supported targets to compile)
+
* Radio
* apps/tests/LplBroadcastPeriodicDelivery (needs to add TARGET_INTELMOTE2 to the list of supported targets to compile)
+
** apps/tests/LplBroadcastCountToLeds (needs to add TARGET_INTELMOTE2 to the list of supported targets to compile)
 +
** apps/tests/LplBroadcastPeriodicDelivery (needs to add TARGET_INTELMOTE2 to the list of supported targets to compile)
 +
** apps/tests/LplUnicastPeriodicDelivery (needs to add TARGET_INTELMOTE2 to the list of supported targets to compile)
 +
** apps/tests/TestAcks/
 +
** apps/tests/TestPacketLink/
 +
* Flash
 +
** apps/tests/storage/Block
 +
** apps/tests/storage/CircularLog
 +
** apps/tests/storage/Config
  
 
Feel free to add to either of these lists if you successfully use the GCC 4.2.4 tools.
 
Feel free to add to either of these lists if you successfully use the GCC 4.2.4 tools.
  
 
--[[User:Gwa|Gwa]] 14:07, 11 July 2008 (EDT)
 
--[[User:Gwa|Gwa]] 14:07, 11 July 2008 (EDT)

Revision as of 11:51, 11 July 2008

This article assumes that you already have tinyos-2.x installed on your system. Go to http://www.tinyos.net/tinyos-2.x/doc/html/install-tinyos.html for install instructions. Do not install the xscale tools from that page (step 3 can be skipped).

Installing xscale-elf toolchain with Debian packages

Download packages

Download the following package files:

xscale-elf-binutils-2.15-2.i386.deb

xscale-elf-gcc-3.4.3-2.i386.deb

xscale-elf-newlib-1.13.0-1.i386.deb

Install the packages

$ dpkg --install xscale-elf-binutils-2.15-2.i386.deb
$ dpkg --install xscale-elf-gcc-3.4.3-2.i386.deb
$ dpkg --install xscale-elf-newlib-1.13.0-1.i386.deb

That's it. Run make on Blink (or other code) to see if it works:

$ cd $TOSROOT/apps/Blink
$ make intelmote2

You should see an executable output.

Installing xscale-elf toolchain from source

If you can install debian packages and do no need the source, this section is not for you. Scroll up and install the packages.

The xscale-elf rpms on the Tinyos-2.x install page contain a version of newlib that does not work on debian linux. Instead, we opted for a newer version of newlib (1.13). In this section, we mostly followed the instructions from the Harvard imote2 install page for compiling from source: [1]

Download source

To compile a working xscale-elf toolchain on debian from source, you will need to download the following source distributions:

xscale-elf-binutils 2.15

xscale-elf-gcc 3.4.3

newlib 1.13

Note: The links to the source files are different from the ones on the Harvard imote2 install page.

Define environment variables

These can be removed after the installation.

$ export TARGET=xscale-elf
$ export PREFIX=/usr

If you don't already have the bin subdir of the directory specified by PREFIX added to your PATH, add it now:

$ export PATH=${PREFIX}/bin:${PATH}

Build binutils

$ tar xzf xscale-elf-binutils-2.15.tgz
$ cd xscale-elf-binutils-2.15
$ mkdir build; cd build
$ ../configure --target=$TARGET --prefix=$PREFIX
$ make all install

Build bootstrap compiler

$ tar xzf xscale-elf-gcc-3.4.3.tgz
$ cd xscale-elf-gcc-3.4.3
$ mkdir build; cd build
$ ../configure --target=$TARGET --prefix=$PREFIX \
   --with-newlib --without-headers --with-gnu-as \
   --with-gnu-ld --disable-shared --enable-languages=c
$ make all-gcc install-gcc

Build newlib

$ tar xzf newlib-1.13.0.tar.gz
$ cd newlib-1.13.0
$ mkdir build; cd build
$ ../configure --target=$TARGET --prefix=$PREFIX
$ make all install

Rebuild gcc

$ cd xscale-elf-gcc-3.4.3
$ cd build
$ rm -rf *
$ ../configure --target=$TARGET --prefix=$PREFIX \
   --with-gnu-as --with-gnu-ld --enable-languages=c
$ make all install

Verification

You should now be able to compile Blink:

$ cd $TOSROOT/apps/Blink
$ make intelmote2

You should see an executable output.

--Ian Freeman

Note: These instructions were tested and found to be working on Ubuntu 8.04 and XubunTOS-2.0 (Ubuntu 7.04). Some times during the testing, instead of the

/usr

, we tried with

/opt

directory and it still works.

Using Newer Toolchain

Given that several members of our group had had difficulty compiling certain applications using the GNU toolchain described above, I have tested these instructions using GCC 4.2.4 and Binutils 2.17 (later versions of Binutils (2.18) may work; I did test with GCC 4.3.1 and was unable to compile for the "arm-eabi" target.) A few small diffs are needed against the generally excellent instructions above, including:

  • Apparently xscale-elf support is being phased out, so you need to export TARGET=arm-eabi.
  • Once you have compiled and installed the toolchain, you need to fix a few things in various places in the T2 tree to get the compilation process to work correctly. In our T2 tree I've created a new compilation target called intelmote2-gcc42, which should be apparently how to do from the diffs below, but in general you need to make the following changes in the following places:
    • support/make/pxa27x/pxa27x.rules, to fix various pieces of the toolchain:
      • s/xscale-elf-as/arm-eabi-as/, s/xscale-elf-objdump/arm-eabi-objdump/, s/xscale-elf-objcopy/arm-eabi-objcopy/. You can probably do a global search and replace changing "xscale-elf" to "arm-eabi".
      • Add "PFLAGS += -mcpu=xscale". If you do not set this correctly the compiler will emit incorrect instructions causing some things to work and others to fail miserably.
    • tos/platforms/intelmote2/.platform, to fix the compiler target: (not sure why this is hidden here)
      • s/xscale-elf-gcc/arm-eabi-gcc/.

Testing Newer Toolchain

So far the following things seem to work:

  • apps/Blink
  • apps/RadioCountToLeds
  • Our volcano application, which is quite complex and exercises the radio and Flash as well as a number of other things.

I've run a few of the things in the test directory for fun:

  • Radio
    • apps/tests/LplBroadcastCountToLeds (needs to add TARGET_INTELMOTE2 to the list of supported targets to compile)
    • apps/tests/LplBroadcastPeriodicDelivery (needs to add TARGET_INTELMOTE2 to the list of supported targets to compile)
    • apps/tests/LplUnicastPeriodicDelivery (needs to add TARGET_INTELMOTE2 to the list of supported targets to compile)
    • apps/tests/TestAcks/
    • apps/tests/TestPacketLink/
  • Flash
    • apps/tests/storage/Block
    • apps/tests/storage/CircularLog
    • apps/tests/storage/Config

Feel free to add to either of these lists if you successfully use the GCC 4.2.4 tools.

--Gwa 14:07, 11 July 2008 (EDT)