LinHT Image Build

From M17 Foundation Wiki
Jump to navigation Jump to search

You'll need git, repo and docker installed to setup this build environment

Setup compulab docker environment

cd ~
mkdir compulab-yocker
cd compulab-yocker
git clone https://github.com/compulab-yokneam/yocker.git .
sudo docker build -t yocto-build:v1 - < $(pwd)/docker/Dockerfile-22.04
sudo docker run --interactive --tty --privileged --volume $(pwd)/work:/work yocto-build:v1

Setup internal work folder inside the docker container

sudo mkdir in-work
sudo chown $USER:$USER in-work
cd in-work

Prepare NXP and CompuLab repos:

mkdir compulab-nxp-bsp
cd compulab-nxp-bsp
repo init -u https://github.com/nxp-imx/imx-manifest.git -b imx-linux-scarthgap -m imx-6.6.52-2.2.0.xml
mkdir -p .repo/local_manifests
wget --directory-prefix .repo/local_manifests https://raw.githubusercontent.com/compulab-yokneam/meta-bsp-imx9/EVAL-MCM-iMX93-2.0.1/scripts/meta-bsp-imx9.xml
repo sync

Setup the build environment

source compulab-setup-env build-mcm-imx93
cd ../sources/
git clone https://github.com/M17-Project/meta-linht-sdr.git
git clone https://github.com/M17-Project/meta-linht-hardware.git
git clone https://github.com/M17-Project/meta-linht-software.git

bitbake-layers add-layer meta-linht-sdr
bitbake-layers add-layer meta-linht-hardware
bitbake-layers add-layer meta-linht-software

Add Shared State Cache (optional). Text from the yocto docs:

You can significantly speed up your build and guard against fetcher failures by using Shared State Cache mirrors and enabling Hash Equivalence. This way, you can use pre-built artifacts rather than building them. This is relevant only when your network and the server that you use can download these artifacts faster than you would be able to build them.

To use such mirrors, uncomment the below lines in your conf/local.conf file in the Build Directory:

BB_HASHSERVE_UPSTREAM = "wss://hashserv.yoctoproject.org/ws"
SSTATE_MIRRORS ?= "file://.* http://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH"
BB_HASHSERVE = "auto"
BB_SIGNATURE_HANDLER = "OEEquivHash"

The hash equivalence server needs the websockets python module version 9.1 or later. Debian GNU/Linux 12 (Bookworm) and later, Fedora, CentOS Stream 9 and later, and Ubuntu 22.04 (LTS) and later, all have a recent enough package. Other supported distributions need to get the module some other place than their package feed, e.g. via pip.

For the docker image we are using, the command should be: pip install websockets

Remove the unused packages by adding this to your conf/local.conf

# Remove distribution features
DISTRO_FEATURES:remove = "bluetooth wifi"

# Remove machine features
MACHINE_FEATURES:remove = "bluetooth wifi"

# Exclude problematic packages
PACKAGE_EXCLUDE += "kernel-module-nxp-wlan"
PACKAGE_EXCLUDE += "bluez5"
PACKAGE_EXCLUDE += "linux-firmware-bluetooth-bcm4343"

# Remove from image installation
IMAGE_INSTALL:remove = "kernel-module-nxp-wlan"
IMAGE_INSTALL:remove = "bluez5"

# Disable module autoloading
KERNEL_MODULE_AUTOLOAD:remove = "bluetooth cfg80211"

# Force fortran (python3-scipy depends on it)
FORTRAN:forcevariable = ",fortran"

First build

Build the linht-image:

cd ../
bitbake linht-image

Enter Docker container and build

Enter container:

cd compulab-yocker/
docker run --interactive --tty --volume $(pwd)/work:/work yocto-build:v1

Run build:

cd in-work/compulab-nxp-bsp/
source compulab-setup-env build-mcm-imx93
bitbake -k linht-image

Troubeshooting

There is a problem with apparmor, if your using Ubuntu 24.04 as your host system:

ERROR: PermissionError: [Errno 1] Operation not permitted

You can temporarily bypass it using the following command outside of the container on the host system:

sudo apparmor_parser -R /etc/apparmor.d/unprivileged_userns

Fast device tree deployment

This script will build and deploy the custom device tree to LinHT and reboots it (Inside the container mentioned above). Backup all files from your LinHT! It's possible that no boot is possible, if there are problems with the deployed device tree! Use at your own risk!

#!/bin/bash
set -e

BUILD_DIR="/work/in-work/compulab-nxp-bsp/build-mcm-imx93/tmp/work/mcm_imx93-poky-linux/linux-compulab/6.6.52/build"
SOURCE_DIR="/work/in-work/compulab-nxp-bsp/build-mcm-imx93/tmp/work-shared/mcm-imx93/kernel-source"
OVERLAY_DIR="/work/in-work/compulab-nxp-bsp/sources/meta-linht-hardware/recipes-kernel/linux/files"

cp -v "${OVERLAY_DIR}/sbc-mcm-imx93.dts" \
      "${SOURCE_DIR}/arch/arm64/boot/dts/compulab/"
cp -v "${OVERLAY_DIR}/sbc-mcm-imx93.dtsi" \
      "${SOURCE_DIR}/arch/arm64/boot/dts/compulab/"

cd "${BUILD_DIR}"
make ARCH=arm64 dtbs

DTB_PATH="/work/in-work/compulab-nxp-bsp/build-mcm-imx93/tmp/work/mcm_imx93-poky-linux/linux-compulab/6.6.52/build/arch/arm64/boot/dts/compulab/sbc-mcm-imx93.dtb"

ssh root@10.17.17.17 'mkdir -p /mnt/boot && mount /dev/mmcblk0p1 /mnt/boot 2>/dev/null || true'
scp ${DTB_PATH} root@10.17.17.17:/mnt/boot/
ssh root@10.17.17.17 'reboot'

index.php?title=Category:Manuals index.php?title=Category:LinHT