VAR-SOM-MX6 Yocto Krogoth Build Yocto release

From Variscite Wiki
VAR-SOM-MX6 - Yocto fsl-yocto-L4.1.15_2.0.0-ga Krogoth Build Yocto release

1 Installing required packages

Follow the link below and install all required packages on your machine.

www.yoctoproject.org/docs/latest/yocto-project-qs/yocto-project-qs.html

Please make sure you host PC is running Ubuntu 14.04 64-bit and install the following packages:

sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev
sudo apt-get install autoconf libtool libglib2.0-dev libarchive-dev
sudo apt-get install python-git xterm sed cvs subversion coreutils texi2html
sudo apt-get install docbook-utils python-pysqlite2 help2man make gcc g++ desktop-file-utils libgl1-mesa-dev
sudo apt-get install libglu1-mesa-dev mercurial automake groff curl lzop asciidoc u-boot-tools dos2unix mtd-utils
sudo apt-get install pv

2 Documentation

Freescale Krogoth documents

3 Download Yocto Krogoth for i.MX Freescale source

$ git config --global user.name "Your Name"
$ git config --global user.email "Your Email"

$ mkdir ~/bin (this step may not be needed if the bin folder already exists)
$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
$ export PATH=~/bin:$PATH

$ mkdir ~/var-imx-yocto-krogoth
$ cd ~/var-imx-yocto-krogoth
$ repo init -u https://source.codeaurora.org/external/imx/fsl-arm-yocto-bsp.git -b imx-4.1-krogoth
$ repo sync -j4

4 Download Meta Variscite i.MX support for Yocto

$ cd ~/var-imx-yocto-krogoth/sources
$ git clone https://github.com/varigit/meta-variscite-imx.git -b Krogoth-imx-4.1.15-var01

5 Choose build release

The following releases are available for compilation:

  • Latest development release - This is the latest available release that updates with new patches.
  • Latest recovery SD card - This release is for building the same image you can download from our FTP site.
  • Older recovery SD card - The older releases of recovery SD Card.

Build Release examples:

5.1 To compile the latest development release

$ cd ~/var-imx-yocto-krogoth/sources/meta-variscite-imx
$ git checkout -b Krogoth-imx-4.1.15-var01

$ cp scripts/var-setup-release.sh ../..

5.2 To compile the latest recovery SD card

$ cd ~/var-imx-yocto-krogoth/sources/meta-variscite-imx
$ git log --no-walk --tags --decorate --simplify-by-decoration --oneline

It will show all the recovery SD card releases available.
Choose the latest one. For example: var-som-mx6_SD_card_v71

$ git checkout -b Krogoth-imx-4.1.15_2.0.0-mx6_SDv71 var-som-mx6_SD_card_v71

$ cp scripts/var-setup-release.sh ../..

6 Setup and build Yocto

The following distros can be used:

  • fsl-imx-x11 - Only X11 graphics
  • fsl-imx-wayland - Wayland weston graphics
  • fsl-imx-xwayland - Wayland graphics and X11. X11 applications using EGL are not supported
  • fsl-imx-fb - Frame Buffer graphics - no X11 or Wayland


Note: refer to ftp://customerv:Variscite1@ftp.variscite.com/VAR-SOM-MX6/Software/Linux/Yocto/fsl-yocto-imx-4.1.15_2.0.0-docs/i.MX_Yocto_Project_User's_Guide.pdf
Chapter 5 for further information.

Sample build scenarios:

6.1 Build X11 GUI image

$ cd ~/var-imx-yocto-krogoth
$ MACHINE=var-som-mx6 DISTRO=fsl-imx-x11 source var-setup-release.sh -b build_x11

Optional steps: local.conf customization

launch bitbake:

Without Qt content:
$ bitbake fsl-image-gui

Or with Qt content:
$ bitbake fsl-image-qt5

6.2 Build Qt5 image without X11

$ cd ~/var-imx-yocto-krogoth
$ MACHINE=var-som-mx6 DISTRO=fsl-imx-fb source var-setup-release.sh -b build_fb

Optional steps: local.conf customization

launch bitbake:

$ bitbake fsl-image-qt5

6.3 local.conf customization

6.3.1 Change the downloads directory

Create a /opt/yocto_downloads directory and set its permissions:

$ sudo mkdir /opt/yocto_downloads
$ sudo chmod 777 /opt/yocto_downloads/

Direct downloads to it, by replacing 'DL_DIR ?= "${BSPDIR}/downloads/"' with 'DL_DIR = "/opt/yocto_downloads/"' in conf/local.conf:

$ sed -i 's/DL_DIR ?= "${BSPDIR}\/downloads/DL_DIR = "\/opt\/yocto_downloads/g' conf/local.conf

6.3.2 Add Eclipse debug and Qt creator support to your images

Append the following to the conf/local.conf file in your Yocto build directory, to add Eclipse debug and Qt creator support to your images:

EXTRA_IMAGE_FEATURES = " \
    debug-tweaks \
    tools-debug \
    eclipse-debug \
    "

IMAGE_INSTALL_append = " \
    tcf-agent \
    openssh-sftp-server \
    "

6.3.3 Use systemd instead of SysV init

Append the following to the conf/local.conf file in your Yocto build directory, to use systemd instead of SysV init in your images:

DISTRO_FEATURES_append = " systemd"
VIRTUAL-RUNTIME_init_manager = "systemd"
DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
VIRTUAL-RUNTIME_initscripts = ""
IMX_DEFAULT_DISTRO_FEATURES_append = " systemd"

6.4 Build Results

The resulted images are located in tmp/deploy/images/var-som-mx6.

Image Name
How to use
fsl-image-gui-var-som-mx6.sdcard 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.
fsl-image-gui-var-som-mx6.tar.bz2 Tarball with rootfs files.
Can be used to create an NFS root file system on the host.
See the Setup TFTP/NFS Yocto system section for more info.
Also used to create our extended SD card.
See the Create a bootable SD card section below.
fsl-image-gui-var-som-mx6.ubi A complete UBI image containing a UBIFS volume, for writing to NAND Flash.
uImage Linux kernel image, same binary for SD card or NAND Flash.
SPL-var-som-mx6-nand SPL built for NAND-Flash.
The SPL is a pre-U-Boot SW component, required for DDR initialization.
u-boot-var-som-mx6.img-nand U-Boot built for NAND Flash.
SPL-var-som-mx6-sd SPL built for SD card boot, or eMMC boot in case of DART-MX6.
u-boot-var-som-mx6.img-sd U-Boot built for SD card boot, or eMMC boot in case of DART-MX6.
Device Tree Name
SOM type
Carrier Board type
LCD Type
Evaluation Kit name
uImage-imx6q-var-som-cap.dtb VAR-SOM-MX6_V2 (Quad / Dual) VAR-MX6CustomBoard Capacitive touch VAR-DVK-MX6_V2-PRO
VAR-STK-MX6_V2
uImage-imx6q-var-som-res.dtb VAR-SOM-MX6_V2 (Quad / Dual) VAR-MX6CustomBoard Resistive touch VAR-DVK-MX6_V2-PRO
VAR-STK-MX6_V2
uImage-imx6q-var-som-vsc.dtb VAR-SOM-MX6_V2 (Quad / Dual) VAR-SOLOCustomBoard Capacitive LVDS touch N/A
uImage-imx6dl-var-som-cap.dtb VAR-SOM-MX6_V2 (DualLite/ Solo) VAR-MX6CustomBoard Capacitive touch N/A
uImage-imx6dl-var-som-res.dtb VAR-SOM-MX6_V2 (DualLite/ Solo) VAR-MX6CustomBoard Resistive touch N/A
uImage-imx6dl-var-som-vsc.dtb VAR-SOM-MX6_V2 (DualLite/ Solo) VAR-SOLOCustomBoard Capacitive LVDS touch N/A
uImage-imx6dl-var-som-solo-vsc.dtb VAR-SOM-SOLO / VAR-SOM-DUAL VAR-SOLOCustomBoard Capacitive LVDS touch VAR-DVK-SOLO/DUAL
VAR-STK-SOLO/DUAL
uImage-imx6dl-var-som-solo-cap.dtb VAR-SOM-SOLO / VAR-SOM-DUAL VAR-MX6CustomBoard Capacitive touch N/A
uImage-imx6dl-var-som-solo-res.dtb VAR-SOM-SOLO / VAR-SOM-DUAL VAR-MX6CustomBoard Resistive touch N/A
uImage-imx6q-var-dart.dtb VAR-SOM-SOLO / VAR-SOM-DUAL VAR-DT6CustomBoard Capacitive LVDS touch VAR-DVK-DT6
VAR-STK-DT6

7 Create a bootable SD card

7.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 SPL and u-boot.img. They can be replaced with a dd command described in the Build U-Boot out of Yocto tree section.
  • The first partition is a fat16 partition used for the device tree files and Linux uImage file. You can copy them as described in the Linux out of tree section.
  • The second partition is an ext4 partition that contains the complete file system and 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.

7.2 Yocto pre-built bootable SD card

The Yocto build products contains many files as explained in the Build Results section. For example, fsl-image-gui-var-som-mx6.sdcard, depending on your build. This is a complete image to be flashed directly to an SD card.

Example usage:

$ sudo umount /dev/sdX*

# For GUI-X11 & QT5-X11
$ cd ~var-imx-yocto-krogoth/build_x11
Or
# For QT5-FB
$ cd ~/var-imx-yocto-krogoth/build_fb

# For fsl-image-gui image (GUI-X11)
$ sudo dd if=tmp/deploy/images/var-som-mx6/fsl-image-gui-var-som-mx6.sdcard of=/dev/sdX bs=1M && sync
Or
# For fsl-image-qt5 image (QT5-X11 & QT5-FB)
$ sudo dd if=tmp/deploy/images/var-som-mx6/fsl-image-qt5-var-som-mx6.sdcard 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 .sdcard yocto-built image:

  • The second partition size doesn't use the entire SD card.
  • The second partition is not labeled as rootfs.
  • The NAND and eMMC flashing scripts are not included.

7.3 Create an extended SD card

Variscite provides the var-create-yocto-sdcard.sh script which creates our NAND/eMMC recovery SD card - an SD card based on the fsl-image-gui filesystem, which copies the NAND flash burning scripts and relevant binaries for your convenience.
Later, you will be able to follow either the more automatic VAR-SOM-MX6 Yocto Recovery SD card guide or the more manual VAR-SOM-MX6 NAND flash burning 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 Android recovery (Android-eMMC) is only present on the pre-built SD image, and not on the SD card built from the Yocto script.
  • 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 fsl-image-gui.
  • 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)
$ sudo MACHINE=var-som-mx6 ~/var-imx-yocto-krogoth/sources/meta-variscite-imx/scripts/var_mk_yocto_sdcard/var-create-yocto-sdcard.sh <options> /dev/sdX
(Replace /dev/sdX with your actual device)
options:
  -h            Display help message
  -s            Only show partition sizes to be written, without actually write them
  -a            Automatically set the rootfs partition size to fill the SD card
  -r            Select alternative rootfs for recovery images (default: build_x11/tmp/deploy/images/var-som-mx6/fsl-image-gui-var-som-mx6.*)

If you don't use the '-a' option, a default rootfs size of 3700MiB will be used
The '-r' option allows you to create a bootable SD card with an alternative image for the installation to NAND flash or eMMC.
Example: "-r tmp/deploy/images/var-som-mx6/fsl-image-qt5-var-som-mx6" -- selected the "Qt5 image with X11" recovery image

8 Boot the board with a bootable SD card

8.1 Booting your specific Developer Kit

Select the one you are using.

8.1.1 MX6CustomBoard

Booting your MX6CustomBoard system from SD card requires while powering up the system. See picture below.

Mx6 boot.jpg

To boot a board using an SD card, follow the steps below:

  • Power-off the board.
  • Insert the SD card into the SD/MMC slot of the carrier board (DVK)
  • Push the middle button (Boot Select) and hold
  • Power-up the board
  • Release the middle button (Boot Select) after system starts to boot.
  • The board will automatically boot into Linux from the SD card

8.1.2 SoloCustomBoard

Booting your system requires switching the relevant DIP switch to "Boot from MMC". See picture below.

Solo boot.jpg

To boot board with SD card, Follow the steps below:

  • Power-off the board.
  • Insert the SD card into the SD/MMC slot of the carrier board (DVK)
  • Switch the relevant DIP switch to "Boot from MMC"
  • Power-up board
  • The board will automatically boot into Linux from SD card

8.1.3 DT6CustomBoard

Booting your system requires switching the relevant DIP switch to "Boot from SD card". See picture below.

Dart boot.jpg

To boot board with SD card, Follow the steps below:

  • Power-off the board.
  • Insert the SD card into the SD/MMC slot of the carrier board (DVK)
  • Switch the relevant DIP switch to "Boot from SD card"
  • Power-up board
  • The board will automatically boot into Linux from SD card

8.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 (sometimes they are renamed without the "uImage-" prefix).
We implemented a script in U-Boot's environment, which sets the fdt_file environment variable based on the detected hardware.

8.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

9 Flash images to NAND

Please refer to VAR-SOM-MX6 NAND Flash burning

10 QT5/Embedded environment variables

The QT5/Embedded require environment variables to run correctly. You need to have them avilable on the target. For example /etc/profile.d/tslib.sh can be edited.

export TSLIB_TSDEVICE=/dev/input/touchscreen0
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/etc/ts.conf
export QT_QPA_GENERIC_PLUGINS=tslib:/dev/input/event0
export QT_QPA_EGLFS_PHYSICAL_HEIGHT=480
export QT_QPA_EGLFS_PHYSICAL_WIDTH=800
export QT_QPA_EGLFS_HEIGHT=480
export QT_QPA_EGLFS_WIDTH=800
export QT_EGLFS_IMX6_NO_FB_MULTI_BUFFER=1
export QT_QPA_EGLFS_DEPTH=24
export QT_QPA_PLATFORM=eglfs

11 UBIFS

By default we create ubifs image for 512MB NAND-flash size. You can change the size by editing ~/var-imx-yocto-krogoth/sources/meta-variscite-imx/conf/machine/var-som-mx6.conf
and comment / uncomment the relevant section based on size.

12 DDR size and Contiguous Memory Allocator

By default Freescale allocates 256MB of RAM to the Contiguous Memory Allocator - this is for proper operation of the IPU VPU, X11 etc.
On a VAR-SOM-SOLO with 256MB DDR RAM size, it will cause a kernel freeze during boot. Adding cma=32MB to the bootargs parameters is required to fix it.

13 Update Yocto Krogoth Meta-Variscite

From time to time we will post updates to meta-variscite that will include new features and bug fixes.
Follow the instructions below to update your tree:

$ cd ~/var-imx-yocto-krogoth/sources/meta-variscite-imx/
$ git fetch origin
$ git checkout Krogoth-imx-4.1.15-var01
$ git pull

Setup your enviroment:
$ cd ~/var-imx-yocto-krogoth

for X11 image
$ MACHINE=var-som-mx6 DISTRO=fsl-imx-x11 source var-setup-release.sh -b build_x11
for FB image
$ MACHINE=var-som-mx6 DISTRO=fsl-imx-fb source var-setup-release.sh -b build_fb

In order to update the kernel, U-Boot and rootfs:
$ bitbake -c cleanall u-boot-variscite linux-variscite kernel-module-imx-gpu-viv ti-compat-wireless-wl18xx wl18xx-firmware cryptodev-module

for GUI image
$ bitbake -c clean fsl-image-gui
for Qt5 image
$ bitbake -c clean fsl-image-qt5

and build your image:
for GUI image
$ bitbake fsl-image-gui
for Qt5 image
$ bitbake fsl-image-qt5

14 Make changes to the rootfs

The following is usually not the recommended way to work with Yocto.
You should usually create new specific recipes (.bb files) and/or append to specific present recipes by using .bbappend files.
However, if you are not yet experienced enough with Yocto, and you just want to quickly add your files to the the resultant filesystem (or make any other change to it), you can do it in a general way, by using the following variable:

ROOTFS_POSTPROCESS_COMMAND

    Specifies a list of functions to call once the OpenEmbedded build system has created the root filesystem.
    You can specify functions separated by semicolons:

         ROOTFS_POSTPROCESS_COMMAND += "function; ... "                  

    If you need to pass the root filesystem path to a command within a function, you can use ${IMAGE_ROOTFS},
    which points to the directory that becomes the root filesystem image. See the IMAGE_ROOTFS variable for more information. 

The functions will be called right after the root filesystem is created and right before it is packed to images (.sdcard, .ubi, .tar.bz2, etc.).

14.1 Example

Let's say you have your files that you want to put in the filesystem arranged on your host under a directory called /my_rootfs_additions, like the following:

my_rootfs_additions/
├── data
│   ├── example.m4v
│   └── example.bin
├── etc
│   └── example.conf
└── home
    └── root
        └── .example

And let's say you want to build the fsl-image-gui image.

Create a file called ~/var-imx-yocto-krogoth/sources/meta-variscite-imx/recipes-images/images/fsl-image-gui.bbappend
with the following content:

add_my_files() {
    cp -r /my_rootfs_additions/*  ${IMAGE_ROOTFS}/
}

ROOTFS_POSTPROCESS_COMMAND += "add_my_files;"

Now, when you bitbake fsl-image-gui, the files in /my_rootfs_additions will be added to the rootfs (be careful when overwriting files).

15 Useful Bitbake commands

Bitbake Cheat Sheet

Useful bitbake commands

i.MX Yocto Project: ltib versus bitbake