We went through the software specifications of Intel Galileo in the previous section and booted Intel Galileo with the Linux image on its SPI flash.
In this section, we are going to cover how to build a customized image for Intel Galileo with some additional software packages using the Yocto Project, and we will boot Intel Galileo from the microSD card with our new Linux image.
The Yocto Project is an open source project that helps embedded Linux developers by providing a set of tools such as Poky to ease the customization of Linux filesystems, building kernel images. This project uses a folder structure to store the metadata of the build information of individual software projects. Each software application or library has a metadata file called recipes
with the .bb
and .bbclass
files. A quick start guide for developers is available at http://www.yoctoproject.org/docs/current/yocto-project-qs/yocto-project-qs.html, where you can get the basics of the Yocto Project.
You will also learn some basics of the Yocto Project to build and customize Linux filesystems for Intel Galileo.
There are prebuilt SD card images for Intel Galileo; you can easily get them from the Intel download page at https://communities.intel.com/docs/DOC-22226.
Learning about the build process will teach you how to customize Linux for future needs. Before that, the following prerequisites are needed:
$ sudo apt-get install p7zip
A good way to deal with the build process and all the mess created is to create a unique folder in our home
directory, such as /home/onur/galileo_build
, and do all the build work in that directory. I will refer to our build in the directory as BUILD_DIR
.
You need to follow these steps to build a Linux filesystem:
$ cd /home/onur/galileo_build $ mv ~/Downloads/board_support_package_sources_for_intel_quark_v1.0 .1.7z . $ mv ~/Downloads/BSP-Patches-and- Build_Instructions.1.0.4.tar.bz2 . $ 7z x board_support_package_sources_for_intel_quark_v1.0.1.7z
BSP includes packages for the layers of software for Intel Galileo. Grub OS Loader, Linux Filesystem build files for Yocto Project, EDKII (Firmware for Quark), Linux Kernel for Intel Quark, SPI-Flash tools, and System Image files are the packages required by developers to rebuild and reuse. Our focus will be on the meta-clanton_v1.0.1.tar.gz
file to create the Linux filesystem to boot with the SD card.
The board_support_package_sources_for_intel_quark_v1.0.1.7z
file includes the following compressed files:
grub-legacy_5775f32a+v1.0.1.tar.gz
meta-clanton_v1.0.1.tar.gz
Quark_EDKII_v1.0.1.tar.gz
quark_linux_v3.8.7+v1.0.1.tar.gz
spi-flash-tools_v1.0.1.tar.gz
sysimage_v1.0.1.tar.gz
sha1sum.txt
BSP-Patches-and-Build_Instructions
file includes a folder called patches
. It has a number of patches to apply the Yocto Project metadata (recipe
) .bb
files:$ tar xvf BSP-Patches-and-Build_Instructions.1.0.4.tar.bz2
meta-clanton_v1.0.1
directory:$ tar xvf meta-clanton_v1.0.1.tar.gz
It is highly recommended that you apply patches inside the extracted patches
folder that comes along with the BSP_Patches_and_Instructions
file. Instructions are stored in the patches/patches.txt
file. If you don't apply the patches before starting the build process, you are highly likely to get errors.
$ sudo apt-get install git diffstat texinfo gawk chrpath file build-essential gcc-multilib chrpath
meta-clanton_v1.0.1
folder to start the build process:$ cd $BUILD_DIR/meta-clanton_v1.0.1
This is where all the metadata is placed for building Linux filesystems. After applying the patches, we can start executing the scripts to start building:
setup.sh
script in the meta-clanton_v1.0.1
folder to get the required external sources. It will also create the folder yocto_build
with the required configuration files to define metadata layers for the Yocto build tool BitBake:$ ./setup.sh
$ source poky/oe-init-build-env yocto_build
After you initialize the environment variables, you will be redirected to the yocto_build
folder. This is the folder where all the downloaded sources and the output of the build process will be copied.
Now we are ready to start the build process with the Yocto Project command tool BitBake.
There is already a metadata file defined to build a full image, which includes many open source projects such as Node.js, OpenCV, and additional kernel modules to support mini PCI-E Wi-Fi cards.
$ bitbake image-full-galileo
Loading cache: 100% |##########################################################################################################################################################################################################| ETA: 00:00:00 Loaded 1617 entries from dependency cache. Build Configuration: BB_VERSION = "1.18.0" BUILD_SYS = "x86_64-linux" NATIVELSBSTRING = "Ubuntu-12.04" TARGET_SYS = "i586-poky-linux-uclibc" MACHINE = "clanton" DISTRO = "clanton-tiny" DISTRO_VERSION = "1.4.2" TUNE_FEATURES = "m32 i586" TARGET_FPU = "" meta meta-yocto meta-yocto-bsp = "clanton:d734ab491a30078d43dee5440c03acce2d251425" meta-intel = "clanton:048def7bae8e3e1a11c91f5071f99bdcf8e6dd16" meta-oe = "clanton:13ae5105ee30410136beeae66ec41ee4a8a2e2b0" meta-clanton-distro meta-clanton-bsp = "<unknown>:<unknown>" Currently 12 running tasks (179 of 2924): 0: uclibc-initial- 0.9.33+gitAUTOINC+946799cd0ce0c6c803c9cb173a84f4d607bde350- r8.4 do_unpack (pid 32309) 1: binutils-cross-2.23.1-r3 do_unpack (pid 32304) 2: linux-libc-headers-3.8-r0 do_fetch (pid 32307) 3: gcc-cross-initial-4.7.2-r20 do_fetch (pid 32308) 4: libmpc-native-0.8.2-r1 do_compile (pid 32305) 5: python-native-2.7.3-r0.1 do_unpack (pid 32316) 6: uclibc- 0.9.33+gitAUTOINC+946799cd0ce0c6c803c9cb173a84f4d607bde350- r8.4 do_unpack (pid 32310) 7: elfutils-native-0.148-r11 do_compile (pid 32314) 8: file-native-5.13-r0 do_compile (pid 32315) 9: readline-native-6.2-r4 do_configure (pid 32311) 10: openssl-native-1.0.1h-r15.0 do_install (pid 32312) 11: attr-native-2.4.46-r4 do_configure (pid 32313)
The build process can take around 2 hours to finish, depending on the processing power of your host machine.
The build process will start by parsing recipes in the board's support package and will fetch the source code, configure, build, and install on the final Linux filesystem image.
If everything goes well and the build process finishes successfully, all the required files will be created in the $BUILD_DIR/meta_clanton_v1.0.1/yocto_build/tmp/deploy/images
folder to be used for your SD card.
When the build process is successful, you can go ahead and copy the required files onto your microSD card to boot with Intel Galileo.
First, you need a microSD card; Intel Galileo supports SD cards up to 32 GB in capacity. Format your microSD card as FAT32 for first-time use and then copy the following files to your microSD card:
/dev/sdd
or /dev/mmcblk0
should be assigned to it. You can use device messages (the dmesg
command) to check the assigned device file for the SD card. Run the dmesg
command before and after you have attached the SD card on your host PC terminal. Then, you can see the assigned device file. In this section, we will use /dev/sdX
to indicate the SD card's device file:$ sudo mkfs.msdos /dev/sdX
$ sudo mount /dev/sdX /mnt/sdcard
$ cd $BUILD_DIR/meta- clanton_v1.0.1/yocto_build/tmp/deploy/images/ $ cp image-full-galileo-clanton.ext3 core-image-minimal- initramfs-clanton.cpio.gz bzImage grub.efi -t /mnt/sdcard $ cp –r boot/ -t /mnt/sdcard
The image-full-galileo-clanton.ext3
file includes the Linux root filesystem. The bzImage
file is the Linux kernel image. The core-image-minimal-initramfs-clanton.cpio.gz
file is the initial RAM file system. grub.efi
is the file, and GRUB/UEFI
is the firmware for Intel Galileo. The boot
folder includes the GRUB configuration.
$ sudo unmount /mnt/sdcard
Connect the serial cable, as shown in the previous section, and power up Intel Galileo. When Intel Galileo is booting from the SD card, an LED starts to blink. This is the LED on which the SD card is writing.
When you are prompted to log in, just like when you booted the SPI image in the previous section, you can log in with the root user and wander around the additional installed packages with the SD image.
An advantage of using an SD card instead of using an SPI flash image is that you will have more storage, so you can install more software.
Created files are also not volatile on an SD card; they will not be removed when you reboot the board. If you are using the Intel Galileo board from the SPI flash image, it will remove all the created files when you reboot the board.
While booting from the SD card, you may encounter problems. If the version of firmware on the Intel Galileo board and the BSP version that you build on the Linux filesystem don't match, the board doesn't boot the SD card. You can easily see this as the SD card's LED doesn't blink.
Check whether you formatted the SD card correctly to FAT32 and the files have been copied correctly. If the SD card format and files are not corrupted, it is suggested that you upgrade the firmware on the Intel Galileo board you have, as follows:
/dev/ttyACM0
. You can check the device messages (dmesg
) to check whether Intel Galileo is connected correctly.$ tar xvf arduino-linux64-1.0.4.tgz
arduino-linux64-1.0.4.tgz
folder and run the Arduino IDE
executable with sudo
:$ cd arduino-linux-1.0.4.tgz
If the firmware on your device has a lower version, the Arduino IDE will prompt you to upgrade. Click on OK to upgrade the firmware and follow the instructions. This should take approximately 5 to 10 minutes. The Arduino IDE will prompt when the upgrade has been successfully installed.
We have gone through the steps to get the board's support packages and to build the Linux kernel as well as the filesystem. Since we are going to develop and build applications for Intel Galileo, we need an SDK to compile and build.
The Yocto Project allows you to easily create the SDK for embedded devices, similar to creating a filesystem. We need to run one more command right after we build the filesystem.
All the commands used to build an SDK are similar to the commands used to build a filesystem, but only the last command changes to create a toolchain, as follows:
$ bitbake image-full-galileo –c populate_sdk
After the successful execution of the populate_sdk
command, the SDK installer will be deployed into the $BUILD_DIR/meta_clanton_v1.0.1/yocto_build/tmp/deploy/sdk
folder:
$ ls tmp/deploy/sdk clanton-tiny-uclibc-x86_64-i586-toolchain-1.4.2.sh
In this example, BitBake created an image for a 64-bit host; if you build on a 32-bit host, BitBake will create a toolchain for a 32-bit architecture.