CM-FX6 Yocto Linux

From Compulab Mediawiki
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 CM-FX6 support. The following two approaches are covered:

Evaluate CM-FX6 Yocto Image

This approach is useful for evaluation of CM-FX6 and Yocto image capabilities prior to setting up and building a customized Yocto image.

$ mkdir -p ~/tmp/yocto-release
$ wget --output-document ~/tmp/yocto-release/yocto-cm-fx6.tar.bz2 \
http://compulab.co.il/utilite-computer/download/utilite/unofficial_unsupported/armhf/Yocto/image/yocto-cm-fx6.tar.bz2
  • Validate:
$ cd ~/tmp/yocto-release/
$ export MD5="ae8ce7e30012f2112c9f46bd13f12e47"
$ md5sum yocto-cm-fx6.tar.bz2 | awk '($0=$1)' | diff - <(echo $MD5) 1>/dev/null && echo "Valid" || echo "Invalid"
  • Unpack:
$ tar -C ~/tmp/yocto-release -xvf ~/tmp/yocto-release/yocto-cm-fx6.tar.bz2
  • Create an environment variable BSP_IMAGES_DIR for use during deployment.
$ export BSP_IMAGES_DIR=~/tmp/yocto-release

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.10.17-1.0.0_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.

CM-FX6 Support

CM-FX6 Patches

  • Go to the fsl-release-bsp root and create a tmp directory:
$ cd ${FSL_BSP_ROOT}
$ mkdir ${FSL_BSP_ROOT}/tmp
$ wget --output-document ${FSL_BSP_ROOT}/tmp/yocto-cm-fx6.patch.tar.bz2 \
http://compulab.co.il/utilite-computer/download/utilite/unofficial_unsupported/armhf/Yocto/patch/yocto.cm-fx6.patch.tar.bz2
  • Unpack the downloaded archive:
$ tar -C ${FSL_BSP_ROOT}/tmp/ -xvf  ${FSL_BSP_ROOT}/tmp/yocto-cm-fx6.patch.tar.bz2
  • 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 ${FSL_BSP_ROOT}/tmp/*.patch

Gitorius dead link fix

$ wget --output-document ${FSL_BSP_ROOT}/tmp/0001-qt-embedded-dead-link-fix.patch \
http://compulab.co.il/utilite-computer/download/utilite/unofficial_unsupported/armhf/Yocto/patch/0001-qt-embedded-dead-link-fix.patch
  • Go to the fsl-release-bsp/source/meta-fsl-demos directory and apply the patch:
$ cd ${FSL_BSP_ROOT}/sources/meta-fsl-demos
$ git am ${FSL_BSP_ROOT}/tmp/0001-qt-embedded-dead-link-fix.patch
  • Go to the fsl-release-bsp root:
$ cd ${FSL_BSP_ROOT}

Build x11 image for CM-FX6

$ export MACHINE=cm-fx6
$ source fsl-setup-release.sh –b build -e x11
$ bitbake fsl-image-x11

If bitbake displays an error indicating that fsl-image-x11 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

  • fsl-image-x11-cm-fx6.sdcard - SD card image that provides the full system to boot with U-Boot and Linux kernel
  • fsl-image-x11-cm-fx6.tar.bz2 - rootfs tar ball for deployment onto any (including NFS) storage or further customization
  • modules-cm-fx6.tgz - the Linux kernel modules matching the below kernel zImage-cm-fx6.bin
  • zImage-cm-fx6.bin - ready to run Linux kernel image binary for CM-FX6
  • zImage-imx6q-sbc-fx6.dtb - SBC-FX6 quad device tree blob
  • zImage-imx6dl-sbc-fx6.dtb - SBC-FX6 dual device tree blob
  • zImage-imx6q-sbc-fx6m.dtb - SBC-FX6m quad device tree blob
  • zImage-imx6dl-sbc-fx6m.dtb - SBC-FX6m dual device tree blob
  • cm-fx6-firmware - ready to flash CM-FX6 firmware (SPL and U-Boot)

SD card deployment

Flashing an SD card

Admolition note.png In the below section, sdX is used as an entire device special file, not a partition
Example: /dev/sde
  • Flash the SD card image:
$ cd ${BSP_IMAGES_DIR}
$ SDCARD_IMAGE=$(ls -tr *.sdcard | head -1)
$ sudo dd if=${SDCARD_IMAGE} of=/dev/sdX bs=1M && sync

Booting from an SD card

  • Plug the SD card into the SDIO3(BOOT) SD card socket of the SB-FX6
  • Hold the BOOT SELECT (SW5) button while resetting/powering on the CM-FX6 evaluation system
  • The CM-FX6 will boot from the SD card
  • Press a button as soon as "Hit any key to stop autoboot:" shows up
  • Prepare boot environment and boot the device:
CM-FX6 # setenv mmcdev 2
CM-FX6 # setenv loadaddr 0x10800000
CM-FX6 # setenv fdt_high 0xffffffff
CM-FX6 # setenv fdt_addr  0x15000000
CM-FX6 # setenv bootm_low 0x15000000
CM-FX6 # setenv zimage zImage
CM-FX6 # setenv bootargs 'console=ttymxc3,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rw rootwait ip=dhcp'
CM-FX6 # setenv load_kernel 'load mmc ${mmcdev} ${loadaddr} ${zimage}'
CM-FX6 # setenv load_dtb 'load mmc ${mmcdev} ${fdt_addr} ${fdt_file}'
CM-FX6 # setenv bootcmd 'mmc dev ${mmcdev}; run load_kernel ; run load_dtb; bootz ${loadaddr} - ${fdt_addr}'
  • Specify the correct dtb file:
    • For CM-FX6 with Quad core SoC and SB-FX6 base board:
      CM-FX6 # setenv fdt_file imx6q-sbc-fx6.dtb
    • For CM-FX6 with Quad core SoC and SB-FX6m/Utilite base board:
      CM-FX6 # setenv fdt_file imx6q-sbc-fx6m.dtb
    • For CM-FX6 with Solo core SoC and SB-FX6 base board:
      CM-FX6 # setenv fdt_file imx6dl-sbc-fx6.dtb
    • For CM-FX6 with Solo core SoC and SB-FX6m/Utilite base board:
      CM-FX6 # setenv fdt_file imx6dl-sbc-fx6m.dtb
  • Save the U-Boot environment and boot:
CM-FX6 # saveenv
CM-FX6 # boot

NAND deployment

Install on the NAND flash

Admolition note.png Requires a Yocto SD card to be prepared first.
Poky (Yocto Project Reference Distro) 1.5.1 cm-fx6 /dev/ttymxc3

cm-fx6 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 NAND flash.

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.
  • Select a correct device tree file that meets the configuration requirements:
  • CM-FX6 with Quad core SoC and SB-FX6 base board:
 root@compulab:~# export fdt_file=zImage-imx6q-sbc-fx6.dtb 
  • CM-FX6 with Quad core SoC and SB-FX6m/Utilite base board:
 root@compulab:~# export fdt_file=zImage-imx6q-sbc-fx6m.dtb 
  • CM-FX6 with Solo core SoC and SB-FX6 base board:
 root@compulab:~# export fdt_file=zImage-imx6dl-sbc-fx6.dtb 
  • CM-FX6 with Solo core SoC and SB-FX6m/Utilite base board:
 root@compulab:~# export fdt_file=zImage-imx6dl-sbc-fx6m.dtb 
  • Format the NAND flash kernel partition and write the kernel image onto it:
root@cm-fx6:~# flash_erase /dev/mtd3 0 0
root@cm-fx6:~# nandwrite -p /dev/mtd3 /mount/point/zImage-cm-fx6.bin
root@cm-fx6:~# nandwrite -p /dev/mtd3 -s 0x780000 /mount/point/${fdt_file}
  • Format the NAND flash root filesystem partition:
root@cm-fx6:~# ubiformat /dev/mtd4
  • Attach the NAND flash root filesystem partition:
root@cm-fx6:~# ubiattach -m 4 -d 0
  • Create a ubi volume and name it "rootfs":
root@cm-fx6:~# ubimkvol /dev/ubi0 -m -N rootfs
  • Mount the ubi volume:
root@cm-fx6:~# mkdir -p /media/rootfs && mount -t ubifs ubi0:rootfs /media/rootfs
  • Extract the content of fsl-image-x11-cm-fx6.tar.bz2 onto the /media/rootfs:
root@compulab:~# tar --numeric-owner -xvpjf /mount/point/fsl-image-x11-cm-fx6.tar.bz2 -C /media/rootfs && sync
  • Unmount the ubi volume:
root@compulab:~# umount /media/rootfs
  • Reboot the machine:
root@compulab:~# reboot

Booting from the NAND

  • Power on the device.
  • Press a button as soon as "Hit any key to stop autoboot:" shows up.
  • Prepare boot environment and boot the device:
CM-FX6 # setenv loadaddr 0x10800000
CM-FX6 # setenv fdt_high 0xffffffff
CM-FX6 # setenv fdt_addr 0x15000000
CM-FX6 # setenv bootm_low 0x15000000
CM-FX6 # setenv bootm_size 0x20000000
CM-FX6 # setenv bootargs 'console=ttymxc3,115200 root=ubi0:rootfs rw rootfstype=ubifs ubi.mtd=rootfs ip=dhcp'
CM-FX6 # setenv load_kernel 'nand read ${loadaddr} 0 600000'
CM-FX6 # setenv load_dtb 'nand read ${fdt_addr} 780000 10000'
CM-FX6 # setenv bootcmd 'run load_kernel ; run load_dtb; bootz ${loadaddr} - ${fdt_addr}'
CM-FX6 # saveenv
CM-FX6 # boot

See Also