This article will help the intended reader in setting up an environment for Embedded Linux application development. The resulting environment enables cross-platform application development for Toradex ARM-based embedded devices using a typical desktop Linux workstation.
Please refer to the release notes document for information concerning a specific image. The release notes can be found at the Linux BSP Release.
The following block diagram illustrates the hardware setup suitable for development.
There are a few ways to have a development workstation setup. Some (but not all) examples are given below:
Cross Compilation Toolchain:
Target Root File System:
In the present article, the following is used: Linaro or OpenEmbedded generated cross toolchain, Toradex Embedded Linux pre-built image root file system and Eclipse IDE provided in the distribution feeds. In the subsequent article Hello World application on Embedded Linux, it is presented how to configure Eclipse using the Linaro toolchain.
For beginners, the step-by-step Getting Started Guide uses pre-built OpenEmbedded SDK and Eclipse IDE from the Eclipse Installer. It explains comprehensively how to configure Eclipse to use the toolchain and root file system provided by the SDK.
When you start using Yocto/OpenEmbedded, the Linux SDKs article uses custom SDK built with OpenEmbedded and Eclipse IDE (assumed it is already installed). It explains objectively how to configure Eclipse to use the toolchain and root file system provided by the SDK.
One can choose any Linux distribution (like Fedora, SUSE, Debian) for development. A 64-bit install is preferred as you might want to use the machine also for OpenEmbedded work. Cross-compiling certain packages requires the larger address space available. Also, the latest cross toolchains from Linaro are provided only for 64-bit hosts. Should you choose Ubuntu, use the bash shell instead of dash. (Google for 'ubuntu bash update-alternatives')
In this article, we will be using Ubuntu 14.04. Visit the Ubuntu website to explore how to install Ubuntu on your development workstation.
To start a terminal on the host:
In Gnome Desktop Environment:
Applications menu -> Accessories -> Terminal
In Unity Desktop Environment:
In the launcher click the 'Dash home' icon
Dash -> enter 'Terminal' in the search box
Dash -> click 'Terminal' in found results, a new Terminal window opens, a Terminal icon appears in the Launcher
Right click the new Terminal icon, click 'Lock to Launcher' to have it permanently attached to the Launcher
At the host terminal:
E.g. for Ubuntu 14.04:
sudo apt-get update sudo apt-get upgrade sudo apt-get install build-essential meld git gawk eclipse-cdt eclipse-cdt-launch-remote eclipse-rse minicom sudo apt-get install gtk+-2.0-dev #if you have a 64-bit Linux host install your distributions 32-bit compatibility libraries. sudo dpkg --add-architecture i386 sudo apt-get update sudo apt-get install libz1:i386 libncurses5:i386 libbz2-1.0:i386 libstdc++6:i386
The latest Linux images are available at:
Download the latest image for your module and extract the archive on the host machine with root privileges. For example:
sudo mkdir -p /srv/nfs cd /srv/nfs sudo wget http://files.toradex.com/Colibri/Linux/Images/Colibri_T20_LinuxImageV2.4Beta1_20150518.tar.bz2 sudo tar xjvf Colibri_T20_LinuxImageV2.4Beta1_20150518.tar.bz2
The rootfs will be used on the host machine to compile and link against. The extracted files will also be used later to flash the full image onto the target.
Create a symbolic link to have the target root file system at a stable location. For example:
cd /srv/nfs sudo ln -s Colibri_T20_LinuxImageV2.3/rootfs rootfs cd
Note: In this example, the link is placed to an NFS server path. Any path may be used for software development; however, by hosting the rootfs on an NFS server it is possible for the target device to mount the rootfs via the network allowing simultaneous access to the live rootfs by both target & host.
A cross-toolchain (often times just called cross-compiler) is used to build an application on the host which later on can be executed on the target device.
Beginning with image 2.7b2, as part of our OpenEmbedded Morty update we transitioned to using version 6.2 of the gcc compiler. Linaro releases well tested binary toolchains which can be used to cross compile software for our modules (choose gcc-linaro-6.2.1-2016.11-x86_64_arm-linux-gnueabihf.tar.xz):
Beginning with image V2.6, as part of our OpenEmbedded Jethro update we transitioned to using version 5.2 of the gcc compiler. Linaro releases well tested binary toolchains which can be used to cross compile software for our modules (choose gcc-linaro-5.2-2015.11-2-x86_64_arm-linux-gnueabihf.tar.xz):
Beginning with image V2.0, we transitioned to using the hard-float ABI:
Note: Since the 14.11 release Linaro only provides x86_64 toolchains. If you use 32-bit Linux on your host machine (check using uname -m), you can still download the older 14.09 release which is still 32-bit:
To install the toolchain on your host machine, unpack the tar.xz file:
cd wget -c https://releases.linaro.org/components/toolchain/binaries/5.2-2015.11-2/arm-linux-gnueabihf/gcc-linaro-5.2-2015.11-2-x86_64_arm-linux-gnueabihf.tar.xz tar xvf gcc-linaro-5.2-2015.11-2-x86_64_arm-linux-gnueabihf.tar.xz ln -s gcc-linaro-5.2-2015.11-2-x86_64_arm-linux-gnueabihf gcc-linaro
The U-Boot and Linux makefiles use the environment variables ARCH/CROSS_COMPILE to configure and call the compiler correctly. Therefore, these environment variables must be exported in any shell instance that will run configure/compile commands to build U-Boot or Linux for the target module.
export ARCH=arm export PATH=~/gcc-linaro/bin/:$PATH export CROSS_COMPILE=arm-linux-gnueabihf-
Alternatively, if you did an OpenEmbedded build, you can use the toolchain generated as part of the build by entering the following:
export ARCH=arm export PATH=~/oe-core/build/tmp-glibc/sysroots/x86_64-linux/usr/bin:~/oe-core/build/tmp-glibc/sysroots/x86_64-linux/usr/bin/arm-angstrom-linux-gnueabi/:$PATH export CROSS_COMPILE=arm-angstrom-linux-gnueabi-
Note: In BSP releases prior to V2.6.1 tmp-glibc was actually known as out-(e)glibc.
You can put those commands into a file and source that file to export it more easily:
echo "export ARCH=arm" >> ~/export_compiler echo "export PATH=~/gcc-linaro/bin/:$PATH" >> ~/export_compiler echo "export CROSS_COMPILE=arm-linux-gnueabihf-" >> ~/export_compiler source ~/export_compiler
At the host terminal:
Accept the default workspace location. Once on the welcome screen click "Workbench". You might want to have Eclipse on the launcher. Right click the Eclipse icon in the launcher and click 'Lock to Launcher'.
Minicom is a virtual terminal application. We will use it to see console output from the target during boot and may use it to login and work with the Linux command line on the target.
Put yourself into the dialout group (or whatever is needed to have access rights to serial devices in your distribution). Configure minicom for the serial port you will be using on your host, 115200 8N1 no hardware flow control. Set init, reset and hang-up modem control strings to empty and set modem has DCD line to no.
Save your minicom configuration as default. (Save setup as dfl)
sudo adduser YOUR_USER dialout sudo minicom -s +-----[configuration]------+ | Filenames and paths | | File transfer protocols | | Serial port setup | | Modem and dialing | | Screen and keyboard | | Save setup as dfl | | Save setup as.. | | Exit | | Exit from Minicom | +--------------------------+ +-----------------------------------------------------------------------+ | A - Serial Device : /dev/ttyUSB0 | | B - Lockfile Location : /var/lock | | C - Callin Program : | | D - Callout Program : | | E - Bps/Par/Bits : 115200 8N1 | | F - Hardware Flow Control : No | | G - Software Flow Control : No | | | | Change which setting? | +-----------------------------------------------------------------------+ +--------------------[Modem and dialing parameter setup]---------------------+ | | | A - Init string ......... | | B - Reset string ........ | | C - Dialing prefix #1.... ATDT | | D - Dialing suffix #1.... ^M | | E - Dialing prefix #2.... ATDP | | F - Dialing suffix #2.... ^M | | G - Dialing prefix #3.... ATX1DT | | H - Dialing suffix #3.... ;X4D^M | | I - Connect string ...... CONNECT | | J - No connect strings .. NO CARRIER BUSY | | NO DIALTONE VOICE | | K - Hang-up string ...... | | L - Dial cancel string .. ^M | | | | M - Dial time ........... 45 Q - Auto bps detect ..... No | | N - Delay before redial . 2 R - Modem has DCD line .. No | | O - Number of tries ..... 10 S - Status line shows ... DTE speed | | P - DTR drop time (0=no). 1 T - Multi-line untag .... No | | | | Change which setting? (Return or Esc to exit) | +----------------------------------------------------------------------------+
You should already have downloaded and extracted the appropriate Linux image to your host machine. If you skipped this step, then do it now.
Our latest Embedded Linux BSP demo images & release notes are provided at:
When the update is complete the target should be booting the latest Linux OS.
At the target device's terminal:
In the opening dialog:
Change Configuration to 'MANUAL'
Enter IP address, Netmask and Gateway
For a more complex network setup, refer to How to setup Networking for Embedded Linux Application Development.
You're now ready to write your first application! Continue with the Hello World application on Embedded Linux.