Difference between revisions of "IMote2 Compiler"

From TinyOS Wiki
Jump to: navigation, search
m (Newer Toolchains)
m
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
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).
+
This article focuses on the cross compiler required to obtain exec files for the iMote2 platform. It does not deal with TinyOS tree, for that information see [[Imote2| iMote2 article]] on this wiki or the [[Installing_TinyOS_2.1.1| regular TinyOS installation instructions]]. However, users should be aware of fact that regarding iMote2 the latter includes instructions that may not work out at all times or are outperformed by alternatives referred hereafter.
  
== Installing xscale-elf toolchain with Debian packages ==
+
== Introduction ==
 +
iMote2 integrates an XScale processor (PXA271) whose core is ARM. Therefore, suitable compilers for iMote2 can be named after the processor family name or the overall architecture, namely ARM.
  
=== Download packages ===
+
Contents are structured in two more sections: one for packaged compilers (deb or rpm) which is the fastest and cleanest way of installing and deleting the compiler and another one to do it from source code, which is just recommended if such packages are unavailable or incompatible with your system setup.
  
Download the following package files:
+
== Packaged compilers ==
 +
This is the simplest and fastest way to install our compiler either on Debian-based systems or on Cygwin (Windows), for other Linux distributions see section on [[#Install_from_source_code| Install from source code]]. Generally, you will need to download one or more files (packages) and install them on the command line or simply double clicking if you have X Window installed.
  
[http://www.andes.ucmerced.edu/download/xscale/xscale-elf-binutils-2.15-2.i386.deb xscale-elf-binutils-2.15-2.i386.deb]
+
=== GCC 4.x ===
 +
GCC v4.x is just available as Debian packages. However, Debian/Ubuntu users will likely perceive a noticeable improvement regarding exec size, execution times and compatibility with other WSN platforms such as micaZ whose compiler had installation conflicts with previous packaged versions (v3.4.3). Two ''flavours'' are available for two different compiler versions: elf and eabi. Both have been reported to work fine <ref>[http://www.gaps.ssr.upm.es/en/research/wsn/138-compiling-for-an-arm-architecture-imote2-tinyos Compiling for an ARM architecture: iMote2-TinyOS. Experiences at Consolider COMONSENS]</ref>, eabi is the most recent definition for binary files though.
  
[http://www.andes.ucmerced.edu/download/xscale/xscale-elf-gcc-3.4.3-2.i386.deb xscale-elf-gcc-3.4.3-2.i386.deb]
+
==== Download and Install ====
 +
You may download and install any package or even both on the same system as they are not mutually incompatible. Upon compiling your application you will have to decide which one to invoke. Most likely you will not change it every now and then as two files from your TinyOS tree need to be edited. For further information on elf and none-eabi regarding these packages see [http://oa.upm.es/3837/3/tech.rep-10-01_11.pdf Compiling for an ARM architecture: iMote2-TinyOS]. Unlike other packages, all you need to install is the compiler from the links below: there is no need to search binutils or newlib since they are already included within the same package.
  
[http://www.andes.ucmerced.edu/download/xscale/xscale-elf-newlib-1.13.0-1.i386.deb xscale-elf-newlib-1.13.0-1.i386.deb]
+
* [http://forja.rediris.es/frs/download.php/2004/arm-compiler-none-eabi-4.3.3-3.deb arm-compiler-none-eabi-4.3.3-3.deb]
  
=== Install the packages ===
+
* [http://forja.rediris.es/frs/download.php/1969/arm-compiler-elf_4.1.1-1.deb arm-compiler-elf_4.1.1-1.deb]
  
<pre>$ dpkg --install xscale-elf-binutils-2.15-2.i386.deb
+
Once you have them downloaded, installation can be done on the command line or, if you have an X Window system, assisted by an application such as GDebi. Command line users can do it moving to the directory where the packages were downloaded: 
$ dpkg --install xscale-elf-gcc-3.4.3-2.i386.deb
+
<pre>
$ dpkg --install xscale-elf-newlib-1.13.0-1.i386.deb</pre>
+
$ cd <same_directory_as_downloaded_packages>
 +
$ dpkg --install arm-compiler-<flavour>.deb
 +
</pre>
  
That's it. Run make on Blink (or other code) to see if it works:
+
After the installation is completed, it is possible to invoke them from the command line, but a few '''minor edits in your TinyOS tree installation''' are required to build your TinyOS applications by means of them. It is recommended to check section 7 of ''Compiling for an ARM architecture: iMote2-TinyOS'' <ref>[http://oa.upm.es/3837/3/tech.rep-10-01_11.pdf Compiling for an ARM architecture: iMote2-TinyOS. Technical Report.]</ref> for such changes and '''indications to optimize your compilation'''.
  
<pre>$ cd $TOSROOT/apps/Blink
+
After installing, you may see if your compiler works properly. See [[#Verification|Verify subsection]] for a simple way to check it out.
$ make intelmote2</pre>
 
  
You should see an executable output.
+
=== GCC 3.4.3 ===
 +
This version is available both as Debian and RPM packages and it is the one referred at the regular TinyOS installation instructions on this wiki <ref name="inst-TOS211">[[Installing_TinyOS_2.1.1| Installing TinyOS 2.1.1. TinyOS installation method. TinyOS wiki]]</ref>. Still, this way is faster than doing from source. Some users have reported installation incompatibilities with <tt>avr-gcc-tinyos</tt>, if you do not need to code for mica2 or micaZ you can remove it before installing.  
  
=== Newer Toolchains ===
+
==== Download and Install ====
You may wish to install available deb packages with updated compiler versions, namely 4.1.1 or even 4.3.3. They have been successfully tested for some months at a [http://www.gaps.ssr.upm.es/en/research/wsn/138-compiling-for-an-arm-architecture-imote2-tinyos lab] and now are publicly available. You do not need to install any other package (such as newlib or binutils) as they are already included. Should you experience any trouble, make sure you are actually using the proper version rather than any other previously installed on your system.
+
You will need to download three packages, depending on your working environment they will be RPMs or deb:
  
[http://forja.rediris.es/frs/download.php/1969/arm-compiler-elf_4.1.1-1.deb arm-compiler-elf_4.1.1-1.deb]
+
{| class="wikitable"
 +
|-
 +
! style="background: #efefef;" |Package
 +
! style="background: #efefef;" |Cygwin (Windows)
 +
! style="background: #efefef;" |Debian<font color="red">†</font>
 +
|-
 +
| xscale-elf-binutils
 +
| [http://sing.stanford.edu/intelmote2/tools/windows/xscale-elf-binutils-2.15-1.cygwin.i386.rpm xscale-elf-binutils-2.15tinyos-1.cygwin.i386.rpm]
 +
| [http://www.andes.ucmerced.edu/download/xscale/xscale-elf-binutils-2.15-2.i386.deb xscale-elf-binutils-2.15-2.i386.deb]
 +
|-
 +
| xscale-elf-gcc
 +
| [http://sing.stanford.edu/intelmote2/tools/windows/xscale-elf-gcc-3.4.3-1.cygwin.i386.rpm xscale-elf-gcc-3.4.3-1.cygwin.i386.rpm]
 +
| [http://www.andes.ucmerced.edu/download/xscale/xscale-elf-gcc-3.4.3-2.i386.deb xscale-elf-gcc-3.4.3-2.i386.deb]
 +
|-
 +
| xscale-elf-newlibc
 +
| [http://sing.stanford.edu/intelmote2/tools/windows/xscale-elf-newlib-1.11.0tinyos-1.cygwin.i386.rpm xscale-elf-newlib-1.11.0tinyos-1.cygwin.i386.rpm]
 +
| [http://www.andes.ucmerced.edu/download/xscale/xscale-elf-newlib-1.13.0-1.i386.deb xscale-elf-newlib-1.13.0-1.i386.deb]
 +
|}
 +
<font color="red">†</font>''these deb packages are hosted on a server at UC Merced, different from the ones referred in <ref name="inst-TOS211"/>
  
[http://forja.rediris.es/frs/download.php/2004/arm-compiler-none-eabi-4.3.3-3.deb arm-compiler-none-eabi-4.3.3-3.deb]
+
Once downloaded, they should be installed in the same order as listed above since there are dependencies among them.
  
For further information on compilation optimization with such packages or their usage, check section 7 of [http://oa.upm.es/3837/2/DOPICO_MONO_2010_01.pdf Compiling for an ARM architecture: iMote2-TinyOS].
+
If you wish to see other alternatives on GCC 3.4.3, there is an outstanding compilation that takes into account [http://web.ics.purdue.edu/~paulshin/research_Imote2.html several ways of setting up the iMote2 compiler] <ref>[http://web.ics.purdue.edu/~paulshin/research_Imote2.html iMote2 environment installation. Includes a thorough compilation of installation tutorials. Paul Shin.]</ref>.
  
== Installing xscale-elf toolchain from source ==
+
=== Verification ===
 +
It is as simple as building Blink or other application code you wish:
 +
<pre>$ cd $TOSROOT/apps/Blink
 +
$ make intelmote2</pre>
 +
If you obtain an executable output, most likely your set up did the trick.
  
If you can install debian packages and do no need the source, this section is not for you. Scroll up and install the packages.
+
== Install from source code ==
 +
=== GCC 3.4.3 ===
 +
This section is suitable for you in the event that you cannot use the previous package files on your computer.
  
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: [http://www.eecs.harvard.edu/~konrad/projects/imote2Camera/IMote2-Installation-Instructions.html]
+
==== Download ====
 +
To compile a working XScale elf compiler on debian from source, you will need to download the following source distributions:
  
=== Download source ===
+
* [http://www.tinyos.net/dist-1.2.0/tools/source/xscale-elf-binutils-2.15.tgz xscale-elf-binutils 2.15]
  
To compile a working xscale-elf toolchain on debian from source, you will need to download the following source distributions:
+
* [http://www.tinyos.net/dist-1.2.0/tools/source/xscale-elf-gcc-3.4.3.tgz xscale-elf-gcc 3.4.3]
  
[http://www.tinyos.net/dist-1.2.0/tools/source/xscale-elf-binutils-2.15.tgz xscale-elf-binutils 2.15]
+
* [ftp://sources.redhat.com/pub/newlib/newlib-1.13.0.tar.gz newlib 1.13]
 
 
[http://www.tinyos.net/dist-1.2.0/tools/source/xscale-elf-gcc-3.4.3.tgz xscale-elf-gcc 3.4.3]
 
 
 
[ftp://sources.redhat.com/pub/newlib/newlib-1.13.0.tar.gz newlib 1.13]
 
  
 
'''Note: The links to the source files are different from the ones on the Harvard imote2 install page.'''
 
'''Note: The links to the source files are different from the ones on the Harvard imote2 install page.'''
  
=== Define environment variables ===
+
==== Define environment variables ====
  
 
These can be removed after the installation.
 
These can be removed after the installation.
Line 64: Line 91:
 
<pre>$ export PATH=${PREFIX}/bin:${PATH}</pre>
 
<pre>$ export PATH=${PREFIX}/bin:${PATH}</pre>
  
=== Build binutils ===
+
==== Build binutils ====
  
 
<pre>$ tar xzf xscale-elf-binutils-2.15.tgz
 
<pre>$ tar xzf xscale-elf-binutils-2.15.tgz
Line 72: Line 99:
 
$ make all install</pre>
 
$ make all install</pre>
  
=== Build bootstrap compiler ===
+
==== Build bootstrap compiler ====
  
 
<pre>
 
<pre>
$ tar xzf xscale-elf-gcc-3.4.3.tgz
+
$ tar xzf xscale-elf-gcc-3.4.3.tgzInstall from source code
 
$ cd xscale-elf-gcc-3.4.3
 
$ cd xscale-elf-gcc-3.4.3
 
$ mkdir build; cd build
 
$ mkdir build; cd build
Line 83: Line 110:
 
$ make all-gcc install-gcc</pre>
 
$ make all-gcc install-gcc</pre>
  
=== Build newlib ===
+
==== Build newlib ====
  
 
<pre>$ tar xzf newlib-1.13.0.tar.gz
 
<pre>$ tar xzf newlib-1.13.0.tar.gz
Line 91: Line 118:
 
$ make all install</pre>
 
$ make all install</pre>
  
=== Rebuild gcc ===
+
==== Rebuild gcc ====
  
 
<pre>$ cd xscale-elf-gcc-3.4.3
 
<pre>$ cd xscale-elf-gcc-3.4.3
Line 100: Line 127:
 
$ make all install</pre>
 
$ make all install</pre>
  
=== Verification ===
+
==== Verification ====
  
 
You should now be able to compile Blink:
 
You should now be able to compile Blink:
Line 118: Line 145:
  
 
A few small diffs are needed against the generally excellent instructions above, including:
 
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.
 
* Apparently xscale-elf support is being phased out, so you need to export TARGET=arm-eabi.
Line 152: Line 178:
  
 
--[[User:Gwa|Gwa]] 14:07, 11 July 2008 (EDT)
 
--[[User:Gwa|Gwa]] 14:07, 11 July 2008 (EDT)
 +
 +
== References ==
 +
 +
<references/>

Latest revision as of 08:51, 13 December 2010

This article focuses on the cross compiler required to obtain exec files for the iMote2 platform. It does not deal with TinyOS tree, for that information see iMote2 article on this wiki or the regular TinyOS installation instructions. However, users should be aware of fact that regarding iMote2 the latter includes instructions that may not work out at all times or are outperformed by alternatives referred hereafter.

Introduction

iMote2 integrates an XScale processor (PXA271) whose core is ARM. Therefore, suitable compilers for iMote2 can be named after the processor family name or the overall architecture, namely ARM.

Contents are structured in two more sections: one for packaged compilers (deb or rpm) which is the fastest and cleanest way of installing and deleting the compiler and another one to do it from source code, which is just recommended if such packages are unavailable or incompatible with your system setup.

Packaged compilers

This is the simplest and fastest way to install our compiler either on Debian-based systems or on Cygwin (Windows), for other Linux distributions see section on Install from source code. Generally, you will need to download one or more files (packages) and install them on the command line or simply double clicking if you have X Window installed.

GCC 4.x

GCC v4.x is just available as Debian packages. However, Debian/Ubuntu users will likely perceive a noticeable improvement regarding exec size, execution times and compatibility with other WSN platforms such as micaZ whose compiler had installation conflicts with previous packaged versions (v3.4.3). Two flavours are available for two different compiler versions: elf and eabi. Both have been reported to work fine <ref>Compiling for an ARM architecture: iMote2-TinyOS. Experiences at Consolider COMONSENS</ref>, eabi is the most recent definition for binary files though.

Download and Install

You may download and install any package or even both on the same system as they are not mutually incompatible. Upon compiling your application you will have to decide which one to invoke. Most likely you will not change it every now and then as two files from your TinyOS tree need to be edited. For further information on elf and none-eabi regarding these packages see Compiling for an ARM architecture: iMote2-TinyOS. Unlike other packages, all you need to install is the compiler from the links below: there is no need to search binutils or newlib since they are already included within the same package.

Once you have them downloaded, installation can be done on the command line or, if you have an X Window system, assisted by an application such as GDebi. Command line users can do it moving to the directory where the packages were downloaded:

$ cd <same_directory_as_downloaded_packages> 
$ dpkg --install arm-compiler-<flavour>.deb

After the installation is completed, it is possible to invoke them from the command line, but a few minor edits in your TinyOS tree installation are required to build your TinyOS applications by means of them. It is recommended to check section 7 of Compiling for an ARM architecture: iMote2-TinyOS <ref>Compiling for an ARM architecture: iMote2-TinyOS. Technical Report.</ref> for such changes and indications to optimize your compilation.

After installing, you may see if your compiler works properly. See Verify subsection for a simple way to check it out.

GCC 3.4.3

This version is available both as Debian and RPM packages and it is the one referred at the regular TinyOS installation instructions on this wiki <ref name="inst-TOS211"> Installing TinyOS 2.1.1. TinyOS installation method. TinyOS wiki</ref>. Still, this way is faster than doing from source. Some users have reported installation incompatibilities with avr-gcc-tinyos, if you do not need to code for mica2 or micaZ you can remove it before installing.

Download and Install

You will need to download three packages, depending on your working environment they will be RPMs or deb:

Package Cygwin (Windows) Debian
xscale-elf-binutils xscale-elf-binutils-2.15tinyos-1.cygwin.i386.rpm xscale-elf-binutils-2.15-2.i386.deb
xscale-elf-gcc xscale-elf-gcc-3.4.3-1.cygwin.i386.rpm xscale-elf-gcc-3.4.3-2.i386.deb
xscale-elf-newlibc xscale-elf-newlib-1.11.0tinyos-1.cygwin.i386.rpm xscale-elf-newlib-1.13.0-1.i386.deb

these deb packages are hosted on a server at UC Merced, different from the ones referred in <ref name="inst-TOS211"/>

Once downloaded, they should be installed in the same order as listed above since there are dependencies among them.

If you wish to see other alternatives on GCC 3.4.3, there is an outstanding compilation that takes into account several ways of setting up the iMote2 compiler <ref>iMote2 environment installation. Includes a thorough compilation of installation tutorials. Paul Shin.</ref>.

Verification

It is as simple as building Blink or other application code you wish:

$ cd $TOSROOT/apps/Blink
$ make intelmote2

If you obtain an executable output, most likely your set up did the trick.

Install from source code

GCC 3.4.3

This section is suitable for you in the event that you cannot use the previous package files on your computer.

Download

To compile a working XScale elf compiler on debian from source, you will need to download the following source distributions:

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.tgzInstall from source code
$ 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.) (Bor-rong Chen update: I was able to compile the toolchain using GCC 4.3.2, binutils 2.18, newlib 1.16)

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)

References

<references/>