Toolchain

From LORIX One - Wiki

Jump to: navigation, search

Prerequisites

The toolchain concerned by this document has been created using Yocto project 2.1.2 and has been tested on Ubuntu 16.04 LTS (the host).

The following packages must be installed on the host prior to begin:

$ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm

Download

The toolchain can be downloaded on the Yocto directoy of the LORIX One:

poky-wifx-glibc-x86_64-wifx-base-sdk-cortexa5hf-neon-toolchain-2.1.2.tar.bz2 (archive containing a script file 534MB)


Or by using a terminal:

$ wget https://www.lorixone.io/yocto/sdk/2.1.2/poky-wifx-glibc-x86_64-wifx-base-sdk-cortexa5hf-neon-toolchain-2.1.2.tar.bz2

The manifest files containing the packages included into the toolchain:

poky-wifx-glibc-x86_64-wifx-base-sdk-cortexa5hf-neon-toolchain-2.1.2.host.manifest

poky-wifx-glibc-x86_64-wifx-base-sdk-cortexa5hf-neon-toolchain-2.1.2.target.manifest

Install

Prior to install the toolchain, you need to extract the installation script file from the archive:

$ tar -xjvf poky-wifx-glibc-x86_64-wifx-base-sdk-cortexa5hf-neon-toolchain-2.1.2.tar.bz2
poky-wifx-glibc-x86_64-wifx-base-sdk-cortexa5hf-neon-toolchain-2.1.2.sh

You can now install the toolchain using the script:

$ ./poky-wifx-glibc-x86_64-wifx-base-sdk-cortexa5hf-neon-toolchain-2.1.2.sh
Poky (Yocto Project Reference Distro) SDK installer version 2.1.2
=================================================================
Enter target directory for SDK (default: /opt/poky-wifx/2.1.2): <enter for default or enter>
The directory "/opt/poky-wifx/2.1.2" already contains a SDK for this architecture.
If you continue, existing files will be overwritten! Proceed[Y/n]? <validate with y>
[sudo] password for : <enter your password>
Extracting SDK.........................................................................................................................done
Setting it up...done SDK has been successfully set up and is ready to be used. Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g. $ . /opt/poky-wifx/2.1.2/environment-setup-cortexa5hf-neon-poky-linux-gnueabi

Use example

A simple example can be done with the "Hello world" application. Begin by creating a main.c file and put the following code inside:

#include <stdio.h>

int main(){
    printf("Hello world!\n");
    return 0;
}

Source the toolchain parameters and compile the C file:

$ . /opt/poky-wifx/2.1.2/environment-setup-cortexa5hf-neon-poky-linux-gnueabi
$ $CC main.c -o main

The CC value contains the compiler command and some usefull parameters to compile the source code specially for the LORIX One:

$ echo $CC
arm-poky-linux-gnueabi-gcc -march=armv7-a -marm -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a5 --sysroot=/opt/poky-wifx/2.1.2/sysroots/cortexa5hf-neon-poky-linux-gnueabi

That's all. The created file is an ARM binary compiled for the LORIX One:

$ file main
main: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=031145f7a71c583a6cfdda1d43488d8df5a1a32d, not stripped

You can use the generated application by writing it on a SD card or using an NFS server (the LORIX One includes a NFS client which can by connected to a server, the host for example).