Introduction

This journal was started in order to document my exploration of Yocto and OpenEmbedded using a popular low-cost platform i.e. the BeagleBone Black. The end objective is to become well versed with the Yocto project and use it as a build system for embedded systems

1. About Yocto

Yocto Project is a collaborative attempt to provide a set of templates, tools and methods to create a custom Linux-based system for embedded products. It was started in 2010 by many hardware manufacturers, open-source operating systems vendors and hardware companies to unify the process of creating an embedded Linux system.

2. About BeagleBoard

BeagleBoard.org Foundation is a non-profit corporation which promotes open source software and open hardware. It was started by enthusiasts from TI with the aim of providing a powerful platform to design embedded solutions. The BeagleBone Black is their fourth board till date which offers a lot of possibilities in a small credit card size form factor.

3. About Free Electrons

Free Electrons is an engineering company consisting of embedded linux experts who support companies using Embedded Linux. They additionally conduct training workshops for companies on different topics such as Linux kernel and device driver development, Android system development, Yocto Project and OpenEmbedded development, etc. This journal uses the Free Electrons training material which they publish online to explore Embedded Linux with the BeagleBone Black board from TI.

Training and Workbench Setup

This section covers the setup software and hardware used in this journal. The sources of the training material and references are mentioned as well as details about how to procure the hardware.

4. Hardware

4.1. BeagleBone Black

The BeagleBone Black is the newest member in the BeagleBoard family. The board is designed to be a low sized small form factor board. The size of the board is comparable to the size of a credit card and it offers expansion headers to add headers called as capes similar to the Raspberry Pi.

BeagleBoneBlackREV A5A
Beagle Bone Black Revision A5A Board

The table below highlights the key onboard components of the board along with the connectors available on the board. The diagram of the table below is taken from the BeagleBone Black System Reference Manual.

BeagleBoneBlackFeatures
Beagle Bone Black Feature Table

5. Software

5.1. Ubuntu

To work with an embedded system you need a work station on which you can perform the various tasks that are required in the development life cycle. These tasks include:

  1. Editing your build scripts and source code

  2. Cross-compiling your source code for the embedded target

  3. Transferring or accessing the cross-compiled application and libraries to or from the embedded target

  4. Collecting debug information from the target

  5. Communicating with the target remotely using its interfaces like serial, USB, network, etc..

In this document we use the popular Debian based Linux operating system, Ubuntu as our work station for all the tasks listed above. Ubuntu can be easily downloaded and installed on any PC or laptop.

Do not use a virtual machine runnning Ubuntu as your workstation

This document uses Ubuntu 14.04 running on a HP laptop. Use of a similar environment through a virtual machine runnning on VMWare or Oracle VirtualBox is not recommended.

5.2. GIT

The source code management tool used by the Linux kernel community is GIT. To use GIT we need to install the packages required on our work station using the Advanced Packaging Tool(APT) using a command line terminal.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~$ sudo apt-get install git gitk git-email

Once the packages are successfully installed we will need to configure GIT with some basic information about our name and email address

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~$ git config --global user.name Conrad Gomes
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~$ git config --global user.email conrad.s.j.gomes@gmail.com

Further infomation about GIT can be obtained at:
http://git-scm.com/.

5.3. Free Electrons Yocto and OpenEmbedded Data

Since we are going through the training material provided by Free Electrons we’ll need to download their slides and lab data from their website link:
http://free-electrons.com/training/yocto/

As Free Electrons continues to improve on their training material, this journal will be based on the version available at the time of its writing:

6. Installing Prerequisite Packages Required For Yocto

We need to install a couple of packages on our workstation before proceeding with the Yocto labs. Depending on the state of your workstation APT will install the appropriate packages and dependencies. The packages required are bc, build-essential, chrpath, diffstat, gawk, git, texinfo, wget and vim.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/techeuphoria$ sudo apt-get install bc build-essential chrpath diffstat gawk git texinfo wget vim
[sudo] password for conrad:
no talloc stackframe at ../source3/param/loadparm.c:4864, leaking memory
Reading package lists... Done
Building dependency tree
Reading state information... Done
bc is already the newest version.
build-essential is already the newest version.
gawk is already the newest version.
vim is already the newest version.
git is already the newest version.
wget is already the newest version.
The following packages were automatically installed and are no longer required:
  linux-headers-3.13.0-36 linux-headers-3.13.0-36-generic
  linux-image-3.13.0-36-generic linux-image-extra-3.13.0-36-generic
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  libencode-locale-perl libfile-listing-perl libfont-afm-perl
  libhtml-form-perl libhtml-format-perl libhtml-parser-perl
  libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl
  libhttp-daemon-perl libhttp-date-perl libhttp-message-perl
  libhttp-negotiate-perl libintl-perl libio-html-perl libio-socket-inet6-perl
  libio-socket-ssl-perl liblwp-mediatypes-perl liblwp-protocol-https-perl
  libmailtools-perl libnet-http-perl libnet-smtp-ssl-perl libnet-ssleay-perl
  libsocket6-perl libtext-unidecode-perl liburi-perl libwww-perl
  libwww-robotrules-perl libxml-libxml-perl libxml-namespacesupport-perl
  libxml-parser-perl libxml-sax-base-perl libxml-sax-expat-perl
  libxml-sax-perl
Suggested packages:
  libdata-dump-perl libintl-xs-perl libcrypt-ssleay-perl libauthen-ntlm-perl
  texlive-base texlive-latex-base texlive-generic-recommended
  texinfo-doc-nonfree
The following NEW packages will be installed:
  chrpath diffstat libencode-locale-perl libfile-listing-perl libfont-afm-perl
  libhtml-form-perl libhtml-format-perl libhtml-parser-perl
  libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl
  libhttp-daemon-perl libhttp-date-perl libhttp-message-perl
  libhttp-negotiate-perl libintl-perl libio-html-perl libio-socket-inet6-perl
  libio-socket-ssl-perl liblwp-mediatypes-perl liblwp-protocol-https-perl
  libmailtools-perl libnet-http-perl libnet-smtp-ssl-perl libnet-ssleay-perl
  libsocket6-perl libtext-unidecode-perl liburi-perl libwww-perl
  libwww-robotrules-perl libxml-libxml-perl libxml-namespacesupport-perl
  libxml-parser-perl libxml-sax-base-perl libxml-sax-expat-perl
  libxml-sax-perl texinfo
0 upgraded, 37 newly installed, 0 to remove and 24 not upgraded.
Need to get 2,723 kB/3,996 kB of archives.
After this operation, 15.1 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://lk.archive.ubuntu.com/ubuntu/ trusty/main chrpath i386 0.14-3ubuntu1 [12.2 kB]
Get:2 http://lk.archive.ubuntu.com/ubuntu/ trusty/main libfont-afm-perl all 1.20-1 [14.3 kB]
.
.
.
Replacing config file /etc/perl/XML/SAX/ParserDetails.ini with new version
Setting up texinfo (5.2.0.dfsg.1-2) ...
Setting up libwww-perl (6.05-2) ...
Setting up liblwp-protocol-https-perl (6.04-2ubuntu0.1) ...
Setting up libxml-parser-perl (2.41-1build3) ...
Setting up libxml-sax-expat-perl (0.40-2) ...
update-perl-sax-parsers: Registering Perl SAX parser XML::SAX::Expat with priority 50...
update-perl-sax-parsers: Updating overall Perl SAX parser modules info file...
Replacing config file /etc/perl/XML/SAX/ParserDetails.ini with new version

7. Installing Lab Data

Download the lab data provided by Free Electrons from http://free-electrons.com/doc/training/yocto/yocto-labs.tar.xz

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Training/yocto$ wget http://free-electrons.com/doc/training/yocto/yocto-labs.tar.xz                (1)
--2015-05-06 18:27:08--  http://free-electrons.com/doc/training/yocto/yocto-labs.tar.xz
Resolving free-electrons.com (free-electrons.com)... 87.98.146.151
Connecting to free-electrons.com (free-electrons.com)|87.98.146.151|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 28480 (28K) [application/x-tar]
Saving to: ‘yocto-labs.tar.xz’

100%[==============================================================================================================================================>] 28,480      --.-K/s   in 0.02s

2015-05-06 18:27:08 (1.18 MB/s) - ‘yocto-labs.tar.xz’ saved [28480/28480]

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Training/yocto$
1 Using wget to download the Yocto lab data

Unpackage the lab data after successfully downloading it.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Training/yocto$ tar Jvxf yocto-labs.tar.xz        (1)
yocto-labs/
yocto-labs/nunchuck/
yocto-labs/nunchuck/ninvaders/
yocto-labs/nunchuck/ninvaders/joystick-support.patch
yocto-labs/nunchuck/linux/
yocto-labs/nunchuck/linux/0001-Add-nunchuk-driver.patch
yocto-labs/nunchuck/linux/0002-Add-i2c1-and-nunchuk-nodes-in-dts.patch
yocto-labs/nunchuck/linux/defconfig
yocto-labs/script/
yocto-labs/script/format_sdcard.sh
yocto-labs/0001-beaglebone-use-the-am335x_boneblack-u-boot-configura.patch
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Training/yocto$ cd yocto-labs/
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Training/yocto/yocto-labs$ ls                (2)
0001-beaglebone-use-the-am335x_boneblack-u-boot-configura.patch  nunchuck  script
1 Tar command used to unpack the package
2 Listing the contents of the package

First Yocto Project Build

We’ll dive into the build mechanism of the Yocto project

8. Lab1: First Yocto Build

This is a hands on session based on the Free Electrons labs with the following objectives
  1. Download the sources

  2. Set up an OpenEmbedded environment

  3. Configure the project and choose a target

  4. Build your first Poky image

8.1. Clone The Stable Release

We need to download the latest stable releases of the Yocto project in order to start building our first images.

Diverging from yocto-labs.pdf

The downloaded PDF yocto-labs.pdf suggests downloading the "dora" release of yocto. However problems are seen while building with bitbake with that release. One of the problems that were seen was that the initial sanity check was failing and our version of Ubuntu 14.04 is not supported by the dora release download package poky-dora-10.0.1.tar.bz2. We diverge here from the labs and clone the git branch of daisy of the Yocto project.

We clone the sources as shown below. This repository has support for BeagleBone Black and so we don’t clone the meta-ti project as mentioned in the yocto-labs.pdf from Free Electrons.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git$ git clone git://git.yoctoproject.org/poky.git -b daisy

8.2. Set Up The Build Environment

8.2.1. Configure Default Shell As bash

If you’re on Ubuntu make sure the default shell is bash and not dash. This can be done by running:

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Training/yocto/yocto-labs$ sudo dpkg-reconfigure dash

Select <No> and hit "Enter".

yoctooe dash reconfigure
Reconfigure dash

8.2.2. Source oe-init-build-env

Before building all the needed environment variables have to be exported and a build directory must be specified. To do this we can use oe-init-build-env, which is present in the Poky package. It will create the default build directory as build if nothing is specified

Before sourcing the script our environment variables

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ printenv > pre_environment.txt

We now source the oe-init-build-env script as follows. It creates a build directory by default as we haven’t specified any build directory.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ source oe-init-build-env        (1)
You had no conf/local.conf file. This configuration file has therefore been
created for you with some default values. You may wish to edit it to use a
different MACHINE (target hardware) or enable parallel build options to take
advantage of multiple cores for example. See the file for more information as
common configuration options are commented.

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 had no conf/bblayers.conf file. The configuration file has been created for
you with some default values. To add additional metadata layers into your
configuration please add entries to this file.

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/



### Shell environment set up for builds. ###

You can now run 'bitbake <target>'

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

You can also run generated qemu images with a command like 'runqemu qemux86'
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky/build$
1 Sourcing the oe-init-build-env script without specifying a build directory

We now capture the environment variables to check what has changed.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky/build$ printenv > post_environment.txt

With diff we see the difference in the environment variables after sourcing the script.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky/build$ diff ../pre_environment.txt post_environment.txt
11c11
< OLDPWD=/home/conrad/Git
---
> OLDPWD=/home/conrad/Git/poky
24c24
< PATH=/usr/local/gcc-arm-none-eabi-4_7-2013q3/bin/:/usr/local/gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/conrad/.rvm/bin:/home/conrad/.rvm/bin
---
> PATH=/home/conrad/Git/poky/scripts:/home/conrad/Git/poky/bitbake/bin:/usr/local/gcc-arm-none-eabi-4_7-2013q3/bin/:/usr/local/gcc-linaro-arm-linux-gnueabihf-4.8-2014.04_linux/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/conrad/.rvm/bin:/home/conrad/.rvm/bin        (1)
28c28
< PWD=/home/conrad/Git/poky
---
> PWD=/home/conrad/Git/poky/build
38a39
> BUILDDIR=/home/conrad/Git/poky/build        (2)
60a62
> BB_ENV_EXTRAWHITE=MACHINE DISTRO TCMODE TCLIBC HTTP_PROXY http_proxy HTTPS_PROXY https_proxy FTP_PROXY ftp_proxy FTPS_PROXY ftps_proxy ALL_PROXY all_proxy NO_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY SDKMACHINE BB_NUMBER_THREADS BB_NO_NETWORK PARALLEL_MAKE GIT_PROXY_COMMAND SOCKS5_PASSWD SOCKS5_USER SCREENDIR STAMPS_DIR        (3)
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky/build$
1 Two paths added to the PATH variable: …​poky/scripts and …​poky/bitbake/bin
2 New variable BUILDDIR=/home/conrad/Git/poky/build added
3 New variable BB_ENV_EXTRAWHITE added. This describes the list of environment variables to be imported into BitBake data store.

8.3. Set Up The build/conf/ Directory

After sourcing the oe-init-build-env script we are placed in the build directory. There are three files present in the conf folder which can be used to tune the build configuration

bblayers.conf

List the available layers e.g. meta-ti

local.conf

Configuration variables for the current user

templateconf.cfg

Path of the templates from which the bblayers.conf and local.conf were created

In the older versions of Yocto We would have to update the BB_NUMBER_THREADS and PARALLEL_MAKE to define how many tasks should be run in parallel. In the newer version this is updated directly. This will be specific to the build system and can be inferred as follows:

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Training/yocto/yocto-labs$ grep "processor" -ri /proc/cpuinfo
processor        : 0
processor        : 1

As indicated above we can set those parallelization variables to 2. However the OpenEmbedded utilities takes care of it for us. The main change we need to do is set the MACHINE to beaglebone.

yoctooe conf local
conf/local.conf variable modifications

In the older versions as BeagleBone Black was not supported we would have to clone the meta-ti layer in the poky directory from git://git.yoctoproject.org/meta-ti.git. However it is not required as the newer versions of Yocto supports the BeagleBone Black board.

yoctooe conf bblayers
conf/bblayers.conf modifications

8.4. Build The Image

Once the build configuration has been set we can start the compilation using bitbake [options] [recipe/target…​]

Common targets that were listed when sourcing the script: core-image-minimal::A small image to boot a device and have access to core command line commands and services. core-image-sato:: Image with Sato support. Sato is a GNOME mobile-based user interface. meta-toolchain:: Includes development headers and libraries to develop directly on the target. adt-installer:: Build the application development toolkit installer. meta-ide-support:: Generates the cross-tool chain

On our first attempt at building the core-image-minimal target we get an error.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky/build$ bitbake core-image-minimal        (1)
Loading cache: 100% |####################################################################################################################################################| ETA:  00:00:00
Loaded 1319 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies
NOTE: multiple providers are available for u-boot (u-boot, u-boot-glsdk, u-boot-ti-staging)
NOTE: consider defining a PREFERRED_PROVIDER entry to match u-boot

Build Configuration:
BB_VERSION        = "1.22.0"
BUILD_SYS         = "i686-linux"
NATIVELSBSTRING   = "Ubuntu-14.04"
TARGET_SYS        = "arm-poky-linux-gnueabi"
MACHINE           = "beaglebone"
DISTRO            = "poky"
DISTRO_VERSION    = "1.6.2"
TUNE_FEATURES     = "armv7a vfp neon callconvention-hard cortexa8"
TARGET_FPU        = "vfp-neon"
meta
meta-yocto
meta-yocto-bsp    = "daisy:91c507ce1cf983a600c2d38c4284e605a80297d6"
meta-ti           = "daisy:b09b86c399eebce475d41c3a5df56477f6024a2b"

NOTE: Preparing runqueue
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
WARNING: Failed to fetch URL http://kernel.org/pub/linux/kernel/v3.0/linux-3.14.tar.xz, attempting MIRRORS if available
WARNING: Failed to fetch URL ftp://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.bz2, attempting MIRRORS if available
WARNING: Failed to fetch URL http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz, attempting MIRRORS if available
WARNING: Failed to fetch URL ftp://ftp.gnu.org/gnu/readline/readline-6.3.tar.gz;name=archive, attempting MIRRORS if available
WARNING: Failed to fetch URL http://zlib.net/pigz/pigz-2.3.1.tar.gz, attempting MIRRORS if available
WARNING: Failed to fetch URL ftp://ftp.debian.org/debian/pool/main/b/base-passwd/base-passwd_3.5.29.tar.gz, attempting MIRRORS if available
WARNING: Failed to fetch URL http://pkg-shadow.alioth.debian.org/releases/shadow-4.1.4.3.tar.bz2, attempting MIRRORS if available
WARNING: Failed to fetch URL ftp://xmlsoft.org/libxml2/libxml2-2.9.1.tar.gz;name=libtar, attempting MIRRORS if available
WARNING: Failed to fetch URL http://www.cpan.org/src/5.0/perl-5.14.3.tar.gz, attempting MIRRORS if available
WARNING: Failed to fetch URL ftp://ftp.debian.org/debian/pool/main/n/netbase/netbase_5.2.tar.gz, attempting MIRRORS if available
WARNING: Failed to fetch URL ftp://ftp.debian.org/debian/pool/main/d/dpkg/dpkg_1.17.4.tar.xz, attempting MIRRORS if available
WARNING: Failed to fetch URL http://ftp.de.debian.org/debian/pool/main/m/mklibs/mklibs_0.1.38.tar.gz, attempting MIRRORS if available
WARNING: Failed to fetch URL http://createrepo.baseurl.org/download/createrepo-0.4.11.tar.gz, attempting MIRRORS if available
NOTE: validating kernel config, see log.do_kernel_configcheck for details
NOTE: Tasks Summary: Attempted 1797 tasks of which 165 didn't need to be rerun and all succeeded.

Summary: There were 13 WARNING messages shown.
1 We build the target core-image-minimal

The build process takes a while depending on your bandwidth and processor speeds.

8.5. Setting Up The SD Card

We will use an SD card to store the bootloader, kernel and root filesystem. Before copying the built files we need to partition and format the SD card using a script available as a part of the yocto-labs data package downloaded from Free Electrons.

The script assumes that our workstation has a micro-SD card slot and will be detected as a /dev/mmcblk0* type of device. In our case we use a micro-SD card to SD card adapter and our device is registered as a /dev/sdb type of device

Take the micro-SD card and insert it into a micro-SD adapter/reader like the one shown in the image below:

sdcard microsd adaptor sd
Micro SD card adapter

This memory card reader/adapter should be inserted into the SD card slot available. If your system has a micro-SD card slot then please use that directly. On checking the kernel logs with dmesg we should be able to identify the card detected in the system. If a micro-SD card slot is available then the system should register it as a /dev/mmcblk0 whereas in this case with a memory card reader we see it as /dev/sdb. The following shows the kernel logs:

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ dmesg
.
.
.
[127595.272118] usb 1-2: new high-speed USB device number 6 using ehci-pci
[127595.405640] usb 1-2: New USB device found, idVendor=058f, idProduct=6366
[127595.405650] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[127595.405658] usb 1-2: Product: Mass Storage Device
[127595.405665] usb 1-2: Manufacturer: Generic
[127595.405671] usb 1-2: SerialNumber: 058F63666433
[127595.406226] usb-storage 1-2:1.0: USB Mass Storage device detected
[127595.407830] scsi9 : usb-storage 1-2:1.0
[127596.532963] scsi 9:0:0:0: Direct-Access     Multiple Card  Reader     1.00 PQ: 0 ANSI: 0
[127596.533754] sd 9:0:0:0: Attached scsi generic sg1 type 0
[127598.192274] sd 9:0:0:0: [sdb] 7744512 512-byte logical blocks: (3.96 GB/3.69 GiB) (1)
[127598.193263] sd 9:0:0:0: [sdb] Write Protect is off
[127598.193269] sd 9:0:0:0: [sdb] Mode Sense: 03 00 00 00
[127598.194256] sd 9:0:0:0: [sdb] No Caching mode page found
[127598.194259] sd 9:0:0:0: [sdb] Assuming drive cache: write through
[127598.199023] sd 9:0:0:0: [sdb] No Caching mode page found
[127598.199028] sd 9:0:0:0: [sdb] Assuming drive cache: write through
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ ls -l /dev/sdb         (2)
brw-rw---- 1 root disk 8, 16 Mar 22 21:09 /dev/sdb
1 We see the device attached as sdb
2 The device node has been created successfully as /dev/sdb

8.5.1. Partition The SD Card

We will have to first partition the micro-SD card using the sfdisk utility which is part of the util-linux APT package. This tool helps us to list the partitions of a device, check the sizes of the partitions, check the partitions on a device and re-partition a device. We must be extra careful when we use such a tool as it could also cause damage to our workstation system if we select the wrong device file unintentionally.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ sudo sfdisk --in-order --Linux --unit M /dev/sdb << EOF                (1)
> 1,48,0xE,*
> ,,,-
> EOF
Checking that no-one is using this disk right now ...
BLKRRPART: Device or resource busy                                                (2)

This disk is currently in use - repartitioning is probably a bad idea.
Umount all file systems, and swapoff all swap partitions on this disk.
Use the --no-reread flag to suppress this check.
Use the --force flag to overrule all checks.
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ mount                (3)
/dev/sda1 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/cgroup type tmpfs (rw)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)
none on /sys/fs/pstore type pstore (rw)
rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
systemd on /sys/fs/cgroup/systemd type cgroup (rw,noexec,nosuid,nodev,none,name=systemd)
nfsd on /proc/fs/nfsd type nfsd (rw)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,user=conrad)
/dev/sdb1 on /media/conrad/boot type vfat (rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,flush,uhelper=udisks2) (4)
1 The command to re-partition the /devsdb device with sfdisk. The options --in-order indicates that the partitions are in order in the input. --Linux tells sfdisk to ignore all warnings irrelevant for Linux.
2 The device is apparently busy.
3 We do a mount to check if it is mounted
4 We see that a partition is mounted in our Workstation at /media/conrad/boot

If the micro-SD card is already partitioned and formated it may be auto mounted by our work station. We will have to un-mount all the partitions before we can proceed.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ sudo umount /media/conrad/boot         (1)
[sudo] password for conrad:
no talloc stackframe at ../source3/param/loadparm.c:4864, leaking memory
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ mount                (2)
/dev/sda1 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/cgroup type tmpfs (rw)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)
none on /sys/fs/pstore type pstore (rw)
rpc_pipefs on /run/rpc_pipefs type rpc_pipefs (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
systemd on /sys/fs/cgroup/systemd type cgroup (rw,noexec,nosuid,nodev,none,name=systemd)
nfsd on /proc/fs/nfsd type nfsd (rw)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,user=conrad)
1 We have to unmount the /dev/sdb1 from the mount point i.e. /media/conrad/boot
2 We check to see if anything else is mounted again

Again we attempt to repartition the micro-SD card

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ sudo sfdisk --in-order --Linux --unit M /dev/sdb << EOF
1,48,0xE,*
,,,-
EOF                                                                                        (1)
Checking that no-one is using this disk right now ...                                        (2)
OK

Disk /dev/sdb: 1023 cylinders, 122 heads, 62 sectors/track
Old situation:                                                                                (3)
Units = mebibytes of 1048576 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start   End    MiB    #blocks   Id  System
/dev/sdb1   *     1     48     48      49152    e  W95 FAT16 (LBA)
/dev/sdb2        49   3780   3732    3821568   83  Linux
/dev/sdb3         0      -      0          0    0  Empty
/dev/sdb4         0      -      0          0    0  Empty
New situation:                                                                                (4)
Units = mebibytes of 1048576 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start   End    MiB    #blocks   Id  System
/dev/sdb1   *     1     48     48      49152    e  W95 FAT16 (LBA)
/dev/sdb2        49   3780   3732    3821568   83  Linux
/dev/sdb3         0      -      0          0    0  Empty
/dev/sdb4         0      -      0          0    0  Empty
Successfully wrote the new partition table

Re-reading the partition table ...
BLKRRPART: Device or resource busy
The command to re-read the partition table failed.
Run partprobe(8), kpartx(8) or reboot your system now,
before using mkfs
If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
1 The sfdisk utility is invoked supplying the information about the partitions
2 sfdisk checking to see that no one is using the disk
3 The old partition map is displayed first. This will vary based on the history of the micro-SD card
4 The new partition map is displayed. The first partition is a W95 FAT16 one which is 48 MB. This is the first line of input to sfdisk. The remaining has been converted to a Linux partition.

8.5.2. Format The Partitions

We will have to format the first partition of the disk using the mkfs.vfat partition.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ sudo mkfs.vfat -F 16 /dev/sdb1 -n boot        (1)
[sudo] password for conrad:
no talloc stackframe at ../source3/param/loadparm.c:4864, leaking memory
mkfs.fat 3.0.26 (2014-03-07)
mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ echo $?                        (2)
0
1 mkfs.vfat is run on the partition /dev/sdb1. The label of the partition is set to boot with the -n option and the -F option specifies the type of file allocation tables used (12, 16 or 32 bit).
2 Checks the return value of the command

We will have to format the second partition of the disk using the mkfs.vfat partition.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ sudo mkfs.ext4 /dev/sdb2 -L rootfs        (1)
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=rootfs
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
239040 inodes, 955392 blocks
47769 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=981467136
30 block groups
32768 blocks per group, 32768 fragments per group
7968 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
1 mkfs.ext4 is run on the partition /dev/sdb2. The label of the partition is set to rootfs with the -L option

On disconnecting the SD card adapter and reconnecting it we see the two partitions mounted under devices. The steps to prepare the SD card are the same as what would be executed by yocto-labs/script/format_sdcard.sh.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ cat ~/Training/yocto/yocto-labs/script/format_sdcard.sh
#!/bin/bash

if [ $(id -u) -ne 0 ]; then
  echo "Please run this script as root"
  exit
fi

if [ $# -ne 1 ]; then
  echo "Usage: $0 mmc_device"
  exit
fi

exec 1>&-
exec 2>&-

dd if=/dev/zero of=$1 bs=1M count=16
sfdisk --in-order --L --unit M $1 <<EOF
1,48,0xE,*
,,,-
EOF

mkfs.vfat -F 16 ${1}p1 -n boot
mkfs.ext4 ${1}p2 -L rootfs

exit 0

8.5.3. Copy The Built Images

We copy the two U-Boot stages, Linux image and compiled device tree in the boot partition.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ ls -l build/tmp/deploy/images/beaglebone/        (1)
total 43064
-rw-r--r-- 1 conrad conrad  2949120 May 11 23:51 core-image-minimal-beaglebone-20150511125839.rootfs.jffs2
-rw-r--r-- 1 conrad conrad      972 May 11 23:51 core-image-minimal-beaglebone-20150511125839.rootfs.manifest
-rw-r--r-- 1 conrad conrad  2264889 May 11 23:51 core-image-minimal-beaglebone-20150511125839.rootfs.tar.bz2
lrwxrwxrwx 1 conrad conrad       57 May 11 23:51 core-image-minimal-beaglebone.jffs2 -> core-image-minimal-beaglebone-20150511125839.rootfs.jffs2
lrwxrwxrwx 1 conrad conrad       60 May 11 23:51 core-image-minimal-beaglebone.manifest -> core-image-minimal-beaglebone-20150511125839.rootfs.manifest
lrwxrwxrwx 1 conrad conrad       59 May 11 23:51 core-image-minimal-beaglebone.tar.bz2 -> core-image-minimal-beaglebone-20150511125839.rootfs.tar.bz2
lrwxrwxrwx 1 conrad conrad       48 May 12 15:15 MLO -> MLO-beaglebone-v2013.07+gitAUTOINC+62c175fbb8-r0
lrwxrwxrwx 1 conrad conrad       48 May 12 15:15 MLO-beaglebone -> MLO-beaglebone-v2013.07+gitAUTOINC+62c175fbb8-r0
-rwxr-xr-x 2 conrad conrad   102348 May 12 15:15 MLO-beaglebone-v2013.07+gitAUTOINC+62c175fbb8-r0
-rw-rw-r-- 2 conrad conrad 33333836 May 12 02:04 modules--3.14.4+git0+183622e809_0143c6ebb4-r0-beaglebone-20150511125839.tgz
lrwxrwxrwx 1 conrad conrad       75 May 12 02:04 modules-beaglebone.tgz -> modules--3.14.4+git0+183622e809_0143c6ebb4-r0-beaglebone-20150511125839.tgz
-rw-rw-r-- 2 conrad conrad      294 May 12 02:04 README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt
lrwxrwxrwx 1 conrad conrad       55 May 12 15:15 u-boot-beaglebone.img -> u-boot-beaglebone-v2013.07+gitAUTOINC+62c175fbb8-r0.img
-rwxr-xr-x 2 conrad conrad   356456 May 12 15:15 u-boot-beaglebone-v2013.07+gitAUTOINC+62c175fbb8-r0.img
lrwxrwxrwx 1 conrad conrad       55 May 12 15:15 u-boot.img -> u-boot-beaglebone-v2013.07+gitAUTOINC+62c175fbb8-r0.img
lrwxrwxrwx 1 conrad conrad       74 May 12 02:04 uImage -> uImage--3.14.4+git0+183622e809_0143c6ebb4-r0-beaglebone-20150511125839.bin
-rw-r--r-- 2 conrad conrad    28596 May 12 02:04 uImage--3.14.4+git0+183622e809_0143c6ebb4-r0-am335x-bone-20150511125839.dtb
-rw-r--r-- 2 conrad conrad    29192 May 12 02:04 uImage--3.14.4+git0+183622e809_0143c6ebb4-r0-am335x-boneblack-20150511125839.dtb
-rw-r--r-- 2 conrad conrad  4985352 May 12 02:04 uImage--3.14.4+git0+183622e809_0143c6ebb4-r0-beaglebone-20150511125839.bin
lrwxrwxrwx 1 conrad conrad       80 May 12 02:04 uImage-am335x-boneblack.dtb -> uImage--3.14.4+git0+183622e809_0143c6ebb4-r0-am335x-boneblack-20150511125839.dtb
lrwxrwxrwx 1 conrad conrad       75 May 12 02:04 uImage-am335x-bone.dtb -> uImage--3.14.4+git0+183622e809_0143c6ebb4-r0-am335x-bone-20150511125839.dtb
lrwxrwxrwx 1 conrad conrad       74 May 12 02:04 uImage-beaglebone.bin -> uImage--3.14.4+git0+183622e809_0143c6ebb4-r0-beaglebone-20150511125839.bin
.
.
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ cp build/tmp/deploy/images/beaglebone/MLO-beaglebone /media/conrad/boot/MLO        (2)
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ cp build/tmp/deploy/images/beaglebone/u-boot-beaglebone.img /media/conrad/boot/u-boot.img        (3)
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ sync
.
.
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ sudo tar xpf build/tmp/deploy/images/beaglebone/core-image-minimal-beaglebone.tar.bz2 -C /media/conrad/rootfs        (4)
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ sync
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ ls -l /media/conrad/rootfs/
total 60
drwxr-xr-x  2 root root 4096 May 11 23:51 bin
drwxr-xr-x  2 root root 4096 May 11 20:51 boot
drwxr-xr-x  2 root root 4096 May 11 20:51 dev
drwxr-xr-x 17 root root 4096 May 11 23:51 etc
drwxr-sr-x  3 root root 4096 May 11 23:51 home
drwxr-xr-x  3 root root 4096 May 11 23:51 lib
drwxr-xr-x  2 root root 4096 May 11 20:51 media
drwxr-xr-x  2 root root 4096 May 11 20:51 mnt
drwxr-xr-x  2 root root 4096 May 11 20:51 proc
drwxr-xr-x  2 root root 4096 May 11 20:51 run
drwxr-xr-x  2 root root 4096 May 11 23:51 sbin
drwxr-xr-x  2 root root 4096 May 11 20:51 sys
drwxrwxrwt  2 root root 4096 May 11 20:51 tmp
drwxr-xr-x  9 root root 4096 May 11 23:30 usr
drwxr-xr-x  7 root root 4096 May 11 20:50 var
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ sudo tar xpf build/tmp/deploy/images/beaglebone/modules-beaglebone.tgz -C /media/conrad/rootfs        (5)
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ sync
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ sudo cp build/tmp/deploy/images/beaglebone/uImage-beaglebone.bin /media/conrad/rootfs/boot/uImage
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ sudo cp build/tmp/deploy/images/beaglebone/uImage-am335x-boneblack.dtb /media/conrad/rootfs/boot/am335x-boneblack.dtb        (6)
1 Listing the images built
2 Copying the first stage bootloader MLO to the boot partition
3 Copying the second stage bootloader u-boot.img to the boot partition
4 Untar the root filesystem in the rootfs partition
5 Untar the kernel modules in the rootfs partition as we have built a core-image-minimal target
6 Copy the compiled device tree binary

8.6. Setting Up Serial Communication With The Board

The debug serial header connector is a 1x6 header. Serial capability is provided by UART0 of the processor. It would be good to read the section on the debug serial header given in the Technical Reference Manual.

The only two signals available are TX and RX on the connector and the levels on these signals is 3.3V. A FTDI USB to serial cable is recommended as this serves to provide a serial port to PCs/Laptops making use of the available USB port. The FTDI chip translates the USB data to serial and vice versa. There are several provided in the elinux.org website link at:
http://elinux.org/Beagleboard:BeagleBone_Black_Serial.

8.6.1. Rhydolabz FTDI USB To Serial Breakout Board

In this journal a breakout board was purchased from Rhydolabz. There are several boards available but one without a 1x6 connector was chosen. All the signals of the FTDI can be exposed by soldering a bergstrip pin-out for advanced users but for our use case GND, RX and TX are provided with an easy to access 4 pin connector. The board is also capable of outputing both 5V and 3.3V. This is controlled by soldering the 3.3V leads at the back of the breakout board. The board can be picked up from:
http://www.rhydolabz.com/index.php?main_page=product_info&cPath=80&products_id=1090

rhydolabz ftdi usb to serial interface module
Rhydolabz breakout board with mini USB cable

8.6.2. Connecting The Breakout Board

The FTDI breakout board comes with a Grove 4 pin Female jumper to 4 pin conversion cable. Each of the cables can be connected to female connectors to be slotted into the serial debug header pins. We need only the GND, RXD and TXD signals from the board. Before connecting the board signals make sure the 3.3V leads are shorted at the bottom of the board. The board from Rhydolabz comes with the 5V lead shorted and must be converted for the Beagle Bone Black.

  1. Connect the GND cable of the FTDI breakout board to pin 1 of the serial header.

  2. Next connect RXD of the FTDI breakout board to pin 5 which is the TX of the serial debug header.

  3. Finally connect TXD of the board to pin 4 which is the RX of the serial debug header.

It is always good to understand the specifications of the connectors whenever interfacing electronic circuits. In this case we know that the BeagleBone Black takes 3.3V from the System Reference Manual. If a different cable is to be used check and see if its connector is compatible with the header. The figure below shows the setup where GND is the orange cable on the right, next RXD is the brown cable followed by the TXD which is the red cable.

beagleboneblacktux rhydolabz ftdi serial debug connection
Rhydolabz breakout board serial connection to BeagleBone Black 1x6 header

Once the connections are in place between the BeagleBone Black serial debug header and the FTDI cable or breakout board then connect the USB cable to the breakout board. The picture shows that the board lights up.

beagleboneblacktux rhydolabz ftdi mini usb connection
Rhydolabz breakout board mini USB connection

The linux kernel running on the workstation should register the new USB device connected. We can probe the kernel logs to see if there is any activity using dmesg.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/fe-kernel-training/linux-kernel-labs$ dmesg
.
.
.
[60269.932101] usb 6-1: new full-speed USB device number 2 using uhci_hcd
[60270.125794] usb 6-1: New USB device found, idVendor=0403, idProduct=6001
[60270.125804] usb 6-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[60270.125812] usb 6-1: Product: FT232R USB UART
[60270.125819] usb 6-1: Manufacturer: FTDI
[60270.125825] usb 6-1: SerialNumber: A602I2CN
[60270.212583] usbcore: registered new interface driver usbserial
[60270.212599] usbcore: registered new interface driver usbserial_generic
[60270.212611] usbserial: USB Serial support registered for generic
[60270.230288] usbcore: registered new interface driver ftdi_sio
[60270.230305] usbserial: USB Serial support registered for FTDI USB Serial Device
[60270.230972] ftdi_sio 6-1:1.0: FTDI USB Serial Device converter detected
[60270.231033] usb 6-1: Detected FT232RL
[60270.231036] usb 6-1: Number of endpoints 2
[60270.231039] usb 6-1: Endpoint 1 MaxPacketSize 64
[60270.231041] usb 6-1: Endpoint 2 MaxPacketSize 64
[60270.231043] usb 6-1: Setting MaxPacketSize 64
[60270.233850] usb 6-1: FTDI USB Serial Device converter now attached to ttyUSB0        (1)
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/fe-kernel-training/linux-kernel-labs$ ls -l /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 0 Mar 25 22:28 /dev/ttyUSB0        (2)
1 The device has been recognized as a tty device and is named ttyUSB0
2 A device node /dev/ttyUSB0 is created in the root filesystem

8.6.3. Accessing The Serial Port With Picocom

We can now access the serial port with a terminal application like picocom. This can be installed as follows:

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/fe-kernel-training/linux-kernel-labs$ sudo apt-get install picocom        (1)
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/fe-kernel-training/linux-kernel-labs$ sudo adduser $USER dialout        (2)
1 Installing picocom with apt-get
2 Adding $USER to the dialout group to use picocom without sudo. $USER is set to the username i.e conrad in the above case.

We can now start picocom and connect it to the /dev/ttyUSB0 device which was created earlier. The baud rate is specified with the -b option. The default serial port settings for the board are:

  1. Baud 115,200

  2. Bits 8

  3. Parity N

  4. Stop Bits 1

  5. Handshake None

After starting the picocom application we should be able to see the serial port is opened and the settings should be the default settings. If they are not then try to get the settings by providing options to picocom. Once we get the desired settings we can apply power to the connected BeagleBone Black. At this point we will boot up the board for the first time and should see the serial logs of the bootloader U-Boot. The boot process can be interrupted by hitting any key on the keyboard and allowing us to configure the U-Boot environment.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/techeuphoria/quests/beagleboneblacktux/free_electrons_linux_kernel$ picocom -b 115200 /dev/ttyUSB0 (1)
picocom v1.7

port is        : /dev/ttyUSB0
flowcontrol    : none
baudrate is    : 115200
parity is      : none
databits are   : 8
escape is      : C-a
local echo is  : no
noinit is      : no
noreset is     : no
nolock is      : no
send_cmd is    : sz -vv
receive_cmd is : rz -vv
imap is        :
omap is        :
emap is        : crcrlf,delbs,

Terminal ready        (2)
1 We run the picocom application setting the baud rate to 115200 and choosing the device as /dev/ttyUSB0
2 picocom shows that the terminal is ready after printing the serial port settings

8.7. Booting The Board

Insert the micro-SD card in the dedicated slot on the BeagleBone Black. Press the S2 push button (located just above the previous slot), plug in the power supply (External/USB) and release the push button. You should see boot messages on the console.

Terminal ready
"
"
U-Boot SPL 2013.07 (May 12 2015 - 15:15:09)
musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, HB-ISO Rx, HB-ISO Tx, SoftConn)
musb-hdrc: MHDRC RTL version 2.0
musb-hdrc: setup fifo_mode 4
musb-hdrc: 28/31 max ep, 16384/16384 memory
USB Peripheral mode controller at 47401000 using PIO, IRQ 0
musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, HB-ISO Rx, HB-ISO Tx, SoftConn)
musb-hdrc: MHDRC RTL version 2.0
musb-hdrc: setup fifo_mode 4
musb-hdrc: 28/31 max ep, 16384/16384 memory
USB Host mode controller at 47401800 using PIO, IRQ 0
OMAP SD/MMC: 0
reading args
spl: error reading image args, err - -1
reading u-boot.img
reading u-boot.img


U-Boot 2013.07 (May 12 2015 - 15:15:09)                (1)

I2C:   ready
DRAM:  512 MiB
WARNING: Caches not enabled
NAND:  0 MiB
MMC:   OMAP SD/MMC: 0, OMAP SD/MMC: 1
*** Warning - readenv() failed, using default environment

musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, HB-ISO Rx, HB-ISO Tx, SoftConn)
musb-hdrc: MHDRC RTL version 2.0
musb-hdrc: setup fifo_mode 4
musb-hdrc: 28/31 max ep, 16384/16384 memory
USB Peripheral mode controller at 47401000 using PIO, IRQ 0
musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, HB-ISO Rx, HB-ISO Tx, SoftConn)
musb-hdrc: MHDRC RTL version 2.0
musb-hdrc: setup fifo_mode 4
musb-hdrc: 28/31 max ep, 16384/16384 memory
USB Host mode controller at 47401800 using PIO, IRQ 0
Net:   <ethaddr> not set. Validating first E-fuse MAC
cpsw, usb_ether
Hit any key to stop autoboot:  0
mmc0 is current device
SD/MMC found on device 0
reading uEnv.txt
** Unable to read file uEnv.txt **
4985352 bytes read in 865 ms (5.5 MiB/s)
29192 bytes read in 35 ms (814.5 KiB/s)
Booting from mmc ...                                        (2)
## Booting kernel from Legacy Image at 82000000 ...
   Image Name:   Linux-3.14.0-yocto-standard
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    4985288 Bytes = 4.8 MiB
   Load Address: 80008000
   Entry Point:  80008000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 88000000
   Booting using the fdt blob at 0x88000000
   Loading Kernel Image ... OK
   Loading Device Tree to 8fff5000, end 8ffff207 ... OK

Starting kernel ...

Booting Linux on physical CPU 0x0
Initializing cgroup subsys cpuset
Initializing cgroup subsys cpu
Initializing cgroup subsys cpuacct
Linux version 3.14.0-yocto-standard (conrad@conrad-HP-Pavilion-dm3-Notebook-PC) (gcc version 4.8.2 (GCC) ) #1 PREEMPT Tue May 12 01:59:26 IST 2015
CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c53c7d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine model: TI AM335x BeagleBone
cma: CMA: reserved 16 MiB at 9e800000
Memory policy: Data cache writeback
CPU: All CPU(s) started in SVC mode.
AM335X ES2.0 (sgx neon )
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 129792
Kernel command line: console=ttyO0,115200n8 root=/dev/mmcblk0p2 ro rootfstype=ext4 rootwait        (3)
PID hash table entries: 2048 (order: 1, 8192 bytes)
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
allocated 1048576 bytes of page_cgroup
please try 'cgroup_disable=memory' option if you don't want memory cgroups
Memory: 489444K/523264K available (7491K kernel code, 520K rwdata, 2456K rodata, 488K init, 757K bss, 33820K reserved, 0K highmem)
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    vmalloc : 0xe0800000 - 0xff000000   ( 488 MB)
    lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
    pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
    modules : 0xbf000000 - 0xbfe00000   (  14 MB)
      .text : 0xc0008000 - 0xc09bf044   (9949 kB)
      .init : 0xc09c0000 - 0xc0a3a034   ( 489 kB)
      .data : 0xc0a3c000 - 0xc0abe0d4   ( 521 kB)
       .bss : 0xc0abe0d4 - 0xc0b7b678   ( 758 kB)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Preemptible hierarchical RCU implementation.
NR_IRQS:16 nr_irqs:16 16
IRQ: Found an INTC at 0xfa200000 (revision 5.0) with 128 interrupts
Total of 128 interrupts on 1 active controller
OMAP clockevent source: timer2 at 24000000 Hz
sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 178956969942ns
OMAP clocksource: timer1 at 24000000 Hz
Console: colour dummy device 80x30
Calibrating delay loop... 548.86 BogoMIPS (lpj=2744320)
pid_max: default: 32768 minimum: 301
Security Framework initialized
.
.
.
omap_rtc 44e3e000.rtc: setting system clock to 2000-01-01 00:00:01 UTC (946684801)
EXT4-fs (mmcblk0p2): INFO: recovery required on readonly filesystem
EXT4-fs (mmcblk0p2): write access will be enabled during recovery
mmc1: BKOPS_EN bit is not set
mmc1: new high speed MMC card at address 0001
mmcblk1: mmc1:0001 MMC02G 1.78 GiB
mmcblk1boot0: mmc1:0001 MMC02G partition 1 1.00 MiB
mmcblk1boot1: mmc1:0001 MMC02G partition 2 1.00 MiB
 mmcblk1: p1 p2
 mmcblk1boot1: unknown partition table
 mmcblk1boot0: unknown partition table
EXT4-fs (mmcblk0p2): recovery complete
EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
VFS: Mounted root (ext4 filesystem) readonly on device 179:2.        (4)
devtmpfs: mounted
Freeing unused kernel memory: 488K (c09c0000 - c0a3a000)
INIT: version 2.88 booting
Starting udev
udevd[80]: starting version 182
EXT4-fs (mmcblk0p2): re-mounted. Opts: data=ordered
Starting Bootlog daemon: bootlogd.
random: nonblocking pool is initialized
Mon May 11 18:21:00 UTC 2015
INIT: Entering runlevel: 5
Configuring network interfaces... net eth0: initializing cpsw version 1.12 (0)
net eth0: phy found : id is : 0x7c0f1
libphy: PHY 4a101000.mdio:01 not found
net eth0: phy 4a101000.mdio:01 not found on slave 1
IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
udhcpc (v1.22.1) started
Sending discover...
Sending discover...
Sending discover...
No lease, failing
Starting syslogd/klogd: done
Stopping Bootlog daemon: bootlogd.

Poky (Yocto Project Reference Distro) 1.6.2 beaglebone /dev/ttyO0

beaglebone login: root        (5)
root@beaglebone:~#
root@beaglebone:~# pwd
/home/root
1 Our compiled U-Boot with it’s timestamp is loaded
2 The kernel and compiled device tree binary is booted from mmc
3 The kernel arguments show that root=/dev/mmcblk0p2 the second partition is the root filesystem
4 The second partition is successfully mounted as the root filesystem
5 We have access to the root login.

Advanced Yocto configuration

We’ll configure the build, customize the images and use a NFS root file system.

9. Lab2: Advanced Yocto Configuration

This is a hands on session based on the Free Electrons labs with the following objectives
  1. Customize the package selection

  2. Configure the build system

9.1. Using rootfs Over NFS

In the previous lab we flashed the compiled images and rootfilesystem onto the microSD card. The flashing process does take a while even with the fastest SD cards and also may cause the connectors to wear out thereby damaging the board. Another disadvantage is that with each write operation the life of the SD card also reduces. We need to switch to a network type of development environment to solve these problems. This enables us to build our binaries on the workstation and test it on the board without having to flash the board which saves time as well as prolongs the life of the eMMC device or micro-SD card. We will enable a NFS type of root filesystem which will allow us to test cross-compiled binaries on board.

9.1.1. Setting Up The NFS Server

We will now need to setup our workstation as a NFS server. This will require installation of the nfs-kernel-server package.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/fe-kernel-training$ sudo apt-get install nfs-kernel-server

Once installed we need to edit the /etc/exports file to configure the server to allow a NFS client to connect to it and mount a directory. In this case we want to configure the NFS server in such a way so as to allow our BeagleBone Black platform to mount the root filesystem which is there in our workstation lab data directory.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/fe-kernel-training$ cat /etc/exports                 (1)
# /etc/exports: the access control list for filesystems which may be exported
#                to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#
/home/conrad/fe-kernel-training/linux-kernel-labs/modules/nfsroot 192.168.0.100(rw,no_root_squash,no_subtree_check)
/home/conrad/Training/yocto/nfs 192.168.0.100(rw,no_root_squash,no_subtree_check)                (2)
1 After editing the file we cat its contents
2 The directory of nfsroot is exported to IP 192.168.0.100 which is our BBB IP

Finally before we boot make sure to restart the NFS server as shown below. If there are any errors then the server will refuse to start and error logs will appear. The /etc/exports file must be revisited and the syntax of the line must be inspected and corrected. Fix the errors and ensure the NFS server restarts before proceeding.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/fe-kernel-training$ sudo service nfs-kernel-server restart
 * Stopping NFS kernel daemon                                 [ OK ]
 * Unexporting directories for NFS kernel daemon...     [ OK ]
 * Exporting directories for NFS kernel daemon...       [ OK ]
 * Starting NFS kernel daemon                           [ OK ]
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/fe-kernel-training$

Now we will connect an ethernet cable between our workstation and the BeagleBone Black ethernet connector. If the workstation does not have any more connections then we will have to use a USB ethernet adapter. In this case we have an unused connection so we will connect the cable as shown.

beagleboneblacktux ethernet connection
BeagleBone Black connected to ethernet cable

We next have to configure the network interface on the workstation side. Click on the network manager tasklet on the desktop and select Edit Connections.

beagleboneblacktux ethernet screenshot edit connections
Screen shot of Edit Connections selected in the network manager tasklet

Click on the Add button on the left and then Create.. an ethernet connection.

beagleboneblacktux ethernet screenshot add new connection
Screen shot of adding a new ethernet conneciton

Edit the new ethernet connection by changing its name to BBB. Change the IPV4 settings by selecting the method as manual. And finally add the static address as 192.168.0.1 and netmask as 255.255.255.0. There’s no need to add a gateway but if the cursor is in the textbox enter 0.0.0.0. Save the settings and the interface is set up on the workstation.

beagleboneblacktux ethernet screenshot edit new connection
Screen shot of editing IPV4 settings of the new ethernet connection

9.2. Modifying The U-Boot Args With uEnv.txt

Our next step is to modify the U-Boot environment in order to setup the U-Boot image to mount the root filesystem from a NFS file server. We basically make use of the bootcmd variable in the default U-Boot environment.

bootcmd=run findfdt; mmc dev ${mmcdev}; if mmc rescan; then echo SD/MMC found on device ${mmcdev};if run loadbootenv; then echo Loaded environment from ${bootenv};run importbootenv;fi;if test -n $uenvcmd; then echo Running uenvcmd ...;run uenvcmd;fi;if run loaduimage; then run loadfdt;run mmcboot;fi;else run nandboot;fi;        (1)
1 The bootcmd in the default U-Boot environment

The bootcmd will search for a uEnv.txt file in the same partition as the u-boot.img. If found it is loaded into memory and then imported into the environment ready to be read or executed. After this, the script checks to see if the variable uenvcmd is defined. If it is defined, the script in the variable is executed. The script can be reordered as follows to give it decode it. Certain variables such as loadbootenv are defined in the U-Boot environment variables.

run findfdt;
mmc dev ${mmcdev};
if mmc rescan;
        then echo SD/MMC found on device ${mmcdev};
        if run loadbootenv;
                then echo Loaded environment from ${bootenv};
                run importbootenv;
        fi;
        if test -n $uenvcmd;
                then echo Running uenvcmd ...;
                run uenvcmd;
        fi;
        if run loaduimage;
                then run loadfdt;
                run mmcboot;
        fi;
else
        run nandboot;
fi;

We create a uEnv.txt file so as to override the required variables and execute our own bootcmd using uenvcmd.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ cat /media/conrad/boot/uEnv.txt
bootpart=0:2
bootdir=/boot
bootfile=uImage
loadaddr=0x82000000
fdtaddr=0x88000000
loadfdt=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}
loaduimage=load mmc ${bootpart} ${loadaddr} ${bootdir}/${bootfile}
ipaddr=192.168.0.100
bootargs=console=ttyO0,115200n8 root=/dev/nfs nfsroot=192.168.0.1:/home/conrad/Training/yocto/nfs rw ip=192.168.0.100        (1)
uenvcmdx=run loaduimage;run loadfdt;bootm ${loadaddr} - ${fdtaddr}        (2)
uenvcmd=run uenvcmdx                                                        (3)
                                                                        (4)
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$
1 The bootargs is set to instruct the kernel to boot the root filesystem from a NFS server
2 We create a variable to store our instructions for uenvcmd
3 The uenvcmd is defined to run uenvcmdx
4 We need a space at the end of the file after all the variables are set.

Further information about using uEnv.txt can be obtained from http://www.linuxjournal.com/content/handy-u-boot-trick.

9.2.1. Explanation Of The Bootargs

root=/dev/nfs

We set the root filesystem device as /dev/nfs to indicate that NFS is to be used. rw::The root filesystem should be mounted with read and write capabilities

ip=192.168.0.100

The IP of the BeagleBone Black board should be 192.168.0.100 before mounting the NFS root filesystem

console=ttyO0

The console to be used is serial port 0. The character before the 0 is 'O' as in "OMAP".

nfsroot=192.168.0.1:/home/conrad/Training/yocto/nfs

The NFS root filesystem server IP and path of the directory. This is similar to the workstation settings. The IP is the workstation ethernet static IP and the path is the same as that in the /etc/exports.

9.2.2. Prepare The NFS Export Directory

We have untar the core-image-minimal-beaglebone.tar.bz2 package to the NFS export directory /home/conrad/Training/yocto/nfs in order to have a successful mount of the root filesystem.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ sudo tar xpvjf build/tmp/deploy/images/beaglebone/core-image-minimal-beaglebone.tar.bz2 -C ~/Training/yocto/nfs        (1)
./
./home/
./home/root/
./var/
./var/lock
./var/run
./var/spool/
./var/volatile/
./var/volatile/log/
./var/volatile/tmp/
./var/log
./var/lib/
./var/lib/wdj/
./var/lib/wdj/l10n/
./var/lib/urandom/
./var/lib/misc/
./var/tmp
./var/local/
./var/backups/
.
.
./bin/df
./bin/pidof.sysvinit
./bin/chmod
./bin/pwd
./bin/true
./bin/ash
./bin/busybox.suid
./bin/cpio
./bin/cat
./bin/chattr
./bin/dd
./bin/chgrp
./bin/login
./bin/echo
./bin/kill
./bin/mknod
1 Untar the package to our NFS export directory

9.2.3. Boot The System

Make sure the BeagleBone Black is connected to the USB to serial connector correctly as was described in Lab1. Also make sure your etherned cable is connected between the board and your workstation.

After saving the uEnv.txt file in the boot partition of the microSD card we unmount the device and plug it into the BeagleBone Black SD card slot. Press the S2 push button (located just above the previous slot), plug in the power supply (External/USB) and release the push button. You should see boot messages on the console.

U-Boot SPL 2013.07 (May 12 2015 - 15:15:09)
musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, HB-ISO Rx, HB-ISO Tx, SoftConn)
musb-hdrc: MHDRC RTL version 2.0
musb-hdrc: setup fifo_mode 4
musb-hdrc: 28/31 max ep, 16384/16384 memory
USB Peripheral mode controller at 47401000 using PIO, IRQ 0
musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, HB-ISO Rx, HB-ISO Tx, SoftConn)
musb-hdrc: MHDRC RTL version 2.0
musb-hdrc: setup fifo_mode 4
musb-hdrc: 28/31 max ep, 16384/16384 memory
USB Host mode controller at 47401800 using PIO, IRQ 0
OMAP SD/MMC: 0
reading args
spl: error reading image args, err - -1
reading u-boot.img
reading u-boot.img


U-Boot 2013.07 (May 12 2015 - 15:15:09)

I2C:   ready
DRAM:  512 MiB
WARNING: Caches not enabled
NAND:  0 MiB
MMC:   OMAP SD/MMC: 0, OMAP SD/MMC: 1
*** Warning - readenv() failed, using default environment

musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, HB-ISO Rx, HB-ISO Tx, SoftConn)
musb-hdrc: MHDRC RTL version 2.0
musb-hdrc: setup fifo_mode 4
musb-hdrc: 28/31 max ep, 16384/16384 memory
USB Peripheral mode controller at 47401000 using PIO, IRQ 0
musb-hdrc: ConfigData=0xde (UTMI-8, dyn FIFOs, HB-ISO Rx, HB-ISO Tx, SoftConn)
musb-hdrc: MHDRC RTL version 2.0
musb-hdrc: setup fifo_mode 4
musb-hdrc: 28/31 max ep, 16384/16384 memory
USB Host mode controller at 47401800 using PIO, IRQ 0
Net:   <ethaddr> not set. Validating first E-fuse MAC
cpsw, usb_ether
Hit any key to stop autoboot:  0
mmc0 is current device
SD/MMC found on device 0
reading uEnv.txt                                                                (1)
439 bytes read in 3 ms (142.6 KiB/s)
Loaded environment from uEnv.txt
Importing environment from mmc ...
Running uenvcmd ...                                                                (2)
4985352 bytes read in 864 ms (5.5 MiB/s)
29192 bytes read in 34 ms (837.9 KiB/s)
## Booting kernel from Legacy Image at 82000000 ...
   Image Name:   Linux-3.14.0-yocto-standard
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    4985288 Bytes = 4.8 MiB
   Load Address: 80008000
   Entry Point:  80008000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 88000000
   Booting using the fdt blob at 0x88000000
   Loading Kernel Image ... OK
   Loading Device Tree to 8fff5000, end 8ffff207 ... OK

Starting kernel ...

Booting Linux on physical CPU 0x0
Initializing cgroup subsys cpuset
Initializing cgroup subsys cpu
Initializing cgroup subsys cpuacct
Linux version 3.14.0-yocto-standard (conrad@conrad-HP-Pavilion-dm3-Notebook-PC) (gcc version 4.8.2 (GCC) ) #1 PREEMPT Tue May 12 01:59:26 IST 2015
CPU: ARMv7 Processor [413fc082] revision 2 (ARMv7), cr=10c53c7d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine model: TI AM335x BeagleBone
cma: CMA: reserved 16 MiB at 9e800000
Memory policy: Data cache writeback
CPU: All CPU(s) started in SVC mode.
AM335X ES2.0 (sgx neon )
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 129792
Kernel command line: console=ttyO0,115200n8 root=/dev/nfs nfsroot=192.168.0.1:/home/conrad/Training/yocto/nfs rw ip=192.168.0.100        (3)
PID hash table entries: 2048 (order: 1, 8192 bytes)
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
allocated 1048576 bytes of page_cgroup
please try 'cgroup_disable=memory' option if you don't want memory cgroups
Memory: 489444K/523264K available (7491K kernel code, 520K rwdata, 2456K rodata, 488K init, 757K bss, 33820K reserved, 0K highmem)
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    vmalloc : 0xe0800000 - 0xff000000   ( 488 MB)
    lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
    pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
    modules : 0xbf000000 - 0xbfe00000   (  14 MB)
      .text : 0xc0008000 - 0xc09bf044   (9949 kB)
      .init : 0xc09c0000 - 0xc0a3a034   ( 489 kB)
      .data : 0xc0a3c000 - 0xc0abe0d4   ( 521 kB)
       .bss : 0xc0abe0d4 - 0xc0b7b678   ( 758 kB)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Preemptible hierarchical RCU implementation.
.
.
.
IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
 mmcblk1boot1: unknown partition table
 mmcblk1boot0: unknown partition table
libphy: 4a101000.mdio:00 - Link is Up - 100/Full
IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
IP-Config: Guessing netmask 255.255.255.0
IP-Config: Complete:
     device=eth0, hwaddr=90:59:af:49:c8:ef, ipaddr=192.168.0.100, mask=255.255.255.0, gw=255.255.255.255
     host=192.168.0.100, domain=, nis-domain=(none)
     bootserver=255.255.255.255, rootserver=192.168.0.1, rootpath=
VFS: Mounted root (nfs filesystem) on device 0:12.                        (4)
devtmpfs: mounted
Freeing unused kernel memory: 488K (c09c0000 - c0a3a000)
INIT: version 2.88 booting
Starting udev
udevd[76]: starting version 182
random: nonblocking pool is initialized
Starting Bootlog daemon: bootlogd.
Populating dev cache
Mon May 11 18:21:00 UTC 2015
INIT: Entering runlevel: 5
Configuring network interfaces... ifup skipped for nfsroot interface eth0
run-parts: /etc/network/if-pre-up.d/nfsroot exited with code 1
Starting syslogd/klogd: done
Stopping Bootlog daemon: bootlogd.

Poky (Yocto Project Reference Distro) 1.6.2 beaglebone /dev/ttyO0

beaglebone login: root
root@beaglebone:~# cat /proc/cmdline
console=ttyO0,115200n8 root=/dev/nfs nfsroot=192.168.0.1:/home/conrad/Training/yocto/nfs rw ip=192.168.0.100
root@beaglebone:~# mount
rootfs on / type rootfs (rw)
192.168.0.1:/home/conrad/Training/yocto/nfs on / type nfs (rw,relatime,vers=2,rsize=4096,wsize=4096,namlen=255,hard,nolock,proto=udp,timeo=11,retrans=3,sec=sys,mountaddr=192.168.0.1,mountvers=1,mountproto=udp,local_lock=all,addr=192.168.0.1)        (5)
devtmpfs on /dev type devtmpfs (rw,relatime,size=244720k,nr_inodes=61180,mode=755)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /var/volatile type tmpfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,gid=5,mode=620)
root@beaglebone:~#
1 The uEnv.txt file is loaded
2 The uenvcmd is executed
3 Our bootargs is taken as Kernel parameters
4 The kernel successfully mounts the NFS server
5 We see the root filesystem is mounted from our NFS server

9.3. Add A Package To The Rootfs Image

We will now add the dropbear package to the packages installed in the built Yocto image. To do this we have to append the keyword _append to the configuration variable IMAGE_INSTALL in our conf/local.conf file.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky/build$ tail conf/local.conf
PACKAGECONFIG_pn-nativesdk-qemu = "sdl"
ASSUME_PROVIDED += "libsdl-native"


# CONF_VERSION is increased each time build/conf/ changes incompatibly and is used to
# track the version of this file when it was generated. This can safely be ignored if
# this doesn't mean anything to you.
CONF_VERSION = "1"

IMAGE_INSTALL_append = "dropbear"        (1)
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky/build$
1 We’ve added dropbear by using the append method
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky$ source oe-init-build-env        (1)

### Shell environment set up for builds. ###

You can now run 'bitbake <target>'

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

You can also run generated qemu images with a command like 'runqemu qemux86'
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky/build$ bitbake core-image-minimal        (2)
Parsing recipes: 100% |#################################################################################################################################################| Time: 00:02:10
Parsing of 862 .bb files complete (0 cached, 862 parsed). 1221 targets, 61 skipped, 0 masked, 0 errors.
NOTE: Resolving any missing task queue dependencies

Build Configuration:
BB_VERSION        = "1.22.0"
BUILD_SYS         = "i686-linux"
NATIVELSBSTRING   = "Ubuntu-14.04"
TARGET_SYS        = "arm-poky-linux-gnueabi"
MACHINE           = "beaglebone"
DISTRO            = "poky"
DISTRO_VERSION    = "1.6.2"
TUNE_FEATURES     = "armv7a vfp neon callconvention-hard cortexa8"
TARGET_FPU        = "vfp-neon"
meta
meta-yocto
meta-yocto-bsp    = "daisy:91c507ce1cf983a600c2d38c4284e605a80297d6"

NOTE: Preparing runqueue
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
NOTE: Tasks Summary: Attempted 1809 tasks of which 1794 didn't need to be rerun and all succeeded.
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky/build$
modules--3.14.4+git0+183622e809_0143c6ebb4-r0-beaglebone-20150511125839.tgz
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky/build$ ls -l tmp/deploy/images/beaglebone/        (3)
total 48408
-rw-r--r-- 1 conrad conrad  2949120 May 11 23:51 core-image-minimal-beaglebone-20150511125839.rootfs.jffs2
-rw-r--r-- 1 conrad conrad      972 May 11 23:51 core-image-minimal-beaglebone-20150511125839.rootfs.manifest
-rw-r--r-- 1 conrad conrad  2264889 May 11 23:51 core-image-minimal-beaglebone-20150511125839.rootfs.tar.bz2        (4)
-rw-r--r-- 1 conrad conrad  3080192 May 13 20:15 core-image-minimal-beaglebone-20150513143651.rootfs.jffs2
-rw-r--r-- 1 conrad conrad     1009 May 13 20:15 core-image-minimal-beaglebone-20150513143651.rootfs.manifest
-rw-r--r-- 1 conrad conrad  2387393 May 13 20:15 core-image-minimal-beaglebone-20150513143651.rootfs.tar.bz2        (5)
lrwxrwxrwx 1 conrad conrad       57 May 13 20:15 core-image-minimal-beaglebone.jffs2 -> core-image-minimal-beaglebone-20150513143651.rootfs.jffs2
lrwxrwxrwx 1 conrad conrad       60 May 13 20:15 core-image-minimal-beaglebone.manifest -> core-image-minimal-beaglebone-20150513143651.rootfs.manifest
lrwxrwxrwx 1 conrad conrad       59 May 13 20:15 core-image-minimal-beaglebone.tar.bz2 -> core-image-minimal-beaglebone-20150513143651.rootfs.tar.bz2        (6)
lrwxrwxrwx 1 conrad conrad       48 May 12 15:15 MLO -> MLO-beaglebone-v2013.07+gitAUTOINC+62c175fbb8-r0
lrwxrwxrwx 1 conrad conrad       48 May 12 15:15 MLO-beaglebone -> MLO-beaglebone-v2013.07+gitAUTOINC+62c175fbb8-r0
-rwxr-xr-x 2 conrad conrad   102348 May 12 15:15 MLO-beaglebone-v2013.07+gitAUTOINC+62c175fbb8-r0
-rw-rw-r-- 2 conrad conrad 33333836 May 12 02:04 modules--3.14.4+git0+183622e809_0143c6ebb4-r0-beaglebone-20150511125839.tgz
lrwxrwxrwx 1 conrad conrad       75 May 12 02:04 modules-beaglebone.tgz -> modules--3.14.4+git0+183622e809_0143c6ebb4-r0-beaglebone-20150511125839.tgz
-rw-r--r-- 2 conrad conrad      294 May 13 20:12 README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt
lrwxrwxrwx 1 conrad conrad       55 May 12 15:15 u-boot-beaglebone.img -> u-boot-beaglebone-v2013.07+gitAUTOINC+62c175fbb8-r0.img
-rwxr-xr-x 2 conrad conrad   356456 May 12 15:15 u-boot-beaglebone-v2013.07+gitAUTOINC+62c175fbb8-r0.img
lrwxrwxrwx 1 conrad conrad       55 May 12 15:15 u-boot.img -> u-boot-beaglebone-v2013.07+gitAUTOINC+62c175fbb8-r0.img
lrwxrwxrwx 1 conrad conrad       74 May 12 02:04 uImage -> uImage--3.14.4+git0+183622e809_0143c6ebb4-r0-beaglebone-20150511125839.bin
-rw-r--r-- 2 conrad conrad    28596 May 12 02:04 uImage--3.14.4+git0+183622e809_0143c6ebb4-r0-am335x-bone-20150511125839.dtb
-rw-r--r-- 2 conrad conrad    29192 May 12 02:04 uImage--3.14.4+git0+183622e809_0143c6ebb4-r0-am335x-boneblack-20150511125839.dtb
-rw-r--r-- 2 conrad conrad  4985352 May 12 02:04 uImage--3.14.4+git0+183622e809_0143c6ebb4-r0-beaglebone-20150511125839.bin
lrwxrwxrwx 1 conrad conrad       80 May 12 02:04 uImage-am335x-boneblack.dtb -> uImage--3.14.4+git0+183622e809_0143c6ebb4-r0-am335x-boneblack-20150511125839.dtb
lrwxrwxrwx 1 conrad conrad       75 May 12 02:04 uImage-am335x-bone.dtb -> uImage--3.14.4+git0+183622e809_0143c6ebb4-r0-am335x-bone-20150511125839.dtb
lrwxrwxrwx 1 conrad conrad       74 May 12 02:04 uImage-beaglebone.bin -> uImage--3.14.4+git0+183622e809_0143c6ebb4-r0-beaglebone-20150511125839.bin
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky/build$
1 Source the oe-init-build-env script
2 Build the core-image-minimal target again
3 We list the built images and see the core-image-minimal rootfs has been rebuilt
4 The older core-image-minimal-beaglebone tar package
5 The newer core-image-minimal-beaglebone tar package
6 The soft link pointing to the newer core-image-minimal-beaglebone tar package

Now untar the root filesystem to the NFS export directory. Be careful to delete the contents of the directory before untarring the new package.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky/build$ sudo rm -Rf /home/conrad/Training/yocto/nfs/*conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky/build$ ls -l /home/conrad/Training/yocto/nfs/        (1)
total 0
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky/build$ sudo tar xpvjf tmp/deploy/images/beaglebone/core-image-minimal-beaglebone-20150513143651.rootfs.tar.bz2 -C ~/Training/yocto/nfs        (2)
./
./home/
./home/root/
.
.
./bin/kill
./bin/mknod
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky/build$ ls -l /home/conrad/Training/yocto/nfs/        (3)
total 60
drwxr-xr-x  2 root root 4096 May 13 20:14 bin
drwxr-xr-x  2 root root 4096 May 11 20:51 boot
drwxr-xr-x  2 root root 4096 May 11 20:51 dev
drwxr-xr-x 18 root root 4096 May 13 20:15 etc
drwxr-sr-x  3 root root 4096 May 13 20:14 home
drwxr-xr-x  4 root root 4096 May 13 20:15 lib
drwxr-xr-x  2 root root 4096 May 11 20:51 media
drwxr-xr-x  2 root root 4096 May 11 20:51 mnt
drwxr-xr-x  2 root root 4096 May 11 20:51 proc
drwxr-xr-x  2 root root 4096 May 11 20:51 run
drwxr-xr-x  2 root root 4096 May 13 20:14 sbin
drwxr-xr-x  2 root root 4096 May 11 20:51 sys
drwxrwxrwt  2 root root 4096 May 11 20:51 tmp
drwxr-xr-x  9 root root 4096 May 11 23:30 usr
drwxr-xr-x  7 root root 4096 May 13 20:11 var
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky/build$
1 Remove the old NFS export directory contents
2 Untar the package
3 List the contents of the NFS export directory

This time in the boot logs we see that the Dropbear server has been started.

.
.
.
udevd[76]: starting version 182
random: nonblocking pool is initialized
Starting Bootlog daemon: bootlogd.
Populating dev cache
Wed May 13 14:45:00 UTC 2015
INIT: Entering runlevel: 5
Configuring network interfaces... ifup skipped for nfsroot interface eth0
run-parts: /etc/network/if-pre-up.d/nfsroot exited with code 1
Starting Dropbear SSH server: Generating key, this may take a while...        (1)
Public key portion is:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCzQCH8KKC3o65RCZnp8sNta+QtqX8t60Iyq3msHPIG1LBI+UvJ+pBnGcFG5CQfG56ZyUNm3ugL7nFGMeABAbfTiXYXW8INQbp09x4pm3sJr2OkL2IZZWO+O8iY/O26xHszPfzeH8czCm+Kws7BPS65GAng6+a9FZSNKH36WeRn8fYdcCXK+PK5nyuT8JmfH/Ig7DXDgkvQdz0RnndO/NzmeBfwYB7EMplDEksE861rU3bEemhFPNgyBpgHiK0ofzVS1KgCXzCyyXoA0ZeN/KVrA0JtTsNJwZ0l+xdaGdiia5+W7/Qmhmjb9CwhNcps4Ck0vGjhQF9Sx/547YjG5kgv root@beaglebone
Fingerprint: md5 e6:ed:ed:24:3e:80:59:e3:cf:1d:71:d8:5d:99:bd:18
dropbear.
Starting syslogd/klogd: done
Stopping Bootlog daemon: bootlogd.

Poky (Yocto Project Reference Distro) 1.6.2 beaglebone /dev/ttyO0

beaglebone login: root
root@beaglebone:~#
1 Dropbear server logs

We can now try to ssh to the BeagleBone Black board on its IP. The IP should be the static IP 192.168.0.100 which we set in the uEnv.txt settings for bootargs.

conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky/build$ ping 192.168.0.100        (1)
PING 192.168.0.100 (192.168.0.100) 56(84) bytes of data.
64 bytes from 192.168.0.100: icmp_seq=1 ttl=64 time=0.188 ms
64 bytes from 192.168.0.100: icmp_seq=2 ttl=64 time=0.235 ms
^C
--- 192.168.0.100 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.188/0.211/0.235/0.027 ms
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky/build$ ssh root@192.168.0.100        (2)
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
e6:ed:ed:24:3e:80:59:e3:cf:1d:71:d8:5d:99:bd:18.
Please contact your system administrator.
Add correct host key in /home/conrad/.ssh/known_hosts to get rid of this message.
Offending RSA key in /home/conrad/.ssh/known_hosts:4
  remove with: ssh-keygen -f "/home/conrad/.ssh/known_hosts" -R 192.168.0.100
RSA host key for 192.168.0.100 has changed and you have requested strict checking.
Host key verification failed.
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky/build$ ssh-keygen -f "/home/conrad/.ssh/known_hosts" -R 192.168.0.100        (3)
# Host 192.168.0.100 found: line 4 type RSA
/home/conrad/.ssh/known_hosts updated.
Original contents retained as /home/conrad/.ssh/known_hosts.old
conrad@conrad-HP-Pavilion-dm3-Notebook-PC:~/Git/poky/build$ ssh root@192.168.0.100        (4)
The authenticity of host '192.168.0.100 (192.168.0.100)' can't be established.
RSA key fingerprint is e6:ed:ed:24:3e:80:59:e3:cf:1d:71:d8:5d:99:bd:18.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.100' (RSA) to the list of known hosts.
root@beaglebone:~# uname -a        (5)
Linux beaglebone 3.14.0-yocto-standard #1 PREEMPT Tue May 12 01:59:26 IST 2015 armv7l GNU/Linux
1 We ping the BBB to check if it is alive
2 Our first attempt to ssh with root login gives us a Warning
3 We’ve connected previously with previous experiments so we have to clear the keys
4 Our second attempt to ssh to the BBB is successful
5 We’re able to print the name of the built OS