OpenEmbedded / Yocto Project : build from sources
How to build OE core for MPU
Support for the Microchip MPU SoC family is included in a particular Yocto Project layer, meta-mchp. The source for this layer is hosted on the Linux4Microchip GitHub account on the "Microchip Yocto Project BSP" page.
Building Environment
A step-by-step, comprehensive installation is explained on the "Yocto Project Quick Build" page. The following lines should be considered as an add-on that is MPU-specific or that can facilitate your setup.
Step-by-Step Build Procedure
OpenEmbedded/Yocto Project BSP Layer for Microchip's SoCs
- Description
- The meta-mchp-common layer consolidates common Board Support Package (BSP) components and metadata for Microchip platforms, streamlining development across various Microchip devices for use with OpenEmbedded and/or Yocto Project.
- Supported Machines
- The meta-mchp-common layer provides support for various Microchip platforms. For detailed information about supported machines, please refer to the documentation in the relevant sub-layers:
- Prerequisites
- Before starting, please refer to the Required Packages for Build Host section in the Yocto Project Documentation to install required dependencies for the build environment:
For instance, on Ubuntu or Debian, these packages need to be installed on your development host:
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 repo
Usage
- To integrate this layer into your Yocto Project build environment:
Clone the necessary repositories.
Create an empty directory to hold the workspace:
mkdir yocto-dev
cd yocto-devUse the repo tool to fetch all the required repositories.
repo init -u https://github.com/linux4microchip/meta-mchp-manifest.git -b <branch> -m <target>/default.xmlReplace and with the Yocto Project release branch and the manifest required. For example:
repo init -u https://github.com/linux4microchip/meta-mchp-manifest.git -b scarthgap -m mpu/default.xmlFetch all the required repositories using the following repo command:
repo syncInitialize the build environment.
The meta-mchp repository provides sample configuration templates that help set up BitBake layers and key configuration files in the Yocto Project build directory.
Set the TEMPLATECONF environment variable to point to the appropriate configuration template before initializing the build environment:
export TEMPLATECONF=${TEMPLATECONF:-../meta-mchp/<meta-layer>/conf/templates/default}Replace meta-layer above with the desired layer based on your target platform. For example:
export TEMPLATECONF=${TEMPLATECONF:-../meta-mchp/meta-mchp-mpu/conf/templates/default}Then initialize the Yocto Project build environment:
source openembedded-core/oe-init-build-envSet the target machine and build the image.
MACHINE=<machine> bitbake core-image-minimalEach sub-layer provides several images that include demos and applications tailored for its respective platform.
For more information on the supported images, please refer to the MPU layer README.
Layer Dependencies
This layer depends on the following layers:
- meta-openembedded
- URI: git://git.openembedded.org/meta-openembedded
- Layers: meta-oe, meta-networking, meta-python
- openembedded-core
- URI: git://git.openembedded.org/openembedded-core
- Layers: meta
For information on the specific revisions used, refer to the meta-mchp manifest repository.
- Licensing
- The contents of this layer are licensed under the MIT License. See COPYING.MIT for details
- Contributing
- If you want to contribute changes, you can send GitHub pull requests. See CONTRIBUTING.md for additional information about contribution guidelines.
OE SDK
The meta-toolchain recipes build tarballs which contain cross compilation toolchain, cross compiled libraries, includes and configuration tools suitable for application development outside OE.
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 OE SDK
This SDK is generated using the bitbake handy target populate_sdk.
or
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/oecore-mchp-graphics-image-x86_64-cortexa5t2hf-neon-vfpv4-sama5d27-wlsom1-ek-sd-toolchain-nodistro.0.sh
Install OE 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.
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 Scarthgap branch of OpenEmbedded present in Linux4SAM 2024.10:
OpenEmbedded SDK installer version nodistro.0
=============================================
Enter target directory for SDK (default: /usr/local/oecore-x86_64): /opt/oecore
You are about to install the SDK to "/opt/oecore". Proceed [Y/n]? Y
[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/oecore/environment-setup-cortexa5t2hf-neon-vfpv4-oe-linux-gnueabi
Use OE SDK
The installation directory (/opt/oecore) contains a setup script which can be sourced to initialize all required environment variables.
$ source environment-setup-cortexa5t2hf-neon-vfpv4-oe-linux-gnueabi
You can check your new environment
[...]
declare -x AR="arm-oe-linux-gnueabi-ar"
declare -x ARCH="arm"
declare -x AS="arm-oe-linux-gnueabi-as "
declare -x CC="arm-oe-linux-gnueabi-gcc -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a5 -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 --sysroot=/opt/oecore/sysroots/cortexa5t2hf-neon-vfpv4-oe-linux-gnueabi"
[...]
declare -x CFLAGS=" -O2 -pipe -g -feliminate-unused-debug-types "
declare -x CMAKE_TOOLCHAIN_FILE="/opt/oecore/sysroots/x86_64-oesdk-linux/usr/share/cmake/OEToolchainConfig.cmake"
declare -x CONFIGURE_FLAGS="--target=arm-oe-linux-gnueabi --host=arm-oe-linux-gnueabi --build=x86_64-linux --with-libtool-sysroot=/opt/oecore/sysroots/cortexa5t2hf-neon-vfpv4-oe-linux-gnueabi"
[...]
declare -x OECORE_DISTRO_VERSION="nodistro.0"
declare -x OECORE_NATIVE_SYSROOT="/opt/oecore/sysroots/x86_64-oesdk-linux"
declare -x OECORE_SDK_VERSION="nodistro.0"
declare -x OECORE_TARGET_ARCH="arm"
declare -x OECORE_TARGET_OS="linux-gnueabi"
[...]
To be able to compile the EGT demo applications provided in the Linux4SAM release, SDK needs to be generated using a clone of meta-atmel.
EGT demo applications can be compiled using the OE SDK by following the below steps
$ git clone --recursive https://github.com/linux4sam/egt.git
$ cd egt/
$ ./autogen.sh
$ ./configure --host="arm"
$ make
To 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
- FAQ about audio
- Connect Module From PDA
- Yocto Project FAQ
- GUI Solutions
- Using systemd
- SAM9X60-EK Evaluation Kit - Attaching the TM5000 WVGA Display