This article assumes, you already have development environment setup for yocto, if not please read and setup as per “Building Embedded Linux for Raspberry Pi using Yocto”
Along with recipes for building a compiler for its internal use, OpenEmbedded also has recipes to create a full toolchain / cross-compiler environment for the host. Toolchain can be build using meta-toolchain recipe which is part of “openembedded-core” meta layer, hence we will have to first add that layer as,
$ git clone git://git.openembedded.org/openembedded-core
$ cd openembedded-core/
$ git checkout -b thud origin/thud
$ cd poky
$ source oe-init-build-env
Update local.conf to add openembedded-core layer which contains recipes for compiling toolchain
$ vim conf/bblayers.conf
BBLAYERS ?= " \
/home/myuser/workspace/openembedded-core \
/home/myuser/workspace/poky \
The compilation of toolchain will take some time and its a heavy compilation which might make your development machine unresponsive based on your RAM size, you just have an option to wait, nothing else 🙂
Once the compilation is done successfully, you will see a script generated at build/tmp/deploy/sdk as,
$ ls -l tmp/deploy/sdk/
tmp/deploy/sdk/poky-glibc-x86_64-meta-toolchain-cortexa7t2hf-neon-vfpv4-toolchain-2.6.2.sh
When we want to install this toolchain, use below command or steps for installation. You can either choose the default location as shown below /opt/poky/2.6.2 or override by typing some directory name, which will be created in current working directory i.e. build. We used directory name “sdk” hence the toolchain will be installed as “build/sdk”
$ ./tmp/deploy/sdk/poky-glibc-x86_64-meta-toolchain-cortexa7t2hf-neon-vfpv4-toolchain-2.6.2.sh
Poky (Yocto Project Reference Distro) SDK installer version 2.6.2
=================================================================
Enter target directory for SDK (default: /opt/poky/2.6.2): sdk
You are about to install the SDK to "/home/devlab/yocto/poky/build/sdk". Proceed[Y/n]? Y
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.
$ . /home/devlab/yocto/poky/build/sdk/environment-setup-cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi
As you can see above build/sdk/environment-setup-cortexa7t2hf-neon-vfpv4-poky-linux-gnueabi script is requested to be sourced to your environment since it contain all environment variables auto generated based on your installation of toolchain/sdk.