Yocto for VisionSOM-6ULL/6UL: Difference between revisions
From SomLabs Wiki
No edit summary |
No edit summary |
||
(6 intermediate revisions by one other user not shown) | |||
Line 18: | Line 18: | ||
The [http://www.qt.io/ 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. | The [http://www.qt.io/ 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 | For the 4.9.11 following device tree binaries are built: | ||
# somlabs-visionsom-6ul.dtb | # somlabs-visionsom-6ul.dtb | ||
Line 31: | Line 31: | ||
= Ubuntu Setup = | = Ubuntu Setup = | ||
Ubuntu 16.04 is recommended operating system | Ubuntu 16.04 is a recommended operating system for building images using Yocto. While using other versions of Linux warnings can appear. | ||
Yocto | For proper operation Yocto needs following packages installed: | ||
* build-essential | * build-essential | ||
Line 42: | Line 42: | ||
* texinfo | * texinfo | ||
Invoke console using left | Invoke console using left Ctrl+left Alt+T keys or by clicking on ''Terminal'' icon. When terminal appears type the following command: | ||
<pre>sudo apt-get install build-essential chrpath diffstat gawk libncurses5-dev texinfo git u-boot-tools</pre> | <pre>sudo apt-get install build-essential chrpath diffstat gawk libncurses5-dev texinfo git u-boot-tools</pre> | ||
For 16.04 you also need to install the python 2.7 package: | For Ubuntu 16.04 you also need to install the python 2.7 package: | ||
<pre>sudo apt-get install python2.7</pre> | <pre>sudo apt-get install python2.7</pre> | ||
And then create | And then create links for it in ''/usr/bin'': | ||
<pre>sudo ln -sf /usr/bin/python2.7 /usr/bin/python | <pre>sudo ln -sf /usr/bin/python2.7 /usr/bin/python | ||
Line 68: | Line 68: | ||
cd yocto</pre> | cd yocto</pre> | ||
Create ''build'' directory for | Create ''build'' directory for SoMLabs project: | ||
<pre>mkdir somlabs_build | <pre>mkdir somlabs_build | ||
Line 80: | Line 80: | ||
= Initialize the build directory = | = Initialize the build directory = | ||
Be sure that terminal is in ''poky'' directory and set directories structures and path for current opened console only, type following command: | Be sure that terminal is in the ''poky'' directory and set directories structures and path for current opened console only, type following command: | ||
<pre>source oe-init-build-env ~/yocto/somlabs_build</pre> | <pre>source oe-init-build-env ~/yocto/somlabs_build</pre> | ||
= Customize the configuration files = | = 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): | |||
There are | |||
<pre>cp ~/yocto/poky/meta-somlabs/conf/local.conf.sample ~/yocto/somlabs_build/conf/local.conf | <pre>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</pre> | cp ~/yocto/poky/meta-somlabs/conf/bblayers.conf.sample ~/yocto/somlabs_build/conf/bblayers.conf</pre> | ||
It is necessary to modify | It is necessary to modify copied files. | ||
== Edit bblayers.conf == | == Edit bblayers.conf == | ||
If directories structure is different | If directories structure is different than proposed above (''home/user_name/yocto...'') it is necessary to modify path in ''bblayers.conf'': | ||
<pre> BBLAYERS ?= " \ | <pre> BBLAYERS ?= " \ | ||
${HOME}/yocto/poky/meta \ | ${HOME}/yocto/poky/meta \ | ||
Line 120: | Line 119: | ||
== TMPDIR == | == TMPDIR == | ||
This is where temporary build files and the final build binaries will end up. Expect to use at least 35GB. | 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''. | The default location is in the build directory, in this example ''~/yocto/somlabs_build/tmp''. | ||
If you specify an alternative location | 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 == | == 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. | 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 default location is the build directory: ''~/yocto/somlabs_build/sources''. | ||
== SSTATE_DIR == | == SSTATE_DIR == | ||
Line 136: | Line 135: | ||
== ROOT PASSWORD == | == ROOT PASSWORD == | ||
By default “debug-tweaks” options are used, so | 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: | ||
<pre>#EXTRA_IMAGE_FEATURES = "debug-tweaks" | <pre>#EXTRA_IMAGE_FEATURES = "debug-tweaks" | ||
Line 144: | Line 143: | ||
Password can be changed at any time after log in. | Password can be changed at any time after log in. | ||
= | = Building images = | ||
Before running bitbake command make sure that following action was taken: | Before running bitbake command make sure that following action was taken: | ||
Line 150: | Line 149: | ||
<pre>source oe-init-build-env ~/yocto/somlabs_build</pre> | <pre>source oe-init-build-env ~/yocto/somlabs_build</pre> | ||
It is necessary always when new terminal console is invoked, because source only applies changes in PATH | 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: | SoMLabs prepared custom images: | ||
Line 160: | Line 159: | ||
== console-image == | == console-image == | ||
A basic console developer image. See the recipe meta-somlabs/recipes-images/lab/console-image.bb for | 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 | * ssh/scp server and client | ||
* memtest | * memtest | ||
* kernel modules | * kernel modules | ||
* some | * some WiFi and network applications | ||
The console-image contains a line: | The console-image contains a line: | ||
Line 170: | Line 169: | ||
<pre>inherit core-image</pre> | <pre>inherit core-image</pre> | ||
which is ''poky/meta/classes/core-image.bbclass'' and pulls in some required base packages. This is useful to know | 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 == | == qt5-image == | ||
This image contains Qt5 runtime libraries and similar | This image contains Qt5 runtime libraries and similar applications like the console-image. | ||
== Build == | |||
= Build = | |||
Execute: | Execute: | ||
<pre>bitbake console-image</pre> | <pre>bitbake console-image</pre> | ||
After some time in directory ''~/yocto | or: | ||
<pre>bitbake qt5-image</pre> | |||
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 = | = 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 | 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 | ||
<pre>sudo fdisk -l</pre> | <pre>sudo fdisk -l</pre> | ||
Output will be similar to this: | |||
<pre> | <pre> | ||
Disk /dev/ | ... | ||
... | |||
Disk /dev/sdc: 7,4 GiB, 7969177600 bytes, 15564800 sectors | |||
Units: sectors of 1 * 512 = 512 bytes | Units: sectors of 1 * 512 = 512 bytes | ||
Sector size (logical/physical): 512 bytes / 512 bytes | Sector size (logical/physical): 512 bytes / 512 bytes | ||
I/O size (minimum/optimal): 512 bytes / 512 bytes | I/O size (minimum/optimal): 512 bytes / 512 bytes | ||
Disklabel type: dos | Disklabel type: dos | ||
Disk identifier: | Disk identifier: 0x9de2d76a | ||
Device Boot Start End Sectors Size Id Type | |||
/dev/sdc1 16384 1628159 1611776 787M 83 Linux | |||
... | |||
... | |||
</pre> | </pre> | ||
In this example SD card is /dev/ | In this example SD card is /dev/sdc. | ||
''NOTE:'' | '''NOTE:''' Double-check /dev/sdx identifier, '''wrong identifier can damage data on your host drive!!!''' | ||
Now it’s time to unpack image and write | Now it’s time to unpack image and write it on SD card, to do that use following commands: | ||
For qt5 image: | For qt5 image: | ||
<pre>gunzip -c '/home/user_name/yocto/tmp/deploy/images/ | <pre>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</pre> | ||
For console image: | For console image: | ||
<pre>gunzip -c '/home/user_name/yocto/tmp/deploy/images/ | <pre>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</pre> | ||
'''NOTE:''' | '''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 [[How_to_resize_Debian_9.2_root_partition_to_fit_SD_card|this guide]]. | |||
= Customizing the Kernel = | = Customizing the Kernel = | ||
To customize Kernel use: | To customize Kernel use: | ||
<pre>bitbake -c menuconfig linux-imx</pre> | |||
<pre>bitbake -c menuconfig linux-imx | |||
bitbake | and for console-image: | ||
<pre>bitbake console-image</pre> | |||
or: | or for qt5-image: | ||
<pre>bitbake | <pre>bitbake qt5-image</pre> | ||
When new Kernel configuration needs to be stored it is necessary to copy contents of hidden file ''.config'' into ''defconfig'' in ''linux-imx'' directory | When new Kernel configuration needs to be stored it is necessary to copy contents of hidden file ''.config'' into ''defconfig'' in ''linux-imx'' directory | ||
Line 239: | Line 247: | ||
''defconfig'' is stored in ''~/yocto/poky/meta-somlabs/recipes-kernel/linux/linux-imx.4.9.11/imx''. | ''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 | 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. |
Latest revision as of 18:23, 26 May 2018
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:
- somlabs-visionsom-6ul.dtb
- somlabs-visionsom-6ul-emmc.dtb
- somlabs-visionsom-6ull.dtb
- somlabs-visionsom-6ull-emmc.dtb
- somlabs-visionsom-6ull-nand.dtb
- 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.