0% found this document useful (0 votes)
14 views

Embedded Linux

Uploaded by

Hamza Aslam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Embedded Linux

Uploaded by

Hamza Aslam
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Embedded Linux:

Elements of embedded Linux:

- Toolchain: compile code for you, for your target system


- Bootloader: A program that takes you from where you turn on the
power to a point where you run the linux (UBOOT in ARM and RISC-V,
BIOS in x86)
- Kernel: customized to your hardware which run the resources
- Root filesystem: a user space componenet that has libraries shells
1) Toolchain: C/C++ Compiler + C library + debugger
Compiler, linker, debugger comes from GCC or Clang
Type of C libraries; glibc(bigger with more functionalities), and musl
libc(smaller format systems)
 Types of Toolchains:
o Nativ toolchain: install and develop on target
o Cross Toolchain: build on pc and deploy on controller,
target and development environment are separate, this is
most common
2) Bootloader: Responsible for initializing the system and run the linux
kernel(kernel command line, device tree, initial ramfs)
 Das U-BOOT: Most common and a place to start
 Barebox: more specialized and derived from U-BOOT
 Little Kernel: Mediatek and Qualcom use it
 GRUB 2: for x86, BIOS initialize the system GRUB use to fetch
and load the linux kernel
3) Kernel: Non x86 boards seldom use mainline Linux, mainline linux
generally doesn’t have support SoC you are running, you need a
vendor kernel which means you have the dependency on your SoC
vendor
Vendor kernel has initialization code for chip, drivers for on chip
peripherals
Pain Point: Vendors does not update as the mainline update
Device Tree: Used for communicating to Kernel which on top which
hardware it is running on in order to load the device drivers, in case of
ARM servers and x86 they use ACPI table(Information of peripherals on
motherboard) and PCI server,through PCI and ACPI kernel knows the
device drivers which are the resources of the system, but embedded
devices don’t have BIOS and don’t have PCI’s in the core of kernel,
thus we use Device Tree which is a datastructure or tree which
describes the hardware components, everything apart from intel uses
device trees, ARM, RISC-5, PPC, MIPS and others use Device Tree
4) Root File System: The user space part of OS is Root File system, once
OS is loaded the first thing it runs is the INIT program, so atleast each
core of linux contains the init deamon program, then other deamons
started by init(network services, authentication services, monitoring
and logging services)

Embedded Build Systems: An embedded build system refers to the set of


tools, scripts, and configurations used to compile source code, configure
dependencies, and generate a bootable image or file system that runs on
embedded devices. In the context of Embedded Linux, build systems are
responsible for handling the cross-compilation, packaging, and deployment
of the entire software stack onto an embedded target.

Initially embedded build systems were manually crafted with developers


compiling individual components (Linux kernel, bootloader, libraries,
applications) one by one

Modern embedded build systems have become more standardized and


automated, handling many of the complex steps automatically. Some
common modern build systems include Yocto, Buildroot, and OpenWRT.

Discussion of Embedded Build System types:

1) Buildroot: Oldest build system since 2001, very easy to use but you
cannot scale it, share data of it thus it is not made for complex tasks,
can employ ARM, RISC-V, PowerPC, it has more than 250
configurations. Root Filesystem can also build toolchain, bootloader,
kernel
2) OpenEmbedded: Inroduced after Buildroot, contain meta layers which
has “recipes”, recipe is something to cuild something, recipes are
processed by a task scheduler named BitBake, layers allow you to
move chunk of recipes from one environment to another, you can
share with different environment and organizations, in other words
OpenEmbedded is a tool to create custom Linux Distribution
3) OpenEmbedded Core: Use to build other build systems such as
OpenEmbedded itself, Poky(part of Yocto Project), ELDK from Denx,
Mentor Graphics Linux
4) Yocto Project: Alinux foundation sponsored project, commonly used
to build reliable embedded systems, it consist of
 Oe-core and BitBake also shared with OpenEmbedded
 Poky
 Ref. BSP’s include BeagleBone

Real-Time: In order to achive 100% accuration of no missing of deadline is


only possible mathematically that could be implemented at bare-metal
programming at MCU’s, thus for critical RTOS we use MCU’s because critical
RTOS operation cannot be done on MPU’ s because they are not 100%
accurate

What we would do for Real-Time and Linux?

Real-time in user space: Linux scheduling policies:

- SCHED_NORMAL -> Not deterministic, Use to each thread a fair share


of CPU time
- SCHED_FIFO ->Threads based on Priority(just like I did with PendSV
having more priority than SysTick)

Scheduler prefers to run SCHED_FIFO threads. Only when we have left with
no threads then algorithm runs Real-time threads always preempts
SCHED_NORMAL

You can change the behavior of linux by setting kernel preemption, that
means kernel is now preemptable, that means if we get an interrupt while
running interrupt code we will go that interrupt and do re-schedule and run
high priority thread using CONFIG_PREEMPT

PREEMPT_RT: Real-time is not fast because it is deterministic, if you want the


system to fast then you need non-deteministic approach

Raspberry Pi altogh not good embedded processor and even you should
use it in grand scehem of thing s but it is commonly used and well
supported, but running an OS on RaspberryPi is not a good idea

YACTO PROJECT:

1) Embedded Hardware:
a. Commodity Hardware: Plugin-play(PC, x86, Rapsberry PI but not
industry spec(see RPi CM)
b. Bespoke Hardware: Custom design board, cheaper less power
dissipation, mostly ARM and now RISC-V is catching up
c. Semi-Bespoke: Single Board computer, System On Board
2) Yocto Project: allows you to create your own distro, Yocto project and
OpenEmbedded has been used to create the software running on many
many millions of devices, WebOS used in LG is running Yocto,
Automotive Grade Linux used by Toyota manufacturers in their engine,
Oniro used in IoT and based on eclipse based projects, Oniro has
integration Zephyr which is used for remot sensors, Yocto use as a
gateway, about 100 million plus devices are running by Yocto
now
Little History: 2003 OpenEmbedded born because Linux now can run
small devices, 2004 Poky Linux born at building WebPad N770 by a guy
called Richard Perdy, Intel and Linux Foundation create a Ypcto project
in 2010
i) Yocto project versions: releses twice a year with named like
Rocko Zeus and Thud, each version is maintained by 12 months
to 12 months, everyone chooses a version called LTS(Long Term
Support) and they supported for 24 months
ii) Getting Yocto Project:
$ git clone -b scarthgap https://github.com/yoctoproject/poky
//initialize your shell by sourcing your source script and variables
that are need by Yocto build systems
$ source ./oe-init-build-env <builddir>
git

You might also like