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 Start. 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.

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 2020.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, sama5d2-ptc-ek, sama5d2-icp, sama5d27-wlsom1-ek-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


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


Dependencies
============
This Layer depends on :
- poky
URI: git://git.yoctoproject.org/poky
Branch: dunfell
Tag: 33fdf03169ab2a3355e090d41ba034855d47f865

- meta-openembedded
URI: git://git.openembedded.org/meta-openembedded
URI: http://cgit.openembedded.org/meta-openembedded/
Branch: dunfell
Tag: a62ad77973b16daac1cbaa03cbda3c6b9b91f2ff

- meta-aws (for AWS Greengrass, mandatory for SAMA5D2 microchip-* images)
URI: git://github.com/aws/meta-aws.git
URI: https://github.com/aws/meta-aws
Branch: dunfell
Tag: 6fdd1bd619bde0207e990dde13f5a512e5a6552b

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 git://git.yoctoproject.org/poky -b dunfell

2/ Clone meta-openembedded git repository with the proper branch ready
git clone git://git.openembedded.org/meta-openembedded -b dunfell

3/ Clone meta-aws git repository with the proper branch ready
git clone git://github.com/aws/meta-aws -b dunfell

4/ Clone meta-atmel layer with the proper branch ready
git clone git://github.com/linux4sam/meta-atmel.git -b dunfell

5/ Clone aws layer with the proper branch ready
git clone git://github.com/aws/meta-aws -b dunfell

6/ Enter the poky directory to configure the build system and start the build process
cd poky

7/ Change TEMPLATECONF from .templateconf to:
export TEMPLATECONF=${TEMPLATECONF:-../meta-atmel/conf}
Note: If it's the first time you use Yocto Project templates, and if the
build-microchip directory remains from a previous use, we advice you start
from a fresh directory. Keep your build-microchip/conf/local.conf file for
reference.

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

9/ Build core minimal image
[MACHINE=] bitbake core-image-minimal

10/ Build images
[MACHINE=] bitbake microchip-headless-image


Typical bitbake output
======================
Build Configuration:
BB_VERSION           = "1.46.0"
BUILD_SYS            = "x86_64-linux"
NATIVELSBSTRING      = "universal"
TARGET_SYS           = "arm-poky-linux-gnueabi"
MACHINE              = "sama5d2-xplained-sd"
DISTRO               = "poky-atmel"
DISTRO_VERSION       = "3.1"
TUNE_FEATURES        = "arm vfp cortexa5 neon vfpv4 thumb callconvention-hard"
TARGET_FPU           = "hard"
meta                 
meta-poky            
meta-yocto-bsp       = "dunfell:33fdf03169ab2a3355e090d41ba034855d47f865"
meta-oe              
meta-networking      
meta-python          
meta-initramfs       
meta-multimedia      = "dunfell:a62ad77973b16daac1cbaa03cbda3c6b9b91f2ff"
meta-atmel           = "dunfell:070cc006f6a1f35493c6aa4a6cf7d50a24075f23"
meta-aws             = "dunfell:6fdd1bd619bde0207e990dde13f5a512e5a6552b"

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.

AT91 Forum:
http://www.at91.com/discussions/

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

Maintainers:
Codrin Ciubotariu 
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 sama5d2 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-sama5d2-xplained-sd-toolchain-3.1.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 Dunfell branch of OpenEmbedded present in Linux4SAM 2020.04:

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

Use Atmel Poky SDK

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

cd /opt/poky-atmel/3.1/
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 AS="arm-poky-linux-gnueabi-as "
declare -x CC="arm-poky-linux-gnueabi-gcc  -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a5 --sysroot=/opt/poky-atmel/3.1/sysroots/cortexa5t2hf-neon-poky-linux-gnueabi"
declare -x CFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types "
declare -x CPP="arm-poky-linux-gnueabi-gcc -E  -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a5 --sysroot=/opt/poky-atmel/3.1/sysroots/cortexa5t2hf-neon-poky-linux-gnueabi"
declare -x CROSS_COMPILE="arm-poky-linux-gnueabi-"
declare -x LD="arm-poky-linux-gnueabi-ld  --sysroot=/opt/poky-atmel/3.1/sysroots/cortexa5t2hf-neon-poky-linux-gnueabi"
declare -x LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed"
[...]
declare -x OECORE_DISTRO_VERSION="3.1"
declare -x OE_QMAKE_CC="arm-poky-linux-gnueabi-gcc  -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a5 --sysroot=/opt/poky-atmel/3.1/sysroots/cortexa5t2hf-neon-poky-linux-gnueabi"
[...]
NoteTo be able to compile the EGT demo applications provided in the Linux4SAM 6.2 release, SDK needs to be generated using a clone of meta-atmel.

Tips & tricks

BitBake

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

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)
r33 - 27 May 2020 - 15:23:46 - CodrinCiubotariu
 
Linux & Open Source related information for AT91 Smart ARM Microcontrollers

Copyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.

Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.

Atmel® and others, are registered trademarks or trademarks of Atmel Corporation or its subsidiaries. This site is powered by the TWiki collaboration platform

ARM® and others are registered trademarks or trademarks of ARM Ltd. Other terms and product names may be trademarks of others.

Ideas, requests, contributions ? Connect to LinksToCommunities page.

Syndicate this siteRSS ATOM