jann.cc

Linux, electronics, open source software and hardware, ...

Building Freescale’s Community Yocto BSP for the OLinuXino

This tutorial is based on https://github.com/Freescale/fsl-community-bsp-platform.

Basics

BSP = Board Support Package

Yocto Project™: http://www.yoctoproject.org/about

The Yocto Project is a Linux Foundation workgroup whose goal is to produce tools and processes that will enable the creation of Linux distributions for embedded software that are independent of the underlying architecture of the embedded software itself. The project was announced by the Linux Foundation in 2010. In March 2011, the project aligned itself with OpenEmbedded, an existing framework with similar goals, with the result being The OpenEmbedded-Core Project.

—Source: https://en.wikipedia.org/wiki/Yocto_Project

OpenEmbedded: http://www.openembedded.org/wiki/Main_Page

OpenEmbedded is a software framework to create Linux distributions aimed for, but not restricted to, embedded devices. The build system is based on BitBake recipes, which behaves like Gentoo’s ebuilds. The OpenEmbedded-Core Project (OE-Core for short) resulted from the merge of the Yocto Project with OpenEmbedded.

—Source: https://en.wikipedia.org/wiki/OpenEmbedded

Step by Step

Install the repo utility

[chris@thinkpad tools]$ curl --create-dirs -o ~/bin/repo https://dl-ssl.google.com/dl/googlesource/git-repo/repo
[chris@thinkpad tools]$ chmod a+x ~/bin/repo

The ~/bin directory should have been added already to your $PATH, Ubuntu adds it in ~/.profile and Fedora in ~/.bash_profile, if this is not the case you can add the following line in your ~/.bashrc:

PATH=$PATH:$HOME/.local/bin:$HOME/bin

Download the source code

[chris@thinkpad tools]$ mkdir fsl-community-bsp
[chris@thinkpad tools]$ cd fsl-community-bsp
[chris@thinkpad fsl-community-bsp]$ repo init -u https://github.com/Freescale/fsl-community-bsp-platform -b denzil
Get https://gerrit.googlesource.com/git-repo
remote: Counting objects: 1, done
remote: Counting objects: 1705, done
remote: Finding sources: 100% (98/98)
remote: Getting sizes: 100% (4/4)
remote: Compressing objects: 100% (2/2)
remote: Total 1703 (delta 1039), reused 1702 (delta 1039)
Receiving objects: 100% (1703/1703), 892.35 KiB | 238 KiB/s, done.
Resolving deltas: 100% (1040/1040), done.
From https://gerrit.googlesource.com/git-repo
* [new branch]      maint      -> origin/maint
* [new branch]      master     -> origin/master
...
repo initialized in /home/chris/tools/fsl-community-bsp
[chris@thinkpad fsl-community-bsp]$

[chris@thinkpad fsl-community-bsp]$ repo sync
remote: Counting objects: 287, done.
remote: Counting objects: 181, done.
...
[chris@thinkpad fsl-community-bsp]$

Setup the build environment

Have a look at the fsl-community-bsp/sources/meta-fsl-arm-extra/conf/machine/ directory, there are some example configurations, to use the configuration for the OLinuXino-Micro we have to run the following command:

[chris@thinkpad fsl-community-bsp]$ MACHINE=imx233-olinuxino-micro . ./setup-environment build

Welcome to Freescale Community BSP

The Yocto Project has extensive documentation about OE including a
reference manual which can be found at:
    http://yoctoproject.org/documentation

For more information about OpenEmbedded see their website:
    http://www.openembedded.org/

You can now run 'bitbake <target>'

Common targets are:
    core-image-minimal
    meta-toolchain
    meta-toolchain-sdk
    adt-installer
    meta-ide-support

Your build environemnt has been configured with:

    MACHINE=imx233-olinuxino-micro
    SDKMACHINE=i686
    DISTRO=poky
[chris@thinkpad build]$

Build the SD card image

Now we can build the SD card image, this needs around 20 GiB of disk space and takes nearly 2 hours:

[chris@thinkpad fsl-community-bsp]$ bitbake -v core-image-minimal 2>&1 | tee output-bitbake.txt
...
NOTE: package core-image-minimal-1.0-r0: task do_rootfs: Succeeded
NOTE: Running noexec task 2312 of 2312 (ID: 5, /home/chris/tools/fsl-community-bsp/sources/poky/meta/recipes-core/images/core-image-minimal.bb, do_build)
NOTE: Tasks Summary: Attempted 2312 tasks of which 368 didn't need to be rerun and all succeeded.

Summary: There were 57 WARNING messages shown.
[chris@thinkpad build]$

The file fsl-community-bsp/build/output-bitbake.txt contains the full build log and is 65 MiB big.

Copy the file system image to the SD card and boot it

Now we can test our newly created image on the hardware, just use dd to write the new image to the SD card:

[chris@thinkpad build]$ sudo dd if=tmp/deploy/images/core-image-minimal-imx233-olinuxino-micro-20120808140358.rootfs.sdcard of=/dev/mmcblk0 bs=1M
dd: writing to `/dev/mmcblk0': No space left on device
1984001+0 records in
1984000+0 records out
1015808000 bytes (1.0 GB) copied, 472.179 s, 2.2 MB/s
[chris@thinkpad build]$

My current SD card has only 1 GB capacity so not the full image has been copied but the last part of the image should only contain zeros.

[chris@thinkpad ~]$ sudo fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 1015 MB, 1015808000 bytes
4 heads, 32 sectors/track, 15500 cylinders, total 1984000 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
Disk identifier: 0x0001a4c6

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            2048       10239        4096   53  OnTrack DM6 Aux3
/dev/mmcblk0p2           10240     6639615     3314688   83  Linux

So the partition layout has changed and it starts fine:

...
mxs-rtc mxs-rtc.0: setting system clock to 1970-01-01 00:00:10 UTC (10)
RAMDISK: Couldn't find valid RAM disk image starting at 0.
Waiting for root device /dev/mmcblk0p2...
mmc0: new SD card at address e624
mmcblk0: mmc0:e624 SU01G 968 MiB
mmcblk0: p1 p2
mmcblk0: p2 size 6629376 extends beyond EOD, truncated
EXT4-fs (mmcblk0p2): feature flags set on rev 0 fs, running e2fsck is recommended
EXT4-fs warning (device mmcblk0p2): ext4_update_dynamic_rev: updating to rev 1 because of new feature flag, running e2fsck is recommended
EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
VFS: Mounted root (ext2 filesystem) on device 179:2.
Freeing init memory: 108K
INIT: version 2.88 booting
Starting udev
udevd[388]: error opening ATTR{/sys/class/sound/controlC0/../uevent} for writing: No such file or directory

Starting Bootlog daemon: bootlogd: cannot allocate pseudo tty: No such file or directory
bootlogd.
EXT4-fs (mmcblk0p2): re-mounted. Opts: barrier=1,data=ordered
Caching udev devnodes
Populating dev cache
Configuring network interfaces... ifconfig: SIOCGIFFLAGS: No such device
done.
Wed Aug  8 16:10:00 UTC 2012
Running postinst /etc/rpm-postinsts/*...
ERROR: postinst /etc/rpm-postinsts/* failed.
INIT: Entering runlevel: 5
Starting syslogd/klogd: done
Stopping Bootlog daemon: bootlogd.

Yocto (Built by Poky 7.0.1) 1.2.1 imx233-olinuxino-micro ttyAMA0

imx233-olinuxino-micro login: root
root@imx233-olinuxino-micro:~#

Customize the kernel

Use menuconfig to create a custom kernel configuration

[chris@thinkpad fsl-community-bsp]$ bitbake -c menuconfig linux-imx
bash: bitbake: command not found
[chris@thinkpad fsl-community-bsp]$ MACHINE=imx233-olinuxino-micro . ./setup-environment build

Welcome to Freescale Community BSP

The Yocto Project has extensive documentation about OE including a
reference manual which can be found at:
    http://yoctoproject.org/documentation

For more information about OpenEmbedded see their website:
    http://www.openembedded.org/

You can now run 'bitbake <target>'

Common targets are:
    core-image-minimal
    meta-toolchain
    meta-toolchain-sdk
    adt-installer
    meta-ide-support

Your configuration files at build has not been touched.
[chris@thinkpad build]$ bitbake -c menuconfig linux-imx
Screenshot "bitbake -c menuconfig linux-imx"

Screenshot “bitbake -c menuconfig linux-imx”

Load an Alternate Configuration File

Load /home/chris/tools/fsl-community-bsp/sources/meta-fsl-arm-extra/recipes-kernel/linux/linux-imx-2.6.35.3/imx233-olinuxino/defconfig.

Networking support

[*] Networking support  --->
    [*]   Wireless (NEW)  --->
    --- Wireless
    <*>   cfg80211 - wireless configuration API
    [ ]     nl80211 testmode command (NEW)
    [ ]     enable developer warnings (NEW)
    [ ]     cfg80211 regulatory debugging (NEW)
    [*]     enable powersave by default (NEW)
    [ ]     use statically compiled regulatory rules database (NEW)
    [*]     cfg80211 wireless extensions compatibility (NEW)
    [*]   Wireless extensions sysfs files (NEW)
    <*>   Common routines for IEEE802.11 drivers
    [ ]   lib80211 debugging messages (NEW)
    <*>   Generic IEEE 802.11 Networking Stack (mac80211)
    [ ]   PID controller based rate control algorithm (NEW)
    [*]   Minstrel (NEW)
          Default rate control algorithm (Minstrel)  --->
    [ ]   Enable mac80211 mesh networking (pre-802.11s) support (NEW)
    [*]   Enable LED triggers
    [ ]   Select mac80211 debugging features (NEW)  --->

Device Drivers

Device Drivers  --->
  [*] Network device support  --->
    [*]   Wireless LAN  --->
      < >   Marvell 8xxx Libertas WLAN driver support with thin firmware (NEW)
      < >   Atmel at76c503/at76c505/at76c505a USB cards (NEW)
      < >   USB ZD1201 based Wireless device support
      < >   Wireless RNDIS USB support (NEW)
      <*>   Realtek 8187 and 8187B USB support
      < >   Simulated radio testing tool for mac80211 (NEW)
      <*>   Atheros Wireless Cards  --->
      < >   Broadcom 43xx wireless support (mac80211 stack) (NEW)
      < >   Broadcom 43xx-legacy wireless support (mac80211 stack) (NEW)
      < >   IEEE 802.11 for Host AP (Prism2/2.5/3 and WEP/TKIP/CCMP)
      < >   Intel Wireless Multicomm 3200 WiFi driver (NEW)
      < >   Marvell 8xxx Libertas WLAN driver support (NEW)
      < >   Softmac Prism54 support (NEW)
      <*>   Ralink driver support  --->
          --- Ralink driver support
            <*>   Ralink rt2500 (USB) support
            <*>   Ralink rt2501/rt73 (USB) support
            <*>   Ralink rt2800 (USB) support (EXPERIMENTAL)
            [*]     rt2800usb - Include support for rt30xx (USB) devices
            [*]     rt2800usb - Include support for rt35xx (USB) devices
            [ ]     rt2800usb - Include support for unknown (USB) devices
            [*]   Ralink debug output
      < >   TI wl12xx driver support (NEW)  --->
      < >   ZyDAS ZD1211/ZD1211B USB-wireless support (NEW)
      < >   Atheros AR600x support (non mac80211)

Save it

Save it somewhere and overide /home/chris/tools/fsl-community-bsp/sources/meta-fsl-arm-extra/recipes-kernel/linux/linux-imx-2.6.35.3/imx233-olinuxino/defconfig.

Rebuild the kernel

[chris@thinkpad build]$ bitbake -c cleansstate linux-imx
Loading cache: 100% |########################################| ETA:  00:00:00
Loaded 1530 entries from dependency cache.

OE Build Configuration:
BB_VERSION        = "1.15.2"
TARGET_ARCH       = "arm"
TARGET_OS         = "linux-gnueabi"
MACHINE           = "imx233-olinuxino-micro"
DISTRO            = "poky"
DISTRO_VERSION    = "1.2.1"
TUNE_FEATURES     = "armv5 dsp thumb arm926ejs"
TARGET_FPU        = "soft"
meta
meta-yocto        = "(nobranch):73cdebf60df225ee10f2eb215935be3b61e1b831"
meta-oe           = "(nobranch):568b98668fdf11b17839e20cb917922b7d51acce"
meta-fsl-arm      = "(nobranch):4c37cc8af65709b9f29a2bc9115bc5c4ef9b7464"
meta-fsl-arm-extra = "(nobranch):d33a3a13f10ff6d10dfa3bc186de1e26b4c4125b"
meta-fsl-demos    = "(nobranch):b42cd3ca7f1e9dbd14198f6c0e408a2335fbd90e"

NOTE: Resolving any missing task queue dependencies
NOTE: Preparing runqueue
NOTE: Executing RunQueue Tasks
NOTE: Running task 1 of 2 (ID: 0, /home/chris/tools/fsl-community-bsp/sources/meta-fsl-arm/recipes-kernel/linux/linux-imx_2.6.35.3.bb, do_clean)
NOTE: package linux-imx-2.6.35.3-r37: task do_clean: Started
NOTE: package linux-imx-2.6.35.3-r37: task do_clean: Succeeded
NOTE: Running task 2 of 2 (ID: 1, /home/chris/tools/fsl-community-bsp/sources/meta-fsl-arm/recipes-kernel/linux/linux-imx_2.6.35.3.bb, do_cleansstate)
NOTE: package linux-imx-2.6.35.3-r37: task do_cleansstate: Started
NOTE: package linux-imx-2.6.35.3-r37: task do_cleansstate: Succeeded
NOTE: Tasks Summary: Attempted 2 tasks of which 0 didn't need to be rerun and all succeeded.
[chris@thinkpad build]$ bitbake core-image-minimal
...
NOTE: package core-image-minimal-1.0-r0: task do_rootfs: Started
NOTE: package core-image-minimal-1.0-r0: task do_rootfs: Succeeded
NOTE: Running noexec task 2312 of 2312 (ID: 5, /home/chris/tools/fsl-community-bsp/sources/poky/meta/recipes-core/images/core-image-minimal.bb, do_build)
NOTE: Tasks Summary: Attempted 2312 tasks of which 2296 didn't need to be rerun and all succeeded.

Summary: There were 2 WARNING messages shown.
[chris@thinkpad build]$

Copy the new image to the SD card and boot it

[chris@thinkpad build]$ sudo dd if=tmp/deploy/images/core-image-minimal-imx233-olinuxino-micro-20120809193457.rootfs.sdcard of=/dev/mmcblk0 bs=1M
dcard of=/dev/mmcblk0 bs=1M
dd: writing `/dev/mmcblk0': No space left on device
969+0 records in
968+0 records out
1015808000 bytes (1.0 GB) copied, 264.582 s, 3.8 MB/s
[chris@thinkpad build]$
Starting Bootlog daemon: bootlogd: cannot allocate pseudo tty: No such file or directory
bootlogd.
EXT4-fs (mmcblk0p2): re-mounted. Opts: barrier=1,data=ordered
Caching udev devnodes
Populating dev cache
Configuring network interfaces... ifconfig: SIOCGIFFLAGS: No such device
done.
Thu Aug  9 19:42:00 UTC 2012
Running postinst /etc/rpm-postinsts/*...
ERROR: postinst /etc/rpm-postinsts/* failed.
INIT: Entering runlevel: 5
Starting syslogd/klogd: done
Stopping Bootlog daemon: bootlogd.

Yocto (Built by Poky 7.0.1) 1.2.1 imx233-olinuxino-micro ttyAMA0

imx233-olinuxino-micro login: root
root@imx233-olinuxino-micro:~# lsmod
  Not tainted
root@imx233-olinuxino-micro:~#
usb 1-1: new high speed USB device using fsl-ehci and address 2
usb 1-1: New USB device found, idVendor=148f, idProduct=5370
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1: Product: 802.11 n WLAN
usb 1-1: Manufacturer: Ralink
usb 1-1: SerialNumber: 1.0
root@imx233-olinuxino-micro:~# ifconfig
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Still WiFi isn’t working, the firmware is probably missing, the directory /lib/firmware is empty.

On the Yocto mailing list there are some messages how to add WiFi support to the core-image-minimal but I haven’t tested it yet, the Yocto stuff is just too time consuming.

My tip: Just use Arch Linux ARM, Arch’s package manager pacman to install extra programs and building a 3.x kernel for the OLinuXino is also faster without Yocto.