SlideShare ist ein Scribd-Unternehmen logo
1 von 52
Downloaden Sie, um offline zu lesen
Building Embedded Linux
(Full Tutorial for ARM)
Information Technology Institute (ITI)
Sherif Mousa
Embedded Linux @ Information Technology Institute 1
2Embedded Linux @ Information Technology Institute
Using Linux in an
embedded project is easier, and
more fun, than ever 
Tips for Linux
• Read instructions and tips carefully.
• Always read error messages carefully, in
particular the first one which is issued.
• Never stay stuck with a strange problem more
than 5 minutes.
• If you ran commands from a root shell by
mistake, your regular user may no longer be able
to handle the corresponding generated files. In
this case, use the chown –R command to give the
new files back to your regular user.
3Embedded Linux @ Information Technology Institute
Tips for Linux
• You should only use the root user for
operations that require super-user privileges,
such as: mounting a file system, loading a
kernel module, changing file ownership,
configuring the network. Most regular tasks
(such as downloading, extracting sources,
compiling...) can be done as a regular user.
4Embedded Linux @ Information Technology Institute
5
Hardware for Linux systems
Embedded Linux @ Information Technology Institute
Processor and Arch.
• The Linux kernel and most other architecture-
dependent component support a wide range
of 32 and 64 bits architectures
– x86 and x86-64, as found on PC platforms, but
also embedded systems (multimedia, industrial)
– ARM, with hundreds of different SoC (multimedia,
industrial)
– PowerPC (mainly real-time, industrial
applications)
6Embedded Linux @ Information Technology Institute
RAM & Storage
• RAM: a very basic Linux system can work within 8
MB of RAM, but a more realistic system will
usually require at least 32 MB of RAM. Depends
on the type and size of applications.
• Storage: a very basic Linux system can work
within 4 MB of storage, but usually more is
needed.
– Flash storage is supported, both NAND and NOR flash,
with specific filesystems.
– Block storage including SD/MMC cards and eMMC.
7Embedded Linux @ Information Technology Institute
Communication
• The Linux kernel has support for many common
communication busses
– USB
– SPI (Serial Peripheral Interface)
– CAN (Controller Area Network)
– 1-wire
• And also extensive networking support
– Ethernet, Wi, Bluetooth, CAN, etc.
– IPv4, IPv6, TCP, UDP, etc.
– Firewalling, advanced routing.
8Embedded Linux @ Information Technology Institute
Types of HW platforms
• Evaluation platforms from the SoC vendor. Usually
expensive, but many peripherals are built-in. Generally
unsuitable for real products.
• Component on Module, a small board with only
CPU/RAM/ash and a few other core components, with
connectors to access all other peripherals. Can be used
to build end products for small to medium quantities.
• Custom platform. Schematics for evaluation boards or
development platforms are more and more commonly
freely available, making it easier to develop custom
platforms. (Open Hardware)
9Embedded Linux @ Information Technology Institute
Tips for HW
• Make sure the hardware you plan to use is
already supported by the Linux kernel, and has an
open-source bootloader.
• Having support in the official versions of the
projects (kernel, bootloader) is a lot better:
quality is better, and new versions are available.
• Some SoC vendors and/or board vendors do not
contribute their changes back to the mainline
Linux kernel.
10Embedded Linux @ Information Technology Institute
11
Software Components
Embedded Linux @ Information Technology Institute
Software Components
• Cross-compilation ToolChain
• Bootloader
• Linux Kernel
• System libraries (C library)
• Filesystem with other libraries & apps.
12Embedded Linux @ Information Technology Institute
Embedded Linux Output
• Board Support Package development
– A BSP contains a bootloader and kernel with the
suitable device drivers for the targeted hardware
• System integration
– Integrate all the components, bootloader, kernel,
third-party libraries and applications and in-house
applications into a working system
• Development of applications
– Normal Linux applications, but using specially chosen
libraries
13Embedded Linux @ Information Technology Institute
Cross-ToolChain
14Embedded Linux @ Information Technology Institute
X86 Binary Target Binary
X86
X86 Target CPU
Source Code
Native ToolChain Cross ToolChain
15
Where to get Cross-ToolChain
Embedded Linux @ Information Technology Institute
Where to get Cross-ToolChain
• http://elinux.org/Toolchains
• Codesourcery, ready-made
– http://www.mentor.com/embedded-
software/codesourcery
• Linaro, ready made
– http://www.linaro.org/
• Buildroot, tool to build
– http://www.buildroot.net/
• Crosstool-NG, tool to build
– http://crosstool-ng.org/
16Embedded Linux @ Information Technology Institute
17
Building Cross-ToolChain
Embedded Linux @ Information Technology Institute
Cross-ToolChain
• Three machines must be distinguished when
discussing toolchain creation
– The build machine, where the toolchain is built.
– The host machine, where the toolchain will be
executed.
– The target machine, where the binaries created
by the toolchain are executed.
18Embedded Linux @ Information Technology Institute
Cross-ToolChain components
19Embedded Linux @ Information Technology Institute
GDB (optional)
GCC CompilerC/C++ libs
binutils Kernel Headers
Binutils
• Binutils is a set of tools to generate and
manipulate binaries for a given CPU architecture
– as, the assembler, that generates binary code from
assembler source code
– ld, the linker
– ar, ranlib, to generate .a archives, used for libraries
– objdump, readelf, size, nm, strings, to inspect
binaries. Very useful analysis tools!
– strip, to strip useless parts of binaries in order to
reduce their size
• http://www.gnu.org/software/binutils/
20Embedded Linux @ Information Technology Institute
Kernel Headers
• The C library and compiled programs needs to
interact with the kernel
– Available system calls and their numbers
– Constant definitions
– Data structures, etc.
• Therefore, compiling the C library requires
kernel headers, and many applications also
require them.
21Embedded Linux @ Information Technology Institute
GCC
• GNU Compiler Collection, the famous free
software compiler
• Can compile C, C++, Ada, Fortran, Java,
Objective-C, Objective-C++, and generate
code for a large number of CPU architectures,
including ARM, AVR, Blackfin, CRIS, FRV, M32,
MIPS, MN10300, PowerPC, SH, v850, i386, x86
64, IA64, Xtensa, etc.
• http://gcc.gnu.org/
22Embedded Linux @ Information Technology Institute
C Library
• The C library is
– Interface between the applications and the kernel
– Provides the well-known standard C API to ease
application development
• Several C libraries are available:
– glibc, uClibc, eglibc, dietlibc, newlib, etc.
• The choice of the C library must be made at the
time of the cross-compiling toolchain generation,
as the GCC compiler is compiled against a specific
c C library.
• We will use uClibc: http://www.uclibc.org/
23Embedded Linux @ Information Technology Institute
24
crosstool-ng
Embedded Linux @ Information Technology Institute
crosstool-ng
• Don’t forget the required pkgs
– sudo apt-get install ncurses-dev bison texinfo
flex autoconf automake libtool libexpat1-dev
libncurses5-dev patch curl cvs build-essential
subversion gawk python-dev gperf
• http://crosstool-ng.org
• Untar the source code, then build it
– ./configure --enable-local
– make
25Embedded Linux @ Information Technology Institute
crosstool-ng
• You can use help
– ./ct-ng help
– ./ct-ng list-samples
• We will use
– ./ct-ng arm-unknown-linux-uclibcgnueabi
26Embedded Linux @ Information Technology Institute
crosstool-ng
• You can configure it again
– ./ct-ng menuconfig
• We will use
– ./ct-ng arm-unknown-linux-uclibcgnueabi
• In Path and misc options:
– Prefix directory
– Change Maximum log level to see to DEBUG
• In Toolchain options:
– Set Tuple’s alias to arm-linux
27Embedded Linux @ Information Technology Institute
crosstool-ng
• In Debug facilities:
• Enable gdb, strace and ltrace.
• Remove the other options (dmalloc and
duma).
• In gdb options:
– Make sure that the Cross-gdb and Build a static
gdbserver options are enabled; the other options
are not needed.
– Set gdb version to 7.4.1
28Embedded Linux @ Information Technology Institute
crosstool-ng
• Build
– Create in you home directory
• src >> save the tarballs it will download
• x-tools >> the outbut
– ./ct-ng build
And wait
29Embedded Linux @ Information Technology Institute
30
Using Cross-ToolChain
Embedded Linux @ Information Technology Institute
Using Cross-ToolChain
• Now you have your own built toolchain from
ARM arch. Inside x-tools directory.
• Add the bin directory to your PATH
environment variable to be able to use it from
anywhere
export PATH=$PATH:PATH_TO_BIN_INSIDE_TOOLCHAIN
• You can add this line to bash startup script to
be global every time you log in.
sudo gedit /etc/bash.bashrc
31Embedded Linux @ Information Technology Institute
Compile a simple program
• Compile any C program to check the toolchain
arm-linux-gcc hello.c -o hello
• Or by using static compiling
arm-linux-gcc -static hello.c -o hellostatic
• You can view the file type
file hello
32Embedded Linux @ Information Technology Institute
33
Kernel Compilation
Embedded Linux @ Information Technology Institute
Kernel Compilation
• Where to get Linux Kernel source
– https://www.kernel.org/
• You can download any Linux version according
to your needs.
34Embedded Linux @ Information Technology Institute
Kernel patching
• Changes to the kernel sources are distributed
as patch files. The patch utility is used to apply
a series of edits to a set of source files. So, for
example, if you have the 2.0.29 kernel source
tree and you wanted to move to the 2.0.30
source tree, you would obtain the 2.0.30
patch file and apply the patches (edits) to that
source tree:
patch -p1 < patch-2.0.30
35Embedded Linux @ Information Technology Institute
Linux source dir
• arch
– The arch subdirectory contains all of the architecture specific kernel
code. It has further subdirectories, one per supported architecture, for
example i386 and alpha.
• include
– The include subdirectory contains most of the include files needed to
build the kernel code. It too has further subdirectories including one
for every architecture supported. The include/asm subdirectory is a
soft link to the real include directory needed for this architecture, for
example include/asm-i386. To change architectures you need to edit
the kernel makefile and rerun the Linux kernel configuration program.
• init
– This directory contains the initialization code for the kernel and it is a
very good place to start looking at how the kernel works.
36Embedded Linux @ Information Technology Institute
Linux source dir
• mm
– This directory contains all of the memory management code. The
architecture specific memory management code lives down in
arch/*/mm/, for example arch/i386/mm/fault.c.
• drivers
– All of the system's device drivers live in this directory. They are further
sub-divided into classes of device driver, for example block.
• ipc
– This directory contains the kernels inter-process communications
code.
• modules
– This is simply a directory used to hold built modules.
• fs
– All of the file system code. This is further sub-divided into directories,
one per supported file system, for example vfat and ext2.
37Embedded Linux @ Information Technology Institute
Linux source dir
• kernel
– The main kernel code. Again, the architecture specific
kernel code is in arch/*/kernel.
• net
– The kernel's networking code.
• lib
– This directory contains the kernel's library code. The
architecture specific library code can be found in
arch/*/lib/.
• scripts
– This directory contains the scripts (for example awk and tk
scripts) that are used when the kernel is configured.
38Embedded Linux @ Information Technology Institute
Kernel Compilation
• Configure the Linux kernel
make vexpress_defconfig ARCH=arm CROSS_COMPILE=arm-linux-
• Edit the default configuration
make menuconfig
• Build the kernel image
make all ARCH=arm CROSS_COMPILE=arm-linux-
• You will find the kernel image in
arch/arm/boot/zImage
39Embedded Linux @ Information Technology Institute
40
HW Emulators
Embedded Linux @ Information Technology Institute
HW Emulators
• Hardware emulation is the process of
imitating the behavior of one or more pieces
of hardware (typically a system under design)
with another piece of hardware, typically a
special purpose emulation system.
41Embedded Linux @ Information Technology Institute
Qemu
• QEMU is a generic and open source machine
emulator and virtualizer.
• QEMU lets you run another operating system on
top of your existing OS.
• When used as a machine emulator, QEMU can
run OSes and programs made for one machine
(e.g. an ARM board) on a different machine (e.g.
your own PC). By using dynamic translation, it
achieves very good performance.
42Embedded Linux @ Information Technology Institute
Qemu
• Install Qemu on Ubuntu
sudo apt-get install qemu-system
• Test Qemu running
qemu-system-i386 -m 256M –kernel 
/boot/vmlinuz-3.2.0-57-generic-pae 
-initrd /boot/initrd.img-3.2.0-57-generic-pae
• This command will run your current installed
Linux kernel inside Qemu emulator
43Embedded Linux @ Information Technology Institute
Qemu ARM
• To run the ARM kernel inside Qemu
• We need the zImage Kernel & initrd image
filesystem with init process to run
• Compile a simple C program
arm-linux-gcc -static hello.c -o init
• Generate the initramfs image
echo init | cpio -o --format=newc > initramfs
44Embedded Linux @ Information Technology Institute
Qemu ARM
• Put the zImage & initramfs together and
execute the command
qemu-system-arm -M vexpress-a9 
-kernel zImage -initrd initramfs 
-append "console=tty1“
• The Linux system should start and execute the
single process init.
45Embedded Linux @ Information Technology Institute
46
Building full ARM system with Busybox
Embedded Linux @ Information Technology Institute
Linux Kernel
• The same zImage kernel already built.
47Embedded Linux @ Information Technology Institute
Busybox
• Inside Busybox source dir, configure & cross-
compile for ARM (static)
make ARCH=arm CROSS_COMPILE=arm-linux- defconfig
make ARCH=arm CROSS_COMPILE=arm-linux- menuconfig
Busybox Settings -->
Build Options -->
Build Busybox as a static binary (CHECK)
• Command to start building
make CONFIG_PREFIX=/home/user-name/ARM_SYSTEM_DIR
ARCH=arm CROSS_COMPILE=arm-linux- install
48Embedded Linux @ Information Technology Institute
Complete the filesystem dirs
• Inside the ARM_SYSTEM_DIR
mkdir proc sys dev etc etc/init.d
gedit etc/init.d/rcS
#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
/sbin/mdev –s
• Change the rcS file permissions
chmod +x etc/init.d/rcS
49Embedded Linux @ Information Technology Institute
Create the root fs image file
• Inside the ARM_SYSTEM_DIR
find . | cpio -o --format=newc > ../rootfs.img
cd ..
gzip -c rootfs.img > rootfs.img.gz
• Now you have the kernel image & the root fs
image compressed
50Embedded Linux @ Information Technology Institute
Run Qemu emulator
qemu-system-arm -M vexpress-a9 
-kernel zImage -initrd rootfs.img.gz 
-append "root=/dev/ram rdinit=/bin/sh“
• Now you got a console running, and can try
any command or app installed.
51Embedded Linux @ Information Technology Institute
eng.sherif.mosa@gmail.com
http://about.me/shatrix
52Embedded Linux @ Information Technology Institute

Weitere ähnliche Inhalte

Was ist angesagt?

linux device driver
linux device driverlinux device driver
linux device driverRahul Batra
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device driversHoucheng Lin
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBshimosawa
 
Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)RuggedBoardGroup
 
Debian or Yocto Project? Which is the best for your Embedded Linux project?
Debian or Yocto Project? Which is the best for your Embedded Linux project?Debian or Yocto Project? Which is the best for your Embedded Linux project?
Debian or Yocto Project? Which is the best for your Embedded Linux project?Chris Simmonds
 
Linux on RISC-V with Open Source Hardware (Open Source Summit Japan 2020)
Linux on RISC-V with Open Source Hardware (Open Source Summit Japan 2020)Linux on RISC-V with Open Source Hardware (Open Source Summit Japan 2020)
Linux on RISC-V with Open Source Hardware (Open Source Summit Japan 2020)Drew Fustini
 
LCU13: An Introduction to ARM Trusted Firmware
LCU13: An Introduction to ARM Trusted FirmwareLCU13: An Introduction to ARM Trusted Firmware
LCU13: An Introduction to ARM Trusted FirmwareLinaro
 
Trusted firmware deep_dive_v1.0_
Trusted firmware deep_dive_v1.0_Trusted firmware deep_dive_v1.0_
Trusted firmware deep_dive_v1.0_Linaro
 
Linux Kernel Module - For NLKB
Linux Kernel Module - For NLKBLinux Kernel Module - For NLKB
Linux Kernel Module - For NLKBshimosawa
 
SFO15-503: Secure storage in OP-TEE
SFO15-503: Secure storage in OP-TEESFO15-503: Secure storage in OP-TEE
SFO15-503: Secure storage in OP-TEELinaro
 
Yocto - Embedded Linux Distribution Maker
Yocto - Embedded Linux Distribution MakerYocto - Embedded Linux Distribution Maker
Yocto - Embedded Linux Distribution MakerSherif Mousa
 
Build your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto projectBuild your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto projectYen-Chin Lee
 

Was ist angesagt? (20)

linux device driver
linux device driverlinux device driver
linux device driver
 
Arm device tree and linux device drivers
Arm device tree and linux device driversArm device tree and linux device drivers
Arm device tree and linux device drivers
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKB
 
Linux kernel
Linux kernelLinux kernel
Linux kernel
 
Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)Embedded Linux BSP Training (Intro)
Embedded Linux BSP Training (Intro)
 
Debian or Yocto Project? Which is the best for your Embedded Linux project?
Debian or Yocto Project? Which is the best for your Embedded Linux project?Debian or Yocto Project? Which is the best for your Embedded Linux project?
Debian or Yocto Project? Which is the best for your Embedded Linux project?
 
Embedded Operating System - Linux
Embedded Operating System - LinuxEmbedded Operating System - Linux
Embedded Operating System - Linux
 
Linux on RISC-V with Open Source Hardware (Open Source Summit Japan 2020)
Linux on RISC-V with Open Source Hardware (Open Source Summit Japan 2020)Linux on RISC-V with Open Source Hardware (Open Source Summit Japan 2020)
Linux on RISC-V with Open Source Hardware (Open Source Summit Japan 2020)
 
LCU13: An Introduction to ARM Trusted Firmware
LCU13: An Introduction to ARM Trusted FirmwareLCU13: An Introduction to ARM Trusted Firmware
LCU13: An Introduction to ARM Trusted Firmware
 
Linux Systems: Getting started with setting up an Embedded platform
Linux Systems: Getting started with setting up an Embedded platformLinux Systems: Getting started with setting up an Embedded platform
Linux Systems: Getting started with setting up an Embedded platform
 
Trusted firmware deep_dive_v1.0_
Trusted firmware deep_dive_v1.0_Trusted firmware deep_dive_v1.0_
Trusted firmware deep_dive_v1.0_
 
Linux I2C
Linux I2CLinux I2C
Linux I2C
 
Linux Kernel Module - For NLKB
Linux Kernel Module - For NLKBLinux Kernel Module - For NLKB
Linux Kernel Module - For NLKB
 
SFO15-503: Secure storage in OP-TEE
SFO15-503: Secure storage in OP-TEESFO15-503: Secure storage in OP-TEE
SFO15-503: Secure storage in OP-TEE
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
BusyBox for Embedded Linux
BusyBox for Embedded LinuxBusyBox for Embedded Linux
BusyBox for Embedded Linux
 
Yocto - Embedded Linux Distribution Maker
Yocto - Embedded Linux Distribution MakerYocto - Embedded Linux Distribution Maker
Yocto - Embedded Linux Distribution Maker
 
Build your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto projectBuild your own embedded linux distributions by yocto project
Build your own embedded linux distributions by yocto project
 
SPI Drivers
SPI DriversSPI Drivers
SPI Drivers
 
Linux Internals - Part I
Linux Internals - Part ILinux Internals - Part I
Linux Internals - Part I
 

Ähnlich wie Building Embedded Linux Full Tutorial for ARM

Building Embedded Linux Systems Introduction
Building Embedded Linux Systems IntroductionBuilding Embedded Linux Systems Introduction
Building Embedded Linux Systems IntroductionSherif Mousa
 
Module 4 Embedded Linux
Module 4 Embedded LinuxModule 4 Embedded Linux
Module 4 Embedded LinuxTushar B Kute
 
Embedded Linux from Scratch to Yocto
Embedded Linux from Scratch to YoctoEmbedded Linux from Scratch to Yocto
Embedded Linux from Scratch to YoctoSherif Mousa
 
Linux for embedded_systems
Linux for embedded_systemsLinux for embedded_systems
Linux for embedded_systemsVandana Salve
 
Embedded linux
Embedded linuxEmbedded linux
Embedded linuxWingston
 
Building Embedded Linux
Building Embedded LinuxBuilding Embedded Linux
Building Embedded LinuxSherif Mousa
 
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B KuteUnit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B KuteTushar B Kute
 
Embedded Linux primer
Embedded Linux primerEmbedded Linux primer
Embedded Linux primerDrew Fustini
 
Lec 10-linux-review
Lec 10-linux-reviewLec 10-linux-review
Lec 10-linux-reviewabinaya m
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python ProgrammingAkhil Kaushik
 
NXP IMX6 Processor - Embedded Linux
NXP IMX6 Processor - Embedded LinuxNXP IMX6 Processor - Embedded Linux
NXP IMX6 Processor - Embedded LinuxNEEVEE Technologies
 
Linux – an introduction
Linux – an introductionLinux – an introduction
Linux – an introductionWingston
 
Introduction to EasyBuild: Tutorial Part 1
Introduction to EasyBuild: Tutorial Part 1Introduction to EasyBuild: Tutorial Part 1
Introduction to EasyBuild: Tutorial Part 1inside-BigData.com
 
embedded-linux-120203.pdf
embedded-linux-120203.pdfembedded-linux-120203.pdf
embedded-linux-120203.pdftwtester
 
EclipseCon Eu 2012 - Buildroot Eclipse Bundle : A powerful IDE for Embedded L...
EclipseCon Eu 2012 - Buildroot Eclipse Bundle : A powerful IDE for Embedded L...EclipseCon Eu 2012 - Buildroot Eclipse Bundle : A powerful IDE for Embedded L...
EclipseCon Eu 2012 - Buildroot Eclipse Bundle : A powerful IDE for Embedded L...melbats
 

Ähnlich wie Building Embedded Linux Full Tutorial for ARM (20)

Building Embedded Linux Systems Introduction
Building Embedded Linux Systems IntroductionBuilding Embedded Linux Systems Introduction
Building Embedded Linux Systems Introduction
 
Module 4 Embedded Linux
Module 4 Embedded LinuxModule 4 Embedded Linux
Module 4 Embedded Linux
 
Embedded Linux from Scratch to Yocto
Embedded Linux from Scratch to YoctoEmbedded Linux from Scratch to Yocto
Embedded Linux from Scratch to Yocto
 
Linux for embedded_systems
Linux for embedded_systemsLinux for embedded_systems
Linux for embedded_systems
 
Intro to linux
Intro to linux Intro to linux
Intro to linux
 
Embedded Linux on ARM
Embedded Linux on ARMEmbedded Linux on ARM
Embedded Linux on ARM
 
Embedded linux
Embedded linuxEmbedded linux
Embedded linux
 
Building Embedded Linux
Building Embedded LinuxBuilding Embedded Linux
Building Embedded Linux
 
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B KuteUnit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
Unit 6 Operating System TEIT Savitribai Phule Pune University by Tushar B Kute
 
Hands on OpenCL
Hands on OpenCLHands on OpenCL
Hands on OpenCL
 
Embedded Linux primer
Embedded Linux primerEmbedded Linux primer
Embedded Linux primer
 
Lec 10-linux-review
Lec 10-linux-reviewLec 10-linux-review
Lec 10-linux-review
 
The Linux System
The Linux SystemThe Linux System
The Linux System
 
Embedded Linux - Building toolchain
Embedded Linux - Building toolchainEmbedded Linux - Building toolchain
Embedded Linux - Building toolchain
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
 
NXP IMX6 Processor - Embedded Linux
NXP IMX6 Processor - Embedded LinuxNXP IMX6 Processor - Embedded Linux
NXP IMX6 Processor - Embedded Linux
 
Linux – an introduction
Linux – an introductionLinux – an introduction
Linux – an introduction
 
Introduction to EasyBuild: Tutorial Part 1
Introduction to EasyBuild: Tutorial Part 1Introduction to EasyBuild: Tutorial Part 1
Introduction to EasyBuild: Tutorial Part 1
 
embedded-linux-120203.pdf
embedded-linux-120203.pdfembedded-linux-120203.pdf
embedded-linux-120203.pdf
 
EclipseCon Eu 2012 - Buildroot Eclipse Bundle : A powerful IDE for Embedded L...
EclipseCon Eu 2012 - Buildroot Eclipse Bundle : A powerful IDE for Embedded L...EclipseCon Eu 2012 - Buildroot Eclipse Bundle : A powerful IDE for Embedded L...
EclipseCon Eu 2012 - Buildroot Eclipse Bundle : A powerful IDE for Embedded L...
 

Mehr von Sherif Mousa

Building Mini Embedded Linux System for X86 Arch
Building Mini Embedded Linux System for X86 ArchBuilding Mini Embedded Linux System for X86 Arch
Building Mini Embedded Linux System for X86 ArchSherif Mousa
 
Android Session "g | Canal Cities" event
Android Session "g | Canal Cities" eventAndroid Session "g | Canal Cities" event
Android Session "g | Canal Cities" eventSherif Mousa
 
Operating systems Basics
Operating systems BasicsOperating systems Basics
Operating systems BasicsSherif Mousa
 
linux minimal os tutorial - by shatrix
linux minimal os tutorial - by shatrixlinux minimal os tutorial - by shatrix
linux minimal os tutorial - by shatrixSherif Mousa
 
001 linux revision
001 linux revision001 linux revision
001 linux revisionSherif Mousa
 

Mehr von Sherif Mousa (9)

Building Mini Embedded Linux System for X86 Arch
Building Mini Embedded Linux System for X86 ArchBuilding Mini Embedded Linux System for X86 Arch
Building Mini Embedded Linux System for X86 Arch
 
Android Session "g | Canal Cities" event
Android Session "g | Canal Cities" eventAndroid Session "g | Canal Cities" event
Android Session "g | Canal Cities" event
 
كيف تفشل
كيف تفشلكيف تفشل
كيف تفشل
 
Operating systems Basics
Operating systems BasicsOperating systems Basics
Operating systems Basics
 
linux minimal os tutorial - by shatrix
linux minimal os tutorial - by shatrixlinux minimal os tutorial - by shatrix
linux minimal os tutorial - by shatrix
 
005 skyeye
005 skyeye005 skyeye
005 skyeye
 
003 scripting
003 scripting003 scripting
003 scripting
 
001 linux revision
001 linux revision001 linux revision
001 linux revision
 
Smile
SmileSmile
Smile
 

Kürzlich hochgeladen

"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 

Kürzlich hochgeladen (20)

"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 

Building Embedded Linux Full Tutorial for ARM

  • 1. Building Embedded Linux (Full Tutorial for ARM) Information Technology Institute (ITI) Sherif Mousa Embedded Linux @ Information Technology Institute 1
  • 2. 2Embedded Linux @ Information Technology Institute Using Linux in an embedded project is easier, and more fun, than ever 
  • 3. Tips for Linux • Read instructions and tips carefully. • Always read error messages carefully, in particular the first one which is issued. • Never stay stuck with a strange problem more than 5 minutes. • If you ran commands from a root shell by mistake, your regular user may no longer be able to handle the corresponding generated files. In this case, use the chown –R command to give the new files back to your regular user. 3Embedded Linux @ Information Technology Institute
  • 4. Tips for Linux • You should only use the root user for operations that require super-user privileges, such as: mounting a file system, loading a kernel module, changing file ownership, configuring the network. Most regular tasks (such as downloading, extracting sources, compiling...) can be done as a regular user. 4Embedded Linux @ Information Technology Institute
  • 5. 5 Hardware for Linux systems Embedded Linux @ Information Technology Institute
  • 6. Processor and Arch. • The Linux kernel and most other architecture- dependent component support a wide range of 32 and 64 bits architectures – x86 and x86-64, as found on PC platforms, but also embedded systems (multimedia, industrial) – ARM, with hundreds of different SoC (multimedia, industrial) – PowerPC (mainly real-time, industrial applications) 6Embedded Linux @ Information Technology Institute
  • 7. RAM & Storage • RAM: a very basic Linux system can work within 8 MB of RAM, but a more realistic system will usually require at least 32 MB of RAM. Depends on the type and size of applications. • Storage: a very basic Linux system can work within 4 MB of storage, but usually more is needed. – Flash storage is supported, both NAND and NOR flash, with specific filesystems. – Block storage including SD/MMC cards and eMMC. 7Embedded Linux @ Information Technology Institute
  • 8. Communication • The Linux kernel has support for many common communication busses – USB – SPI (Serial Peripheral Interface) – CAN (Controller Area Network) – 1-wire • And also extensive networking support – Ethernet, Wi, Bluetooth, CAN, etc. – IPv4, IPv6, TCP, UDP, etc. – Firewalling, advanced routing. 8Embedded Linux @ Information Technology Institute
  • 9. Types of HW platforms • Evaluation platforms from the SoC vendor. Usually expensive, but many peripherals are built-in. Generally unsuitable for real products. • Component on Module, a small board with only CPU/RAM/ash and a few other core components, with connectors to access all other peripherals. Can be used to build end products for small to medium quantities. • Custom platform. Schematics for evaluation boards or development platforms are more and more commonly freely available, making it easier to develop custom platforms. (Open Hardware) 9Embedded Linux @ Information Technology Institute
  • 10. Tips for HW • Make sure the hardware you plan to use is already supported by the Linux kernel, and has an open-source bootloader. • Having support in the official versions of the projects (kernel, bootloader) is a lot better: quality is better, and new versions are available. • Some SoC vendors and/or board vendors do not contribute their changes back to the mainline Linux kernel. 10Embedded Linux @ Information Technology Institute
  • 11. 11 Software Components Embedded Linux @ Information Technology Institute
  • 12. Software Components • Cross-compilation ToolChain • Bootloader • Linux Kernel • System libraries (C library) • Filesystem with other libraries & apps. 12Embedded Linux @ Information Technology Institute
  • 13. Embedded Linux Output • Board Support Package development – A BSP contains a bootloader and kernel with the suitable device drivers for the targeted hardware • System integration – Integrate all the components, bootloader, kernel, third-party libraries and applications and in-house applications into a working system • Development of applications – Normal Linux applications, but using specially chosen libraries 13Embedded Linux @ Information Technology Institute
  • 14. Cross-ToolChain 14Embedded Linux @ Information Technology Institute X86 Binary Target Binary X86 X86 Target CPU Source Code Native ToolChain Cross ToolChain
  • 15. 15 Where to get Cross-ToolChain Embedded Linux @ Information Technology Institute
  • 16. Where to get Cross-ToolChain • http://elinux.org/Toolchains • Codesourcery, ready-made – http://www.mentor.com/embedded- software/codesourcery • Linaro, ready made – http://www.linaro.org/ • Buildroot, tool to build – http://www.buildroot.net/ • Crosstool-NG, tool to build – http://crosstool-ng.org/ 16Embedded Linux @ Information Technology Institute
  • 17. 17 Building Cross-ToolChain Embedded Linux @ Information Technology Institute
  • 18. Cross-ToolChain • Three machines must be distinguished when discussing toolchain creation – The build machine, where the toolchain is built. – The host machine, where the toolchain will be executed. – The target machine, where the binaries created by the toolchain are executed. 18Embedded Linux @ Information Technology Institute
  • 19. Cross-ToolChain components 19Embedded Linux @ Information Technology Institute GDB (optional) GCC CompilerC/C++ libs binutils Kernel Headers
  • 20. Binutils • Binutils is a set of tools to generate and manipulate binaries for a given CPU architecture – as, the assembler, that generates binary code from assembler source code – ld, the linker – ar, ranlib, to generate .a archives, used for libraries – objdump, readelf, size, nm, strings, to inspect binaries. Very useful analysis tools! – strip, to strip useless parts of binaries in order to reduce their size • http://www.gnu.org/software/binutils/ 20Embedded Linux @ Information Technology Institute
  • 21. Kernel Headers • The C library and compiled programs needs to interact with the kernel – Available system calls and their numbers – Constant definitions – Data structures, etc. • Therefore, compiling the C library requires kernel headers, and many applications also require them. 21Embedded Linux @ Information Technology Institute
  • 22. GCC • GNU Compiler Collection, the famous free software compiler • Can compile C, C++, Ada, Fortran, Java, Objective-C, Objective-C++, and generate code for a large number of CPU architectures, including ARM, AVR, Blackfin, CRIS, FRV, M32, MIPS, MN10300, PowerPC, SH, v850, i386, x86 64, IA64, Xtensa, etc. • http://gcc.gnu.org/ 22Embedded Linux @ Information Technology Institute
  • 23. C Library • The C library is – Interface between the applications and the kernel – Provides the well-known standard C API to ease application development • Several C libraries are available: – glibc, uClibc, eglibc, dietlibc, newlib, etc. • The choice of the C library must be made at the time of the cross-compiling toolchain generation, as the GCC compiler is compiled against a specific c C library. • We will use uClibc: http://www.uclibc.org/ 23Embedded Linux @ Information Technology Institute
  • 24. 24 crosstool-ng Embedded Linux @ Information Technology Institute
  • 25. crosstool-ng • Don’t forget the required pkgs – sudo apt-get install ncurses-dev bison texinfo flex autoconf automake libtool libexpat1-dev libncurses5-dev patch curl cvs build-essential subversion gawk python-dev gperf • http://crosstool-ng.org • Untar the source code, then build it – ./configure --enable-local – make 25Embedded Linux @ Information Technology Institute
  • 26. crosstool-ng • You can use help – ./ct-ng help – ./ct-ng list-samples • We will use – ./ct-ng arm-unknown-linux-uclibcgnueabi 26Embedded Linux @ Information Technology Institute
  • 27. crosstool-ng • You can configure it again – ./ct-ng menuconfig • We will use – ./ct-ng arm-unknown-linux-uclibcgnueabi • In Path and misc options: – Prefix directory – Change Maximum log level to see to DEBUG • In Toolchain options: – Set Tuple’s alias to arm-linux 27Embedded Linux @ Information Technology Institute
  • 28. crosstool-ng • In Debug facilities: • Enable gdb, strace and ltrace. • Remove the other options (dmalloc and duma). • In gdb options: – Make sure that the Cross-gdb and Build a static gdbserver options are enabled; the other options are not needed. – Set gdb version to 7.4.1 28Embedded Linux @ Information Technology Institute
  • 29. crosstool-ng • Build – Create in you home directory • src >> save the tarballs it will download • x-tools >> the outbut – ./ct-ng build And wait 29Embedded Linux @ Information Technology Institute
  • 30. 30 Using Cross-ToolChain Embedded Linux @ Information Technology Institute
  • 31. Using Cross-ToolChain • Now you have your own built toolchain from ARM arch. Inside x-tools directory. • Add the bin directory to your PATH environment variable to be able to use it from anywhere export PATH=$PATH:PATH_TO_BIN_INSIDE_TOOLCHAIN • You can add this line to bash startup script to be global every time you log in. sudo gedit /etc/bash.bashrc 31Embedded Linux @ Information Technology Institute
  • 32. Compile a simple program • Compile any C program to check the toolchain arm-linux-gcc hello.c -o hello • Or by using static compiling arm-linux-gcc -static hello.c -o hellostatic • You can view the file type file hello 32Embedded Linux @ Information Technology Institute
  • 33. 33 Kernel Compilation Embedded Linux @ Information Technology Institute
  • 34. Kernel Compilation • Where to get Linux Kernel source – https://www.kernel.org/ • You can download any Linux version according to your needs. 34Embedded Linux @ Information Technology Institute
  • 35. Kernel patching • Changes to the kernel sources are distributed as patch files. The patch utility is used to apply a series of edits to a set of source files. So, for example, if you have the 2.0.29 kernel source tree and you wanted to move to the 2.0.30 source tree, you would obtain the 2.0.30 patch file and apply the patches (edits) to that source tree: patch -p1 < patch-2.0.30 35Embedded Linux @ Information Technology Institute
  • 36. Linux source dir • arch – The arch subdirectory contains all of the architecture specific kernel code. It has further subdirectories, one per supported architecture, for example i386 and alpha. • include – The include subdirectory contains most of the include files needed to build the kernel code. It too has further subdirectories including one for every architecture supported. The include/asm subdirectory is a soft link to the real include directory needed for this architecture, for example include/asm-i386. To change architectures you need to edit the kernel makefile and rerun the Linux kernel configuration program. • init – This directory contains the initialization code for the kernel and it is a very good place to start looking at how the kernel works. 36Embedded Linux @ Information Technology Institute
  • 37. Linux source dir • mm – This directory contains all of the memory management code. The architecture specific memory management code lives down in arch/*/mm/, for example arch/i386/mm/fault.c. • drivers – All of the system's device drivers live in this directory. They are further sub-divided into classes of device driver, for example block. • ipc – This directory contains the kernels inter-process communications code. • modules – This is simply a directory used to hold built modules. • fs – All of the file system code. This is further sub-divided into directories, one per supported file system, for example vfat and ext2. 37Embedded Linux @ Information Technology Institute
  • 38. Linux source dir • kernel – The main kernel code. Again, the architecture specific kernel code is in arch/*/kernel. • net – The kernel's networking code. • lib – This directory contains the kernel's library code. The architecture specific library code can be found in arch/*/lib/. • scripts – This directory contains the scripts (for example awk and tk scripts) that are used when the kernel is configured. 38Embedded Linux @ Information Technology Institute
  • 39. Kernel Compilation • Configure the Linux kernel make vexpress_defconfig ARCH=arm CROSS_COMPILE=arm-linux- • Edit the default configuration make menuconfig • Build the kernel image make all ARCH=arm CROSS_COMPILE=arm-linux- • You will find the kernel image in arch/arm/boot/zImage 39Embedded Linux @ Information Technology Institute
  • 40. 40 HW Emulators Embedded Linux @ Information Technology Institute
  • 41. HW Emulators • Hardware emulation is the process of imitating the behavior of one or more pieces of hardware (typically a system under design) with another piece of hardware, typically a special purpose emulation system. 41Embedded Linux @ Information Technology Institute
  • 42. Qemu • QEMU is a generic and open source machine emulator and virtualizer. • QEMU lets you run another operating system on top of your existing OS. • When used as a machine emulator, QEMU can run OSes and programs made for one machine (e.g. an ARM board) on a different machine (e.g. your own PC). By using dynamic translation, it achieves very good performance. 42Embedded Linux @ Information Technology Institute
  • 43. Qemu • Install Qemu on Ubuntu sudo apt-get install qemu-system • Test Qemu running qemu-system-i386 -m 256M –kernel /boot/vmlinuz-3.2.0-57-generic-pae -initrd /boot/initrd.img-3.2.0-57-generic-pae • This command will run your current installed Linux kernel inside Qemu emulator 43Embedded Linux @ Information Technology Institute
  • 44. Qemu ARM • To run the ARM kernel inside Qemu • We need the zImage Kernel & initrd image filesystem with init process to run • Compile a simple C program arm-linux-gcc -static hello.c -o init • Generate the initramfs image echo init | cpio -o --format=newc > initramfs 44Embedded Linux @ Information Technology Institute
  • 45. Qemu ARM • Put the zImage & initramfs together and execute the command qemu-system-arm -M vexpress-a9 -kernel zImage -initrd initramfs -append "console=tty1“ • The Linux system should start and execute the single process init. 45Embedded Linux @ Information Technology Institute
  • 46. 46 Building full ARM system with Busybox Embedded Linux @ Information Technology Institute
  • 47. Linux Kernel • The same zImage kernel already built. 47Embedded Linux @ Information Technology Institute
  • 48. Busybox • Inside Busybox source dir, configure & cross- compile for ARM (static) make ARCH=arm CROSS_COMPILE=arm-linux- defconfig make ARCH=arm CROSS_COMPILE=arm-linux- menuconfig Busybox Settings --> Build Options --> Build Busybox as a static binary (CHECK) • Command to start building make CONFIG_PREFIX=/home/user-name/ARM_SYSTEM_DIR ARCH=arm CROSS_COMPILE=arm-linux- install 48Embedded Linux @ Information Technology Institute
  • 49. Complete the filesystem dirs • Inside the ARM_SYSTEM_DIR mkdir proc sys dev etc etc/init.d gedit etc/init.d/rcS #!/bin/sh mount -t proc none /proc mount -t sysfs none /sys /sbin/mdev –s • Change the rcS file permissions chmod +x etc/init.d/rcS 49Embedded Linux @ Information Technology Institute
  • 50. Create the root fs image file • Inside the ARM_SYSTEM_DIR find . | cpio -o --format=newc > ../rootfs.img cd .. gzip -c rootfs.img > rootfs.img.gz • Now you have the kernel image & the root fs image compressed 50Embedded Linux @ Information Technology Institute
  • 51. Run Qemu emulator qemu-system-arm -M vexpress-a9 -kernel zImage -initrd rootfs.img.gz -append "root=/dev/ram rdinit=/bin/sh“ • Now you got a console running, and can try any command or app installed. 51Embedded Linux @ Information Technology Institute