Difference between revisions of "iMX8M Industrial Yocto Image Building"

From Voipac Wiki
Jump to navigation Jump to search
Line 13: Line 13:
 
All the source files for this customized Yocto Project, together with the recent changes made, can be inspected and downloaded at the [https://github.com/voipac Voipac GitHub] repository.
 
All the source files for this customized Yocto Project, together with the recent changes made, can be inspected and downloaded at the [https://github.com/voipac Voipac GitHub] repository.
  
== Building using a script ==
+
== Cloning the project ==
The quickest option how to build an image provides the [https://github.com/voipac/yocto-imx8m-voipac/blob/master/build_image.sh prepared script] wich automatically copies the latest meta layers, set the machine and build the image. Locate the directory, where the script is located, then run it to fetch and build the Yocto image:
+
Create a new directory for the project environment:
 +
<syntaxhighlight lang="bash">
 +
mkdir ~/voipac-yocto
 +
cd ~/voipac-yocto
 +
</syntaxhighlight>
 +
 
 +
Clone the iMX8M Industrial Yocto Project into the host machine:
 +
<syntaxhighlight lang="bash">
 +
git clone https://github.com/voipac/yocto-imx8m-voipac.git
 +
</syntaxhighlight>
 +
 
 +
== Building the image ==
 +
Voipac provides quick and simple-to-use option how to build an image by using [https://github.com/voipac/yocto-imx8m-voipac/blob/master/build_image.sh prepared script]:
 +
<syntaxhighlight lang="bash">
 +
#!/bin/bash
 +
 
 +
set -e
 +
 
 +
# Copy manifests helper function
 +
copy_manifests() {
 +
rm -rf .repo
 +
mkdir -p .repo/manifests
 +
cp scripts/voipac.xml .repo/manifests/
 +
}
 +
 
 +
# Fetch the latest meta layers
 +
if ! diff -q .repo/manifests/voipac.xml scripts/voipac.xml >/dev/null 2>&1; then
 +
        copy_manifests
 +
        repo init -u "$(pwd)"/.repo/repo -b default -m voipac.xml
 +
fi
 +
       
 +
repo sync --optimized-fetch
 +
 
 +
MACHINE=imx8mq-voipac DISTRO=fslc-xwayland source ./setup-environment build-voipac
 +
bitbake -f voipac-image
 +
</syntaxhighlight>
 +
 
 +
The script initializes or automatically updates the latest meta layers and synchronize the directories afterwards. These include manifest files where all the sources are described. The second to last script line sets up the machine for which the last command '''bitbake''' compiles and builds output files. Besides defining '''MACHINE''' wchich defines setup for iMX8M Industrial Development Kit, '''DISTRO''' provides several building options concerrning graphical interface:
 +
* '''fsl-imx-wayland''' - Wayland weston graphics
 +
* '''fsl-imx-xwayland''' - Wayland graphics and X11
 +
* '''fsl-imx-fb''' - framebuffer graphics (no Wayland or X11)
 +
 
 +
The script can be run to fetch and build the Yocto image:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 
./build_image.sh
 
./build_image.sh
 
</syntaxhighlight>
 
</syntaxhighlight>
  
== Building via console commands ==
+
'''''Note:''''' Make sure that synchronization finished with no errors showcasing it by the following massage:
As this method delivers the same result as the script above, it can furthermore provide additional insight and variability.
 
=== Downloading sources ===
 
Create a new directory for the project environment:
 
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
mkdir ~/imx-yocto
+
repo sync has finished successfully.
cd ~/imx-yocto
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Initialize repo with manifest file where all the sources described:
+
'''''Note:''''' The first successful build can take several hours (depending on multiple factors affecting the host machine like CPU, internet bandwidth, alocated disk space, etc.).
 +
 
 +
== Locating output files ==
 +
After the complyiling process completed, the freshly built oputput files are located in directory:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-kirkstone -m imx-5.15.71-2.2.0.xml
+
cd ~/voipac-yocto/yocto-imx8m-voipac/build-voipac/tmp/deploy/images
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Synchronize the directories afterwards:
+
The files which need to be flashed into the development kit are located in this directory. To make them more accesible, the files can be copied and unpacked:
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
repo sync
+
cp -prv imx-boot ~/
 +
cp -prv voipac-image-imx8mq-voipac-20230512212054.rootfs.wic.gz ~/voipac-image-imx8mq-voipac.wic.gz
 +
gzip -d ~/voipac-image-imx8mq-voipac.wic.gz
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== Setting up the machine ===
+
At this point everything was prepared to flash the binaries. Follow the [[iMX8M Industrial Flashing Procedure|flashing procedure]] instructions how to start the development kit with these compiled bianries.
NXP, the CPU manufacturer, provides a usefull script called '''imx-setup-release.sh''' which simplifies the machine setup.
 
To setup e.g. imx8mqevk machine we use it in following way:
 

Revision as of 02:20, 9 December 2023

This Wiki page guides thorugh the process of downloading the Yocto Project source files for release 3.1 (dunfell), preparing and building images for the iMX8M Industrial Development Kit.

Before images can be built, neccesary steps need to be performed to setup the host machine.


All the source files for this customized Yocto Project, together with the recent changes made, can be inspected and downloaded at the Voipac GitHub repository.

Cloning the project

Create a new directory for the project environment:

mkdir ~/voipac-yocto
cd ~/voipac-yocto

Clone the iMX8M Industrial Yocto Project into the host machine:

git clone https://github.com/voipac/yocto-imx8m-voipac.git

Building the image

Voipac provides quick and simple-to-use option how to build an image by using prepared script:

#!/bin/bash

set -e

# Copy manifests helper function
copy_manifests() {
	rm -rf .repo
	mkdir -p .repo/manifests
	cp scripts/voipac.xml .repo/manifests/
}

# Fetch the latest meta layers
if ! diff -q .repo/manifests/voipac.xml scripts/voipac.xml >/dev/null 2>&1; then
        copy_manifests
        repo init -u "$(pwd)"/.repo/repo -b default -m voipac.xml
fi
		        
repo sync --optimized-fetch

MACHINE=imx8mq-voipac DISTRO=fslc-xwayland source ./setup-environment build-voipac
bitbake -f voipac-image

The script initializes or automatically updates the latest meta layers and synchronize the directories afterwards. These include manifest files where all the sources are described. The second to last script line sets up the machine for which the last command bitbake compiles and builds output files. Besides defining MACHINE wchich defines setup for iMX8M Industrial Development Kit, DISTRO provides several building options concerrning graphical interface:

  • fsl-imx-wayland - Wayland weston graphics
  • fsl-imx-xwayland - Wayland graphics and X11
  • fsl-imx-fb - framebuffer graphics (no Wayland or X11)

The script can be run to fetch and build the Yocto image:

./build_image.sh

Note: Make sure that synchronization finished with no errors showcasing it by the following massage:

repo sync has finished successfully.

Note: The first successful build can take several hours (depending on multiple factors affecting the host machine like CPU, internet bandwidth, alocated disk space, etc.).

Locating output files

After the complyiling process completed, the freshly built oputput files are located in directory:

cd ~/voipac-yocto/yocto-imx8m-voipac/build-voipac/tmp/deploy/images

The files which need to be flashed into the development kit are located in this directory. To make them more accesible, the files can be copied and unpacked:

cp -prv imx-boot ~/
cp -prv voipac-image-imx8mq-voipac-20230512212054.rootfs.wic.gz ~/voipac-image-imx8mq-voipac.wic.gz
gzip -d ~/voipac-image-imx8mq-voipac.wic.gz

At this point everything was prepared to flash the binaries. Follow the flashing procedure instructions how to start the development kit with these compiled bianries.