embedded linux from scratch to yocto

20
Embedded Linux @ Information Technology Institute 1 Embedded Linux From Scratch To Yocto Information Technology Institute Sherif Mousa

Upload: sherif-mousa

Post on 14-Jul-2015

729 views

Category:

Engineering


5 download

TRANSCRIPT

Page 1: Embedded Linux from Scratch to Yocto

Embedded Linux @ Information Technology Institute 1

Embedded Linux

From Scratch To Yocto

Information Technology Institute

Sherif Mousa

Page 2: Embedded Linux from Scratch to Yocto

Embedded Linux @ Information Technology Institute 2

Linux

● Unix (Ken Thompson & Dennis Ritchie) AT&T company 1969

● FSF & GNU (Gnu is Not Unix) & GPL (Richard Stallman) 1984

● Hurd Kernel● Linux (LinusTorvalds) 1991● GNU/Linux 1992 (complete, open source, UNIX-

like operating system)– https://www.gnu.org/gnu/linux-and-gnu.html–

Page 3: Embedded Linux from Scratch to Yocto

Embedded Linux @ Information Technology Institute 3

Embedded Linux

● Embedded Linux is the use of Linux in embedded computer systems.

● Adapting the Linux kernel and customizing the user-land libraries and utilities to embedded applications such as those in use in consumer electronics, military, medical, industrial, network, and auto industries.

● Creating an Embedded Linux based system is like a puzzle. Putting the right pieces together will create the final image.

Page 4: Embedded Linux from Scratch to Yocto

Embedded Linux @ Information Technology Institute 4

Some Whys ...

● Why OS for Embedded ?– Make use of micro-processor capabilities (Multi-Tasking …).– Easy to program.– System scalability.

● Why Embedded not Normal OS ?– Systems with small and limited resources.– Special-Purpose systems.– Real-Time systems.

● Why Linux ?– Inexpensive, robust, easy to program, open source.– Ported to a variety of CPU architectures.– Large device drivers coverage.

Page 5: Embedded Linux from Scratch to Yocto

Embedded Linux @ Information Technology Institute 5

Why build from scratch ?

● “When you bake it at the factory that’s what it does forever. “ 

Tim Bird, Sony Entertainment

● You can use ready-made distributions as well, but you will face some restrictions if you need to modify something.

Page 6: Embedded Linux from Scratch to Yocto

Embedded Linux @ Information Technology Institute 6

Some Facts ...

● Is it easy?– NO, IT’S NOT EASY.– To finish a complete OS, it’s not just Linux kernel to

compile, you need to build and integrate the other OS components (BootLoader, Libraries, Commands, …….)

– And you will do all of this without getting a PhD degree in OS building :)

● Do I need more knowledge ?

– If you are a Linux super user, and you think that you need to learn more things to enter the Embedded Linux field, THAT’S WRONG.

Page 7: Embedded Linux from Scratch to Yocto

Embedded Linux @ Information Technology Institute 7

Embedded Linux Development

Page 8: Embedded Linux from Scratch to Yocto

Embedded Linux @ Information Technology Institute 8

Some definitions

● Cross Compiler– A cross compiler is a compiler capable of creating

executable code for a platform other than the one on which the compiler is running.

● Toolchain– Set of programming tools that are used to create a

product (typically another computer program), used in chain.

– A simple software development ToolChain consists of a compiler and linker to transform the source code into an executable program, libraries to provide interfaces to the operating system, and a debugger.

Page 9: Embedded Linux from Scratch to Yocto

Embedded Linux @ Information Technology Institute 9

Some definitions (cont'd)

● Cross-Toolchain– The usual development tools available on a

GNU/Linux workstation is a native ToolChain.– For embedded systems, it is usually impossible or

not interesting to use a ToolChain installed on it● The target is restricted in terms of storage and memory● The target is very slow compared to your workstation

– Therefore, Cross -ToolChain is used. Runs on your workstation but generates binaries for your target.

Page 10: Embedded Linux from Scratch to Yocto

Embedded Linux @ Information Technology Institute 10

Cross-Toolchain

X86 BinaryX86 Binary Target BinaryTarget Binary

X86

X86 Target CPU

Source CodeSource Code

Native ToolChainNative ToolChain Cross ToolChainCross ToolChain

Page 11: Embedded Linux from Scratch to Yocto

Embedded Linux @ Information Technology Institute 11

Embedded Linux System Components

● Cross-compilation ToolChain– Compiler, debugger, libraries, headers, extra tools.

● Boot Loader (grub, lilo, uboot)– Started by the hardware.– Responsible for basic initialization, loading and executing the kernel.

● Linux Kernel (Normal or Real-Time)– Contains the process and memory management, network stack, device drivers, and

many other core OS responsibilities, and provides services to userspace applications.● C Library (glibc, uclibc, ….)

– The interface between the kernel and the userspace applications.● User Land

– Configuration files– Common system commands– User application(s)

Page 12: Embedded Linux from Scratch to Yocto

Embedded Linux @ Information Technology Institute 12

Linux System Running

HardwareHardware

Linux KernelLinux Kernel

UserLandC LibraryC Library

app Aapp A app Bapp B

Calla service

ManageHardware

EventHandler

Eventnotification

Page 13: Embedded Linux from Scratch to Yocto

Embedded Linux @ Information Technology Institute 13

Booting Sequence

● Bootloader– Executed by the hardware at a fixed location in ROM / Flash– Initializes support for the device where the kernel image is found (local

storage, network, removable media)

– Loads the kernel image in RAM and execute.

● Linux Kernel– Uncompresses itself– Initializes the kernel core and statically compiled drivers (required to access

the root filesystem)– Mounts the root filesystem (specified by the root kernel parameter)– Executes the first userspace program (specified by the init kernel parameter)

● First userspace program Configures userspace and starts up system services and any installed user interface (graphical or terminal based).

Page 14: Embedded Linux from Scratch to Yocto

Embedded Linux @ Information Technology Institute 14

Building Process

Page 15: Embedded Linux from Scratch to Yocto

Embedded Linux @ Information Technology Institute 15

How to build?

● From scratch– The original way, you need to build every single

component from scratch, from its source code. Applying your configurations, compiler options, building each component of the system, then integrate all these parts together.

● Auto-Build tools– Automated tools in the form of “build scripts”,

written by the experts in this field to make it easy for everyone to build a full embedded Linux system with the minimal knowledge of building process.

Page 16: Embedded Linux from Scratch to Yocto

Embedded Linux @ Information Technology Institute 16

Building from scratch

● Components you need to build– Cross-Toolchain (ready or build)– BootLoader– Linux Kernel configuration and compiling– Root filesystem hierarchy– System command (BusyBox)– Startup scripts and variables

● Two approaches– Bottom-Up approach (start with minimal system)– Top-Down approach (start with ready base system)

Page 17: Embedded Linux from Scratch to Yocto

Embedded Linux @ Information Technology Institute 17

Auto-Build Tools

● Buildroot– It’s a set of Makefiles and patches that simplifies

and automates the process of building a complete Linux system for an embedded system, by using cross-compilation.

– Useful mainly while working with small or embedded systems, using various CPU architectures – including x86, ARM, MIPS, and PowerPC.

Page 18: Embedded Linux from Scratch to Yocto

Embedded Linux @ Information Technology Institute 18

Auto-Build Tools

● Yocto – It is a Linux Foundation workgroup– It's a complete embedded Linux development

environment with tools, metadata, and documentation - everything you need

– The Yocto Project has the objective of attempting to improve the lives of developers of customized Linux systems supporting the ARM, MIPS, PowerPC and x86/x86 64 architectures.

Page 19: Embedded Linux from Scratch to Yocto

Embedded Linux @ Information Technology Institute 19

Page 20: Embedded Linux from Scratch to Yocto

Embedded Linux @ Information Technology Institute 20

[email protected]

[email protected]

http://about.me/shatrix