OpenEmbedded / Yocto Project / Poky: build from sources


How to build Poky for AT91

Note that building an entire distribution is a long process. It also requires a big amount of free disk space.

The support for Atmel AT91 SoC family is included in a particular Yocto layer: meta-atmel. The source for this layer are hosted on Linux4SAM GitHub account: https://github.com/linux4sam/meta-atmel

Building environment

A step-by-step comprehensive installation is explained in the Yocto Project Quick Build. The following lines have to be considered as an add-on that is AT91 specific or that can facilitate your setup.

Prerequisite

Here are the reference pages for setting up a Yocto building environment: What You Need and How You Get It.

Note add git-lfs to the package requirement list from whichever Linux distribution you use.

For instance, on Ubuntu or debian, these packages need to be installed on your development host:

sudo apt-get install gawk wget git-core git-lfs diffstat unzip texinfo gcc-multilib \
     build-essential chrpath socat cpio python3 python3-pip python3-pexpect \
     xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev \
     pylint3 xterm

Step by step build procedure

Note here is a copy of the README procedure available directly in the meta-atmel layer. This file in the meta-atmel layer repository must be considered as the reference and the following copy can be out-of-sync.

Note starting with Linux4SAM 2021.04 release, the meta-atmel layer supports Yocto templates, so make sure you create a new build environment using oe-init-build-env

This layer provides support for Microchip microprocessors (aka AT91)
====================================================================

For more information about the Microchip MPU product line see:
http://www.microchip.com/design-centers/32-bit-mpus
Linux & Open Source on Microchip microprocessors:
http://www.linux4sam.org


Supported SoCs / MACHINE names
==============================
Note that most of the machine names below, have a SD Card variant that can be
built by adding an "-sd" suffix to the machine name.
- SAMA5D2 product family / sama5d2-xplained, sama5d2-xplained-emmc, sama5d27-som1-ek-sd, sama5d27-som1-ek-optee-sd, sama5d2-ptc-ek, sama5d2-icp, sama5d27-wlsom1-ek-sd, sama5d29-curiosity-sd
- SAMA5D4 product family / sama5d4ek, sama5d4-xplained
- SAMA5D3 product family / sama5d3xek, sama5d3-xplained
- AT91SAM9x5 product family (AT91SAM9G15, AT91SAM9G25, AT91SAM9X25, AT91SAM9G35 and AT91SAM9X35) / at91sam9x5ek
- AT91SAM9RL / at91sam9rlek
- AT91SAM9G45 / at91sam9m10g45ek
- SAM9X60 / sam9x60ek, sam9x60-curiosity
- SAMA7G5 / sama7g5ek-sd, sama7g5ek-emmc, sama7g5ek-ospi


Sources
=======
- meta-atmel
URI: https://github.com/linux4sam/meta-atmel.git
Branch: kirkstone


Dependencies
============
This Layer depends on :
- poky
URI: https://git.yoctoproject.org/poky
Branch: kirkstone
Tag:yocto-4.0.13

- meta-openembedded
URI: https://git.openembedded.org/meta-openembedded
Branch: kirkstone
Tag/commit:79a6f60dabad9e5b0e041efa91379447ef030482

- meta-arm (for optee components)
URI: https://git.yoctoproject.org/meta-arm
Branch: kirkstone
Tag:yocto-4.0.1

Build procedure
===============

0/ Create a directory
mkdir my_dir
cd my_dir

1/ Clone yocto/poky git repository with the proper branch ready
git clone https://git.yoctoproject.org/poky && cd poky && \
git checkout -b kirkstone yocto-4.0.13 && cd -

2/ Clone meta-openembedded git repository with the proper branch ready
git clone git://git.openembedded.org/meta-openembedded && \
cd meta-openembedded && git checkout -b kirkstone 79a6f6 && cd -

3/ Clone meta-atmel layer with the proper branch ready
git clone https://github.com/linux4sam/meta-atmel.git -b kirkstone

4/ Clone meta-arm layer with the proper branch ready
git clone https://git.yoctoproject.org/meta-arm && cd meta-arm && \
git checkout -b kirkstone yocto-4.0.1 && cd -

5/ Enter the poky directory to configure the build system and start the build process
cd poky
If not created yet, add a new "build-microchip" directory:
mkdir build-microchip
Else, if it's the first time you use Yocto Project templates, and if the
build-microchip directory remains from a previous use, we advise you to start
from a fresh directory. Keep your build-microchip/conf/local.conf file for
reference.

6/ Inside the .templateconf file, you will need to modify the TEMPLATECONF
variable to match the path to the meta-atmel layer "conf" directory:
export TEMPLATECONF=${TEMPLATECONF:-../meta-atmel/conf}

7/ Initialize build directory
source oe-init-build-env build-microchip

8/ To build a small image provided by Yocto Project:
[MACHINE=] bitbake core-image-minimal

Example for sama5d2-xplained-sd SD card image:
MACHINE=sama5d2-xplained-sd bitbake core-image-minimal

9/ To build the microchip image with no graphics support:
[MACHINE=] bitbake microchip-headless-image

Example for sama5d2-xplained-sd SD card image:
MACHINE=sama5d2-xplained-sd bitbake microchip-headless-image

10/ To build the microchip image with graphics support (EGT):
[MACHINE=] bitbake microchip-graphics-image

Example for sama5d2-xplained-sd SD card image:
MACHINE=sama5d2-xplained-sd bitbake microchip-graphics-image

Typical bitbake output
======================
Build Configuration:
BB_VERSION           = "2.0.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "arm-poky-linux-gnueabi"
MACHINE              = "sam9x60-curiosity-sd"
DISTRO               = "poky-atmel"
DISTRO_VERSION       = "4.0.13"
TUNE_FEATURES        = "arm armv5 thumb dsp"
TARGET_FPU           = "soft"
meta                 
meta-poky            
meta-yocto-bsp       = "heads/kirkstone-4.0.13:e51bf557f596c4da38789a948a3228ba11455e3c"
meta-oe              
meta-networking      
meta-webserver
meta-python
meta-initramfs       = "79a6f60dabad9e5b0e041efa91379447ef030482:79a6f60dabad9e5b0e041efa91379447ef030482"
meta-atmel           = "heads/linux4microchip-2023.10-rc3:c94eec92946f6469d8adb30490d26f55021e1299"
meta-multimedia      = "79a6f60dabad9e5b0e041efa91379447ef030482:79a6f60dabad9e5b0e041efa91379447ef030482"
meta-arm
meta-arm-toolchain   = "heads/yocto-4.0.2:96aad3b29aa7a5ee4df5cf617a6336e5218fa9bd"

Contributing
============
To contribute to this layer you should submit the patches for review to:
the github pull-request facility directly or the forum. Anyway, don't forget to
Cc the maintainers.

Microchip Forum:
https://www.microchip.com/forums/f542.aspx

for some useful guidelines to be followed when submitting patches:
http://www.openembedded.org/wiki/How_to_submit_a_patch_to_OpenEmbedded

Maintainers:
Hari Prasath G E 
Nicolas Ferre 

When creating patches insert the [meta-atmel] tag in the subject, for example
use something like:
git format-patch -s --subject-prefix='meta-atmel][PATCH' 

Atmel Poky SDK

The meta-toolchain recipes build tarballs which contain cross compilation toolchain, cross compiled libraries, includes and configuration tools suitable for application development outside Poky.
The cross-compilation toolchain and all coss-compiled libraries will be present in this SDK allowing the user to exactly match what is provided in the associated Linux4SAM demo image.

If a random cross-compilation toolchain was used, it would lead to undefined symbols and unmatched library calls. With this SDK matching what is present on the target, cross-development is enhanced with all possibilities offered by shared libraries that any embedded Linux developer could expect from such a system.
This cross-development cycle doesn't have to be integrated within an OpenEmbedded integration flow: usual Makefiles, cmake, IDE... in short: any developer-friendly environment could be used allowing the separation of the development phase from the integration phase.

Build Atmel Poky SDK

This SDK is generated using the bitbake handy target populate_sdk.

bitbake -c populate_sdk microchip-graphics-image
or
bitbake -c populate_sdk microchip-headless-image

It will produce a comprehensive SDK script (auto-extracting archive) available in the deployment directory: from the build directory it is usually located in tmp/deploy/sdk.
For instance, for the sama5d27-wlsom1-ek-sd graphic image type of SDK, you can find it available in: tmp/deploy/sdk/poky-atmel-glibc-x86_64-microchip-graphics-image-cortexa5t2hf-neon-vfpv4-sama5d27-wlsom1-ek-sd-toolchain-4.0.9.sh

Install Atmel Poky SDK

Once the SDK archive is generated, you can install it by running the script directly. Choose the appropriate script name according to your board.

HELP Note that some of the SDK variants can apply on several boards or SoC (sama5d2 or sama5d4 SDK could match all boards equipped with these SoCs). You can check the Yocto Project SDK table for more information about the different SDK "flavors".

Some installation information will be asked to the user as well as the appropriate installation rights:

Hereunder is an example with a SDK from the Kirkstone branch of OpenEmbedded present in Linux4SAM 2022.10:

$ ./poky-atmel-glibc-x86_64-microchip-graphics-image-cortexa5t2hf-neon-vfpv4-sama5d27-wlsom1-ek-sd-toolchain-4.0.9.sh
Poky (Yocto Project Reference Distro) SDK installer version 4.0.9
=================================================================
Enter target directory for SDK (default: /opt/poky-atmel/4.0.9): 
You are about to install the SDK to "/opt/poky-atmel/4.0.9". Proceed [Y/n]?  
[sudo] password for dharma: 
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-atmel/4.0.9/environment-setup-cortexa5t2hf-neon-vfpv4-poky-linux-gnueabi

Use Atmel Poky SDK

The installation directory (/opt/poky-atmel/4.0.9) contains a setup script which can be sourced to initialize all required environment variables.

cd /opt/poky-atmel/4.0.9/
source environment-setup-cortexa5t2hf-neon-vfpv4-poky-linux-gnueabi

You can check your new environment

export | less
[...]
declare -x AR="arm-poky-linux-gnueabi-ar"
declare -x ARCH="arm"
declare -x AS="arm-poky-linux-gnueabi-as "
declare -x CC="arm-poky-linux-gnueabi-gcc  -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a5 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/poky-atmel/4.0.9/sysroots/cortexa5t2hf-neon-vfpv4-poky-linux-gnueabi"
declare -x CFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types "
declare -x CONFIGURE_FLAGS="--target=arm-poky-linux-gnueabi --host=arm-poky-linux-gnueabi --build=x86_64-linux --with-libtool-sysroot=/opt/poky-atmel/4.0.9/sysroots/cortexa5t2hf-neon-vfpv4-poky-linux-gnueabi"
declare -x CONFIG_SITE="/opt/poky-atmel/4.0.9/site-config-cortexa5t2hf-neon-vfpv4-poky-linux-gnueabi"
declare -x CPP="arm-poky-linux-gnueabi-gcc -E  -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a5 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/poky-atmel/4.0.9/sysroots/cortexa5t2hf-neon-vfpv4-poky-linux-gnueabi"
declare -x CROSS_COMPILE="arm-poky-linux-gnueabi-"
declare -x CXX="arm-poky-linux-gnueabi-g++  -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a5 -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/poky-atmel/4.0.9/sysroots/cortexa5t2hf-neon-vfpv4-poky-linux-gnueabi"
declare -x CXXFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types "
declare -x LD="arm-poky-linux-gnueabi-ld  --sysroot=/opt/poky-atmel/4.0.9/sysroots/cortexa5t2hf-neon-vfpv4-poky-linux-gnueabi"
declare -x LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed  -Wl,-z,relro,-z,now"
[...]
declare -x OECORE_DISTRO_VERSION="4.0.9"
[...]
NoteTo be able to compile the EGT demo applications provided in the Linux4SAM release, SDK needs to be generated using a clone of meta-atmel.

Note EGT demo applications can be compiled using the poky SDK by following the below steps

$ source /opt/poky-atmel/4.0.9/environment-setup-armv5e-poky-linux-gnueabi
$ git clone --recursive https://github.com/linux4sam/egt.git
$ cd egt/
$ ./autogen.sh
$ ./configure --host="arm"
$ make

NoteTo use the SDK toolchain directly one can refer to the Yocto Project documentation.

Tips & tricks

BitBake

  • BitBake User Manual
  • BitBake Cheat Sheet
  • List tasks provided by a package:
    bitbake -c listtasks <package_name>
    You can use one of those tasks to have a fine grained control over the package building.

Hello World example

Reference to the "Hello World" example.

Recent FAQ

YoctoProject

Using Systemd: Basic systemd user guide. (Sama5d29Curiosity, Sam9x75Curiosity, Sam9x60Curiosity, Sama7g5-ek, Sama5d2-icp, Sam9x60EK, Sama5d27WLSom1EK, Sama5d27Som1EK)
Sam 9 x 60 Ek Attaching Tm 5000 Display: Addition to the other generic FAQ about LCD displays: ConnectModuleFromPDA. (Sam9x60EK)
Audio FAQ: Audio with ALSA. ()
Gui Solutions: Presentation of some GUI solutions. (Sama5d27Som1EK, Sama5d2PtcEK, Sama5d2Xplained, Sama5d4Xplained, Sama5d4ek, Sama5d3Xplained, Sama5d3xek)
Yocto Project FAQ: Some Yocto Project FAQ entries. (Sama5d27Som1EK, Sama5d2PtcEK, Sama5d2Xplained, Sama5d4Xplained, Sama5d4ek, Sama5d3Xplained, Sama5d3xek, AT91sam9x5-ek)