Following content is quick start guide for, Someone looking for understanding working of Embedded Linux at the same time practical consideration involved for getting the system online.
2. License
• Following content is licensed under -
• Creative Commons Attribution Share Alike 4.0 International
https://creativecommons.org/licenses/by-sa/4.0/
https://creativecommons.org/licenses/by-sa/4.0/legalcode
3. Disclaimer
• Following content is no way meant for begginers, as it contains several steps,
which if not performed carefully can render the host system to halt.
• Steps mentioned here, are performed on a particular host system/distribution,
so these steps might require some tweaking. Which won’t require much effort
if you understand the core idea/concept behind Embedded GNU/Linux.
• As possible, every step mentioned is detailed with a thorough introduction
regarding big picture behind it. More consideration on details will be given on
future works.
• Corrections, feedback, enhancements are always welcome.
4. Objectives
● Understanding the typical design workflow for embedded GNU/Linux target
system.
● Understanding building blocks of an embedded GNU/Linux target system.
● Understanding the beaglebone black hardware.
● Understanding Buildroot tool, design & comparison.
● Using Buildroot for creating a embedded GNU/Linux distribution.
● Getting ready the Beaglebone black hardware for first boot of our crafted
GNU/Linux distribution.
● Learning Partitioning & packaging techniques.
5. Contents
● Prerequisites
● Embedded GNU/Linux introduction & designing paradigms
● Buildroot introduction, design, comparison & setup
● Crafting our first distribution using buildroot
● Beaglebone black introduction & setup
● First boot & post booting checks
● Future Works
● References
6. Dumps required
● Buildroot from https://buildroot.org/download.html- download latest stable
tarball.
● Download prebuilt rootfs(Optional) from.
http://downloads.yoctoproject.org/releases/yocto/yocto-
2.2/machines//beaglebone/core-image-minimal-beaglebone.tar.bz2.
● Go through the beagleboard page from https://beagleboard.org/getting-
started.
7. Prerequisites- Setting up the Host System
● Familiarity with GNU/Linux development process.
● You can use any GNU/Linux distribution as your host system, as long as it
provide basic development tools with stable version. Otherwise you have
manually fetch them. For this presentation I’ve used Ubuntu.
● Tools required- current GCC Compiler, GNUMake & GUI Configuration
supporting libraries--libncurses-dev(for menuconfig!! Sounds familiar!).
8. Embedded GNU/Linux introduction & designing
paradigms
● A typical embedded GNU/Linux system comprises of following sub-systems –
• Toolchains
• Bootloader
• GNU/Linux kernel
• Root filesystem
9. Embedded GNU/Linux introduction & designing
paradigms
● Embedded Linux - Operating systems based on the GNU/Linux kernel, designed &
tailored to be used in embedded systems(Constrained systems as compared to
desktop's).
● A developer's target is, to configure,build & Integrate these individual sub-
systems according to our target hardware platform, which in following case
is Beaglebone black board.
10. Designing paradigms
Basically two paradigms exist for designing embedded GNU/Linux system exist-
● Designing & building the entire distribution(all subsystems) from scratch. That is
building right from source code itself.
● Intelligently Automating the in-between process of building sub-systems,
without losing the configurability of individual the sub-system. & Finally
Integrating all sub-systems to a complete embedded distribution with the help of
tools available at our disposal.
● In this presentation, we'll follow the second approach using Buildroot as our
helping tool. We'll be designing our distribution using Buildroot & finally testing
on the beaglebone black as target board.
11. Buildroot introduction, design, comparison &
setup
● Buildroot - Buildroot is a simple, efficient and easy-to-use tool to generate
embedded GNU/Linux systems through cross-compilation. In essence,
Buildroot is a set of Makefiles & Configuration files to automate the entire
process of generating embedded GNU/Linux system.
● Other tools available – YoctoProject,OpenEmbedded,OpenWrt,OpenBricks.
● Buildroot is specifically targeted for embedded & constrained systems as
compared to other tools.
12. Buildroot design, comparison & setup
Why Buildroot-
● Buildroot is set of open source Makefiles & Configuration files, organized in
a manner to provide fully configurable environment for each & every sub-
system mentioned above.
● A fully configurable environment for individual sub-system, at the same time
facilitates the configuration saving feature for an build that enables &
enhance the entire development process.
● Favours both approaches, building from scratch & Integrating individual
subsystems with an additional advantage of automating entire process.
13. Design of Buildroot
● Buildroot is based upon Kconfig for configuration interface, which is also the
same system used in GNU/Linux configuration interface. Therefore a plus
point for GNU/Linux developer.
● Smaller code size as compared to other available tools, since Buildroot
specifically targets embedded systems. This feature enable the developer to
hack into the source code of Buildroot & tailor it according to their target
requirements.
14. Design of Buildroot
● Buildroot is designed to automatically fetch the latest stable source code of
the sub-systems over the Internet without any user intervention. We can
also configure Buildroot to use specified sources if available offline by
changing configuration to fetch from a user directory.
● After setting up the sources Buildroot will automatically extract, patch,
configure,compile and install the selected components, taking care of
following the necessary dependencies while building the target.
15. Design of Buildroot
● After a successful build Buildroot will dump all the generated target to a
Output/images directory of the Buildroot source. These may include,
depending upon the configuration setup, root filesystem, bootloader, kernel.
16. Crafting our first distribution using Buildroot
● We'll be targeting our distribution for Beaglebone black board with U-Boot as
the bootloader.
● We'll direct Buildroot to download source of sub-systems & other
intermediate process & getting ready for build. This may take some time
depend upon your Internet connection.
● In this presentation we'll target to a minimalistic kernel configuration &
default configuration for bootloader with zImage & first phase bootloader &
uboot.img image. These are essential for our boot partition discussed later.
17. Crafting our first distribution using Buildroot
● We'll use an ext4 type rootfs with Busybox as initscript & glibc target C
library.
● You can customize everything, if you don't want to build a sub-system just
unselect it in GUI configuration menu, or want to tune a sub-system. Once
you've booted for the first time, rest configuration expertise is just a matter
of time.
● run make mrproper.
● run make beaglebone_defconfig - a default Configuration for beaglebone
board. You can also explore the configs directory of Buildroot sources to
find available default configuration of other boards.
18. Crafting our first distribution using buildroot
● run make ARCH=arm menuconfig & save the configuration.
● run make. do not use -j4 ot -jn like we do during kernel compilation,
Buildroot will implicitly take care of running parallel jobs during entire build
process.
● After a successful build, you'll see images of the sub-systems configured,
in Output/images directory. In our case MLO, u-boot.img, zImage and
am335x-boneblack.dtb.
19. Beaglebone black introduction & setup
● BeagleBone Black is a low-cost, community-supported development
platform for developers and hobbyists.
Hardware features-
● Processor - Sitara AM3359AZCZ1001GHz, 2000 MIPS, Cortex-A8,
Microarchitecture- ARMv7-A.
● RAM - 512MB DDR3L 606MHZ.
21. Beaglebone black introduction & setup
● Serial Port - UART0 access via 6 pin 3.3V TTL Header. we'll use UART
interface at boot time to monitor possible crashing of the system.
● SD/MMC - Connector microSD , 3.3V. We'll using this interface for external
booting purposes, we'll put our distribution in a SD card & direct board to
boot from external SD card.
● User Input - Reset Button, Power Button, Boot Button. We'll use Boot Button
for redirection of boot sequence of board. i.e boot from SD card.
22. Partitioning process
We had to get ready our partitions process for getting ready for our first boot.
● Unmount all partitions of your SD card (they are generally automatically
mounted by Ubuntu) & before Unmounting close any window or active
terminal accessing it.
● Erase the beginning of the SD card to ensure that the existing partitions are
not going to be mistakenly detected:
● sudo dd if=/dev/zero of=/dev/sdb. Use mmcblk0 or sdc instead of sdb if
needed. (It's distribution dependent). In any case do not run any root
privileged command on sda partitions.
23. Partitioning process
● Create the two partitions.
● Start the cfdisk tool, for that:
sudo cfdisk /dev/sdb
● Chose the dos partition table type
● Create a first small partition (16 MB or 32 MB), primary, with type e (W95 FAT16)
and mark it bootable.
● Create a second partition, also primary, with the rest of the available space, with
type 83 (Linux).
24. Partitioning process
● Exit cfdisk
● Format the first partition as a FAT16 filesystem:
sudo mkfs.vfat -F 16 -n boot /dev/sdb1. Use sdc1 or mmclbk0p1 instead of sdb if
needed.
● Format the second partition as an ext4 filesystem:
sudo mkfs.ext4 -L rootfs -E nodiscard /dev/sdb2. Use sdc2 or mmcblk0p2 instead
of sdb2 if needed.
25. Partitioning process
After this, remove memory card & reinsert it. you can see to partition boot &
rootfs mounted, if not mounted mount them.
Flashing-
● Copy the MLO, u-boot.img, zImage and am335x-boneblack.dtb files from
output/images/ to the boot partition of the SD card.
● Extract the rootfs.tar file to the rootfs partition of the SD card, using:
sudo tar -C /media/<user>/rootfs/ -xf output/images/rootfs.tar.
26. Partitioning process
● Create a file named uEnv.txt in the boot partition. This file should contain
the following lines:
bootpart=0:1
bootdir=
bootargs=console=ttyyO0, 115200n8 root=/dev/mmcblk0p2 rw rootfstype=ext4 rootwait
uenvcmd=run loadimage;run loadfdt;printenv bootargs;bootz ${loadaddr} - ${fdtaddr};
27. First boot & post booting checks
● You can use USB cable to plug your Beagle into your computer. This will both
power the board and provide a development interface. BeagleBone Black will
boot Linux from the on-board 4GB eMMC. BeagleBone is provided with a pre-
configured 4GB microSD card with an prebuilt image.
● The Beaglebone serial connector is exported on the 6 male pins close to one of
the 48 pins headers. Use your special USB to Serial adapter mentioned in
datasheet(refer pin configuration of board next slide).
● Once the USB to Serial connector is plugged in, a new serial port should appear:
/dev/ttyUSB0. We can also see this device appear by looking at the output of
dmesg or cat /dev/ttyUSB0.
29. First boot & post booting checks
● To communicate with the board through the serial port, install a serial
communication program, we'll use Picocom.
● Install picocom on your host distribution.
● Now, we can run picocom -b 115200 /dev/ttyUSB0 through terminal, to start
serial communication on /dev/ttyUSB0, with a baudrate of 115200.
● For exiting picocom, press [Ctrl][a] followed by [Ctrl][x].
30. First boot & post booting checks
● Insert the SD card in the BeagleBone Black. Push the S2 button (located
near the USB host connector) and plug the USB power cable while holding
S2. Pushing S2 forces the BeagleBone Black to boot from the SD card
instead of from the internal eMMC.
● You should see your system booting. Make sure that the U-Boot SPL and U-
Boot version and build dates match with the current date. Do the same
check for the Linux kernel.
31. First boot & post booting checks
● Login as root on the BeagleBone Black, and explore the system. Run ps to
see which processes are running, and look at what Buildroot has generated
in /bin, /lib, /usr and /etc.
● It will take less than 10 seconds for booting the system. If boot is successful
we'll be prompted with the terminal.
● Try following commands uname-r, uname -a & explore the rootfs.
● Following is a snapshot after a successful boot.
33. Future Works
● Further works will focus on the process that is being automated by the
Buildroot, therefore hiding peculiar details of the entire process.
● We'll also focus on the technique mentioned above, but wasn't topic of this
presentation, Building distribution from scratch. This topic will ensure &
reveal all the peculiar details & steps of the entire process, which are
certainly accomplished behind the scenes by Buildroot.
● And also Designing a more generic distribution using YoctoProject will be
done.
34. References & Acknowledgements
● Thanks to Buildroot community, Beagleboard community & other open
source community work which might be utilized in this work.
● Thanks to https://ubuntu.com, Google slides,Microsoft PowerPoint.
● A token of gratitude towards Mr. Rajesh Sola Cdac, Acts for mentoring part.
● Thanks to Cdac, Acts for Hardware courtesy.