VAR-SOM-MX7 Yocto Morty build
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
Documentation
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 git://git.freescale.com/imx/fsl-arm-yocto-bsp.git -b imx-4.1-krogoth $ repo sync -j4
Download Meta Variscite i.MX support for Yocto
$ cd ~/var-imx-yocto-krogoth/sources $ git clone https://github.com/varigit/meta-variscite-imx.git
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:
To compile the latest development release
$ cd ~/var-imx-yocto-krogoth/sources/meta-variscite-imx $ git checkout -b Krogoth-imx-4.1.15-var01_r2 $ cp scripts/var-setup-release.sh ../..
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-mx7_SD_card_v12 $ git checkout -b Krogoth-imx-4.1.15_2.0.0-R2-mx7_SDv12 var-som-mx7_SD_card_v12 $ cp scripts/var-setup-release.sh ../..
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:
Build X11 GUI image without Qt content
$ cd ~/var-imx-yocto-krogoth $ MACHINE=imx7-var-som DISTRO=fsl-imx-x11 source var-setup-release.sh -b build_x11
Optional steps: local.conf customization
launch bitbake:
$ bitbake fsl-image-gui
Build Qt5 image without X11
$ cd ~/var-imx-yocto-krogoth $ MACHINE=imx7-var-som DISTRO=fsl-imx-fb source var-setup-release.sh -b build_fb
Optional steps: local.conf customization
launch bitbake:
$ bitbake fsl-image-qt5
local.conf customization
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
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 \ "
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"
Create a read-only root file system
Append the following to the conf/local.conf file in your Yocto build directory, to create a read-only rootfs:
EXTRA_IMAGE_FEATURES += "read-only-rootfs"
Build Results
The resulted images are located at tmp/deploy/images/imx7-var-som:
File Name | Description |
---|---|
fsl-image-gui-imx7-var-som.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. For detailed information refer to the Create a bootable SD card section below. |
fsl-image-gui-imx7-var-som.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-imx7-var-som.ubi | A complete UBI image containing a UBIFS volume, for writing to NAND flash. |
zImage | Linux kernel image, same binary for SD card/eMMC/NAND flash. |
u-boot.imx-sd | U-Boot built for SD card/eMMC. |
u-boot.imx-nand | U-Boot built for NAND flash. |
zImage-imx7d-var-som-emmc.dtb | Device tree blob for SOMs with eMMC. |
zImage-imx7d-var-som-nand.dtb | Device tree blob for SOMs with NAND flash. |
Create a bootable SD card
SD card structure
The first unallocated 4MiB are saved for U-Boot. It can be replaced using the dd command as described in the Build U-Boot from source code section.
The first partition is formatted with FAT16 and contains the Linux image and device tree blobs. You can copy them as described in the Build the Linux kernel from source code section.
The second partition is formatted with ext4 and contains the file system (including the kernel modules).
Yocto pre-built bootable SD card
The Yocto build products contains many files as explained in Build Results section above including a ".sdcard" file. For example, fsl-image-gui-imx7-var-som.sdcard, depending on your build.
This is a complete image to be flashed directly to an SD card.
Example usage:
$ cd ~/var-imx-yocto-krogoth/build_x11 $ sudo umount /dev/sdX* $ sudo dd if=tmp/deploy/images/imx7-var-som/fsl-image-gui-imx7-var-som.sdcard of=/dev/sdX bs=1M && sync Replace sdX with the right device name.
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.
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-MX7 Yocto Recovery SD card guide or the more manual Flashing the internal storage device 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 difference:
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=imx7-var-som ~/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/imx7-var-som/fsl-image-gui-imx7-var-som.*) 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/imx7-var-som/fsl-image-qt5-imx7-var-som" -- selects the "Qt5 image with X11" recovery image
Boot board with a bootable SD card
Setting the BOOT SELECT DIP switches
Make sure the BOOT SELECT DIP switches on the carrier board are set correctly before you power on the board.
SW1-SW2 0 - 0 : Boot from SD card 1 - 0 : Boot from eMMC 0 - 1 : Boot from NAND flash 1 - 1 : Illegal
Note: The VAR-SOM-MX7 SOM comes with either NAND or eMMC, but not both.
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 "zImage-" prefix).
We implemented a script in U-Boot's environment, which sets the fdt_file environment variable based on the detected hardware.
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
Flash images to NAND/eMMC
Please refer to VAR-SOM-MX7 NAND flash burning
QT5/Embedded runtime
Environment Variables
The QT5/Embedded require environment variables to run correctly. VAR-SOM-MX7 support QT Embedded over Linux Frame Buffer. For example /etc/profile.d/tslib.sh can be edited. The following example enable touch, mouse and keyboard:
export TSLIB_TSEVENTTYPE='INPUT' export TSLIB_TSDEVICE='/dev/input/touchscreen0' export TSLIB_CALIBFILE='/etc/pointercal' export TSLIB_CONFFILE='/etc/ts.conf' export TSLIB_CONSOLEDEVICE='none' export TSLIB_FBDEVICE='/dev/fb0' export TSLIB_PLUGINDIR='/usr/lib/ts' export QT_QPA_PLATFORM=linuxfb:fb=/dev/fb0:size=800x480:mmSize=800x480 export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS='/dev/input/touchscreen0' export QT_QPA_GENERIC_PLUGINS='tslib:/dev/input/touchscreen0,evdevmouse:/dev/input/event5,evdevkeyboard:/dev/input/event3'
Running Application
$ cd /usr/share/qt5/examples/ $ touch/dials/dials --platform linuxfb $ gui/rasterwindow/rasterwindow --platform linuxfb $ touch/fingerpaint/fingerpaint --platform linuxfb $ widgets/mainwindows/mainwindow/mainwindow --platform linuxfb
UBIFS
The UBIFS image we create by default is for 512MiB NAND flash.
You can change the size by editing ~/var-imx-yocto-krogoth/sources/meta-variscite-imx/conf/machine/imx7-var-som.conf and comment/uncomment the relevant section.
Update Yocto 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=imx7-var-som DISTRO=fsl-imx-x11 source var-setup-release.sh -b build_x11 For FB image: $ MACHINE=imx7-var-som DISTRO=fsl-imx-fb source var-setup-release.sh -b build_fb In order to update the kernel and U-Boot: $ bitbake -c cleanall u-boot-variscite linux-variscite 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