This guide describes how to build a Yocto Linux image for a 64-bit Arm target using the Poky reference distribution (tag yocto-5.0.10
, part of the scarthgap
release), including Node.js, GCC, and npm. It uses the scarthgap
branch for meta-openembedded
to ensure compatibility with Yocto 5.0, resolving the previous pathspec 'yocto-5.0.10'
error.
Ensure you have a Linux system (e.g., Ubuntu) with sufficient disk space (20-50 GB recommended) and memory. The build process requires a robust development environment.
Install the necessary packages for building and running Yocto:
sudo apt update
sudo apt-get install -y gawk wget git-core diffstat unzip texinfo build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libgl1 libglx-mesa0 libsdl1.2-dev pylint xterm python3-subunit mesa-common-dev lz4
Clone the Poky reference distribution and check out the yocto-5.0.10
tag (part of the scarthgap
release):
cd /home/mint
git clone git://git.yoctoproject.org/poky
cd poky
git checkout tags/yocto-5.0.10 -b yocto-5.0.10-local
Clone the meta-openembedded
repository, which contains the meta-oe
layer required for Node.js, and check out the scarthgap
branch (compatible with Yocto 5.0):
cd /home/mint
git clone git://git.openembedded.org/meta-openembedded
cd meta-openembedded
git checkout scarthgap
Note: The scarthgap
branch in meta-openembedded
is compatible with Poky’s yocto-5.0.10
(Yocto 5.0 release).
Source the environment script to set up the build environment for the 64-bit Arm QEMU target:
cd /home/mint/poky
source oe-init-build-env build-qemu-arm64
This creates a build-qemu-arm64
directory with configuration files (conf/local.conf
and conf/bblayers.conf
) and sets up the build environment. The output will suggest common targets like core-image-full-cmdline
.
Set the target machine to qemuarm64
by uncommenting the relevant line in conf/local.conf
:
sed -i '/qemuarm64/s/^#//g' conf/local.conf
Add the meta-oe
layer to conf/bblayers.conf
to include the Node.js recipe. Append the following line to the BBLAYERS
variable:
echo 'BBLAYERS += "/home/mint/meta-openembedded/meta-oe"' >> conf/bblayers.conf
Alternatively, manually edit conf/bblayers.conf
with a text editor (e.g., nano
) to include:
BBLAYERS ?= " \
/home/mint/poky/meta \
/home/mint/poky/meta-poky \
/home/mint/poky/meta-yocto-bsp \
/home/mint/meta-openembedded/meta-oe \
"
Modify conf/local.conf
to include Node.js, GCC, and npm in the core-image-full-cmdline
image by appending:
echo 'IMAGE_INSTALL:append = " nodejs gcc g++"' >> conf/local.conf
Note: The nodejs
recipe includes npm, and gcc
and g++
provide the C and C++ compilers.
On modern Ubuntu systems, disable AppArmor restrictions for unprivileged user namespaces:
sudo echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
Build the core-image-full-cmdline
image, which now includes Node.js, GCC, and npm:
cd /home/mint/poky/build-qemu-arm64
bitbake core-image-full-cmdline
This process may take an hour or more, depending on your machine's performance. The resulting images will be located in build-qemu-arm64/tmp/deploy/images/qemuarm64
.
Launch the built image on the 64-bit Arm QEMU target without a graphical interface:
runqemu qemuarm64 nographic
The Linux system will boot on your console. Log in with the username root
(no password required).
Check the Linux distribution and architecture:
uname -a
Expected output (version may vary slightly):
Linux qemuarm64 5.15.78-yocto-standard #1 SMP PREEMPT Wed Nov 16 14:17:41 UTC 2022 aarch64 GNU/Linux
Verify that Node.js, npm, and GCC are installed:
node --version
npm --version
gcc --version
Example outputs (versions may vary depending on the scarthgap
branch):
node --version
v18.12.1
npm --version
8.19.2
gcc --version
gcc (GCC) 11.3.0
To exit QEMU, press Ctrl-a
followed by x
.
You have successfully built and run a Yocto Linux image with Node.js, GCC, and npm on a 64-bit Arm QEMU target. Using the scarthgap
branch for meta-openembedded
ensures compatibility with Poky’s yocto-5.0.10
(Yocto 5.0 release), resolving the pathspec 'yocto-5.0.10'
error.
- Layer Errors: Ensure the
meta-openembedded
branch isscarthgap
to match Poky’syocto-5.0.10
. Verify paths inbblayers.conf
. - Git Error: If you encounter
pathspec
errors, rungit fetch --tags
in themeta-openembedded
repository to ensure all branches are available, then confirm thescarthgap
branch exists withgit branch -r
. - Build Time: Adding
nodejs
,gcc
, andnpm
increases build time and disk usage. - Further Help: Consult the Yocto Project documentation at https://docs.yoctoproject.org or the OpenEmbedded website at https://www.openembedded.org/.