B2QT Build Release

From Variscite Wiki
DART-6UL - Boot to Qt 5.15.2 based on Yocto Zeus


1 About Boot to Qt

Boot to Qt is a light-weight, Qt-optimized, full software stack for embedded Linux systems that is installed into the actual target device.

The stack can be customized to production with Build-Your-Own-Stack tooling, including proprietary Yocto Project recipes.

B2QTstack.png

The full B2Qt documentation is available at Qt for Device Creation official page.

2 Requirements

You should be familiar with the Yocto tools and the concept of recipes. For more information, see Yocto Project documentation.

Please make sure your host PC is running Ubuntu 18.04/20.04 64-bit and install the following packages:

$ sudo apt-get install gawk wget git diffstat unzip texinfo gcc-multilib \
build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \
xz-utils debianutils iputils-ping libsdl1.2-dev xterm
$ sudo apt-get install autoconf libtool libglib2.0-dev libarchive-dev python-git \
sed cvs subversion coreutils texi2html docbook-utils python-pysqlite2 \
help2man make gcc g++ desktop-file-utils libgl1-mesa-dev libglu1-mesa-dev \
mercurial automake groff curl lzop asciidoc u-boot-tools dos2unix mtd-utils pv \
libncurses5 libncurses5-dev libncursesw5-dev libelf-dev zlib1g-dev bc rename \
git-core p7zip g++-multilib xterm gperf bison
$ which git-lfs > /dev/null || sudo apt-get install git-lfs || \
  (curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash &&
  sudo apt-get install git-lfs)



Note: Variscite provides Docker containers that can be used for a development environment as an alternative to using a virtual machine or a dedicated computer. To learn more, please see Variscite's Docker Build Environment guide.

3 Setting Up Yocto Build Environment

Run the setup script that initializes the Yocto environment.

$ mkdir -p ~/var-b2qt/sources/
$ cd ~/var-b2qt/sources/
$ git clone https://github.com/varigit/meta-variscite-boot2qt.git -b zeus-var01
$ cd ..
$ ./sources/meta-variscite-boot2qt/b2qt-init-build-env init --device imx6ul-var-dart

b2qt-init-build-env has the following additional command line options:

  • list-devices: show all supported devices that can be used for a Boot to Qt build
  • mirror: create a local mirror of the yocto repositories. This enables you to use the same repository downloads for multiple build environments, when initializing with init --reference <mirror path>.

For all command line options, see:

$ ./sources/meta-variscite-boot2qt/b2qt-init-build-env help

4 Building the Image and Toolchain

After the Yocto environment is set up, you need to configure the build environment for your target device:

$ MACHINE=imx6ul-var-dart source ./setup-environment.sh

Yocto recipes for Boot to Qt for embedded Linux have two main targets to build: The target image, and the external toolchain that can be used with Qt Creator for building Qt applications.

$ MACHINE=imx6ul-var-dart bitbake b2qt-embedded-qt5-image
$ MACHINE=imx6ul-var-dart bitbake meta-toolchain-b2qt-embedded-qt5-sdk

The target rootfs image is located at:

~/var-b2qt/build-imx6ul-var-dart/tmp/deploy/images/imx6ul-var-dart/b2qt-embedded-qt5-image-imx6ul-var-dart.wic.gz

and the new toolchain installation file is:

~/var-b2qt/build-imx6ul-var-dart/tmp/deploy/sdk/b2qt-x86_64-meta-toolchain-b2qt-embedded-qt5-sdk-imx6ul-var-dart.sh

4.1 Build Results

The resulting images are located in tmp/deploy/images/imx6ul-var-dart.


Image Name
How to use
b2qt-embedded-qt5-image-imx6ul-var-dart.wic This image is for SD card boot.
It can be flashed as-is on an SD card that can then be used to boot your system,
according to the relevant startup-guide of your product
(usually requires to press the boot select button, or toggle a DIP switch).
For detailed information refer to the Create a bootable SD card section below.
b2qt-embedded-qt5-image-imx6ul-var-dart.tar.gz Tarball with rootfs files.
Can be used to create an NFS root file system on the host.
See the Yocto Setup TFTP/NFS section for more info.
Also used to create our extended SD card.
See the Create a bootable SD card section below.
b2qt-embedded-qt5-image-imx6ul-var-dart_128kbpeb.ubi A complete UBI image containing a UBIFS volume, for writing to NAND flash with 128KiB PEB
b2qt-embedded-qt5-image-imx6ul-var-dart_256kbpeb.ubi A complete UBI image containing a UBIFS volume, for writing to NAND flash with 256KiB PEB
zImage Linux kernel image, same binary for SD card/eMMC or NAND flash.
SPL-sd SPL built for SD card boot or eMMC boot.
SPL-nand SPL built for NAND flash.
u-boot.img-sd U-Boot built for SD card boot or eMMC boot.
u-boot.img-nand U-Boot built for NAND flash.
File Name Description
imx6ull-var-dart-6ulcustomboard-emmc-sd-card.dtb Device tree blob for DART-6UL with i.MX6ULL SOC, eMMC & SD card enabled. (NAND flash & WiFi disabled)
imx6ull-var-dart-6ulcustomboard-emmc-wifi.dtb Device tree blob for DART-6UL with i.MX6ULL SOC, eMMC & WiFi enabled. (NAND flash & SD card disabled)
imx6ull-var-dart-6ulcustomboard-nand-sd-card.dtb Device tree blob for DART-6UL with i.MX6ULL SOC, NAND flash & SD card enabled. (eMMC & WiFi disabled)
imx6ull-var-dart-6ulcustomboard-nand-wifi.dtb Device tree blob for DART-6UL with i.MX6ULL SOC, NAND flash & WiFi enabled. (eMMC & SD card disabled)
imx6ul-var-dart-6ulcustomboard-emmc-sd-card.dtb Device tree blob for DART-6UL with i.MX6UL SOC, eMMC & SD card enabled. (NAND flash & WiFi disabled)
imx6ul-var-dart-6ulcustomboard-emmc-wifi.dtb Device tree blob for DART-6UL with i.MX6UL SOC, eMMC & WiFi enabled. (NAND flash & SD card disabled)
imx6ul-var-dart-6ulcustomboard-nand-sd-card.dtb Device tree blob for DART-6UL with i.MX6UL SOC, NAND flash & SD card enabled. (eMMC & WiFi disabled)
imx6ul-var-dart-6ulcustomboard-nand-wifi.dtb Device tree blob for DART-6UL with i.MX6UL SOC, NAND flash & WiFi enabled. (eMMC & SD card disabled)
imx6ulz-var-dart-6ulcustomboard-emmc-sd-card.dtb Device tree blob for DART-6UL with i.MX6ULZ SOC, eMMC & SD card enabled. (NAND flash & WiFi disabled)
imx6ulz-var-dart-6ulcustomboard-emmc-wifi.dtb Device tree blob for DART-6UL with i.MX6ULZ SOC, eMMC & WiFi enabled. (NAND flash & SD card disabled)
imx6ulz-var-dart-6ulcustomboard-nand-sd-card.dtb Device tree blob for DART-6UL with i.MX6ULZ SOC, NAND flash & SD card enabled. (eMMC & WiFi disabled)
imx6ulz-var-dart-6ulcustomboard-nand-wifi.dtb Device tree blob for DART-6UL with i.MX6ULZ SOC, NAND flash & WiFi enabled. (eMMC & SD card disabled)
imx6ull-var-som-concerto-board-emmc-sd-card.dtb Device tree blob for VAR-SOM-6UL on Concerto board with i.MX6ULL SOC, eMMC & SD card enabled. (NAND flash & WiFi disabled)
imx6ull-var-som-concerto-board-emmc-wifi.dtb Device tree blob for VAR-SOM-6UL on Concerto board with i.MX6ULL SOC, eMMC & WiFi enabled. (NAND flash & SD card disabled)
imx6ull-var-som-concerto-board-nand-sd-card.dtb Device tree blob for VAR-SOM-6UL on Concerto board with i.MX6ULL SOC, NAND flash & SD card enabled. (eMMC & WiFi disabled)
imx6ull-var-som-concerto-board-nand-wifi.dtb Device tree blob for VAR-SOM-6UL on Concerto board with i.MX6ULL SOC, NAND flash & WiFi enabled. (eMMC & SD card disabled)
imx6ul-var-som-concerto-board-emmc-sd-card.dtb Device tree blob for VAR-SOM-6UL on Concerto board with i.MX6UL SOC, eMMC & SD card enabled. (NAND flash & WiFi disabled)
imx6ul-var-som-concerto-board-emmc-wifi.dtb Device tree blob for VAR-SOM-6UL on Concerto board with i.MX6UL SOC, eMMC & WiFi enabled. (NAND flash & SD card disabled)
imx6ul-var-som-concerto-board-nand-sd-card.dtb Device tree blob for VAR-SOM-6UL on Concerto board with i.MX6UL SOC, NAND flash & SD card enabled. (eMMC & WiFi disabled)
imx6ul-var-som-concerto-board-nand-wifi.dtb Device tree blob for VAR-SOM-6UL on Concerto board with i.MX6UL SOC, NAND flash & WiFi enabled. (eMMC & SD card disabled)
imx6ulz-var-som-concerto-board-emmc-sd-card.dtb Device tree blob for VAR-SOM-6UL on Concerto board with i.MX6ULZ SOC, eMMC & SD card enabled. (NAND flash & WiFi disabled)
imx6ulz-var-som-concerto-board-emmc-wifi.dtb Device tree blob for VAR-SOM-6UL on Concerto board with i.MX6ULZ SOC, eMMC & WiFi enabled. (NAND flash & SD card disabled)
imx6ulz-var-som-concerto-board-nand-sd-card.dtb Device tree blob for VAR-SOM-6UL on Concerto board with i.MX6ULZ SOC, NAND flash & SD card enabled. (eMMC & WiFi disabled)
imx6ulz-var-som-concerto-board-nand-wifi.dtb Device tree blob for VAR-SOM-6UL on Concerto board with i.MX6ULZ SOC, NAND flash & WiFi enabled. (eMMC & SD card disabled)
imx6ull-var-som-symphony-board-emmc-sd-card.dtb Device tree blob for VAR-SOM-6UL on Symphony board with i.MX6ULL SOC, eMMC & SD card enabled. (NAND flash & WiFi disabled)
imx6ull-var-som-symphony-board-emmc-wifi.dtb Device tree blob for VAR-SOM-6UL on Symphony board with i.MX6ULL SOC, eMMC & WiFi enabled. (NAND flash & SD card disabled)
imx6ull-var-som-symphony-board-nand-sd-card.dtb Device tree blob for VAR-SOM-6UL on Symphony board with i.MX6ULL SOC, NAND flash & SD card enabled. (eMMC & WiFi disabled)
imx6ull-var-som-symphony-board-nand-wifi.dtb Device tree blob for VAR-SOM-6UL on Symphony board with i.MX6ULL SOC, NAND flash & WiFi enabled. (eMMC & SD card disabled)
imx6ul-var-som-symphony-board-emmc-sd-card.dtb Device tree blob for VAR-SOM-6UL on Symphony board with i.MX6UL SOC, eMMC & SD card enabled. (NAND flash & WiFi disabled)
imx6ul-var-som-symphony-board-emmc-wifi.dtb Device tree blob for VAR-SOM-6UL on Symphony board with i.MX6UL SOC, eMMC & WiFi enabled. (NAND flash & SD card disabled)
imx6ul-var-som-symphony-board-nand-sd-card.dtb Device tree blob for VAR-SOM-6UL on Symphony board with i.MX6UL SOC, NAND flash & SD card enabled. (eMMC & WiFi disabled)
imx6ul-var-som-symphony-board-nand-wifi.dtb Device tree blob for VAR-SOM-6UL on Symphony board with i.MX6UL SOC, NAND flash & WiFi enabled. (eMMC & SD card disabled)
imx6ulz-var-som-symphony-board-emmc-sd-card.dtb Device tree blob for VAR-SOM-6UL on Symphony board with i.MX6ULZ SOC, eMMC & SD card enabled. (NAND flash & WiFi disabled)
imx6ulz-var-som-symphony-board-emmc-wifi.dtb Device tree blob for VAR-SOM-6UL on Symphony board with i.MX6ULZ SOC, eMMC & WiFi enabled. (NAND flash & SD card disabled)
imx6ulz-var-som-symphony-board-nand-sd-card.dtb Device tree blob for VAR-SOM-6UL on Symphony board with i.MX6ULZ SOC, NAND flash & SD card enabled. (eMMC & WiFi disabled)
imx6ulz-var-som-symphony-board-nand-wifi.dtb Device tree blob for VAR-SOM-6UL on Symphony board with i.MX6ULZ SOC, NAND flash & WiFi enabled. (eMMC & SD card disabled)

5 Create a bootable SD card

5.1 SD card structure

This is the structure of our Recovery/Extended SD card:
SD card part v50.png


The SD card is divided into 3 sections as shown in the picture above:

  • The first unallocated 4MiB are saved space for U-Boot. It can be replaced using the dd commandas described in the Yocto Build U-Boot section.
  • The first partition is a fat16 partition used for the device tree files and the kernel image file.You can copy them as described in the Yocto Build Linux section.
  • The second partition is an ext4 partition that contains the complete root filesystem (including the kernel modules).

Note:
The last unallocated area is not used. It is there so that the rootfs will fit on any 4GB SD card, as not all 4GB SD cards are really the same size. If you want, you can use a program such as GParted to resize the roofs partition and make it end at the end of your specific SD card (of course, you can also use SD cards with much bigger capacity than 4GB, and then it makes more sense to resize the partition).
Also, if you create the extended SD card yourself by following the Create an extended SD card section below, and you use the '-a' option, the rootfs partition will end at the end of your specific SD card automatically.

5.2 B2Qt pre-built bootable SD card

The B2Qt build products contains a complete image to be flashed directly to an SD card.

Example usage:

$ sudo umount /dev/sdX*
$ sudo dd if=tmp/deploy/images/imx6ul-var-dart/b2qt-embedded-qt5-image-imx6ul-var-dart.wic of=/dev/sdX bs=1M && sync
Replace sdX with the right device name. This can be obtained by "dmesg" command on your host Linux PC, after the SD card reader is inserted.
  • Note: Booting your system from an SD card requires pressing the boot-select button, or switching the relevant DIP switch to "Boot from SD card", according to the relevant start-up guide of your system

Drawbacks of the native .wic b2qt-built image, (relative to the Recovery/Extended SD card):

  • The rootfs partition doesn't use the entire SD card.
  • The rootfs partition is not labeled as rootfs.
  • The NAND flash and eMMC installation scripts and images are not included.

5.3 Create an extended SD card

Variscite provides the var-create-yocto-sdcard.sh script which creates our NAND/eMMC recovery SD card. The script copies the NAND/eMMC flash burning scripts and relevant binaries for your convenience.
Later, you will be able to follow Boot2QT Recovery SD card guide to burn your images to NAND flash or eMMC.

Note:
This is essentially the same as our pre-built Recovery SD image, with the following main differences:

  • The pre-built image's rootfs partition size is 3700MiB, which is also the default size when using the script, but the script also has an option to set the rootfs partition size to fill the whole free space of the used SD card. Anyway, you can always resize the partition later with an external tool such as gparted.

Naturally, the pre-built image is more straight forward and easier to use, while the script method is easier to customize.

Usage:

  • Follow the Setup and build Yocto guide, and bitbake b2qt-embedded-qt5-image.
  • Plug-in the SD card to your Linux HOST PC, run dmesg and see which device is added (i.e. /dev/sdX or /dev/mmcblkX)
$ cd ~/var-b2qt
$ sudo MACHINE=imx6ul-var-dart sources/meta-variscite-imx/scripts/var_mk_yocto_sdcard/var-create-yocto-sdcard.sh /dev/sdX

Replace /dev/sdX with your actual device name, e.g. /dev/sdb

5.3.1 Create an extended SD card image using a loop device

It is also possible to use the var-create-yocto-sdcard.sh script to create an extended SD card image, while using a loop device instead of attaching a real SD card.

$ cd ~/var-b2qt

Create an empty file using the following command:

$ dd if=/dev/zero of=imx6ul-var-dart-extended-sd.img bs=1M count=3720

The above command creates a 3720MiB file representing the SD card.

Attach the first available loop device to this file:

$ sudo losetup -Pf imx6ul-var-dart-extended-sd.img

To find the actual loop device being used, run:

$ losetup -a | grep imx6ul-var-dart-extended-sd.img

Write the content to the loop device to generate the SD card image:

$ sudo MACHINE=imx6ul-var-dart sources/meta-variscite-imx/scripts/var_mk_yocto_sdcard/var-create-yocto-sdcard.sh <options> /dev/loopX

(Replace /dev/loopX with your actual loop device, e.g. /dev/loop0)

Detach the loop device from the file:

$ sudo losetup -d /dev/loopX

To compress the SD card image file use the following command:

$ gzip -9 imx6ul-var-dart-extended-sd.img

To write the SD card image to a real SD card device use the following command:

$ zcat imx6ul-var-dart-extended-sd.img.gz | sudo dd of=/dev/sdX bs=1M && sync

(Replace /dev/sdX with your actual SD device, e.g. /dev/sdb)

6 Boot the board with a bootable SD card

Note: The WiFi is not operational when booting from SD card, as the WiFi and SD card are using the same SDIO interface.
A typical use-case is to boot from an SD card, flash the eMMC/NAND flash, and re-boot from the eMMC/NAND flash to have the WiFi operational.

6.1 Setting the Boot Mode

Booting your system from an SD card requires switching the Boot DIP switches. See picture below.
On the VAR-6ULCustomBoard (with a DART-6UL):

Boot switch 6ul1.jpg
  • "00" The current position in the picture will set the system to boot from SD card
  • "01" Moving the right switch will set the system to boot from eMMC
  • "10" Moving the left switch will set the system to boot from NAND flash
  • "11" is illegal.
Be aware that your system has eMMC or NAND but never both.



On the Concerto-Board (with a VAR-SOM-6UL):

Boot switch concerto.jpg
  • ON-EXT: Boot from the external storage (SD card) - the current position in the picture
  • OFF-INT: Boot from the SOM's internal storage (eMMC/NAND flash)

6.2 Automatic device tree selection in U-Boot

As shown in the Build Results table above, we have different kernel device trees, corresponding to our different H/W configurations.
We implemented a script in U-Boot's environment, which sets the fdt_file environment variable based on the detected hardware.

6.2.1 Enable/Disable automatic device tree selection

To enable the automatic device tree selection in U-Boot (already enabled by default):

$ setenv fdt_file undefined
$ saveenv

To disable the automatic device tree selection in U-Boot, set the device tree file manually:

$ setenv fdt_file YOUR_DTB_FILE
$ saveenv

Useful example: To list all files in the boot partition (where the dtb files are by default) of an SD card:

$ ls mmc 0:1
Comment:
Make sure you don't set an inappropriate dtb file, like a dtb with nand on a SOM that has eMMC, or a dtb for mx6ull on a SOM with an mx6ul SOC.