01_Introduction linux
Moatasem Elsayed
History
Green -> opensource
Red -> closed source
Linus Torvalds
1960 s, Bell Labs was involved in a project with MIT->
Multics (scheduler,rings,perm,multiprocessors)
In 1969 a team of programmers in Bell Labs who worked
in Multics decided to make a better OS→unics
In 1973 Ritchie rewrote B and called the new language the C language
In 1983 Bell Labs decided to make a closed commercial
version of unix and called it System V
In 1983 Richard Stallman started a development of free software GNU
In 1991 Linus Torvalds build a free, open source kernel
name it Linux
Combining Linux with the almost complete GNU system
resulted in a complete operating system the GNU/Linux
system
Nowadays, there are many distributions of GNU/Linux
systems such as (ubuntu,arch,fedora,debian,kali,void,etc)
In 1994 Nasa
What is “Linux” ?
What is Linux?
● Linux is an open-source operating system linux=kernel.
● Created by Linus Torvalds in 1991 as a hobby project.
● It's the heart of various Linux distributions (distros).
Features of Linux
● Open Source: Source code is freely available and can be modified.
● Portability: Runs on various hardware platforms.
● Multi-User and Multi-Tasking: Supports multiple users and processes.
● Networking: Excellent support for networking protocols.
● Security: Strong security features and access controls.
Why Choose Linux?
● Cost: No licensing fees, making it cost-effective.
● Customization: Highly customizable and adaptable to different needs.
● Stability: Known for stability and reliability.
● Community: Large and active community for support and collaboration.
● Development: Extensive development tools and libraries available.
Introduction to Embedded
Linux
Embedded Linux
What is the Embedded Linux ?
o Embedded Linux is the customization of Linux on Embedded target .
o Adapting the Linux kernel and customizing the user-land libraries and utilities to
Embedded applications.
User Land
Kernel
Bootloader
YOCTO ..n
TOOLCHAIN Bitbake
Bootloader
2nd
Bootloader
SD-Card
So
Due to its ease of customization, Linux has been shipped in many
embedded devices (smartphones, network devices, PDAs, IVI, GPS
devices, ....).
Why we need Embedded
Linux ?
Why Linux ?
1-Freedom
2-Safe(Secure).
3-abstraction
Up to date
3-Ported to a large variety of CPU architectures
Why Linux ?
5-Large device drivers coverage.
-GPIO OF Raspberry pi
Why Linux ?
6-Hosting huge number of languages &
libraries.
7-Large Community.
8- Ease of Customization
9- File Structure
What are the job profiles ?
What are the job profiles ?
Application Engineer
( C, C++ , python ,java)
Linux
Admin..
Board Support
System Integrated Package
Engineer ( Engineer
Buildroot , Yocto , (Device Drivers)
OpenEmbedded)
(BSP)
Prerequisites for Hardware to
Support Embedded Linux
Prerequisites for Hardware to Support Embedded Linux
Processor Architecture
● The hardware target must use a processor architecture supported by the Linux
kernel.
● Common architectures include ARM, x86, MIPS, PowerPC, etc.
Memory & Storage
● For minimal, you may need around 64MB to 128MB of RAM.
● For a basic graphical user interface (GUI) environment, you may need at least 256MB
to 512MB of RAM.
● MMU
Cont ..
Bootloader
● A bootloader like U-Boot is needed to load the Linux kernel into memory.
● Bootloader configuration must match the hardware specifications.
Kernel Support
● The Linux kernel must have drivers for the hardware components on the target.
● Without proper drivers, the hardware won't function correctly.
● Device Tree is supported
Toolchain
● A cross-compilation toolchain is required to build software for the target platform.
● Toolchain includes compilers, libraries, and utilities for the target architecture.
Power Management:
● Linux systems require power management features for sleep, suspend, and wake-up operations.
The MCU should support power management mechanisms to conserve energy.
Main Components to Build
Linux
Software
1
2
3
4 Toolchain
5
6 Bootloader
7
8 Kernel
9
10 Rootfs
11
12
13
14
Booting Sequence
Booting Process ROM
RAM BIOS/UEFI HDD
1- POST
1- initial HW Drivers [screen, keyboard]
2-check HW Functionality
3-check portable device
4-check short circuit
2-LOAD (MBR/GPT)
CPU
Rom Bootloader
Booting Process EEPROM
Master Bootable Record/GUID Partition Table
RAM load 2nd stage of bootloader
BIOS/Uefi HDD
1- POST
1- initial HW Drivers [screen, keyboard]
2-check HW Functionality 512
512byte
byteMBR/GPT
MBR
512 byte MBR/GPT 3-check portable device
4-check short circuit
2-LOAD (MBR/GPT)
CPU
MBR
2 tera
Booting Process EEPROM
2nd Stage Bootloader
RAM BIOS (Grub[Lx] - BOOTMGR[w7,8,9,10 ] - NTDR(win98,xp) HDD
1- POST 1- select between os
1- initial HW Drivers [screen, keyboard]
2- load kernel
2-check HW Functionality
512 byte MBR 512
512byte
byteMBR
MBR
3-check portable device
4-check short circuit
2-LOAD (MBR)
2nd stage BL(Grub) 2nd stage BL(Grub)
CPU
Booting Process EEPROM
RAM BIOS HDD
1- Load Device Drivers( Printer , GPIO ,
1- POST
Network,etc)
1- initial HW Drivers [screen, keyboard]
2-check HW Functionality
2-memory initializations (RAM) 512
512byte
byteMBR
MBR
512 byte MBR 3-check portable device
3-run init process
4-check short circuit
2-LOAD (MBR)
4- run user process
2nd stage BL(Grub) OS(scheduling-dispatching) 2nd stage BL(Grub)
Kernel
Kernel
CPU
Kernel
Booting Process EEPROM
RAM BIOS HDD
1- POST
1- initial HW Drivers [screen, keyboard]
2-check HW Functionality 512
512byte
byteMBR
MBR
512 byte MBR 3-check portable device
4-check short circuit
2-LOAD (MBR)
2nd stage BL(Grub)
2nd stage BL(Grub)
Kernel
Kernel
Initramfs
CPU Initramfs
InitRamfs not Mandatory for some devices/ if it is not exit so kernel will mount rootfs directly
initramfs (initial RAM filesystem) is an initial root filesystem that is loaded into memory during the boot process before the actual root
filesystem is mounted.
The primary purpose of initramfs is to facilitate the needs for kernel when the kernel needs to perform certain tasks before it can fully
access and mount the root filesystem. These tasks may include:
● Loading Necessary Kernel Modules
● Filesystem Repair and Maintenance
● Root Filesystem Mounting
Mount Root FileSystem EEPROM
RAM BIOS HDD
1- POST
1- initial HW Drivers [screen, keyboard]
2-check HW Functionality 512
512byte
byteMBR
MBR
512 byte MBR 3-check portable device
4-check short circuit
2-LOAD (MBR)
2nd stage BL(Grub)
2nd stage BL(Grub)
Kernel
Kernel
CPU Initramfs
Root FileSystem
Init Process (SV , SD)
1
2
3
4
5
6
7
8
9
10
11
SystemD 12and SystemV are both init systems used in Linux,
13 in the way they manage services and
but they differ
14SystemV uses traditional init scripts and
processes.
runlevels, while SystemD use unit files and targets services
Init Script
init.d—-----> bash scripts
1
2
3 Kernel /sbin/init /etc/inittab rc {runlevel}
4
5
6
7
8 scripts
network,mount,system
9
10
11
12 open shell
13
14
Add script to SV
1
2
3
4
5
6
7
8
9
10
11
12
cp myscript.sh /etc/init.d/
chmod +x 13 /etc/init.d/myscript.sh
14
sudo update-rc.d myscript.sh defaults
-> it will create symlink to rc3.d/
Systemd
1
2
3
4
5
6
7
8
9
10
11
1-12
add file.service to /usr/lib/systemd/
2-13
systemctl daemon-reload
3- systemctl enable file.service
14
4- systemctl start file.service
Init process start to run all services of system
1
2
3
4
5
6
7
8
9 Even If the GUI is service that run server to
10 listen to application that need to create
11 windows
12
13
14
GUI
GUI
1
2
3
4
5
6
7
8
9
10
11
12
13
14
System Call
System Call
1 A system call is a way for programs to interact with the operating system
2
3
4
5 Services Provided by System Calls :
6 1. Process control: end, abort, create, terminate,
allocate and free memory.
7 2. File management: create, open, close, delete, read
file etc.
8 3. Device management
4. Information maintenance
9 5. Communication
10
11
12
13
14
System Call
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Journey of system call in CApp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
How to know all system calls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Linux Distro Is Needed
Linux Distro Is Needed
Install Ubuntu
1 1-Install as primary
2
3 2-Dual Boot
4 3-Run Ubuntu from USB drive without installation
5
6 4-Use virtual machine such as VMware or VirtualBox
7
8
9
10
11
12
13
14
Folder
Structure
Let's see Ubuntu System
1
2
3 Everything is File
4
5
6
7
Command is File Directory is a file Device is a file Process is a file Peripheral is file
8
9
10
11
12
13
14
File System
1 In windows you might have drives like C, D, etc in which your files are slitted However, in
2 Linux there is something called Root Directory in which all your files are present
3
4 the Root directory is the start of absolute paths for all files on the system
5
6
7
8
9
10
11
12
13
14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/bin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/etc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/sbin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
1
2
3
4
5
6
7
8
chrome/matlab
9
10
11
12
13
14
/usr ("Unix System Resources" or "User System Resources,)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Summery
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Tasks
1
2 1- resolv.conf
2-fstab
3
3-.bashrc,.bash_profile
4 4-passwd,groups
5 5-crontab
11-timezone
6 6-uptime
7-/proc/cmdline
7
8-sources.list
8 9-XDG_SESSION_TYPE
9 10-DISPLAY
10
11
12
13 12-
14