Creating a custom distribution image with Yocto for the RIoTboard

Document created by Bryan Hinton on Jan 29, 2015Last modified by Bryan Hinton on Sep 8, 2015
Version 9Show Document
  • View in full screen mode

This guide is an update to "Creating a custom distribution image with Yocto for the RIoTboard" and provides directions for building a GNU/Linux BSP for the RIoTboard with Yocto 1.8 on a 64-bit Fedora 21 GNU/Linux host.  The latest stable version of Yocto (1.8 - Fido) has been incorporated along with build instructions for version 4.0.7 of the GNU/Linux kernel with i.MX 6 patches, U-boot, audio recording and playback support, and a full kernel and application development environment on the target.  This guide is comprised of the following sections.

 

  1. Hardware and software prerequisites.
  2. Required Packages for a 64-bit Fedora 21 Host development system.
  3. Pull the Freescale community BSP platform source code from github.
  4. Setup the build environment using the predefined imx6dl-riotboard machine.
  5. Create a new layer for the custom Linux distribution.
  6. Customize the image in the meta-bsec layer.
  7. Create layer.conf file in the meta-bsec layer.
  8. Create the distribution configuration file in the meta-bsec layer.
  9. Add the new layer to bblayers.conf.
  10. Customize the local configuration.
  11. Execute the build.
  12. Write the GNU/Linux BSP image to an SD card.
  13. Set the physical switches on the RioTboard to boot from the uSD or SD card.
  14. Connect the target to the necessary peripherals for boot.
  15. Test audio recording, audio playback, and Internet connectivity.

 

The BSP will consist of a GNU/Linux 4.0.7 kernel, an EXT3 root filesystem, and the U-Boot bootloader.  All components will be compiled from the latest, public sources.  The GNU/Linux system will include support for audio recording and playback via the RIioTboard's MIC In and Audio Out jacks.  We will also build in support for ethernet, ipv4, bluetooth, USB host and USB gadget, and an ssh server.  The final target image will also contain native ARM compilers, a full SDK, strace, GDB, package management tools, and the GNU/Linux 4.0.7 kernel source code with i.MX 6 patches already applied.

 

In the first guide for Yocto 1.7, a custom distribution and target image was created by extending the core-image-minimal image.  In this guide, a custom distribution and target image will be created by extending the core-image-full-cmdline image.  The resulting target image will be larger in size but will include a much richer set of features for kernel and application level development and debugging on the target.

 

Finally, Yocto will be configured so that all source packages are archived in their original format with accompanying license files.

 

To start with, please read Setting up an ARM® Cortex®-A9 based SBC which outlines the necessary components that you will need to get started.  You will also need a microphone and a set of powered speakers, both with 3.5mm connectors.  I have an Audio-Technica ATR4650 microphone and a pair of Logitech S-00134 powered speakers connected to the RioTboard.  We will need these for testing audio recording and playback.

 

1. Hardware and software prerequisites

Host Operating System

Fedora release 21 for x86_64

GNU/Linux kernel 4.0.7-200.fc21.x86_64 #1 SMP

 

Host Hardware

Intel(R) Core(TM) i7-4600U CPU @ 2.10GHz

Physical Memory 12 GB

My /home partition is 414 GB and resides on a solid state hard drive.

 

The Yocto build requires a large amount of space so I recommend keeping a scratch area on your /home partition of at least 100 GB.  You can get away with less space but if you decide to make changes to the source and binaries within the Yocto tree later on down the line, then it is a good idea to have extra space.

 

2. Required Packages for a 64-bit Fedora 21 Host development system

from the Yocto Project Mega Manual Revision 1.8

 

Execute the following commands on the host.

 

 host]$ sudo yum install gawk make wget tar bzip2 gzip python unzip perl patch diffutils diffstat git cpp gcc gcc-c++ glibc-devel texinfo chrpath \
 ccache perl-Data-Dumper perl-Text-ParseWords perl-Thread-Queue socat findutils which 
 host]$ sudo yum install SDL-devel xterm perl-Thread-Queue
 host]$ sudo yum install make docbook-style-dsssl docbook-style-xsl docbook-dtds docbook-utils fop libxslt dblatex xmlto xsltproc 
 host]$ sudo yum install autoconf automake libtool glib2-devel

 

3. Pull the Freescale community BSP platform source code from github.

Execute the following commands on the host.

 

 host]$ mkdir $HOME/bin  
 host]$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo 
 host]$ chmod a+x $HOME/bin/repo  
 host]$ echo "PATH=$PATH:$HOME/bin" >> $HOME/.bashrc  
 host]$ source .bashrc  
 host]$ mkdir -p $HOME/src/fsl-community-bsp  
 host]$ cd $HOME/src/fsl-community-bsp  
 host]$ repo init -u https://github.com/Freescale/fsl-community-bsp-platform -b fido  
 host]$ repo sync

 

4.. Setup the build environment using the predefined imx6dl-riotboard machine.

Execute the following commands on the host.

 

 host]$ MACHINE=imx6dl-riotboard . ./setup-environment build  

 

5. Create a new layer for the custom Linux distribution

Execute the following commands on the host.

 

 host]$ cd $HOME/src/fsl-community-bsp/sources  
 host]$ mkdir -p meta-bsec/conf/distro  
 host]$ mkdir -p meta-bsec/recipes-bsec/images  
 host]$ cd poky/meta/recipes-extended/images  
 host]$ cp core-image-full-cmdline.bb \
        ../../../../meta-bsec/recipes-bsec/images/bsec-image.bb

 

6. Customize the image in the meta-bsec layer.

Execute the following commands on the host.

 

  host]$ cd $HOME/src/fsl-community-bsp/sources/meta-bsec/recipes-bsec/images

 

Customize bsec-image.bb as follows.  Lines with bold text indicate lines to add to the file.

 

 DESCRIPTION = "A console-only image with more full-featured Linux system \
 functionality installed."


 # customize IMAGE_FEATURES as follows
 IMAGE_FEATURES += "dev-pkgs tools-sdk tools-debug tools-profile tools-testapps \
 debug-tweaks splash ssh-server-openssh package-management"


 # packagegroup-core-tools-profile will build and install tracing and profiling tools to the target image.
 # packagegroup-core-buildessential will build and install autotools, gcc, etc. to the target image.
 # kernel-modules for install of the kernel modules.
 # kernel-devsrc for building out of tree modules.
 # IMAGE_ROOTFS_EXTRA_SPACE_append for adding extra space to the target rootfs image.


 # customize IMAGE_INSTALL as follows
 IMAGE_INSTALL = "\
     packagegroup-core-boot \
     packagegroup-core-full-cmdline \
     packagegroup-core-tools-profile \
     packagegroup-core-buildessential \
     kernel-modules \
     ${CORE_IMAGE_EXTRA_INSTALL} \
     kernel-devsrc \
     "
 inherit core-image

 # Add extra space to the rootfs image
 IMAGE_ROOTFS_EXTRA_SPACE_append += "+ 3000000"

 

7. Create layer.conf file in the meta-bsec layer.

Create sources/meta-bsec/conf/layer.conf with the below contents.

 

 BBPATH .= ":${LAYERDIR}"  
 BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \  
     ${LAYERDIR}/recipes-*/*/*.bbappend"  
 BBFILE_COLLECTIONS += "bsec"  
 BBFILE_PATTERN_bsec = "^${LAYERDIR}/"  
 BBFILE_PRIORITY_bsec = "6"  

 

8. Create the distribution configuration file in the meta-bsec layer.

 

Create sources/meta-bsec/conf/disro/bsecdist.conf with the below contents.

 

 require conf/distro/poky.conf    
 # distro name
 DISTRO = "bsecdist"    
 DISTRO_NAME = "bsecdist distribution"    
 DISTRO_VERSION = "1.0"    
 DISTRO_CODENAME = "bsc"    
 DISTRO_FEATURES_append = " alsa usbhost usbgadget keyboard bluetooth"
 SDK_VENDOR = "-bsecdistsdk"    
 SDK_VERSION := "${@'${DISTRO_VERSION}'.replace('snapshot-${DATE}','snapshot')}"    
 MAINTAINER = "bsecdist "    
 INHERIT += "buildhistory"    
 BUILDHISTORY_COMMIT = "1"

 

9. Add the new layer to bblayers.conf

 

Execute the following commands on the host.

 

 host]$ cd $HOME/src/fsl-community-bsp/build/conf

 

Customize bblayers.conf by adding the meta-bsec layer to BBLAYERS as follows.

 

 LCONF_VERSION = "6"

 BBPATH = "${TOPDIR}"
 BSPDIR := "${@os.path.abspath(os.path.dirname(d.getVar('FILE', True)) + '/../..')}"

 BBFILES ?= ""
 BBLAYERS = " \
   ${BSPDIR}/sources/poky/meta \
   ${BSPDIR}/sources/poky/meta-yocto \
   \
   ${BSPDIR}/sources/meta-openembedded/meta-oe \
   ${BSPDIR}/sources/meta-openembedded/meta-multimedia \
   \
   ${BSPDIR}/sources/meta-fsl-arm \
   ${BSPDIR}/sources/meta-fsl-arm-extra \
   ${BSPDIR}/sources/meta-fsl-demos \
   ${BSPDIR}/sources/meta-bsec \
 "

 

10. Customize the local configuration

 

Customize local.conf as follows.

 

 MACHINE ??= 'imx6dl-riotboard'
 # set distro name
 DISTRO ?= 'bsecdist'
 PACKAGE_CLASSES ?= "package_rpm package_deb"
 EXTRA_IMAGE_FEATURES = " "
 USER_CLASSES ?= "buildstats image-mklibs image-prelink"
 PATCHRESOLVE = "noop"
 BB_DISKMON_DIRS = "\
      STOPTASKS,${TMPDIR},1G,100K \
      STOPTASKS,${DL_DIR},1G,100K \
      STOPTASKS,${SSTATE_DIR},1G,100K \
      ABORT,${TMPDIR},100M,1K \
      ABORT,${DL_DIR},100M,1K \
      ABORT,${SSTATE_DIR},100M,1K" 
 PACKAGECONFIG_append_pn-qemu-native = " sdl"
 PACKAGECONFIG_append_pn-nativesdk-qemu = " sdl"
 ASSUME_PROVIDED += "libsdl-native"
 CONF_VERSION = "1"
 BB_NUMBER_THREADS = '4'
 PARALLEL_MAKE = '-j 4'
 DL_DIR ?= "${BSPDIR}/downloads/"
 ACCEPT_FSL_EULA = "1"
 # archive source code for all of the packages that will be built into the image
 INHERIT += "archiver"
 ARCHIVER_MODE[src] = "original"
 # ensure that license files accompany each binary in final image
 COPY_LIC_MANIFEST = "1"
 COPY_LIC_DIRS = "1"
 # setup source mirror
 # make sure that bitbake checks for all of the source tarballs in a local directory 
 # before going to the Internet to fetch them.
 SOURCE_MIRROR_URL ?= "file://${BSPDIR}/source-mirror/"
 INHERIT += "own-mirrors"
 # create a shareable cache of source code management backends
 BB_GENERATE_MIRROR_TARBALLS = "1"

 

11. Execute the build

 

Execute the following commands on the host.

 

 host]$ cd $HOME/src/fsl-community-bsp/build 
 host]$ time bitbake bsec-image 

 

While the image is building, please take note of the following.

 

The input specifications for the GNU/Linux kernel and U-boot segments of the BSP are in the below files. These specifications include such things as GNU/Linux kernel patch files for i.MX 6 processor features, kernel boot args, kernel load address, cortex specific tuning parameters, etc.

 

 sources/meta-fsl-arm-extra/conf/machine/imx6dl-riotboard.conf  
 sources/poky/meta-yocto/conf/distro/poky.conf  
 sources/meta-fsl-arm/recipes-kernel/linux/linux-imx.inc  
 sources/meta-fsl-arm/recipes-kernel/linux/linux-fslc_4_0.bb  
 sources/poky/meta/conf/machine/include/tune-cortexa9.inc

 

12.  Write the GNU/Linux BSP image to an SD card

 

At this point, the build should be complete, without errors.  You should see something like this on the terminal

 

 real 254m28.335s
 user 737m9.307s
 sys 133m39.529s

 

Insert an SD card into an SD card reader, connect it to the host, and execute the following commands on the host.

 

 host]$ cd $HOME/src/fsl-community-bsp/build/tmp/deploy/images/imx6dl-riotboard
 host]$ sudo umount /dev/sd<X>
 host]$ sudo dd if=bsec-image-imx6dl-riotboard.sdcard of=/dev/sd<X> bs=1M
 host]$ sudo sync

 

13. Set the physical switches on the RioTboard to boot from the uSD or SD card.

 

For booting from the SD card on the bottom of the target, set the physical switches as follows.

SD (J6, bottom) 1 0 1 0 0 1 0 1

 

For booting from the uSD card on the top of the target, set the physical switches as follows.

uSD (J7, top) 1 0 1 0 0 1 1 0

 

14. Connect the target to the necessary peripherals for boot.

 

You have two options here.

 

Option 1

 

Connect one end of an ethernet cable to the target. Connect the other end of the ethernet cable to a hub or DHCP server.

 

Connect the target to the host computer via the J18 serial UART pins on the target.  This will require a serial to USB breakout cable.  Connect TX, RX, and GND to RX, TX, and GND on the cable. The cable must have an FTDI or similar level shifter chip. Connect the USB end of the cable to the host computer.

 

Connect your speakers to the light green 3.5 mm audio out jack and your microphone to the pink 3.5 mm MIC In jack.

 

Connect a 5V / 4 AMP DC power source to the target.

 

Run minicom on the host computer. You will need to configure minicom at 115200 8N1 with no hardware flow control and no software flow control. If you are using a USB to serial cable with an FTDI chip in it, then the cable should show up in /dev as ttyUSB0 in which case, set the serial device in minicom to /dev/ttyUSB0.

 

If you choose this option, you can drop into U-boot after power on by pressing Enter on the host keyboard with minicom open and connected.

 

If you don't press enter after power on, the target will boot and you will get a login prompt.

 

You will now see a login prompt.

 

 

Option 2

 

Connect one end of an ethernet cable to the target. Connect the other end of the ethernet cable to a hub or DHCP server.

Connect a USB keyboard, USB mouse, and monitor (via an HDMI cable) to the target.

 

Connect your speakers to the light green 3.5 mm audio out jack and your microphone to the pink 3.5 mm MIC In jack.

 

Connect a 5V / 4 AMP DC power source to the target.

 

You will now see a login prompt.

 

15. Test audio recording, audio playback, and Internet connectivity

 

Type root to log in to the target. The root password is not set.

 

Execute the following commands on the target

 

 root@imx6dl-riotboard: alsamixer 

 

Press F6.

Press arrow down so that 0 imx6-riotboard-sgtl5000 is highlighted.

Press Enter.

Increase Headphone level to 79<>79.

Increase PCM level to 75<>75.

Press Tab.

Increase Mic level to 59.

Increase Capture to 80<>80.

Press Esc.

 

 root@imx6dl-riotboard: cd /usr/share/alsa/sounds
 root@imx6dl-riotboard: aplay *.wav 

 

You should hear sound played through the speakers.

 

 root@imx6dl-riotboard: cd /tmp
 root@imx6dl-riotboard: arecord -d 10 micintest.wav

 

Talk into the microphone for ten seconds.

 

 root@imx6dl-riotboard: aplay micintest.wav

 

You should hear your recording played through the speakers.

 

 root@imx6dl-riotboard: ping riotboard.org

 

You should get an ICMP reply.

 

root@imx6dl-riotboard: uname -ia 
Linux imx6dl-riotboard 4.0.7-fslc+g4eb30ae #1 SMP Sun Jul 12 17:58:33 CDT 2015 armv7l GNU/Linux
3 people found this helpful

Attachments

    Outcomes