Personal tools

Yocto for VisionSOM-6ULL/6UL

From SomLabs Wiki

Jump to: navigation, search

Building SoMLabs Systems for VisionSOM-6ULL/6UL with Yocto



Yocto is a set of tools for building a custom embedded Linux distributions. Systems are usually targeted at particular applications like commercial products.

Yocto uses meta-layers to define the configuration for a system build. Within each meta-layer there are recipes, classes and configuration files that support the primary build tool, a python framework called bitbake.

The Yocto system, while very powerful, does have a substantial learning curve. You may want to look at another popular tool for building embedded systems - Buildroot.

The meta-somlabs layer generates some basic systems with packages that support C, C++, Qt5, Perl and Python development. Other languages are supported too.

Following approach can be used as a template when starting new SoMLabs projects.

System Info

By default Linux Kernel 4.9.11 is used. The u-boot version is 2017.09. These are sysvinit systems using eudev.

The Qt version is 5.9.4. There is no X11 and no desktop installed. Qt GUI applications can be run using the linuxfb platform plugin.

For the 4.9.11 following device tree binaries are built:

  1. somlabs-visionsom-6ul.dtb
  2. somlabs-visionsom-6ul-emmc.dtb
  3. somlabs-visionsom-6ull.dtb
  4. somlabs-visionsom-6ull-emmc.dtb
  5. somlabs-visionsom-6ull-nand.dtb
  6. somlabs-visionsom-6ul-nand.dtb

Note: Currently it is not possible to change dtb file name. U-boot uses hard-coded somlabs-visionsom-6ul.dtb or somlabs-visionsom-6ull.dtb (depending on CPU type). In future this option will be modified, to be able use custom dtb file.

Ubuntu Setup

Ubuntu 16.04 is a recommended operating system for building images using Yocto. While using other versions of Linux warnings can appear.

For proper operation Yocto needs following packages installed:

  • build-essential
  • chrpath
  • diffstat
  • gawk
  • libncurses5-dev
  • texinfo

Invoke console using left Ctrl+left Alt+T keys or by clicking on Terminal icon. When terminal appears type the following command:

sudo apt-get install build-essential chrpath diffstat gawk libncurses5-dev texinfo git u-boot-tools

For Ubuntu 16.04 you also need to install the python 2.7 package:

sudo apt-get install python2.7

And then create links for it in /usr/bin:

sudo ln -sf /usr/bin/python2.7 /usr/bin/python
sudo ln -sf /usr/bin/python2.7 /usr/bin/python2

For all versions of Ubuntu, you should change the default Ubuntu shell from dash to bash by running this command from a shell:

sudo dpkg-reconfigure dash

Choose No to dash when prompted.

Clone the repositories

In home directory create directory named yocto and enter it:

cd ~
mkdir yocto
cd yocto

Create build directory for SoMLabs project:

mkdir somlabs_build
git clone -b rocko git://git.yoctoproject.org/poky.git poky
cd poky
git clone -b rocko git://git.openembedded.org/meta-openembedded
git clone -b rocko https://github.com/meta-qt5/meta-qt5.git
git clone -b rocko https://github.com/Freescale/meta-freescale.git
git clone -b rocko https://github.com/SoMLabs/meta-somlabs.git

Initialize the build directory

Be sure that terminal is in the poky directory and set directories structures and path for current opened console only, type following command:

source oe-init-build-env ~/yocto/somlabs_build

Customize the configuration files

There are some sample configuration files in the meta-somlabs/conf directory. Copy them to the build/conf directory (removing the ‘-sample’ part):

cp ~/yocto/poky/meta-somlabs/conf/local.conf.sample ~/yocto/somlabs_build/conf/local.conf
cp ~/yocto/poky/meta-somlabs/conf/bblayers.conf.sample ~/yocto/somlabs_build/conf/bblayers.conf

It is necessary to modify copied files.

Edit bblayers.conf

If directories structure is different than proposed above (home/user_name/yocto...) it is necessary to modify path in bblayers.conf:

	BBLAYERS ?= " \
 		${HOME}/yocto/poky/meta \
 		${HOME}/yocto/poky/meta-poky \
		${HOME}/yocto/poky/meta-openembedded/meta-oe \
 		${HOME}/yocto/poky/meta-openembedded/meta-networking \
 		${HOME}/yocto/poky/meta-openembedded/meta-python \
  		${HOME}/yocto/poky/meta-freescale \
 		${HOME}/yocto/poky/meta-qt5 \
 		${HOME}/yocto/poky/meta-somlabs \
 	"

Provide path to poky with meta-layer accordingly.

Edit local.conf

Variables you may want to customize are the following:

  • TMPDIR
  • DL_DIR
  • SSTATE_DIR

The defaults for all of these variables work fine, adjustments are optional.

TMPDIR

This is where temporary build files and the final build binaries will end up. Expect to use at least 35GB. 50GB of free disk space is recommended. The default location is in the build directory, in this example ~/yocto/somlabs_build/tmp. If you specify an alternative location in the example conf file make sure the directory is writable by the user running the build.

DL_DIR

This is where the downloaded source files will be stored. You can share this among configurations and build files so we create a common location for this outside the project directory. Make sure the build user has write permission to the directory you use. The default location is the build directory: ~/yocto/somlabs_build/sources.

SSTATE_DIR

This is another Yocto build directory that can get pretty big, greater than 5GB. You will often put this somewhere else other than your home directory as well. The default location is in the build directory: ~/yocto/somlabs_build/sstate-cache.

ROOT PASSWORD

By default “debug-tweaks” options are used, so root will be able to login without password, but if password is necessary then you need to modify local.conf file:

#EXTRA_IMAGE_FEATURES = "debug-tweaks"
INHERIT += "extrausers"
EXTRA_USERS_PARAMS = "usermod -P password root;"

Password can be changed at any time after log in.

Building images

Before running bitbake command make sure that following action was taken:

source oe-init-build-env ~/yocto/somlabs_build

It is necessary always when new terminal console is invoked, because source only applies changes in PATH locally for current console.

SoMLabs prepared custom images:

  • console-image
  • qt5-image

If it is necessary add own custom images to the same directory.

console-image

A basic console developer image. See the recipe meta-somlabs/recipes-images/lab/console-image.bb for details, some of the installed programs are:

  • ssh/scp server and client
  • memtest
  • kernel modules
  • some WiFi and network applications

The console-image contains a line:

inherit core-image

which is poky/meta/classes/core-image.bbclass and pulls in some required base packages. This is useful to know when you create your own image recipe.

qt5-image

This image contains Qt5 runtime libraries and similar applications like the console-image.

Build

Execute:

bitbake console-image

or:

bitbake qt5-image

After some time in directory ~/yocto/tmp/deploy/images/visionsom6ull image files will appear with symbolic links. For SD Card use *.rootfs.wic.gz file.

Write image to SD Card

For above images (console and qt5) 1GB SD Card is sufficient. Connect SD Card to HOST machine, it is necessary to check device ID. It can be done in many ways, the simplest is

sudo fdisk -l

Output will be similar to this:

...
...

Disk /dev/sdc: 7,4 GiB, 7969177600 bytes, 15564800 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9de2d76a

Device     Boot Start     End Sectors  Size Id Type
/dev/sdc1       16384 1628159 1611776  787M 83 Linux

...
...

In this example SD card is /dev/sdc.

NOTE: Double-check /dev/sdx identifier, wrong identifier can damage data on your host drive!!!

Now it’s time to unpack image and write it on SD card, to do that use following commands:

For qt5 image:

gunzip -c '/home/user_name/yocto/tmp/deploy/images/visionsom6ull/qt5-image-visionsom6ull.wic.gz' | sudo dd of=/dev/sdx bs=1M iflag=fullblock oflag=direct conv=fsync

For console image:

gunzip -c '/home/user_name/yocto/tmp/deploy/images/visionsom6ull/console-image-visionsom6ull.wic.gz' | sudo dd of=/dev/sdx bs=1M iflag=fullblock oflag=direct conv=fsync

NOTE: Replace user_name in paths to your user name.

After image is written to SD card you might want to resize partition to fit SD card, to do that you can follow this guide.

Customizing the Kernel

To customize Kernel use:

bitbake -c menuconfig linux-imx

and for console-image:

bitbake console-image

or for qt5-image:

bitbake qt5-image

When new Kernel configuration needs to be stored it is necessary to copy contents of hidden file .config into defconfig in linux-imx directory

.config is sotred in ~/yocto/tmp/work/visionsom6ull-poky-linux-gnueabi/linux-imx/4.9.11-r0/build.

Remember to select see hidden files in View.

defconfig is stored in ~/yocto/poky/meta-somlabs/recipes-kernel/linux/linux-imx.4.9.11/imx.

After copying content of .config into defconfig kernel will compile from scratch with patch applying etc., so if any work on drivers or any other actions were made, they will be cleared. It is mandatory to remember to make copy of work before this activity.

NXP Partner ST Partner Renesas Partner