CL-SOM-iMX6UL: Yocto Linux: Building

From Compulab Mediawiki
Revision as of 11:36, 16 February 2016 by Valentin (talk) (Install on the eMMC)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Overview

The Yocto Project is an open-source collaboration focused on embedded Linux development.
The purpose of this article is to show how to get Yocto Image with CL-SOM-iMX6UL support.

Build CL-SOM-iMX6UL Yocto Image

Yocto Environment Setup

This section describes the Yocto environment setup and build procedure.

Host Setup

To get the Yocto Project expected behavior in a Linux Host Machine, the packages and utilities described below must be installed. An important consideration is the hard disk space required in the host machine. For example, when building on a machine running Ubuntu, the minimum hard disk space required is about 50 GB for the X11 backend. It is recommended that at least 120 GB be provided, which is enough to compile any backend. The recommended minimum Ubuntu version is 12.04 or later. Earlier versions may cause the Yocto Project build setup to fail, because it requires python versions only available starting with Ubuntu 12.04.

Host Packages

A Freescale Yocto Project Community BSP build requires that some packages be installed for the build that are documented under the Yocto Project. You can go to Yocto Project Quick Start and check for the packages that must be installed for your build machine.

  • Essential Yocto Project host packages:
$ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev
  • i.MX layers host packages for Ubuntu 12.04 or 14.04 host setup are:
$ sudo apt-get install libsdl1.2-dev xterm sed cvs subversion coreutils texi2html \
docbook-utils python-pysqlite2 help2man make gcc g++ desktop-file-utils \
libgl1-mesa-dev libglu1-mesa-dev mercurial autoconf automake groff curl lzop asciidoc
  • i.MX layers host packages for a Ubuntu 12.04 host setup only are:
$ sudo apt-get install uboot-mkimage
  • i.MX layers host packages for a Ubuntu 14.04 host setup only are:
$ sudo apt-get install u-boot-tools

Setting up the repo utility

repo is a tool built on top of Git that makes it easier to manage projects that contain multiple repositories, which do not need to be on the same server. repo complements very well the layered nature of the Yocto Project, making it easier for customers to add their own layers to the BSP.
To install the repo utility, perform these steps:

  • Create a bin folder in the home directory.
$ 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
  • Add the following line to the .bashrc file to ensure that the ~/bin folder is in your PATH variable.
$ export PATH=~/bin:$PATH

Yocto Project Setup

A Yocto Project directory contains a sources directory, which contains the recipes used to build, one or more build directories, and a set of scripts used to set up the environment. The recipes used to build the project come from both the community and Freescale. The following commands are used to download the Freescale Yocto Project Community BSP recipe layers. The Yocto Project layers are downloaded and placed in the sources directory. This sets up the recipes that are used to build the project. For this example, a directory called "fsl-release-bsp" is created for the project.

$ mkdir fsl-release-bsp
$ cd fsl-release-bsp
$ git config --global user.name "Your Name"
$ git config --global user.email "Your Email"
$ repo init -u git://git.freescale.com/imx/fsl-arm-yocto-bsp.git -b imx-3.14.38-6UL_ga
$ repo sync
$ export FSL_BSP_ROOT=`pwd`

When this process is completed, the source code is checked out at fsl-release-bsp/sources. You can perform repo synchronization, with the command repo sync, periodically to update to the latest codes.

CL-SOM-iMX6UL Support

Admolition note.png We assume that /path/to/cl-som-imx6ul-yocto contains unpacked content of the CL-SOM-iMX6UL Yocto Linux Package

CL-SOM-iMX6UL Patches

  • Go to the fsl-release-bsp/source/meta-fsl-arm-extra directory and apply the patches:
$ cd ${FSL_BSP_ROOT}/sources/meta-fsl-arm-extra
$ git am /path/to/cl-som-imx6ul-yocto/development/*.patch
  • Go to the fsl-release-bsp root:
$ cd ${FSL_BSP_ROOT}

Build x11 image for CL-SOM-iMX6UL

$ export MACHINE=cl-som-imx6ul
$ source fsl-setup-release.sh –b build -e x11
$ bitbake fsl-image-gui

If bitbake displays an error indicating that fsl-image-gui cannot be found, this means that fsl-setup-release.sh was not run. This script hooks in the meta-fsl-bsp-release layer with the Yocto Project layer system. Build scripts used to generate prebuilt images for this release are provided in the meta-fsl-bsp-release layer in imx/tools. Use these for additional examples.

Once a build is complete, the created images reside in ${FSL_BSP_ROOT}/build/tmp/deploy/images/${MACHINE}. The image build creates a U-Boot, Linux kernel, and rootfs image type based on the IMAGE_FSTYPES defined in the machine configuration file. Most machine configurations provide an SD card image, ext3 and tar.bz2. The ext3 is the root file system.

Create an environment variable BSP_IMAGES_DIR for use during deployment.

$ export BSP_IMAGES_DIR=${FSL_BSP_ROOT}/build/tmp/deploy/images/${MACHINE}

Image Deployment

Image content

File System

  • fsl-image-gui-cl-som-imx6ul.sdcard - SD card image that provides the full system to boot with U-Boot and Linux kernel
  • fsl-image-gui-cl-som-imx6ul.tar.bz2 - rootfs tar ball for deployment onto any (including NFS) storage or further customization

Kernel and Modules

  • zImage-cl-som-imx6ul.bin - ready to run Linux kernel image binary for CL-SOM-iMX6UL
  • modules-cl-som-imx6ul.tgz - the Linux kernel modules

Device Tree Blobs

  • zImage-imx6ul-cl-som-imx6ul.dtb - CL-SOM-iMX6UL (module only) device tree blob
  • zImage-imx6ul-cl-som-imx6ul-wilink.dtb - CL-SOM-iMX6UL (module only) with WiLink8 device tree blob
  • zImage-imx6ul-sbc-imx6ul.dtb - SBC-iMX6UL (evaluation board) device tree blob
  • zImage-imx6ul-sbc-imx6ul-wilink.dtb - SBC-iMX6UL (evaluation board) with WiLink8 device tree blob

U-Boot

  • u-boot-cl-som-imx6ul.imx - ready to flash CL-SOM-iMX6UL firmware

SD card deployment

Flashing an SD card

  • Flash the SD card image:
Admolition note.png sdX represents an entire device, not a partition
Example: /dev/sde
$ sudo -i
$ cd ${BSP_IMAGES_DIR}
$ SDCARD_IMAGE=$(ls -tr *.sdcard | head -1)
$ dd if=${SDCARD_IMAGE} of=/dev/sdX bs=1M
  • Copy the U-Boot binary to the SD card:
Admolition note.png sdX1 represents the device 1-st partition
Example: /dev/sde1
$ hdparm -z /dev/sdX
$ mkdir /tmp/sdX1
$ mount /dev/sdX1 /tmp/sdX1
$ cp u-boot-cl-som-imx6ul.imx /tmp/sdX1/
  • Unmount and eject the SD card:
$ umount /dev/sdX1
$ eject /dev/sdX
$ exit

Booting from an SD card

  • Plug the SD card into the full size sd slot(P9) of the SB-SOM-iMX6UL
  • Hold the ALT BOOT (SW3) button while resetting/powering on the CL-SOM-iMX6UL evaluation system
  • The CL-SOM-iMX6UL will boot from the SD card
  • Press a button as soon as "Hit any key to stop autoboot:" shows up

Flash the U-Boot

mmc dev 0; mmc rescan
setenv size 0x80000; mw.b ${loadaddr} 0 ${size}
load mmc 0 ${loadaddr} u-boot-cl-som-imx6ul.imx
sf probe ; sf erase 0 0x80000 ; sf write ${loadaddr} 0x400 ${size}

Set and save the default U-Boot environment

env default -a
saveenv
reset

eMMC deployment

Install on the eMMC

Admolition note.png Requires a Yocto SD card to be prepared first.
Poky (Yocto Project Reference Distro) 1.8 cl-som-imx6ul /dev/ttymxc2

cl-som-imx6ul login:
  • Login as root into the system.

Once the board has been booted using a bootable SD Card, the Yocto rootfs can be installed onto the board eMMC.

Admolition note.png We assume that /mount/point contains unpacked content of the BSP_IMAGES_DIR.
  • In this subsection the term /mount/point can be:
    • /mnt/net if NFS is used
    • /media/mmcblk0pX if an MMC/SD card is used, where X is the partition number.
    • /media/sdXY if a USB storage is used, where X is the USB drive letter and Y is the partition number.
  • Flash the SD card image on the eMMC:
$ cd ${BSP_IMAGES_DIR}
$ SDCARD_IMAGE=$(ls -tr *.sdcard | head -1)
$ sudo dd if=${SDCARD_IMAGE} of=/dev/mmcblk1 bs=1M
  • WiLink8 Deployment
$ hdparm -z /dev/sdX
$ mkdir /tmp/sdX2
$ mount /dev/sdX2 /tmp/sdX2
$ tar -C /tmp/sdX2 -xvf /path/to/cl-som-imx6ul-yocto/images/extra/WiLink8.fs.support.tar.bz2
  • Power off the device:
$ poweoff

Booting from the eMMC

  • Power on the device.
  • Press a button as soon as "Hit any key to stop autoboot:" shows up.
  • Update the boot environment and boot the device:
setenv mmcdev 1
setenv mmcroot "/dev/mmcblk${mmcdev}p2 rootwait rw"
setenv fdt_file imx6ul-sbc-imx6ul-wilink.dtb
saveenv
boot

Display Options

SBC-iMX6UL has an option to connecte either an LCD or a DVI display.
The default device tree layout allows using both interfaces at the same time with the 1024x768@60 resolution.

Admolition note.png A side effect is: the LCD display shows upper left part of the screen with geometry 800x480

Below are examples that show how to change the boot environment in order to set the correct interface timing and geometry and work with either an LCD or a DVI display separately.

LCD

setenv lcd+ 'fdt add ${fdt_addr}; fdt rm lcdif/display/display-timings/dvi'
setenv bootcmd 'run mmcargs; run loadfdt; run loadimage; run lcd+; bootz ${loadaddr} - ${fdt_addr}'
saveenv
boot

DVI

setenv dvi+ 'fdt add ${fdt_addr}; fdt rm lcdif/display/display-timings/lcd'
setenv bootcmd 'run mmcargs; run loadfdt; run loadimage; run lcd+; bootz ${loadaddr} - ${fdt_addr}'
saveenv
boot

See Also