How to configure an environment to cross-compile applications for beagleboard-xM
1. ##########################################################################
## CETENE - LINCS - Campina Grande/Recife - Paraíba/Pernambuco - Brasil ##
## Dalton Cézane Gomes Valadares - Embedded Systems Developer ##
## Master's/Specialist/Bachelor in Computer Science - UFCG ##
##########################################################################
Tutorial about how to configure a development environment to cross-compile
applications for beagleboard-xM
- Download the latest version of crosstool-NG: http://crosstool-ng.org/download/crosstool-ng/
- Create a directory to copy and descompact the file:
* sudo mkdir /opt/cross_arm
* sudo cp crosstool-ng-1.13.3.tar.bz2 /opt/cross_arm/.
- Go to created directory and do:
* cd /opt/cross_arm
* sudo tar -xvjpf crosstool-ng-1.13.3.tar.bz2
* cd crosstool-ng-1.13.3.tar.bz2
* sudo ./configure --prefix=/opt/cross_arm (when you run this command, check if all dependencies
are installed - if needed, install the dependencies)
- Now, your screen must present something like this:
"Computing version string... 1.13.3
Building up Makefile... done
crosstool-NG configured as follows:
PREFIX='/opt/cross_arm'
BINDIR='/opt/cross_arm/bin'
LIBDIR='/opt/cross_arm/lib/ct-ng-1.13.3'
DOCDIR='/opt/cross_arm/share/doc/ct-ng-1.13.3'
MANDIR='/opt/cross_arm/share/man'
2. PROG_PFX=''
PROG_SFX=''
PROG_SED=''
Now run:
make
make install"
- Then you can run:
* sudo make
* sudo make install
- The "arm-unknown-linux-uclibcgnueabi" will be used. So, load this configuration with this command:
* sudo ./ct-ng arm-unknown-linux-uclibcgnueabi
- And now, configure some things for your toolchain, before generate it:
* sudo ./ct-ng menuconfig
* Enter "Paths and misc options"
+ Configure the quantity of execution threads --> (2) Number of parallel jobs
+ Configure the setup directory --> (/opt/cross_arm/bb_toolchain/${CT_TARGET}) Prefix directory
* Back to main screen and enter "Toolchain options"
+ Configure the alias --> (arm-linux) Tuple’s alias -- with this, all the tools will begin with "arm-
linux" prefix (arm-linux-gcc, for example)
* Save and exit
- Start the toolchain creation with the command:
* sudo ./ct-ng build (In this step is possible that you have some issue with some dependency that can
not be downloaded by the "build script". So, you have to download manually such dependency and put
the ".tar.gz" into the ".build/tarballs/" directory. After that, run the command again)
- After a long time, your toolchain is created. Verify it in the following directory:
/opt/cross_arm/bb_toolchain/arm-unknown-linux-uclibcgnueabi/bin
- You need to configure the environment variable to use the toolchain:
3. * export PATH=/opt/cross_arm/bb_toolchain/arm-unknown-linux-uclibcgnueabi/bin:$PATH
- Test the toolchain:
* arm-linux-gcc ("arm-linux-gcc: no input files" must be showed)
- Now, you can write some c program (Hello World, for example) and cross-compile using the gcc
generated in the toolchain (arm-linux-gcc):
* arm-linux-gcc yourAppName.c -static -o yourAppName (remember that the PATH must be correctly
configured)
- To confirm that the application was compiled for "arm", use the command "file":
* file yourAppName (the result must be "yourAppName : ELF 32-bit LSB executable, ARM, version
1 (SYSV), statically linked, not stripped")
- To put the application into the beagleboard, it is needed to install some ssh server in the target to
connect with some ssh client in the host. This way, you can do the connection between the target and
the host for pass the application to the target. A good ssh server for embedded systems is the dropbear.
- If you can work with Eclipse, install the following plugins: CDT (C/C++ Development Toolkit) and
RSE (Remote Systems Explorer)
- With the RSE you can see the filesystem of the beagleboard and copy/delete/edit files remotely
- In the Eclipse, go to "Window->Open Perspective->Other->Remote System Explorer"
- To create a connection with the beagleboard, do the following steps:
* Right click in the left windows (with the available connections) and select "New->Connection"
* Select "SSH Only" and click "Next"
* Type the beagleboard IP in the field "Host name" and a name for the connection in the field
"Connection name"
* Click "Finish"
- To test the connection, right click in the connection with the given name and select "Connect", typing
user and password. It's done! Now you can access remotely the rootfs of the device.
- Create a C/C++ Project
- In the Project Explorer, right click in the project name and select "Build Configurations -> Manage..."
4. - Click "New" to configure the Eclipse for cross-compiling
- In the Name field, type the configuration name (beagleboard) and select "Debug" in the "Existing
configuration" point
- Click OK twice to return to the project
- In the Project Explorer, right click in the name of your project and select Properties
- Click Settings at the C/C++ Build item
- Select beagleboard in the "Configuration"
- In the GCC Compiler, change the Command text to: /opt/cross_arm/bb_toolchain/arm-unknown-
linux-uclibcgnueabi/bin/arm-unknown-linux-uclibcgnueabi-gcc (or your correct path, if you did
something different from this tutorial)
- Click Includes under GCC Compiler
- In the Include paths (-l) box (at the top), click in the icon to add a directory path and put:
/opt/crossarm/bb_toolchain/arm-unknown-linux-uclibcgnueabi/arm-unknown-linux-
uclibcgnueabi/include (click OK after)
- Click GCC Linker and change Command text to: /opt/cross_arm/bb_toolchain/arm-unknown-linux-
uclibcgnueabi/bin/arm-unknown-linux-uclibcgnueabi-gcc
- Click Libraries under GCC Linker and in the Library search path (-L) box (at the bottom), click in the
icon to add a directory path and put: /opt/crossarm/bb_toolchain/arm-unknown-linux-
uclibcgnueabi/arm-unknown-linux-uclibcgnueabi/lib (Click OK)
- Click GCC Assembler and change the Command text to: /opt/cross_arm/bb_toolchain/arm-unknown-
linux-uclibcgnueabi/bin/arm-unknown-linux-uclibcgnueabi-as (Click OK)
- In the Project Explorer, right click in the project name, select "Build Configurations -> Set Active"
and select "beagleboard" (the name given to the configuration)
- Now, you can program your applications and put them into beagleboard using Eclipse