make
command. There is some computer preparation that must be done. It is also good to know a little bit about how the build system works and how to compile the SPI and SD card images for Intel Galileo and Intel Quark toolchains in order to have the cross-compilers in hand.Introduction to the Yocto Build System
Yocto and this Book
https://www.yoctoproject.org/documentation
and the manual at
http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html
.Poky
make
command. Imagine that you have a complex project with different software components and you need to run the make
for each of them. Bitbake in a Yocto project context might be considered the “global make
command,” but you will definitely not use any make
commands because bitbake will invoke all of them for you.-
Configuration files: Bitbake based in configuration files (
.conf
) that holds the global definition of variables, the compilation flags, where libraries and applications must be placed, the machine architecture to be used, and so forth. -
Bitbake classes: The bitbake classes, is also known as bbclasses, are defined in a file with the
.bbclass
extension. Mostly, the heavy things during the build are done with the definitions in these files, like how the RPM packages are generated, how the root file system is created, and so forth. -
Recipes: The recipes are the files with
.bb
extensions and define the individual pieces of the software to be built, the packages that must be included, where and how to obtain source code and patches, the dependencies, which features and definitions you want to enable in a source, and others.
.rpm
,
.deb
, or
.ipk
). You will use the IPK files in this book.The Build System Tree at a Glance
poky
that contains the basic structure of a Yocto build system. For example, in the poky
directory there is a bitbake
directory that contains the bitbake binary tool and other utilities, as shown in Figure 2-2 (right), as well as some directories starting with meta*
prefix. Each meta*
directory is, in fact, a layer containing metadata—in other words, recipes, classes, and configuration files.poky
directory are other layers, like meta-clanton-bsp
, meta-clanton-distro
, meta-intel
, and meta-oe
, which, of course, have their respective recipes, classes, and configuration files, as well as any other metadata.bblayers.conf
in the yocto_build/conf
directory shown in Listing 2-1.# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
LCONF_VERSION = "6"
BBPATH = "${TOPDIR}"
BBFILES ?= ""
BBLAYERS ?= " \
/home/mcramon/BSP_1.0.4_T/meta-clanton_v1.0.1/poky/
meta
\
/home/mcramon/BSP_1.0.4_T/meta-clanton_v1.0.1/poky/
meta-yocto
\
/home/mcramon/BSP_1.0.4_T/meta-clanton_v1.0.1/poky/
meta-yocto-bsp
\
/home/mcramon/BSP_1.0.4_T/meta-clanton_v1.0.1/
meta-intel
\
/home/mcramon/BSP_1.0.4_T/meta-clanton_v1.0.1/meta-oe
/meta-oe
\
/home/mcramon/BSP_1.0.4_T/meta-clanton_v1.0.1/
meta-clanton-distro
\
/home/mcramon/BSP_1.0.4_T/meta-clanton_v1.0.1/
meta-clanton-bsp
\
"
An Example of a Recipe (.bb)
meta
layer; if you explore this layer a little, you will find very interesting recipes, like the busybox_1.20.2.bb
recipe shown in Figure 2-3(a).
require busybox.inc
PR = "r7"
file://B921600.patch \
file://get_header_tar.patch \
file://busybox-appletlib-dependency.patch \
file://run-parts.in.usr-bin.patch \
file://watch.in.usr-bin.patch \
...
...
...
file://inetd"
SRC_URI[tarball.md5sum]
= "e025414bc6cd79579cc7a32a45d3ae1c"
SRC_URI[tarball.sha256sum]
= "eb13ff01dae5618ead2ef6f92ba879e9e0390f9583bd545d8789d27cf39b6882"
EXTRA_OEMAKE
+= "V=1 ARCH=${TARGET_ARCH} CROSS_COMPILE=${TARGET_PREFIX} SKIP_STRIP=y"
SRC_URI
variable that defines the URLs to download busybox, and respective md5
and sha256
checksum to make sure that the package downloaded was the one expected. The
EXTRA_OEMAKE
only adds compilation flags during the build.-
do_fetch
-
do_unpack
-
do_patch
-
do_configure
-
do_compile
-
do_install
-
do_package
http://www.yoctoproject.org/docs/1.7/ref-manual/ref-manual.html#ref-tasks
.
An Example of a Configuration File (.conf)
conf
in a layer. A good example is the configuration filename clanton.conf
that belongs to the meta-clanton-bsp
layer under the /conf/machine
folder. The content of this file is shown in Listing 2-3 and Figure 2-3(b).#@TYPE: Machine
#@NAME: clanton
#@DESCRIPTION: Machine configuration for clanton systems
PREFERRED_PROVIDER_virtual/kernel ?= "linux-yocto-clanton"
PREFERRED_VERSION_linux-yocto-clanton ?= "3.8%"
require conf/machine/include/ia32-base.inc
include conf/machine/include/tune-i586.inc
#Avoid pulling in GRUB
MACHINE_ESSENTIAL_EXTRA_RDEPENDS = ""
MACHINE_FEATURES = "efi usb pci"
SERIAL_CONSOLE = "115200 ttyS1"
#SERIAL_CONSOLES = "115200;ttyS0 115200;ttyS1"
EXTRA_IMAGEDEPENDS = "grub"
PREFERRED_VERSION_grub = "0.97+git%"
An Example of a Class File (.bbclass)
classes
with a .bbclass
extension. As an example, using the meta
layer, search for the class file bin_package.bbclass
, as in Listing 2-4 and shown in Figure 2-3(c).#
# ex:ts=4:sw=4:sts=4:et
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
#
# Common variable and task for the binary package recipe.
# Basic principle:
# * The files have been unpacked to ${S} by base.bbclass
# * Skip do_configure and do_compile
# * Use do_install to install the files to ${D}
#
# Note:
# The "subdir" parameter in the SRC_URI is useful when the input package
# is rpm, ipk, deb and so on, for example:
#
#
# Then the files would be unpacked to ${WORKDIR}/foo-1.0, otherwise
# they would be in ${WORKDIR}.
#
# Skip the unwanted steps
do_configure[noexec] = "1"
do_compile[noexec] = "1"
# Install the files to ${D}
bin_package_do_install () {
# Do it carefully
[ -d "${S}" ] || exit 1
cd ${S} || exit 1
tar --no-same-owner --exclude='./patches' --exclude='./.pc' -cpf - . \
| tar --no-same-owner -xpf - -C ${D}
}
FILES_${PN} = "/"
EXPORT_FUNCTIONS do_install
bbclass
file provides information on what must be done for all meta layers that make usage of binary package recipes, and in this cases skips the configure (
do_configure
) and compile (
do_compile
) procedures indexing noexec
to 1
, but takes action during the package installation (
do_install
).
Creating Your Own Intel Galileo Images
Preparing Your Computer
http://www.vmware.com
) or Oracle Virtual Box (
https://www.virtualbox.org
), and install one of the following Linux distributions:
-
Ubuntu 12.04 (LTS)
-
Ubuntu 13.10
-
Ubuntu 14.04 (LTS)
-
Fedora release 19 (Schrödinger’s Cat)
-
Fedora release 20 (Heisenbug)
-
CentOS release 6.4
-
CentOS release 6.5
-
Debian GNU/Linux 7.0 (Wheezy)
-
Debian GNU/Linux 7.1 (Wheezy)
-
Debian GNU/Linux 7.2 (Wheezy)
-
Debian GNU/Linux 7.3 (Wheezy)
-
Debian GNU/Linux 7.4 (Wheezy)
-
Debian GNU/Linux 7.5 (Wheezy)
-
Debian GNU/Linux 7.6 (Wheezy)
-
openSUSE 12.2
-
openSUSE 12.3
-
openSUSE 13.1
http://www.yoctoproject.org/docs/1.7/ref-manual/ref-manual.html#detailed-supported-distros
.mcramon@ubuntu: ∼/ $
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:
Ubuntu 12.04.4
LTS
Release:
12.04
Codename: precise
mcramon@ubuntu:∼/$
sudo apt-get install subversion libcurl4-openssl-dev uuid-dev autoconf texinfo libssl-dev libtool iasl bitbake diffstat gawk chrpath openjdk-7-jdk connect-proxy autopoint p7zip-full build-essential gcc-multilib vim-common gawk wget git-core
mcramon@ubuntu:∼/tools$
sudo apt-get remove iasl
mcramon@ubuntu:∼/tools$
sudo apt-get install libbison-dev flex
mcramon@ubuntu:∼/tools$
mkdir iasl
mcramon@ubuntu:∼/tools$
cd iasl/
mcramon@ubuntu:∼/tools/iasl$
git clone git://github.com/acpica/acpica.git
mcramon@ubuntu:∼/tools$
cd acpica
mcramon@ubuntu:∼/tools/acpica$
make
make
command compiles and links everything, the output files will be in the .../generate/unix/bin
folder.mcramon@ubuntu:∼/tools/acpica$
cd ./generate/unix/bin
mcramon@ubuntu:∼/tools/iasl/acpica/generate/unix/bin$
./iasl
Intel ACPI Component Architecture
ASL+ Optimizing Compiler version 20141107-64 [Dec 12 2014]
Copyright (c) 2000 - 2014 Intel Corporation
Supports
ACPI Specification Revision 5.1
https://github.com/acpica/acpica
.usr/bin/iasl
pointing to your IASL, compiled manually:mcramon@ubuntu
:∼/sudo ln -s <YOUR IASL PATH> /usr/bin/iasl
mcramon@ubuntu
:∼/sudo ln -s /home/mcramon/tools/iasl/acpica/generate/unix/bin/iasl /usr/bin/iasl
The SPI vs. SD Card Images
Building Intel Galileo Images
mcramon@ubuntu:∼/$
mkdir BSP_1.0.4_build
https://downloadcenter.intel.com/Detail_Desc.aspx?DwnldID=24355
and read the instructions on how to compile the BSP. With 1.0.4, there are instructions to access the GitHub link at
https://github.com/01org/Galileo-Runtime
and download the file
https://github.com/01org/Galileo-Runtime/archive/1.0.4.tar.gz
. Next, decompress the downloaded file:mcramon@ubuntu:∼/$
tar -xf Galileo-Runtime-1.0.4.tar.gz
mcramon@ubuntu:∼/$
cd Galileo-Runtime-1.0.4
mcramon@ubuntu:∼/$
tar -xvf patches_v1.0.4.tar.gz
patches_v1.0.4/
patches_v1.0.4/.DS_Store
patches_v1.0.4/meta-clanton.patches/
patches_v1.0.4/._patch.meta-clanton.sh
patches_v1.0.4/patch.meta-clanton.sh
patches_v1.0.4/._patch.Quark_EDKII.sh
patches_v1.0.4/patch.Quark_EDKII.sh
patches_v1.0.4/._patch.sysimage.sh
patches_v1.0.4/patch.sysimage.sh
patches_v1.0.4/Quark_EDKII.patches/
patches_v1.0.4/sysimage.patches/
patches_v1.0.4/sysimage.patches/.DS_Store
patches_v1.0.4/sysimage.patches/sysimage_v1.0.1+1.0.4.patch
patches_v1.0.4/Quark_EDKII.patches/.DS_Store
patches_v1.0.4/Quark_EDKII.patches/Quark_EDKII_v1.0.2+ACPI_for_Windows.patch
patches_v1.0.4/meta-clanton.patches/.DS_Store
patches_v1.0.4/meta-clanton.patches/meta-clanton.post-patch.init.patch
patches_v1.0.4/meta-clanton.patches/meta-clanton_v1.0.1+quark-init.patch
patches_v1.0.4/meta-clanton.patches/post-setup.patches/
patches_v1.0.4/meta-clanton.patches/post-setup.patches/.DS_Store
patches_v1.0.4/meta-clanton.patches/post-setup.patches/1.usb_improv_patch-1.patch
patches_v1.0.4/meta-clanton.patches/post-setup.patches/2.GAL-193-clloader-1.patch
patches_v1.0.4/meta-clanton.patches/post-setup.patches/3.GAL-199-start_spi_upgrade-1.patch
patches_v1.0.4/meta-clanton.patches/post-setup.patches/4.MAKER-222-Sketch_download_unstable-5.patch
patches_v1.0.4/meta-clanton.patches/post-setup.patches/GAL-118-USBDeviceResetOnSUSRES-2.patch
patches_v1.0.4/meta-clanton.patches/post-setup.patches/patch.sh
patches_v1.0.4/meta-clanton.patches/post-setup.patches/uart-1.0.patch
patches_v1.0.4/meta-clanton.patches/post-setup.patches/uart-reverse-8.patch
tar.gz
files extracted in your directory, such as the directory for SPI flash tools, the firmware based on Intel EDKII, and the sysimage
templates; but what really matters at this point is the meta-clanton
directory that must be decompressed.mcramon@ubuntu:∼/$
tar -zxvf meta-clanton_v1.0.1.tar.gz
Galileo-Runtime-1.0.4/
Galileo-Runtime-1.0.4/Quark_EDKII_v1.0.2.tar.gz
Galileo-Runtime-1.0.4/README.txt
Galileo-Runtime-1.0.4/grub-legacy_5775f32a+v1.0.1.tar.gz
Galileo-Runtime-1.0.4/meta-clanton_v1.0.1.tar.gz
Galileo-Runtime-1.0.4/patches_v1.0.4.tar.gz
Galileo-Runtime-1.0.4/quark_linux_v3.8.7+v1.0.1.tar.gz
Galileo-Runtime-1.0.4/spi-flash-tools_v1.0.1.tar.gz
mcramon@ubuntu:∼/$
for file in $(ls *.tar.gz); do tar -zxvf $file;done
meta-clanton
directory, and then observe the files and directories that you have.mcramon@ubuntu:∼/$ cd meta-clanton_v1.0.1/
mcramon@ubuntu:∼/$
ls
LICENSE
meta-clanton-bsp meta-clanton-distro
README setup
setup.sh
meta-clanton
layer, but the main build processor Poky is not present and you need to fetch it.
meta-clanton
patches. Return to the previous directory and run the meta-clanton
patches with following command:mcramon@ubuntu:∼/$
cd ..
mcramon@ubuntu:∼/$
./patches_v1.0.4/patch.meta-clanton.sh
patch.meta-clanton.sh
script calls a second script named setup.sh
that downloads the some new metafiles that are included in the meta-clanton
directory. The new metafiles are meta-intel
and meta-oe
. Also, two new directories were prepared: poky
and yocto_build
. This might take some time, depending on the speed of your Internet connection.mcramon@ubuntu:∼/$
cd meta-clanton_v1.0.1/
mcramon@ubuntu:∼/$ ls
LICENSE
meta-clanton-bsp meta-clanton-distro meta-intel meta-oe poky
README setup setup.sh
yocto_build
meta-clanton_v1.0.1.tar.gz
that mean baseline 1.0.1. In this case, Intel provides patches that must be applied on top of 1.0.1, and once applied, you have a legitimate source 1.0.4. It is great if there is no patch to be applied, because the baseline is in sync with previous Intel Galileo fixes.patch.meta-clanton.sh
is to apply not only code fixes but also possible recipe files that must be correct; for example, patching a new OpenSSL code or applying security fixes..bbappend
files provided as a source, so that you will not need to apply any patches manually.
mcramon@ubuntu:∼/$
cd ./meta-clanton_v1.0.1
mcramon@ubuntu:∼/$
source poky/oe-init-build-env yocto_build
yocto_build
directory.
file .../meta-clanton/yocto_build/conf/local.conf
with the text editor of your preference.BB_NUMBER_THREADS
that represents the maximum number of threads that your bitbake command will be able to handle. My suggestion is to multiply the numbers of threads on your computer processor by 2; for example, if your computer supports 8 threads, you can change this number to 16. If you are using a free version of virtual machines, check the number of core processors that it allows you to set. For example, the free version of VMware only allows setting a maximum of four cores, and if each core of your processor holds one single thread, then BB_NUMBER_THREADS
could be 8.BB_NUMBER_THREADS = "12"
yocto.conf
you can make the following changes:SSTATE_DIR ?= "/tmp/yocto_cache-sstate"
SOURCE_MIRROR_URL ?= "file:///tmp/yocto_cache/"
INHERIT += "own-mirrors"
BB_GENERATE_MIRROR_TARBALLS = "1"
bitbake -s
, which brings all the targets supported by the current configurations:mcramon@ubuntu:$
bitbake -s |grep galileo
galileo-target :0.1-r0
image-full-galileo
:1.0-r0
image-spi-galileo
:1.0-r0
image-full-galileo
creates the SD card image; image-spi-galileo
creates the SPI image; and galileo-target
must be ignored because it is not used anymore.mcramon@ubuntu:$
bitbake image-spi-galileo
do_
actions in place of different recipes, the number of tasks completed and to be completed, and warnings if the mirrors failed to download the expected code. You do not need to worry about warnings, because they are an indication that the code failed to be fetched and a different mirror will be used. You only need to worry if there are errors reported, and in this case, you need to identify the recipe file and check whether the URL mirrors changed, which would fix the file, or if you have a generic error like an Internet connection loss or insufficient space in the device.bitbake image-full-galileo
is used to create SD card releases. Note that there are 2,924 tasks to be done, but only 190 were executed, which means that this is the beginning of the compilation. You can also observe some actions in place, such as do_configure
, do_compile
, do_patch
, and do_unpack
, for different recipes.
...meta-clanton/yocto_build/tmp/deploy/images
directory.
Building and Using the Cross-Compiler Toolchain
Compiling the Toolchain for Different Architectures
.../meta-clanton/yocto_build/conf/local.conf
and add the variable SDKMACHINE
followed by a string that describes the machine architecture designed to the SDK build.SDKMACHINE = "i386-darwin"
BB_NUMBER_THREADS = "12"
PARALLEL_MAKE = "-j 14"
MACHINE = "clanton"
DISTRO ?= "clanton-tiny"
EXTRA_IMAGE_FEATURES = "debug-tweaks"
USER_CLASSES ?= "buildstats image-mklibs image-prelink"
PATCHRESOLVE = "noop"
CONF_VERSION = "1"
String | Target Architecture |
---|---|
i586 | Linux, 32-bit |
x86_64 | Linux, 64-bit |
i386-darwin | OSX |
i686-mingw32 | Windows, 32- and 64-bit |
SDKMACHINE
is not explicitly declared, then the toolchain will assume the computer architecture that runs the Yocto build.mcramon@ubuntu:∼/$
cd meta-clanton_v1.0.1/yocto_build
mcramon@ubuntu:∼/$
echo
'SDKMACHINE = "i586"'
>> conf/local.conf
Building the Toolchains
bitbake
command is different and additional layers must be downloaded.http://www.intel.com/content/dam/www/public/us/en/documents/guides/galileo-quark-x1000-bsp-guide.pdf
.uclibc
library, because it is the default library set in the metafiles. If you are interested in creating the toolchains based in eglibc
, you need to read Chapter 7, specifically the “Preparing the BSP Software Image and Toolchain” section.Linux
mcramon@ubuntu:∼/$
cd ./meta-clanton_v1.0.1
mcramon@ubuntu:∼/$
source poky/oe-init-build-env yocto_build
mcramon@ubuntu:∼/$
echo
'SDKMACHINE = "i586"'
>> conf/local.conf
mcramon@ubuntu:∼/$
bitbake meta-toolchain
SDKMACHINE
to x86_64
. Alternatively, you can replace the command bitbake meta-toolchain
with bitbake image_full –c populate_sdk
and the result will be the same.OSX
OSX-sdk.zip
with following commands:$ mkdir ∼/Desktop/OSX-sdk
$ cd ∼/Desktop/OSX-sdk
$ ditto `xcrun --sdk
macosx10.8
--show-sdk-path` .
$ cd ..
$ zip -yr OSX-sdk OSX-sdk
OSX-sdk.zip
to a directory in your Linux virtual machine. The following are the commands to create the OSX toolchain:mcramon@ubuntu:∼/$
cd ./meta-clanton_v1.0.1
mcramon@ubuntu:∼/$
sed -i 's|setup/gitsetup.py -c setup/$1.cfg -w
mcramon@ubuntu:∼/$
sed -i 's|setup/gitsetup.py -c setup/$1.cfg -w$1|setup/gitsetup.py -c setup/$1.cfg -w $1 --depth=1|' setup/gitsetup.py
mcramon@ubuntu:∼/$
./setup.sh
mcramon@ubuntu:∼/$
git clone git://git.yoctoproject.org/meta-darwin
mcramon@ubuntu:∼/$
cd meta-darwin ; git checkout 03b7dd85732838d78e4879332b1cc005dae25754 ; cd ..
mcramon@ubuntu:∼/$
(cd poky && patch -p1) < meta-darwin/oecore.patch
mcramon@ubuntu:∼/$
mv <YOUR DIRECTORY HERE>/OSX-sdk.zip
meta-darwin/recipes-devtools/osx-runtime/files darwinpath="$(pwd)/meta-darwin"
mcramon@ubuntu:∼/$
echo 'SDKMACHINE = "i386-darwin"' >> yocto_build/conf/local.conf
mcramon@ubuntu:∼/$
echo "BBLAYERS += \"$darwinpath\"" >> yocto_build/conf/bblayers.conf
mcramon@ubuntu:∼/$
source poky/oe-init-build-env yocto_build
mcramon@ubuntu:∼/$
bitbake meta-toolchain
Windows
mcramon@ubuntu:∼/$
sed -i 's|setup/gitsetup.py -c setup/$1.cfg -w $1|setup/gitsetup.py -c setup/$1.cfg -w $1 --depth=1|' setup/gitsetup.py
mcramon@ubuntu:∼/$
./setup.sh
mcramon@ubuntu:∼/$
git clone -b dylan git://git.yoctoproject.org/meta-mingw
mcramon@ubuntu:∼/$
(cd poky && patch -p1) < meta-mingw/oecore.patch
mcramon@ubuntu:∼/$
mingwpath="$(pwd)/meta-mingw"
mcramon@ubuntu:∼/$
echo 'SDKMACHINE = "i686-mingw32"' >> yocto_build/conf/local.conf
mcramon@ubuntu:∼/$
echo "BBLAYERS += \"$mingwpath\"" >> yocto_build/conf/bblayers.conf
mcramon@ubuntu:∼/$
cd $WORKSPACE/meta-clanton_v1.0.1poky
mcramon@ubuntu:∼/$
wget
http://git.yoctoproject.org/cgit.cgi/poky/patch/meta/classes/sstate.bbclass?id=4273aa4287ecd36529f2d752c76ab8d09afc33c3
-O sstate.bbclass.patch
git am sstate.bbclass.patch
mcramon@ubuntu:∼/$
cd $WORKSPACE/meta-clanton_v1.0.1
mcramon@ubuntu:∼/$
source poky/oe-init-build-env yocto_build
mcramon@ubuntu:∼/$
bitbake gcc-crosssdk-initial -c cleansstate
mcramon@ubuntu:∼/$
bitbake meta-toolchain
The Output Files
.../meta-clanton_v1.0.1/yocto_build/tmp/deploy/sdk
directory, while the ipk packages will be in the directory .../meta-clanton_v1.0.1/yocto_build/tmp/deploy/ipk
directory.uclibc
or eglic
library that the image is based on. In the end, you will have just a single script file; however, it is a big file at around 260MB.clanton-tiny-uclibc-x86_64-i586-toolchain-1.4.2.sh
.
Installing the Cross-Compilers
mcramon@ubuntu:∼/toolchain$
./clanton-tiny-uclibc-x86_64-i586-toolchain-1.4.2.sh
Enter target directory for SDK (default: /opt/clanton-tiny/1.4.2):
You are about to install the SDK to
"/opt/clanton-tiny/1.4.2"
. Proceed[Y/n]?Y
[sudo] password for mcramon:
Extracting SDK...done
Setting it up...done
SDK has been successfully set up and is ready to be used.
Creating a Hello World!
environment-setup-*
; for example, in my setup I have the file named as environment-setup-i586-poky-linux-uclibc
.CC
, CXX
, CPP
, AR
, and NM
—that must be exported to your computer shell. They are used to compile, link, and archive your native programs with the toolchain, so primarily you need to make this variable part of the development environment, sourcing it as follows:mcramon@ubuntu:
/opt/clanton-tiny/1.4.2
$
source environment-setup-i586-poky-linux-uclibc
$(CC) -c $(CFLAGS) $(CPPFLAGS)
since CC
points to the C compilers, CFLAGS
to the C compiler flags, and CPPFLAGS
to the C++ compiler flags. If you check some of these variables after sourcing them, you will see something like this:mcramon@ubuntu:/opt/clanton-tiny/1.4.2$
echo $CC
i586-poky-linux-uclibc-gcc -m32 -march=i586 --sysroot=/opt/clanton-tiny/1.4.2/sysroots/i586-poky-linux-uclibc
mcramon@ubuntu:/opt/clanton-tiny/1.4.2$
echo $CFLAGS
-O2 -pipe -g -feliminate-unused-debug-types
mcramon@ubuntu:/opt/clanton-tiny/1.4.2$
echo $CXXFLAGS
-O2 -pipe -g -feliminate-unused-debug-types -fpermissive
code
folder of this chapter.#include <stdio.h>
int
main
(int argc, char const* argv[])
{
printf("Hello, World! This is Intel Galileo!\n");
return 0;
}
mcramon@ubuntu:/
${CC} ${CFLAGS} HelloWorld.c -o HelloWorld
HelloWorld
created using the cross-compiler. Just copy this file to a micro SD card formatted using FAT or FAT32. If you do not know how to format the micro SD card, read the “Boot from SD Card Image" section of this chapter for instructions./media/mmcblk0p1
partition, and execute the HelloWorld
, as shown:root@clanton:/#
cd /media/mmcblk0p1/
root@clanton:/media/mmcblk0p1#
ls
HelloWorld
root@clanton:/media/mmcblk0p1#
./HelloWorld
Hello, World! This is Intel Galileo!
environment-setup-i586-poky-linux-uclibc
as a base. For example, Listing 2-6 shows a makefile for the HelloWorld program.SHELL = /bin/bash
TARGET_NAME = i586-poky-linux-uclibc
DIST = clanton-tiny
CC = $(TARGET_NAME)-gcc -m32 -march=i586 --sysroot
=/opt/$(DIST)/1.4.2/
sysroots/$(TARGET_NAME)
CFLAGS = -O2 -pipe -g -feliminate-unused-debug-types
OUTPUT_FILE = HelloWorld
all
: target
target
: $(patsubst %.c,%.o,$(wildcard *.c))
$(CC) $(CFLAGS) $^ -o $(OUTPUT_FILE)
clean
:
rm -f $(TARGET_BIN) *.o $(OUTPUT_FILE)
i586-poky-linux-uClibc
, as stored in the variable TARGET_NAME
and considers the toolchain installed in the /opt/clanton-tiny
directory according the CC variable. So, if you create the toolchain for a different target, or used a different directory installation, it is necessary to adapt this makefile.clean
to clean all the object files and the output file named as HelloWorld
, because it is the value in the OUTPUT_FILE
variable; all
and target
do the same thing—in other words, compile the C programs, invoking the compiler pointed by CC
and CFLAGS
.make
.mcramon@ubuntu:∼/native$
make
i586-poky-linux-uclibc-gcc -m32 -march=i586 --sysroot=/opt/clanton-tiny/1.4.2/sysroots/i586-poky-linux-uclibc -O2 -pipe -g -feliminate-unused-debug-types -c -o HelloWorld.o HelloWorld.c
i586-poky-linux-uclibc-gcc -m32 -march=i586 --sysroot=/opt/clanton-tiny/1.4.2/sysroots/i586-poky-linux-uclibc -O2 -pipe -g -feliminate-unused-debug-types HelloWorld.o -o
HelloWorld
Debugging Native Applications
https://software.intel.com/en-us/getting-started-for-c-c-plus-plus-eclipse-galileo-and-edison
.manuals
folder of this chapter, or you can access it at
https://communities.intel.com/docs/DOC-22203
.
Booting Intel Galileo with Your Own Images
Booting from SD Card Images
Preparing the Micro SD Card
Windows
Mac OSX
Ubuntu
http://gparted.sourceforge.net
) and Disk Utility for Ubuntu (
https://apps.ubuntu.com/cat/applications/precise/gnome-disk-utility/
). To avoid any new software installation, however, it is possible to format using simple command-line commands. The steps are as follows:
df
to check the partition in your computer, including the micro SD card mounted. Then identify the device name that defines the micro SD card; for example, /dev/sdb1
.umount
command followed by the device name. For example:umount /dev/sdb1
mkdosfs -F 32 -v /dev/sdb1
Copying Files to a Micro SD Card
../yocto_build/tmp/deploy/images
in the directory and type the ls -l
command:mcramon@ubuntu $
cd ./tmp/deploy/images/
mcramon@ubuntu $
ls -l
total 150576
drwxr-xr-x 3 mcramon mcramon 4096 Nov 18 23:01
boot
-rw-r--r-- 2 mcramon mcramon 373760 Nov 19 00:04 bootia32.efi
lrwxrwxrwx 2 mcramon mcramon 42 Nov 18 23:58
bzImage -> bzImage--3.8-r0-clanton-20141119062948.bin
-rw-r--r-- 2 mcramon mcramon 1984512 Nov 18 23:58 bzImage--3.8-r0-clanton-20141119062948.bin
lrwxrwxrwx 2 mcramon mcramon 42 Nov 18 23:58 bzImage-clanton.bin -> bzImage--3.8-r0-clanton-20141119062948.bin
-rw-r--r-- 1 mcramon mcramon 1689687 Nov 19 00:08 core-image-minimal-initramfs-clanton-20141119062948.rootfs.cpio.gz
lrwxrwxrwx 1 mcramon mcramon 66 Nov 19 00:08
core-image-minimal-initramfs-clanton.cpio.gz
-> core-image-minimal-initramfs-clanton-20141119062948.rootfs.cpio.gz
-rw-r--r-- 2 mcramon mcramon 279670 Nov 18 23:59
grub.efi
-rw-r--r-- 1 mcramon mcramon 314572800 Nov 19 00:26 image-full-galileo-clanton-20141119062948.rootfs.ext3
lrwxrwxrwx 1 mcramon mcramon 53 Nov 19 00:26
image-full-galileo-clanton.ext3 -> image-full-galileo-clanton-20141119062948.rootfs.ext3
-rw-rw-r-- 2 mcramon mcramon 1556960 Nov 18 23:58 modules--3.8-r0-clanton-20141119062948.tgz
-rw-rw-r-- 2 mcramon mcramon 294 Nov 19 00:25 README_-_DO_NOT_DELETE_FILES_IN_THIS_DIRECTORY.txt
boot
with files and links. The only function of the links is to make “easy reading” of the files that receive a timestamp in their names. For example, the bzImage--3.8-r0-clanton-20141119062948.bin
, where 20141119062948
is only the timestamp; thus, if you run the bitbake again without any modification, you will have another bzImage
file with a different timestamp and a link pointing to the newest one.boot
(the whole directory, including subdirectories)bzImage
core-image-minimal-initramfs-clanton.cpio.gz
grub.efi
image-full-galileo-clanton.ext3
Booting from SPI Card Images
-
Capsule file: This file contains the system images, the kernel, the file system partition, and the boot loader packages (grub), but it does not contain the platform data. Platform data informs the MAC address of your Ethernet controller and the board model, such as Intel Galileo or Intel Galileo Gen2. This file is very useful in most cases; if you have a board without boot issues and the Ethernet controller is working with a correct MAC address, the file is very handy. Usually, capsule files (or cap files) contain the
.cap
extension, and you can flash Intel Galileo boards using the Intel Arduino IDE or the UEFI shell, which will be discussed later. -
Binary file: This binary file contains everything; in other words, everything in a capsule file, plus the platform data. Usually, these files have the
.bin
extension and must be flashed with an SPI programmer.
layout.conf
that contains all the ingredients necessary to build files a single file that will be used to flash the SPI flash memory.layout.conf
ready, the SPI flash tool is called to generate capsule and binary files without platform data. If the intention is to have files without platform data, at this point the capsule files might be used; otherwise, the platform data must be patched using a Python script, which will be discussed later. A final binary with all the information is created.Creating the Capsule Files Flash Files
spi-flash-tools_v1.0.1.tar.gz
and Quark_EDKII_v1.0.1.tar.gz
.Compiling the UEFI Firmware
Preparing the Environment
-
Python 2.6 or newer
-
Any GCC and G++ with versions between 4.3 and 4.7
-
Subversion
-
uuid-dev
-
IASL
mcramon@ubuntu:∼$
dpkg --get-selections | grep -v deinstall|grep -i python
mcramon@ubuntu:∼$
python --version
Python 2.7.3
https://www.python.org/downloads/
. If you want a quick try using version 2.7.6, you can run the following commands:mcramon@ubuntu:∼/$
tar -zxvf Python-2.7.6.tgz
mcramon@ubuntu:∼/$ cd Python-2.7.6/
mcramon@ubuntu:∼/$
./configure
mcramon@ubuntu:∼/$
make
mcramon@ubuntu:∼/$
make install
Compiling the Firmware
mcramon@ubuntu $
tar -xvf Quark_EDKII_v1.0.2.tar.gz
mcramon@ubuntu $
./patches_v1.0.4/patch.Quark_EDKII.sh
mcramon@ubuntu:∼/$
cd Quark_EDKII_v1.0.2/
mcramon@ubuntu:∼/$
./svn_setup.py
mcramon@ubuntu:∼/$
svn update
mcramon@ubuntu:∼/$
export WORKSPACE=$(pwd)
./svn_setup.py
, is a Python script that brings a series of code related to EDKII to your computer. The command svn update
makes certain that you have the latest changes in fetched files. This step might take few minutes, depending on your Internet connection speed.
mcramon@ubuntu:∼/$
gcc --version
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5)
4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
GCC46
.mcramon@ubuntu:∼/$
export GCCVERSION=$(gcc -dumpversion | cut -c 3)
mcramon@ubuntu:∼/$
echo $GCCVERSION
4
GCCVERSION
; if the version was 4.7.x, the character 7 would be stored.
quarkbuild.sh
. This file is a shell script that compiles the firmware for you with the following options:quarkbuild.sh [-r32 | -d32 | -clean] [GCC43 | GCC44 | GCC45 | GCC46 | GCC47]
[PlatformName] [-DSECURE_LD (optional)] [-DTPM_SUPPORT (optional)]
-
-
clean
: Delete the build files/folders. -
-d32
: Create aDEBUG
build. -
-r32
: Create aRELEASE
build. -
GCC4x
: GCC flags used for this build. -
[PlatformName]
: Name of the Platform package you want to build. -
[-DSECURE_LD]
: Create a Secure Lockdown build (optional). -
[-DTPM_SUPPORT]
: Create EDKII build with TPM support (optional).
CryptoPkg\Library\OpensslLib\Patch-HOWTO.txt
in the EDKII directory that you downloaded and extracted.mcramon@ubuntu:∼/$
./quarkbuild.sh -r32 GCC46 QuarkPlatform
GCCVERSION
variable you can run:mcramon@ubuntu:∼/$
./quarkbuild.sh -r32 GCC4$GCCVERSION QuarkPlatform
Quark_EDKII_v1.0.2/Build/QuarkPlatform/RELEASE_GCC46/FV/FlashModules
.
mcramon@ubuntu:∼/BSP_1.0.4_T/
Quark_EDKII_v1.0.2/Build/QuarkPlatform/RELEASE_GCC46/FV/FlashModules
$
l -1
EDKII_BOOTROM_OVERRIDE.Fv
EDKII_BOOT_STAGE1_IMAGE1.Fv
EDKII_BOOT_STAGE1_IMAGE2.Fv
EDKII_BOOT_STAGE2_COMPACT.Fv
EDKII_BOOT_STAGE2.Fv
EDKII_BOOT_STAGE2_RECOVERY.Fv
EDKII_NVRAM.bin
EDKII_RECOVERY_IMAGE1.Fv
Flash-EDKII-missingPDAT.bin
RMU2.bin
RMU.bin
-d32
flag, as follows:mcramon@ubuntu:∼/$
./quarkbuild.sh -d32 GCC4$(GCCVERSION) QuarkPlatform
DEBUG_GCC4X
directory instead of the RELEASE_GCC4X
directory with same files.
mcramon@ubuntu:∼/Quark_EDKII_v1.0.2$
cd Build/QuarkPlatform/
mcramon@ubuntu:∼/BSP_1.0.4_T/Quark_EDKII_v1.0.2/Build/QuarkPlatform$
ls
DEBUG_GCC46 RELEASE_GCC46
DEBUG_GCC46
and RELEASE_GCC46
are the result of a debug and release compilation using GCC compiler version 4.6. It is necessary to simplify such directories using soft links, naming them DEBUG_GCC
and RELEASE_GCC
only because these are the names that the system image tools will search for.mcramon@ubuntu:∼/$
ln -s DEBUG_GCC46 DEBUG_GCC
mcramon@ubuntu:∼/$
ln -s RELEASE_GCC46 RELEASE_GCC
mcramon@ubuntu:∼/$
ls -l
total 8
lrwxrwxrwx 1 mcramon mcramon 11 Nov 21 20:21 DEBUG_GCC -> ../DEBUG_GCC46
lrwxrwxrwx 1 mcramon mcramon 13 Nov 21 20:21 RELEASE_GCC -> ../RELEASE_GCC46
Troubleshooting Compiling the Firmware
-
Python does not fetch the code . In this case, the first thing to do is check whether your Internet connection is working. You can try to test by opening a web browser or via a command line using a
wget
command like this:
Spider mode enabled. Check if remote file exists.
--2014-11-21 19:53:29--
http://example.com/
Resolving example.com (example.com)... 93.184.216.119, 2606:2800:220:6d:26bf:1447:1097:aa7
Connecting to example.com (example.com)|93.184.216.119|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1270 (1.2K) [text/html]
Remote file exists and could contain further links,
but recursion is disabled -- not retrieving.
∼/.subversion/servers
. Then search for the section [global]
and set your proxy configuration as shown in the following lines:[global]
http-proxy-host = <YOUR HOST IP>
http-proxy-port = <YOUR PORT NUMBER>
http-proxy-username = <YOUR USER NAME>
http-proxy-password = <YOUR PASSWORD>
-
A GCC compiler not supported . If you have a GCC compiler that is not supported, you can download and install one of the versions supported and change the link called
gcc
in the/usr/bin
directory to point to the old one. For example:
mcramon@ubuntu:∼/
cd /usr/bin
mcramon@ubuntu:∼/
sudo ln -s /usr/bin/gcc-4.6 gcc
Preparing layout.conf
mcramon@ubuntu:∼/BSP_1.0.4_T$
tar -zxvf spi-flash-tools_v1.0.1.tar.gz
mcramon@ubuntu:∼/BSP_1.0.4_T$
tar -zxvf sysimage_v1.0.1.tar.gz
mcramon@ubuntu:∼/BSP_1.0.4_T$
tar -zxvf grub-legacy_5775f32a+v1.0.1.tar.gz
mcramon@ubuntu:∼/BSP_1.0.4_T$
tar -zxvf quark_linux_v3.8.7+v1.0.1.tar.gz
mcramon@ubuntu:∼/BSP_1.0.4_T$
./sysimage_v1.0.1/create_symlinks.sh
See if we can: ln -s ./spi-flash-tools_* spi-flash-tools
Found spi-flash-tools_v1.0.1
+ ln -s spi-flash-tools_v1.0.1
spi-flash-tools
See if we can: ln -s ./Quark_EDKII_* Quark_EDKII
Found Quark_EDKII_v1.0.2
+ ln -s Quark_EDKII_v1.0.2
Quark_EDKII
See if we can: ln -s ./sysimage_* sysimage
Found sysimage_v1.0.1
+ ln -s sysimage_v1.0.1
sysimage
See if we can: ln -s ./meta-clanton_* meta-clanton
Found meta-clanton_v1.0.1
+ ln -s meta-clanton_v1.0.1
meta-clanton
See if we can: ln -s ./quark_linux_* quark_linux
Found quark_linux_v3.8.7+v1.0.1
+ ln -s quark_linux_v3.8.7+v1.0.1
quark_linux
See if we can: ln -s ./grub-legacy_* grub-legacy
Found grub-legacy_5775f32a+v1.0.1
+ ln -s grub-legacy_5775f32a+v1.0.1
grub-legacy
tar.gz
files.grub-legacy_5775f32a+v1.0.1
turns grub-legacy
, and the same process is done to the other directories, as you can see if you type ls -l
after the script execution.mcramon@ubuntu:∼/BSP_1.0.4_T$
ls -l
total 5292
-rw-r--r-- 1 mcramon mcramon 2657072 Nov 17 23:11 board_support_package_sources_for_intel_quark_v1.0.1.7z
-rw-r--r-- 1 mcramon mcramon 30720 Nov 17 22:54 BSP-Patches-and-Build_Instructions.1.0.4.tar
lrwxrwxrwx 1 mcramon mcramon 27 Nov 21 20:32
grub-legacy -> grub-legacy_5775f32a+v1.0.1
drwxr-xr-x 2 mcramon mcramon 4096 May 22 2014 grub-legacy_5775f32a+v1.0.1
-rw-rw-r-- 1 mcramon mcramon 192465 May 22 2014 grub-legacy_5775f32a+v1.0.1.tar.gz
lrwxrwxrwx 1 mcramon mcramon 19 Nov 21 20:32
meta-clanton -> meta-clanton_v1.0.1
drwxr-xr-x 9 mcramon mcramon 4096 Nov 18 21:58 meta-clanton_v1.0.1
-rw-rw-r-- 1 mcramon mcramon 517412 May 22 2014 meta-clanton_v1.0.1.tar.gz
drwxr-xr-x 2 mcramon mcramon 4096 Oct 20 13:31 patches
lrwxrwxrwx 1 mcramon mcramon 18 Nov 21 20:32
Quark_EDKII -> Quark_EDKII_v1.0.2
drwxr-x--- 21 mcramon mcramon 4096 Nov 21 18:48 Quark_EDKII_v1.0.2
drwxrwxr-x 6 mcramon mcramon 4096 Nov 21 18:40 Quark_EDKII_v1.0.2-svn_externals.repo
-rwxr-xr-x 1 mcramon mcramon 1502762 Nov 21 15:20 quark_edkii_v1.0.2.tar.gz
lrwxrwxrwx 1 mcramon mcramon 25 Nov 21 20:32
quark_linux -> quark_linux_v3.8.7+v1.0.1
drwxr-xr-x 2 mcramon mcramon 4096 May 22 2014 quark_linux_v3.8.7+v1.0.1
-rw-rw-r-- 1 mcramon mcramon 236544 May 22 2014 quark_linux_v3.8.7+v1.0.1.tar.gz
-rw-rw-r-- 1 mcramon mcramon 480 May 22 2014 sha1sum.txt
lrwxrwxrwx 1 mcramon mcramon 22 Nov 21 20:32
spi-flash-tools -> spi-flash-tools_v1.0.1
drwxr-xr-x 6 mcramon mcramon 4096 May 22 2014 spi-flash-tools_v1.0.1
-rw-rw-r-- 1 mcramon mcramon 219559 May 22 2014 spi-flash-tools_v1.0.1.tar.gz
lrwxrwxrwx 1 mcramon mcramon 15 Nov 21 20:32
sysimage -> sysimage_v1.0.1
drwxr-xr-x 9 mcramon mcramon 4096 May 22 2014 sysimage_v1.0.1
-rw-rw-r-- 1 mcramon mcramon 9876 May 22 2014 sysimage_v1.0.1.tar.gz
-rw-r--r-- 1 mcramon mcramon 2938 Nov 18 22:14 uart-reverse-8.patch
sysimage
directory bringing a configuration file that tells the “ingredients”—in other words, the files that will be used to compose the flash image and the version of the image.sysimage
file:mcramon@ubuntu:∼/BSP_1.0.4_T$
cd sysimage
mcramon@ubuntu:∼/BSP_1.0.4_T/sysimage$
ls -l
total 36
drwxr-xr-x 2 mcramon mcramon 4096 May 22 2014 config
-rwxr-xr-x 1 mcramon mcramon 2496 May 22 2014 create_symlinks.sh
drwxr-xr-x 2 mcramon mcramon 4096 May 22 2014 grub
drwxr-xr-x 2 mcramon mcramon 4096 May 22 2014 inf
-rw-r--r-- 1 mcramon mcramon 1488 May 22 2014 LICENSE
drwxr-xr-x 2 mcramon mcramon 4096 May 22 2014
sysimage.CP-8M-debug
drwxr-xr-x 2 mcramon mcramon 4096 May 22 2014
sysimage.CP-8M-debug-secure
drwxr-xr-x 2 mcramon mcramon 4096 May 22 2014
sysimage.CP-8M-release
drwxr-xr-x 2 mcramon mcramon 4096 May 22 2014
sysimage.CP-8M-release-secure
layout.conf
. This file must be changed to point to the correct “ingredients” of your build and the right version number.mcramon@ubuntu:∼/BSP_1.0.4_T$
./patches_v1.0.4/patch.sysimage.sh
sysimage.CP-8M-debug
for example—and open the layout.conf
file with the text editor of you preference before
running the patch_sysimage.sh
script. layout.conf
is shown in Listing 2-7.# WARNING: this file is indirectly included in a Makefile where it
# defines Make targets and pre-requisites. As a consequence you MUST
# run "make clean" BEFORE making changes to it. Failure to do so may
# result in the make process being unable to clean files it no longer
# has references to.
[main]
size=8388608
type=global
[MFH]
version=0x1
flags=0x0
address=0xfff08000
type=mfh
[Flash Image Version]
type=mfh.version
meta=version
value=0x01000105
[ROM_OVERLAY]
address=0xfffe0000
item_file=../../Quark_EDKII/Build/QuarkPlatform/PLAIN/DEBUG_GCC/FV/FlashModules/EDKII_BOOTROM_OVERRIDE.Fv
type=some_type
[signed-key-module]
address=0xfffd8000
item_file=config/SvpSignedKeyModule.bin
svn_index=0
type=some_type
in_capsule=no
# On a deployed system, the SVN area holds the last known secure
# version of each signed asset.
# TODO: generate this area by collecting the SVN from the assets
# themselves.
[svn-area]
address=0xfffd0000
item_file=config/SVNArea.bin
type=some_type
# A capsule upgrade must implement some smart logic to make sure the
# highest Security Version Number always wins (rollback protection)
in_capsule=no
[fixed_recovery_image]
address=0xfff90000
item_file=../../Quark_EDKII/Build/QuarkPlatform/PLAIN/
DEBUG_GCC
/FV/FlashModules/
EDKII_RECOVERY_IMAGE1.Fv
sign=yes
type=mfh.host_fw_stage1_signed
svn_index=2
# in_capsule=no
[NV_Storage]
address=0xfff30000
item_file=../../Quark_EDKII/Build/QuarkPlatform/PLAIN/
DEBUG_GCC
/FV/FlashModules/
EDKII_NVRAM.bin
type=some_type
[RMU]
address=0xfff00000
item_file=../../Quark_EDKII/Build/QuarkPlatform/PLAIN/
DEBUG_GCC
/FV/FlashModules/
RMU.bin
type=none_registered
[boot_stage1_image1]
address=0xffec0000
item_file=../../Quark_EDKII/Build/QuarkPlatform/PLAIN/
DEBUG_GCC
/FV/FlashModules/
EDKII_BOOT_STAGE1_IMAGE1.Fv
sign=yes
boot_index=0
type=mfh.host_fw_stage1_signed
svn_index=1
[boot_stage1_image2]
address=0xffe80000
item_file=../../Quark_EDKII/Build/QuarkPlatform/PLAIN/DEBUG_GCC/FV/FlashModules/
EDKII_BOOT_STAGE1_IMAGE2.Fv
sign=yes
boot_index=1
type=mfh.host_fw_stage1_signed
svn_index=1
[boot_stage_2_compact]
address=0xffd00000
item_file=../../Quark_EDKII/Build/QuarkPlatform/PLAIN/DEBUG_GCC/FV/FlashModules/
EDKII_BOOT_STAGE2_COMPACT.Fv
sign=yes
type=mfh.host_fw_stage2_signed
svn_index=3
[Ramdisk]
address=0xffa60000
item_file
=../../meta-clanton/yocto_build/tmp/deploy/images/image-spi-clanton.cpio.lzma
sign=yes
type=mfh.ramdisk_signed
svn_index=7
[LAYOUT.CONF_DUMP]
address=0xffcff000
type=mfh.build_information
meta=layout
[Kernel]
address=0xff852000
item_file
=../../meta-clanton/yocto_build/tmp/deploy/images/bzImage
sign=yes
type=mfh.kernel_signed
svn_index=6
[grub.conf]
address=0xff851000
item_file=
grub/grub-spi.conf
sign=yes
type=mfh.bootloader_conf_signed
svn_index=5
[grub]
address=0xff800000
item_file
=../../meta-clanton/yocto_build/tmp/deploy/images/grub.efi
sign=yes
fvwrap=yes
guid=B43BD3E1-64D1-4744-9394-D0E1C4DE8C87
type=mfh.bootloader_signed
svn_index=4
-
[Flash Image Version]: It is recommended that you make a simple change in the [Flash Image Version] because it brings version 0x01000105 in the value field. This means that when you boot your board, the version read will be 01.00.01.05, or simply 1.0.1, because 05 is omitted; and considering that the release of this example is based on 1.0.4, it is recommended to change to 0x01000400, which means 1.0.4. If you want to see the correct version number, this change is necessary.
-
[RamDisk]: This section needs to replace the string
image-spi-clanton.cpio.lzma
withimage-spi-galileo-clanton.cpio.lzma
, because if you check the images generated in/meta-clanton/yocto_build/tmp/deploy/images/
, the image generated is namedimage-spi-galileo.cpio.lzma
. Thus, this section should be as follows:
[Ramdisk]
address=0xffa60000
item_file=../../meta-clanton/yocto_build/tmp/deploy/images/image-spi-
galileo-clanton
.cpio.lzma
sign=yes
type=mfh.ramdisk_signed
svn_index=7
PLAIN
directories and pointing to valid paths.sysimage
brings the template with the old version because the tool did not require any changes since 1.0.1, and the template comes with the same version number.create_symlinks.sh
script.patch_sysimage.sh
script, the changes mentioned are automatically done in the layout.conf
files of each directory.Using the SPI Tool
spi-flash-tool
directory that you decompressed. It is used to create the capsule files and binary files with or without platform data.layout.conf
file, run the following command:mcramon@ubuntu:∼/$
../../spi-flash-tools/Makefile
-
Flash-missingPDAT.cap: This is the expected capsule file, absent of platform data, which you can flash to your Intel Galileo.
-
Flash-missingPDAT.bin: This is a binary file absent of platform data necessary to generate SPI images, which is discussed in the “Creating SPI Images with Platform Files” section.
-
FVMAIN.fv: This file is used to recover your board if it does not boot anymore. This is discussed in the “What to Do If Intel Galileo Bricks" section of this chapter.
Flashing the Capsule Files
Flashing the Capsule File with the Intel Arduino IDE
Flash-missingPDAT.cap
file in a specific folder of the IDE, as explained in the “Updating the Firmware with a Different Firmware” section of Chapter 3. This procedure only requires usage of the regular USB data cable, which prevents copying the capsule files with a micro SD card or a USB pen driver.Flashing the Capsule File with a Linux Terminal Shell
/sys/firmware/board_data/flash_version
. It possible to check using a Linux terminal shell and typing the following command:root@clanton:∼# cat /sys/firmware/board_data/flash_version
0x01000105
Flash-missingPDAT.cap
that you created in the previous sections to a micro SD card or a pen driver properly formatted with FAT or FAT32 in a single partition, as described in the “Booting from SD Card” section of this chapter.# insmod /tmp/0.7.5/efi_capsule_update.ko
Or
# insmod /tmp/0.8.0/efi_capsule_update.ko
# modprobe efi_capsule_update
# modprobe sdhci-pci
# modprobe mmc-block
# mkdir /lib/firmware
# cd /media/mmcblk0p1/
# cp Flash-missingPDAT.cap /lib/firmware/Flash-missingPDAT.cap
# echo -n Flash-missingPDAT.cap > /sys/firmware/efi_capsule/capsule_path
# echo 1 > /sys/firmware/efi_capsule/capsule_update
# reboot
reboot
; otherwise, the process to update the capsule file will not work.Flashing the Capsule File with a UEFI Shell
-
The
Flash-missingPDAT.cap
file that must be present in the same directory of yourlayout.conf
. -
The
CapsuleApp.efi
file that was generated when you compiled the EDKII firmware. It must be present in the./Quark_EDKII/Build/QuarkPlatform/PLAIN/DEBUG_GCC/FV/Applications/
directory or the./Quark_EDKII/Build/QuarkPlatform/PLAIN/RELEASE_GCC/FV/ Applications/
directory, depending whether you compile using release or debug flags as discussed in the “Compiling the EDKII Firmware” section of this chapter. -
You will need serial cables to open the terminal shell, as discussed in the “Preparing Your Cables” section in Chapter 1. This will allow you to debug the board using a serial audio jack cable for Intel Galileo or a FTDI cable for Intel Galileo Gen 2.
-
You need to know how to use some serial terminal software. Read the “Testing Your Cables” section in Chapter 1 to understand how to use putty for Windows or minicom for Linux or Mac OSX. However, you also need to configure the serial software to recognize special characters from your keyboard. For putty, click the left panel, Terminal ➤ Keyboard, and select the SCO box from the Functions and Keys and Keypad tab.
-
Finally, you need a micro SD card or a USB pen driver.
CapsuleApp.efi
and Flash-missingPDAT.cap
to the micro SD card.ls
, as shown in Figure 2-12.fs0:\>
CapsuleApp.efi Flash-missingPDAT.cap
CapsuleApp: SecurityAuthenticateImage 0xD504410found.
CapsuleApp: creating capsule descriptors at 0xF0DE510
CapsuleApp: capsule data starts at 0xD504410 with size 0x6F6190
CapsuleApp: capsule block/size 0xD504410/0x6F6190
Flashing the Capsule File with the Firmware Update Tool
https://communities.intel.com/community/makers
to receive more information about this tool, as many other updates will be available.Creating SPI Images Flash Files
platform-data-patch.py
in the .../spi-flash-tools/platform-data
directory. The only thing that this script does is patch the binaries with that platform data configuration file.# Every module contains:
# [unique name]
# id=decimal integer, data type identifier
# desc=string, short description of a data; max 10 characters
# data.value=[ABC | CAFEBEBA | xyz abc | /path/to/file ]
# data.type=[hex.uint[8/16/32/64] | hex.string | utf8.string | file]
# ver=decimal integer, version number; if not specified defaults to 0
# WARNING: the platform type data.value MUST match the MRC data.value below
[Platform Type]
id=1
desc=PlatformID
data.type=hex.uint16
# ClantonPeak 2, KipsBay 3, CrossHill 4, ClantonHill 5, KipsBay-fabD 6, GalileoGen2 8
data.value=2
# WARNING: the MRC data.value MUST match the platform type data.value above
[Mrc Params]
id=6
ver=1
desc=MrcParams
data.type=file
data.value=MRC/clantonpeak.v1.bin
#data.value=MRC/kipsbay.v1.bin
#data.value=MRC/crosshill.v1.bin
#data.value=MRC/clantonhill.v1.bin
#data.value=MRC/kipsbay-fabD.v1.bin
#data.value=MRC/GalileoGen2.bin
# If you are developing MRC for a new system you can alternatively
# inline the value like this:
# data.type=hex.string
# data.value=00000000000000010101000300000100010101017C9200001027000010270000409C000006
# The unique MAC address(es) owned by each device are typically found
# on a sticker. You must find it(them) and change the bogus values
# below.
[MAC address 0]
id=3
desc=1st MAC
data.type=hex.string
data.value=FFFFFFFFFF00
[MAC address 1]
id=4
desc=2nd MAC
data.type=hex.string
data.value=02FFFFFFFF01
galileo-platform-data.ini
—and open this file in the text editor of your preference.# ClantonPeak 2, KipsBay 3, CrossHill 4, ClantonHill 5, KipsBay-fabD 6, GalileoGen2 8
KipsBay-fabD
.
[Platform Type]
id=1
desc=PlatformID
data.type=hex.uint16
# ClantonPeak 2, KipsBay 3, CrossHill 4, ClantonHill 5, KipsBay-fabD 6, GalileoGen2 8
data.value=8
[MAC address 0]
id=3
desc=1st MAC
data.type=hex.string
data.value=984FEE014C6B
mcramon@ubuntu:∼/$
./platform-data-patch.py --help
Usage: platform-data-patch.py
Options:
--version show program's version number and exit
-h, --help show this help message and exit
-i ORIGINAL_IMAGE
, --original-image=ORIGINAL_IMAGE
input flash image [default: Flash-missingPDAT.bin]
-p INPUT_FILE,
--platform-config=INPUT_FILE
configuration (INI) file [default: platform-data.ini]
-n MODIFIED_IMAGE,
--name=MODIFIED_IMAGE
output flash image [default: Flash+PlatformData.bin]
-u, --undefined-order
By default, items are put in the same order as they
come in the config file. However ordering requires
python 2.7 or above.
-i
indicates that the input capsule file, -p
, is the platform-data
file; -n
is the name of your output file; and -u
must be used only if your version of Python is lower than 2.7. So, before using this script, check which Python version is installed on your computer by typing python --version
on your console to determine if the -u option must be used or not. If you have a recent version of Python, you just need to run the script.cool_binary.bin
and the input files were the ones created as examples in this chapter../platform-data-patch.py -i ../../sysimage/sysimage.CP-8M-debug/Flash-missingPDAT.bin -p galileo-platform-data.ini -n cool_binary.bin
Type '0' for 'ClantonPeakSVP' [PID 2]
Type '1' for 'KipsBay' [PID 3]
Type '2' for 'CrossHill' [PID 4]
Type '3' for 'ClantonHill' [PID 5]
Type '4' for 'Galileo' [PID 6]
Type '5' for 'GalileoGen2' [PID 8]
Flashing Using an SPI Flash Programmer
http://www.dediprog.com/pd/spi-flash-solution/sf100
.http://www.flashrom.org/Flashrom
and using the following command line:flashrom -p dediprog -r biosimage.rom
https://communities.intel.com/docs/DOC-21822
), you will notice that Intel Galileo and Intel Galileo Gen 2 uses the same type of memory, W25Q64FV, as shown in Figure 2-16. Just select the write memory and click the OK button.What to Do If Intel Galileo Bricks
-
You lost power during the flash.
-
The SPI programmer flashed some part of the memory incorrectly, corrupting the SPI, and you could not detect the error because you did not verify.
-
You made a mistake in the
layout.conf
file. -
You patched the binaries, declaring a wrong board model in the platform data. For example, you have an Intel Galileo and you incorrectly modified the platform data to Intel Galileo Gen 2.
FVMAIN.fv
, created with SPI flash tool from the “Using the SPI Tool” section of this chapter.FVMAIN.fv
to a USB pen drive.