Hardware, RTOS

Building a Minimal Yocto Layer for Custom Hardware

Introduction

Créer un layer Yocto custom pour du hardware propriétaire est une étape incontournable dans tout projet Linux embarqué professionnel. Ce guide couvre la création d’un BSP minimal fonctionnel, de la configuration machine jusqu’à l’image bootable.

Étape 1 — Créer la structure du layer

cd ~/yocto/poky
source oe-init-build-env build
bitbake-layers create-layer ../meta-opcodelabs
bitbake-layers add-layer ../meta-opcodelabs

Structure générée :

meta-opcodelabs/
  conf/
    layer.conf
  recipes-example/
  COPYING.MIT
  README

Étape 2 — Configurer layer.conf

# meta-opcodelabs/conf/layer.conf
BBPATH .= ":${LAYERDIR}"
BBFILES += "${LAYERDIR}/**/*.bb \
             ${LAYERDIR}/**/*.bbappend"

BBFILE_COLLECTIONS += "opcodelabs"
BBFILE_PATTERN_opcodelabs = "^${LAYERDIR}/"
BBFILE_PRIORITY_opcodelabs = "10"
LAYERDEPENDS_opcodelabs = "core"
LAYERSERIES_COMPAT_opcodelabs = "kirkstone scarthgap"

Étape 3 — Machine config

# meta-opcodelabs/conf/machine/opcode-board.conf
require conf/machine/include/arm/armv8a/tune-cortexa53.inc

MACHINE_FEATURES = "usbhost usbgadget alsa"
KERNEL_IMAGETYPE = "Image"
KERNEL_DEVICETREE = "opcode-board.dtb"
SERIAL_CONSOLES = "115200;ttyS0"
IMAGE_FSTYPES = "ext4 wic.gz"

Étape 4 — Device Tree minimal

/dts-v1/;

/ {
    model = "OpCode Labs Custom Board";
    compatible = "opcode,custom-board", "arm,vexpress";
    #address-cells = <2>;
    #size-cells = <2>;

    memory@80000000 {
        device_type = "memory";
        reg = <0x0 0x80000000 0x0 0x40000000>;
    };

    chosen {
        bootargs = "console=ttyS0,115200 rootwait";
    };
};

Étape 5 — Builder l’image

# Dans build/conf/local.conf
MACHINE = "opcode-board"
DISTRO = "poky"

# Lance le build
bitbake core-image-minimal

Conclusion

Un layer Yocto bien structuré dès le début évite des heures de refactoring. La séparation entre le BSP et les layers applicatifs facilite la maintenance et les mises à jour indépendantes.

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *