Anda di halaman 1dari 142

EC352 : EMBEDDED LINUX

By Hiren Mewada, CSPIT - CHARUSAT


Outline to be covered

Sr. No. Title of the Unit


M e w a d a

1. Introduction to Embedded Linux


2. Boot Loader

3. Kernel Internals & Construction


H i r e n

4. File systems
5. Embedded Linux Device Drivers
B y

6. Advance driver concepts


Outline to be covered
 Books and material:
 Embedded Linux Primer by Christopher Hallinan,
M e w a d a

Prantice Hall
 Embedded Linux System Design & Development by P.
Raghvan, Amol Lad, Sriram Neelakandan
H i r e n

 Linux Device Driver, Jonathan Corbet, Alessandro


Rubini, and Greg Kroah-Hartman, O’Reilly
 Introduction to Linux A Hands on Guide by Machtelt
B y

Garreles
Terminology
 Source code: The version of software as it is
originally written (i.e., typed into a computer) by a
M e w a d a

human in plain text (i.e., human


readable alphanumeric characters).
 An executable file: A binary file (i.e., a file at least
H i r e n

part of which is not plain text) that has


been compiled (i.e., converted using a special type
of program called a compiler) from source
B y

code into machine machine code.


Terminology
 Program: An executable file that is held in storage.
Storage refers to devices or media that can retain
M e w a d a


data for relatively long periods of time (e.g., years
or even decades), such as hard disk drives (HDDs),
optical disks and magnetic tape.
H i r e n

 Memory’s contents can be accessed (i.e., read and


written to) at extremely high speeds but which are
retained only temporarily (i.e., while in use or only
B y

as long as the power supply remains on)


Terminology
 Process: An executing (i.e., running) instance of
a program.
M e w a d a

 Processes are also frequently referred to as tasks.


 A dynamic entities in that they are constantly changing as
their machine code instructions are executed by the CPU.
 Consists of (1) system resources that are allocated to it, (2)
H i r e n

a section of memory, (3) security attributes (such as


its owner and its set of permissions) and (4) the
processor state.
 A program is a passive entity until it is launched, and a
B y

process can be thought of as a program in action.


Terminology
 Process: A process is defined as an entity which
represents the basic unit of work to be implemented
M e w a d a

in the system.
 When a program is loaded into the memory and it
becomes a process, it can be divided into four
H i r e n

sections:
Stack: temporary data such as method/function parameters, return
address and local variables
Heap: dynamically allocated memory to a process during its run
B y

time.
Text: current activity represented by the value of Program Counter
and the contents of the processor's registers.
Data: global and static variables.
Terminology
 Kernel: a program that constitutes the central core
of a computer operating system.
M e w a d a

 It is not a process, but rather a controller of


processes, and it has complete control over
everything that occurs on the system.
H i r e n

 Manages individual user processes within user space


and preventing them from interfering with each
other.
B y
File system
 Computer don’t understand tree structure.
 A file is represented by inode.
M e w a d a

 inode: a kind of serial number consist of  to whom file belongs


to and where it is located in hard drive
 Owner and group owner of the file.
 File type (regular, directory, ...)
H i r e n

 Permissions on the file, Date and time of creation, last read and
change.
 Date and time this information has been changed in the inode.
 Number of links to this file (see later in this chapter).
B y

 File size
 An address defining the actual location of the file data.

file name and directory missing in inode. These are stored in the special directory files
File system
 Get list of inode:
$ ls –I filename
M e w a d a

$ stat filename % to see more information


 To delete file using inode
$ find ./ -inum number -exec rm -i {} \;
H i r e n
B y

file name and directory missing in inode. These are stored in the special directory files
Embedded System
 Single function
 Execute single program, repeatedly
M e w a d a

 Tightly-constrained (real time constraints)


 low cost, low power, small, fast
 Reactive and real time :
H i r e n

 Continually
reacts to changes in the system’s environment
 Must compute certain results in real time without delay

Electronic systems including hardware and software


B y

to control systems designed for specific purpose


Embedded System
 Characteristic of Embedded System:
Contains processing engine i.e. microcontroller
M e w a d a

 Designed for specific application /purpose


 Includes simple/no user interface i.e. automotive engine
ignition control
H i r e n

 Often resource limited and power constraint


 Application software are inbuilt, not user selected i.e.
Mobile
B y

 Embedded system have inbuilt circuit for debugging.


Embedded System
 Embedded operating sytem:
 Wind River’s Vxworks
M e w a d a

 Microsoft Windows CE

 QNX Nuetrino

 Red Hat’s eCosTM


H i r e n

 Sun Microsystems ChorusOSTM

 LynuxWorksTM’s LynxOS
B y
B y H i r e n M e w a d a

Embedded System
B y H i r e n M e w a d a

Embedded System
Embedded System and Linux
 Embedded Linux system: does not involve Linux at
all.
M e w a d a

 Processor reset and start executing code from given


location.
 Bootloader and Linux kernel play role.
H i r e n

Linux system
Boot loader environment
User Space
Load and
Linux Kernel
B y

CPU jump to start


Boot loader
Device driver

Hardware
Embedded System and Linux
 User space: portion of system memory in which user
processes run.
M e w a d a
H i r e n
B y

Include programs that are written in C, Java, Python, Ruby, and other languages
Embedded System and Linux
 Kernel Space: provides abstraction for security,
hardware, and internal data structures.
M e w a d a

 Kernel space can be accessed by user processes


only through the use of system calls.
H i r e n
B y
Embedded System and Linux & C
 C provides user space applications with predefined
interface.
M e w a d a

 Acts as a bridge between the userspace application


and kernel.
 C Versions:
 Desktop PC: GNU C / turbo C
H i r e n

 Full-fledge library available to user


 Embedded system: uClibc or newlib or other
B y

 Skip database lib, limits the number of authentication


method, limits math lib, leaves encryption function.
Cross compilation
 Execute user specified code and generate
compatible binary files.
M e w a d a

 Run on windows/ Linux but generates code that run


on other os i.e android smart phone
 Resulting binary files are utilized and loaded into
H i r e n

hardware
B y
Remembering
 What is CISC?
Which of the following offers external chips for
M e w a d a


memory and peripheral interface circuits?
 a) Microcontroller b) Microprocessor c) Peripheral
system d) Embedded system
H i r e n

 Which one of the following offers CPUs as


integrated memory or peripheral interfaces?
 a) Microcontroller b) Microprocessor c) Embedded
B y

system d) Memory system


Remembering
It retains its content when power is removed. What type
of memory is this?
M e w a d a

a) Volatile memory b) Nonvolatile memory c) RAM


d) SRAM
Name a volatile memory.
Which type of memory is suitable for low volume
H i r e n

production of embedded systems?


a) ROM b) Volatile c) Non-volatile d) RAM
B y
Linux vs Windows
 Server :
M e w a d a

Super computer
H i r e n


B y
Why Linux?
 Vendor independent : Same and common basic
components such as Linux kernel, libraries, basic utility.
M e w a d a

 Time to market:
 Availability of rich set of toolsets and utilities.
 Application can be tested on Linux host and port this
application to the board.
H i r e n

 Varied hardware support:


 Linux support for many architectures and high-end I/O
devices gives you the independence to choose appropriate
B y

hardware for your system.


 Low cost and open source
Why Linux?
 Support a vast variety of hardware devices,
probably more than any other OS
M e w a d a

 Linux supports a huge variety of applications and


networking protocols
 scalable, from small consumer-oriented devices to
H i r e n

large, heavy-iron,carrier-class switches and routers


 Linux can be deployed without the royalties
required by traditional proprietary embedded
B y

operating systems.
What is Linux?
 Linux / Unix is an operating system
 A computer can be divided into 3 main functional
M e w a d a

layers:
 Applications: the highest functional layer. This layer includes
software programs that run for a specific purpose.
 Example: this power point presentation, an email tool, a web
browser
H i r e n

 Operating System: the middle functional layer. The OS


controls the hardware and supports the applications running
above it.
 Example of popular OS: Linux, Unix, Windows, Mac OS
B y

 Hardware: physical devices that make up the computer


 Example hardware include: keyboard, monitor, hard disk
What is Linux?
 The main tasks of an operating system:
 Interactswith the user
M e w a d a

 Manages how applications run

 Handles data storage

 Controls hardware peripherals


H i r e n
B y
Linux Applications
 A wide range of applications:
 The internet runs on Linux servers
M e w a d a

 Movie special effects are created on Linux machines


 Banking and financial transactions are done on Linux
computers
 Video games are developed on Linux platforms
 Military computing are done on Linux machines
H i r e n

 Government records, such as taxes, are kept on Linux


computers
 University engineering and computer departments run
B y

classes on Linux computers


Embedded Linux Vs Desktop Linux
 Device driver: an embedded system may need a flash driver and a
flash file system (such as CRAMFS or JFFS2) whereas they are not
needed in a desktop system.
M e w a d a

 Toolset:
 In embedded Linux more focus is paid to tools that are needed for
development, debugging, and profiling.
 In embedded Linux focus is paid to a set of cross-development tools that
allow developers to build applications for their target on say x86-
based host systems.
H i r e n

 On the other hand, in desktop Linux more focus is paid to a set of


packages that are useful for users such as word processors, e-mail,
newsreaders, and so on.
 Windowing and GUI environments that are used in embedded Linux
B y

differ from the desktop ones.


 Targets deploying embedded Linux mostly run in single-user mode
with almost no system administration capabilities. On the other hand,
system administration plays a very important role in desktop Linux.
History of Linux/Unix
 Unix was officially announced to the world in 1969
 Before Unix, computers had operating systems that
M e w a d a

are:
 hardware specific: Changing computers meant
changing all the software so they could work with the
new hardware
 single tasking: Only one job could be done at a time on
H i r e n

the computer, everyone had to sign up for a timeslot on


the computer
 single user: Sharing data meant making a tape of your
B y

data and giving it to another user


History of Linux/Unix
 Multics (Multiplexed Information and Computing Service):
 Developed by scientists at AT&T Bell Labs, MIT, and GE worked
M e w a d a

together
 A new time-sharing operating system.
 Lead to a multitasking, multi-user OS
 However the Multics project became too large. It was difficult to
manage and the project ended in 1969
H i r e n

 Unix:
 Developed by Bell Labs from Multics to create an even more
progressive operating system, which they originally named Unics,
B y

a play on the word Multics.


 Eventually the spelling of Unics changed to Unix
Characteristic of Unix
 Multi-tasking: the OS appears to do multiple tasks
at the same time by switching between all the tasks
M e w a d a

and giving its time to each task one at a time (also


known as time-sharing)
 Multi-user: the OS can support many users logging
in at the same time, as well as one user logging in
H i r e n

multiple times at once


 Portable: the OS is written in a high-level language
(C) and therefore can be run on different hardware
B y

platform
Story behind Linux development
 University involvement: In 1969 Bell Labs released
Unix, for free, to the Engineering and Computer Science
M e w a d a

departments at different universities.


 The universities embraced Unix and their graduate
students began work developing add-ons to the source
code. One such university was the University of
H i r e n

California, Berkeley.
 Eventually there were 2 major versions of Unix: (1) Unix
System V (developed by AT&T) (2) Unix BSD
B y

(developed by UC Berkeley)
Story behind Linux development
 Industry involvement: The graduate students
eventually went on to found successful start up
M e w a d a

companies such as Sun Microsystem, SGI, etc. and


brought Unix to the high tech industry in the late
1970s and early 1980s.
 The success of the start up companies caused many
H i r e n

established companies such as IBM, Microsoft, HP,


etc. to also adopt Unix.
 Unix became the OS platform for many companies
B y

in the high tech industry.


Story behind Linux development
 Drawback: Unix became copyrighted and had a
high price attached to it. It was partly because of
M e w a d a

this high price that Microsoft, with its less expensive


DOS operating system.
 DOS the operating system of choice when desktop
H i r e n

computers became widely available to the general


public
B y
Story behind Linux development
 Linux: The Free Software Foundation was formed to establish the
open source movement.
Goal is to develop software open for anyone to work on and be
M e w a d a


free of charge.
 Supported by the open source movement, in 1991
Linus Torvalds created a Unix operating system that is
meant to run on a desktop computer. He named it
H i r e n

Linux.
 Linux today:
 Used in many applications, from embedded systems to servers to
supercomputers
B y

 Many people around the world maintain and enhance Linux, since it is an
open source product
 Different packages of Linux are called distributions, and can be
downloaded and installed for free
Linux vs Unix
 Unix is proprietary to each company that uses the Unix
platform. Some examples are IBM AIX, HP UX, SGI IRIX,
Sun Solaris, DEC Ultrix. These OS are all Unix based
M e w a d a

and follow the same, uniform Unix standard called


POSIX.
 Linux is the same way, it follows the same POSIX
standard. But Linux is open source and is free.
H i r e n

 All utilities covered in this class follow this POSIX


standard and will work with both the proprietary Unix
and with Linux. Therefore for the rest of this class,
“Linux” will be used to shorten the full name “Linux /
B y

Unix”

POSIX (Portable operating system interface): a standard maintain compatibility between OS


Linux – Open source
 Linux is open source.
Licensed under the terms of GPL (General Public
M e w a d a


License) – terms as freely available.
 Free means not cost wise but based on freedom.
 User can study, modify and redistribute it.
H i r e n

 Moblin : Mobile Linux initiative


 Area of focus: Memory management, multimedia
B y

performance, power management, security and


storage.
Anatomy of Embedded System

Program
& Data
M e w a d a

storage
H i r e n

Time
Day
B y
Anatomy of Embedded System
M e w a d a
H i r e n
B y
Boot process
 BIOS: Basic input-output system
 Performs system integrity checks (Power on self test (POST)),
Load and execute boot loader
M e w a d a

 MBR: First sector of bootable disc, executes bootloader


 GRUB: Selection of specific kernel image (OS) if
multiple kernel images are available.
KERNAL: mounts root file system specified in grub.conf
H i r e n

 INIT: to decide the Linux run levels


 RUN Levels: to decide which program are loaded at
startup
B y

 Halt, single user mode, multiuser w/o NFS, full multiuser


mode, reboot etc..
Boot process
 RUN Levels:
 Halt: Shuts down system
M e w a d a

 Single-User Mode:
 to boot into the operating system as a superuser
 Booting a system into this mode does not start
networking
H i r e n

 to change the root password for a server on which the


current password is unknown.
Multi-User Mode: Does not configure network
B y


interfaces
Booting process
BIOS reads the first sector of the hard disk
drive.
M e w a d a

BIOS passes the control to Master Boot


Record located at the address 0000:7c00,
which triggers the OS booting process.
H i r e n
B y
Booting process

BIOS • Checks the basic operability of the hardware


POST • Issues a BIOS interrupt, INT 13H, which locates the
M e w a d a

boot sectors on any attached bootable devices.


• The boot sector is really the first stage of the boot
loader.
GRUB2 • GRand Unified Bootloader
H i r e n

• Program which makes the computer just smart enough to


find the operating system kernel and load it into memory
• Allow the user to choose to boot from among several
B y

different kernels for any given Linux distribution


• Load Linux kernel into memory and run it
Booting process
Stage-1 • Searches the attached disks for a boot record, usually
located in the Master Boot Record (MBR) – 512 byte only
(sector – 0 of HDD)
M e w a d a

• No information about the file system


Stage 1.5 • Sector-2 to sector 62 of HDD
• Contains code related to file system
Stage-2 • Located in /boot/grub2 directory and several
H i r e n

subdirectories
• To locate and load a Linux kernel into RAM and turn control
of the computer over to the kernel.
B y

Kernel • Extract the kernel and load systemd file


• Responsible for bringing the Linux host up to a state in which
productive work can be done.
• Mounts file system
BIOS vs Bootloader
 BIOS : Basic Input-output software
Take control of processor as soon as power is
M e w a d a


applied.
 Stored in flash memory
 Initialized the hardware – memory subsystem and
H i r e n

load operating system from system’s hard drive.


B y
Bootloader
 Bootloader: The first section of code to be executed
after the embedded system is powered on or reset
M e w a d a

on any platform
 Software program equivalent to BIOS except work
in embedded system.
Initialized critical hardware components i.e. SDRAM
H i r e n


controller, I/O controller, graphics controller.
 Initialized system memory
B y

 Allocate system resources such as memory and


interrupt circuit to peripheral controller
Bootloader
 Bootloader for Embedded system
U-Boot (Universal Boot loader): Boot loader for
M e w a d a


PowerPC or ARM based embedded Linux systems.
 RedBoot (RedHat eCos derived, portable,
embedded system boot loader)
H i r e n

 rrload (Boot loader for ARM based embedded


Linux systems
B y
Bootloader
 FILO : x86 competible bootloader, load image
without help of BIOS
M e w a d a

 CRL/OOH : flash bootloader for ARM based


embedded linux system
 PPCBoot : bootloader for power pc based
H i r e n

embedded linux system


 Alios: Assembler based linux loader , can initialize
hardware from ROM/RAM
B y
Bootloader
 As we can see, there are various boot loaders for
different CPU architecture and Target Board
M e w a d a

 it is highly processor specific and board specific


 Therefore, it’s nearly possible to develop a boot
loader suited for every platform.
H i r e n

 But we can still summarize concepts of the design of


Boot Loaders
 Bootloader vary from CPU to CPU
B y

 Installation is only in nonvolatile memory i.e. flash


Bootloader
 1st stage
 Initialize hardware components
M e w a d a

 Read/Write non-volatile storage devices (Prepare memory


space for loading 2nd stage program)
 Copy 2nd stage program in memory
 Jump to entry point of 2nd stage
H i r e n

 2nd stage
 Initialize hardware components used in this stage
 Check memory map
B y

 Copy kernel and root file system images into memory


 Set parameters and boot kernels
Bootloader
-Map the RAM to
Power Find program code at
predefined addresses
M e w a d a

Button a specific address


-Set up stack pointer
load the kernel image Initialize the peripheral
from a known location: needed by bootloader
H i r e n

File, Memory, Network i.e. KB, terminal, Ethernet


Read Obj file
Mount root
and extracts the Copy Kernel to RAM
B y

FS, load
memory image Transfer control to Kernel
needed
jump to the entry
modules
point
Bootloader
 Functional blocks:
 Main function module
M e w a d a

 Initialize CPU and set clock rate


 Mask all interrupts
 Set up stack pointer
 Load images of Linux kernel and root file system to system’s RAM, and
execute kernel
I/O channel driver module
H i r e n


 Provide interface to send command to target board or to inform users
the status of target board
 Initialize I/O port
Memory device driver module: Initialize memory
B y


 Configure page size, memory size and other memory management
registers
Bootloader
MPC8548CDS

Starting target board: Initial bootloader serial o/p


M e w a d a

U-Boot 2009.01 (May 20 2009 - FLASH: 16 MB


09:45:35) L2: 512 KB enabled
CPU: 8548E, Version: 2.1, (0x80390021) Invalid ID (ff ff ff ff)
Core: E500, Version: 2.2, (0x80210022) PCI: 64 bit, unknown MHz, async, host,
Clock Configuration: external-arbiter
CPU:990 MHz, CCB:396 MHz, Scanning PCI bus 00
H i r e n

DDR:198 MHz (396 MT/s data rate), PCI on bus 00 - 02


LBC:49.500 MHz PCIE connected to slot as Root Complex (base
L1: D-cache 32 kB enabled address e000a000)
I-cache 32 kB enabled PCIE on bus 3 - 3
Board: CDS Version 0x13, PCI Slot 1 In: serial
B y

CPU Board Revision 0.0 (0x0000) Out: serial


I2C: ready Err: serial
DRAM: Initializing Net: eTSEC0, eTSEC1, eTSEC2, eTSEC3
=>
Bootloader Low level hardware
initialization – RS232

Starting target board: Initial bootloader serial o/p


M e w a d a

U-Boot 2009.01 (May 20 2009 - FLASH: 16 MB


09:45:35) L2: 512 KB enabled
CPU: 8548E, Version: 2.1, (0x80390021) Invalid ID (ff ff ff ff)
Core: E500, Version: 2.2, (0x80210022) PCI: 64 bit, unknown MHz, async, host,
Clock Configuration: external-arbiter
CPU:990 MHz, CCB:396 MHz, Scanning PCI bus 00
H i r e n

DDR:198 MHz (396 MT/s data rate), PCI on bus 00 - 02


LBC:49.500 MHz PCIE connected to slot as Root Complex (base
L1: D-cache 32 kB enabled address e000a000)
I-cache 32 kB enabled PCIE on bus 3 - 3
Board: CDS Version 0x13, PCI Slot 1 In: serial
B y

CPU Board Revision 0.0 (0x0000) Out: serial


I2C: ready Err: serial
DRAM: Initializing Net: eTSEC0, eTSEC1, eTSEC2, eTSEC3
=>
Prepare memory space
Bootloader
Starting target board: Initial bootloader serial o/p
M e w a d a

U-Boot 2009.01 (May 20 2009 - FLASH: 16 MB


09:45:35) L2: 512 KB enabled
CPU: 8548E, Version: 2.1, (0x80390021) Invalid ID (ff ff ff ff)
Core: E500, Version: 2.2, (0x80210022) PCI: 64 bit, unknown MHz, async, host,
Clock Configuration: external-arbiter
CPU:990 MHz, CCB:396 MHz, Scanning PCI bus 00
H i r e n

DDR:198 MHz (396 MT/s data rate), PCI on bus 00 - 02


LBC:49.500 MHz PCIE connected to slot as Root Complex (base
L1: D-cache 32 kB enabled address e000a000)
I-cache 32 kB enabled PCIE on bus 3 - 3
Board: CDS Version 0x13, PCI Slot 1 In: serial
B y

CPU Board Revision 0.0 (0x0000) Out: serial


I2C: ready Err: serial
DRAM: Initializing Net: eTSEC0, eTSEC1, eTSEC2, eTSEC3
=>
2nd stage hardware initialization
Bootloader challenges
 Initialization and allocation of requirements of the
bootloader i.e. DRAM
M e w a d a

 DRAM:
 Require detail knowledge of DRAM architecture, chip and
hardware design
 must be refreshed constantly
H i r e n

 DRAM controller: configure DRAM, refresh the data within


defined time, respond to the read and write operation
Some bootloader copy themselves in DRAM after
B y

initialization.
Bootloader challenges
 Flash and RAM:
Second complexity: to store the bootloader in
M e w a d a


nonvolatile memory but usually loaded into RAM for
faster execution.
 No infrastructure is available when bootloader
H i r e n

gains control.
B y
Bootloader challenges
 Image complexity:
Complete control over how the image is constructed
M e w a d a


and linked
 Need to organize the startup code for specific
processor’s boot sequence
H i r e n

 Linker for constructing a binary executable image


 For bootloader: no such environment, no DRAM
(untill it initializes the processor), Failure of C-
B y

function
Remembering
 Which is not the function of OS?
(a) Memory management (b) Disk management (c ) Virus
M e w a d a

protection
 What is the initial stage of Linux boot process?
(a) System Startup b) Stage 1 boot loader (c) Kernel
H i r e n

(d) init
 In stage 1 boot loader, the first _____ bytes are the
primary boot loader.
B y

a) 450 b) 449 c) 448 d) 446


Bootloader
Call or start the kernel image:
 Set the CPU to supervisor mode with IRQ disabled.
M e w a d a

 Turn off the Memory Management Unit (MMU). The

code running in RAM does not have translated


addressing yet.
H i r e n

 Turn off the data cache

 Set the register r0 to 0, r1 to the ARM Linux machine


type, and r2 to the physical address of the parameter
B y

list
Main component of Linux
 Kernel:
 the core of the OS, only one
M e w a d a

kernel can run per system


 gets loaded into in the main
memory during power up
 manages resources so that
H i r e n

multitasking can take place


 File System: for data storage
 data are organized into files
B y

 files are organized into


directory structures
 Shell: how the user interfaces with the OS
 the shell interprets what the user types on the keyboard so it
can be run by the system
M e w a d a

 there can be more than one shell running at a time


 the shell also coordinates multiple commands in a file and
acts as a programming language
 Utilities: tools to help a user do work on the system
H i r e n

 also called commands


 there are many utilities, each utility is supposed to do one
task and do it well
B y

 they are programs run by the users to do specific tasks, such


as copy a file, send email, communicate with another user,
check system resources
Working with Linux
 Case sensitive: Linux considers uppercase letters to
be different than lowercase letters. This means that
M e w a d a

the utility named cp is not the same as Cp or CP


 To run a utility, always:
 make sure you see the shell prompt first. The line you
H i r e n

type your input is called the command line


 start the command line with the command name

 hit the enter key when you’re done


B y
Working with Linux
 When you work with Linux, you interact with the shell
The shell works in a cycle:
M e w a d a

 prints the shell prompt to indicate that it’s ready for your
input
 interprets the command you type in
H i r e n

 runs the corresponding utility that you request

 sends the output to where you request

 prints the shell prompt again


B y
 Command Format:
command_name options arguments
M e w a d a

 The command_name is one word and is required


 The options are optional. There can be 0, 1, or more
options.
H i r e n

 The arguments maybe required or optional, depending on


the utility you select. There can be 0, 1, or more arguments.
 The command_name, options, and arguments are
separated by at least one space. Typically one space is
B y

used, but more than one space is okay.


More on command_name
 The command name tells the shell which utility you
M e w a d a

want to run.
 Each utility has a unique name. It is one short word
or an abbreviation of a word.
H i r e n

 The command name describes what the utility does

 Examples: find, who, cp (for copy), ln (for link)


B y
Basic Command
 The start and end of a session: passwd, exit
Information on users on the system: who, whoami,
M e w a d a


finger
 Information about your system or your terminal: tty,
stty, uname, clear
H i r e n

 Getting labs done: man, lpr, script, ls, cat


 General use: bc, date, cal, echo
B y
 tty, stty, uname, clear : - Commands related to your
terminal or system
M e w a d a

 tty: (terminal type) shows the ID of the terminal that you


are logged in at
[testuser@abc ~]$ tty
/dev/pts/1
H i r e n

 stty: shows basic settings of the terminal you are


logged in at, -a option: shows all settings
[testuser@abc ~]$ stty
speed 38400 baud; line = 0;
B y

-brkint –imaxbel
 uname: shows basic system information
-a option: shows all system information
M e w a d a

[testuser@abc ~]$ uname -a


Linux abc-desktop 2.6.18-
92.1.10.el5 #1 SMP Wed Jul 23 03:56:11 EDT
H i r e n

2008 x86_64 x86_64 x86_64 GNU/Linux


clear: clears the screen
B y
Script
 Captures output on screen into a file Useful when you
want to show proof of work, or show program output,
or do error reporting by capturing the error on screen
M e w a d a

 When script runs, every character that appears on the


screen also appears in an output file that you choose.
When you exit out of script, the output file is saved and
closed.
H i r e n

 A filename is a recommended argument. If you don’t


give a filename, a default filename (which is typescript)
is used.
B y

 If you give the same filename as an existing file, the


existing file will be overwritten
Script
 The –a option will cause script to append to an
existing file, rather than overwrite it
M e w a d a

 Don’t run script when another script session is


already running. This causes the output file to be
very big and unreadable.
Don’t make too many typing mistakes when script is
H i r e n


running. The mistaken characters and all the
backspacing characters to fix the typing mistakes
will all be recorded and appear as one long, ugly
B y

string in your output file


Script : Capture screen
 [testuser@abc ~]$ script sample<- start screen
capture into file called sample
M e w a d a

 Script started, file is sample


 [testuser@abc ~]$ who
 tran pts/1 2014-07-03 14:05 (153.18.21.226)
H i r e n

 testuser pts/2 2014-07-03 14:21 (c-67-180-237)

 [testuser@abc ~]$ finger testUser


 Login: testuser Name: Test User
B y

 Directory: /home/testuser Shell: /bin/bash


 [testuser@abc ~]$ exit <- end screen capture,
Script done, file is sample
M e w a d a

 [testuser@abc ~]$ script -a sample<- start screen


capture again
 Scriptstarted, file is sample and append into file
H i r e n

called sample
 [testuser@abc ~]$ finger
 Login Name tty Idle Login Time Office Office Phone
B y

 testuser Test User pts/2 Sep 3 14:21 (c-67-180-


237)
 Tran pts/1 15 Sep 3 14:05 (153.18.21.226)
Files in Linux
 The Linux philosophy is “everything is a file”
The term “file” not only means a file of data (the
M e w a d a


typical meaning), it can also refer to an input
device (such as a scanner), an output device (such as
the monitor), a hardware component (such as the
H i r e n

hard drive), or a process (such as the shell that you


work with)
B y
Files in Linux
 Linux divides files into 7 different types:
1. Regular file: a file of data. Data can be text (human
readable) or binary (machine readable)
M e w a d a

2. Directory: a file that can “contain” other files (equivalent


to folders in Windows)
3. Character special file: IO device that processes one
character at a time, such as a printer
H i r e n

4. Block special file: IO device that processes a block of


characters at a time, such as a hard disk
5. Symbolic link: A system to make file/directory visible in
multiple parts of system’s file tree.
B y

6. FIFO: a file used for inter-process communication


7. Socket: a file used for network communication
Special files are available in /dev
Files in Linux
 The –l option to “ls” command displays the file
types, using the first character of each input line.
M e w a d a

Hirenmewada: ~/Documents/ls -l
total 20
-rw-rw-r-- 1 jaime jaime 31744 Feb 21 17:56 intro Linux.doc
-rw-rw-r-- 1 jaime jaime 41472 Feb 21 17:56 Linux.doc
drwxrwxr-x 2 jaime jaime 4096 Feb 25 11:50 course
H i r e n

 Characters determining file types:


Symbol Meaning Symbol Meaning
B y

- Regular file c Special file


d Directory s Socket
l Link P Named pipe
b Block device
Directories
 Directories help you organize files by providing ways to group
similar files together
M e w a d a

 In Linux, files are grouped into directories (which themselves


are files), and directories are grouped under other directories,
in “tree” form called a directory tree or directory hierarchy
 Each file in the hierarchy is called a node
H i r e n

 The top node is called root


 Except for root, each node can have
 1 node above it, called its parent node
B y

 0 or more nodes below it, called its child nodes

 A parent directory can have directory child nodes, called


subdirectories
Directories
 Directory Tree Diagram
In this sample directory tree:
M e w a d a

 There are 9 files


 Each file is a node

 One root node


H i r e n

 DirectoryC is the child node of root, and is the parent


node of a regular file
 DirectoryD is the subdirectory of DirectoryB
B y
Root directory
 There is only one root node for every directory
hierarchy
M e w a d a

 The actual name you type in for root is /


 Some common subdirectories under root are
 bin: (for binary) contains general Linux utilities, in binary
format, contains basic command i.e. cat, chmod, chgrp,
chown, date, dir, dd, df, ln, mv, echo
H i r e n

 sbin: (for system binary) contains utilities for system


administration i.e disk management, n/w management.
 etc: contains configuration files for the system
B y

 usr: (for user) contains applications for the users


 lib: (for library) shared libraries
Root directory
 var: (for variable) contains data files that change when
the system is running i.e. printing files
M e w a d a

 tmp: (for temporary) contains temporary files

 dev: (for device) contains files for hardware devices

 mnt: (for mount) contains mount points for storage


devices
H i r e n

 home: contains home directories of users


df command displays the information about non-swap partitions
hirenmewada:~> df –h
B y

Filesystem Size Used Avail Use% Mounted on


/dev/hda8 496M 183M 288M 39% /
/dev/hda1 124M 8.4M 109M 8% /boot
/dev/hda5 19G 15G 2.7G 85% /opt
 Booting the kernel
tftp command instruct U-Boot to load
M e w a d a

=> tftp 600000 uImage Kernel image into target device memory
Speed: 1000, full duplex
………….
Done
Bytes transferred = 1838553 (1c0dd9 hex)
=> tftp c00000 dtb Board configuration file called a device tree
H i r e n

Speed: 1000, full duplex


Using eTSEC0 device ……
…………………
Bytes transferred = 16384 (4000 hex) Bootm: boot from memory,
B y

=> bootm 600000 - c00000 Instruct U-Boot to boot kernel,


## Booting kernel from Legacy Image at Bootloader cease to exist
00600000 ...
…………..
Kernel Initialization
 Linux mount root file system remotely from PC
Root file contains the application program, system
M e w a d a


libraries and utilities that make linux.
Mount root and executes various codes
Do initialization process
Kernel has access to all physical memory
And have full authority to process
H i r e n

...
Looking up port of RPC 100005/1 on 192.168.0.9
VFS: Mounted root (nfs filesystem).
Freeing unused kernel memory: 152k init
INIT: version 2.86 booting
Enter in user space
B y

...
Operates in virtual memory space
login:
Need kernel services for further access
Advantage: error in one process can’t
trash the memory space of another
Kernel
 The kernel is a program that
constitutes the central core of a
M e w a d a

computer operating system. It has


complete control over everything
that occurs in the system.
H i r e n

 Kernel makes it services available


to the application program
through large collection of entry
B y

points called system call.


Kernel also known as process manager
uname –r : to know the kernel version
Kernel
User Space
M e w a d a

Kernel Hardware
request

Shell
H i r e n

Process Memory IO
Scheduler manager Scheduler

Network
IPC
B y

Services
File Device
system IO driver

Hardware
Kernel
 Abstraction layer : Protect user from the underlying
details of tracks, sectors, heads and free block of
M e w a d a

memory that user had have to get into if wanted to


talk to hardware directly.
#include <fcntl.h>
H i r e n

int main()
{
int fd, count; char buf[1000];
fd=open("mydata", O_RDONLY);
B y

count = read(fd, buf, 1000);


write(1, buf, count);
close(fd);
}
 Kernel is responsible for scheduling when several
process are waiting to run.
M e w a d a

#include <stdlib.h> This program creates a new process;


main() the original process (the parent) and the new
{ process (the child) each write a message to
if (fork()) standard output, then terminate.
{
H i r e n

write(1, "Parent\n", 7); The system calls fork(), exit()


wait(0); and wait() perform process creation,
exit(0); termination and synchronization respectively.
}
B y

else These are elegantly simple calls that hide


{ the underlying complexities of process
write(1, "Child\n", 6); exit(0); management and scheduling
}
}
 Kernel also implements networking protocols such as
IP, TCP and UDP that provide machine –to- machine
M e w a d a

and process-to-process communication over a


network.
 Security: Kernel tracks the user ID and group ID of
H i r e n

each running process and uses these to provide


yes/no decision each time an application attempts
to access resources.
B y
Modular Kernel
 A lot of functionality is contained in modules that is
loaded into the kernel dynamically.
M e w a d a

 Make core of the kernel small and make possible to


load or replace the modules in running kernel
without rebooting.
H i r e n

 Kernel modules are situated in directory:


/lib/modules/KERNELVERSION
To find current loaded module use command: lsmod Usage
B y

Module # lsmod count


name pcspkr 4224 0
hci_usb 18204 2
Depended
size psmouse 38920 0
module
bluetooth 55908 7 rfcomm,l2cap,hci_usb
Modular kernel
 Command to load and unload kernel module is:
#modprobe –r isofs
M e w a d a

 Lower level commands: insmod and rmmod


 The /proc filesystem:
 The information/code can be read via /proc filesystem
H i r e n

 To access the filesystem: open/read/write/close

 $ cat /proc/version
B y
Downloading a kernel
 Git command is used to download the kernel
$ sudo apt-get install git-core %install git
M e w a d a

 $ git clone
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds
/linux-2.6.git linux-2.6
H i r e n
B y
Kernel Phase
 Kernel handles all operating system
 Memory management
M e w a d a

 task scheduling

 I/O

 interprocess communication
H i r e n

 Kernel is available as image file compressed into


zimage or bimage with zlib.
B y
Steps to compile and install kernel
 Installing the sources.
Configuring the kernel (choosing which features and
M e w a d a


Drivers to compile).
 Compiling the kernel (i.e. typing a single command, and
watching...).
H i r e n

 Installing the compiled kernel.


 Updating the boot loader to recognize the new kernel.
 Booting...
B y

 Making the new kernel become the default.


Kernel construction
 Kernel modules need recompiling, linking and
loading.
M e w a d a

 Top-level directory: /usr/src/linux-header-3.11-


26-g…….
 arch/ firmware/ kernel/ scripts/ block/
H i r e n

fs/ lib/ security/ crypto/ include/


mm/ sound/ Documentation/ init/ net/
usr/ drivers/ ipc/ samples/ virt/
B y
Kernel construction
 Configuring the Kernel:
A step before kernel compilation
M e w a d a

 It specify which drivers and features to compile

 Also describes how to compile them (as a module or


inside the kernel’s main file)
H i r e n

 Command: make config


or make ARCH=arm gconfig
The configuration process generates a file called
B y

".config" in the top directory of the kernel sources.


Kernel construction
 Make utility:
%---hello.c------------ make all: do nothing
M e w a d a

#include<stdio.h>
int main(void) make hello.o: Compile hello.c and generate hello.o file
{
printf(“Hello world/n”); make hello.exe:
return 0; convert hello.o file into executable file hello.exe
} make clean:
H i r e n

remove files hello.exe and hello.o


%----Makefile----------
All: hello.exe
./hello.exe
hello.exe : hello.o
B y

gcc –o hello.exe hello.o


Hello.o: hello.c
gcc –c hello.c
Clean
hello.exe hello.o
Kernel construction
 Make utility:
 Clean : remove most generated files, keep config file
M e w a d a

 Mrproper: remove all generated files + config +


backup files
 Config: update current config utilizing a line-oriented
program
H i r e n

 Menuconfig: update current config utilizing a manu


based program
 Xconfig: use QT-based front end
B y

 Gconfig: GTK-based front end


Kernel construction
 gconfig
M e w a d a
H i r e n
B y
Kernel construction
 xconfig
M e w a d a
H i r e n
B y
Kernel construction
 menuconfig
M e w a d a
H i r e n
B y
Kernel construction
 Configuring the kernel: kconfig file
Drives the configuration process for the features
M e w a d a


contained within its subdirectory.
arch/arm/Kconfig <<<<<< (top level Kconfig)
ifdef KBUILD_KCONFIG
|-> init/Kconfig
Kconfig := $(KBUILD_KCONFIG)
| ...
else
H i r e n

|-> arch/arm/mach-iop3xx/Kconfig
Kconfig := arch/$(SRCARCH)/Kconfig
|-> net/Kconfig
endif
| |--> net/ipv4/Kconfig
...
| | |--> net/ipv4/ipvs/Kconfig
gconfig: $(obj)/gconf
| ...
B y

$< $(Kconfig)
|-> drivers/pci/Kconfig
| ...
|-> drivers/usb/Kconfig
| |--> drivers/usb/core/Kconfig
| |--> drivers/usb/host/Kconfig
Kernel construction
 Configuring the kernel: kconfig file
During the build process, the .config file is processes
M e w a d a


in C header file i.e. autoconfig.h
 collection of definition with simple format.
H i r e n
B y
 Kernel Compilation
 Common files : System.map
M e w a d a

 Architecture specific files : vmlinux.elf

 System.map: Human readable list of the kernel


symbols and their address
H i r e n

 Before compilation make sure to start fresh using


command: make clean
Prepare the dependency list: make depend
B y


make bzImage
[root@hirenmewada linux]# ls -l arch/i386/boot/bzImage
-rw-r--r-- 1 root root 1064017 Sept 06 01:53 arch/i386/boot/bzImage
make modules
 $ make ARCH=arm CROSS_COMPILE=xscale_be-
ixp4xx_defconfig
M e w a d a

 Preparethe kernel source tree for XScale architecture


 Generate config file that drive the kernel build

 $ make ARCH=arm CROSS_COMPILE=xscale_be-


H i r e n

zImage
 Desired architecture is ARM
 The tool chain required to build kernel is
B y

CROSS_COMPILE=xscale_be-
bzImage for x86, zImage for ARM, vmImage.gz for Blackfin etc
 vmlinux: a standalone monolithic binary image. No
unresolved external references exists within the
M e w a d a

vmlinux binary
 Consist of several composite binary images.
$ xscale_be-ld -EB -p --no-undefined -X -o vmlinux \
H i r e n

-T arch/arm/kernel/vmlinux.lds \
arch/arm/kernel/head.o \
arch/arm/kernel/init_task.o \
init/built-in.o \
--start-group \
B y

usr/built-in.o \
arch/arm/kernel/built-in.o \
arch/arm/mm/built-in.o \
arch/arm/common/built-in.
 vmlinux: a standalone monolithic binary image. No
unresolved external references exists within the
M e w a d a

vmlinux binary
 Consist of several composite binary images.
$ xscale_be-ld -EB -p --no-undefined -X -o vmlinux \ Output file
H i r e n

-T arch/arm/kernel/vmlinux.lds \
arch/arm/kernel/head.o \ Linker script file to
arch/arm/kernel/init_task.o \ Link kernel binary images
init/built-in.o \
--start-group \
B y

usr/built-in.o \
arch/arm/kernel/built-in.o \
arch/arm/mm/built-in.o \
arch/arm/common/built-in.
 vmlinux: a standalone monolithic binary image. No
unresolved external references exists within the
M e w a d a

vmlinux binary
 Consist of several composite binary images.
$ xscale_be-ld -EB -p --no-undefined -X -o vmlinux \
H i r e n

-T arch/arm/kernel/vmlinux.lds \
arch/arm/kernel/head.o \ Architecture specific
arch/arm/kernel/init_task.o \ low-level kernel initialization
init/built-in.o \
--start-group \ Initial thread and task
B y

usr/built-in.o \ Structure required by


arch/arm/kernel/built-in.o \ kernel
arch/arm/mm/built-in.o \
arch/arm/common/built-in.
Three largest object files:system code, network code, and all the built-in drivers
 Each kernel subdirectory
contains C-code that
M e w a d a

make up the kernel-image


H i r e n
B y
Loadable Kernel Module
 Part of the kernel, bound into the image we boot.
It communicate with base kernel.
M e w a d a

 It do not need building kernel again.


 Helps to diagnosis the system.
H i r e n
B y
 There are six main things LKMs are used for:
 Device drivers: designed for a specific piece of hardware.
M e w a d a

 The kernel uses it to communicate with that piece of hardware


without having to know any details of how the hardware works.
For example, there is a device driver for ATA disk drives.
 Filesystem drivers: interprets the contents of a filesystem
(which is typically the contents of a disk drive) as files and
directories and such.
H i r e n

 There are lots of different ways of storing files and


directories and such on disk drives, on network servers,
and in other ways. For each way, you need a filesystem
B y

driver. For example, there's a filesystem driver for the


ext2 filesystem type used almost universally on Linux disk
drives. There is one for the MS-DOS filesystem too, and
one for NFS.
 System calls: User space programs use system calls to get
services from the kernel. For example, there are system calls to
M e w a d a

read a file, to create a new process, and to shut down the


system.
 Most system calls are integral to the system and very standard, so
are always built into the base kernel (no LKM option). But you can
invent a system call of your own and install it as an LKM. Or you can
H i r e n

decide you don't like the way Linux does something and override an
existing system call with an LKM of your own.
 Network drivers: interprets a network protocol. It feeds and
B y

consumes data streams at various layers of the kernel's


networking function.
 For example, if you want an IPX link in your network, you would use the IPX
driver.
 TTY line disciplines. These are essentially augmentation of
device drivers for terminal devices.
M e w a d a

 Executable interpreters. An executable interpreter loads and


runs an executable. Linux is designed to be able to run
executables in various formats, and each must have its own
executable interpreter.
H i r e n
B y
...
# USB support
#
M e w a d a

Modular kernel CONFIG_USB=m


# CONFIG_USB_DEBUG is not set
# Miscellaneous USB options
#
USB module would be compiled CONFIG_USB_DEVICEFS=y
# CONFIG_USB_BANDWIDTH is not set
H i r e n

And statically linked as part of


the kernel image # CONFIG_USB_DYNAMIC_MINORS is not set
# USB Host Controller Drivers
#
CONFIG_USB_EHCI_HCD=m
B y

# CONFIG_USB_EHCI_SPLIT_ISO is not set


# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
CONFIG_USB_OHCI_HCD=m
CONFIG_USB_UHCI_HCD=m
...
Kernel initialization
 Listing of zImage file:
$ make ARCH=arm CROSS_COMPILE=xscale_be- zImage
M e w a d a

... < many build steps omitted for clarity>


LD vmlinux
SYSMAP System.map
SYSMAP .tmp_System.map
OBJCOPY arch/arm/boot/Image
Kernel: arch/arm/boot/Image is ready
H i r e n

AS arch/arm/boot/compressed/head.o
GZIP arch/arm/boot/compressed/piggy.gz
AS arch/arm/boot/compressed/piggy.o
CC arch/arm/boot/compressed/misc.o
B y

AS arch/arm/boot/compressed/head-xscale.o
AS arch/arm/boot/compressed/big-endian.o
LD arch/arm/boot/compressed/vmlinux
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
Architecture object
M e w a d a
H i r e n
B y

Bootstrap loader is created assembling all object files and wrapped with kernel image
Bootstrap loader
 A second stage loader
Perform checksum verification of the kernel image,
M e w a d a

decompressed and relocate the kernel image.

Bootloader :
H i r e n

Control the board on power-up


Does not rely on Kernel

Bootstrap loader:
B y

Intermediate step between bootloader and Kernel


Provide proper context for kernel to run in
Decompressed and relocate kernel binary image
Bootstrap loader
 Function performed by the bootstrap loader:
 Initializationof low level assembly language processor
M e w a d a

 i.e. Support for enabling the processor’s internal


instruction and data caches
 Disable interrupts and sets C run time environment i.e.
H i r e n

Head.o and head-xscale.o


 Decompressed and relocation code embodied in misc.o

 Processor specific initialization i.e. Big-indian.o


B y
Boot control flow –ARM processor
M e w a d a

Flash
memory
H i r e n

Load OS image Create kernel


from harddrive Decompression &
Architecture
B y

relocation
Environment Specific initialization
 Head.o: a kernel entry point
 Very generic (without any machine dependency )
M e w a d a

 Perform architecture specific initialization


 Check for valid processor and architecture
 Creates initial page table entries
H i r e n

 Enables processor’s memory management unit


(MMU) :
 Jumps to start of the kernel proper (start_kernel())
B y

in main.c
 MMU initialization: Physical addresses are replaced
by virtual addresses
M e w a d a

 Limited memory mapping


 May cause failure while loading firmware having
large size in early stage of kernel boot process.
H i r e n
B y
Kernel Startup
 Kernel startup:
 Main()
M e w a d a

- Setup_arch() % identify the CPU, CPU specific


initialization task
- setup_processor % verify the CPU ID and revision
- display the kernel command line i.e.
H i r e n

console=ttyS0,115200 root=/dev/nfs ip=dhcp


- init thread : Parent of all Linux process in user space
- intialization: call registered functions i.e. _init, _exit
B y

Bootstrap loader builds the command line from .config file.


 Example: “_setup” macro
 Initialize the consol for destination for message during
M e w a d a

bootprocess
 Kernel is “printk.o”. (found in /kernle/printk.c)

 To pass consol parameters to the setup & device driver


H i r e n

 Init.h file is used to associate a portion of the kernel


command line string with a function.
static int __init console_setup(char *str)
B y
B y H i r e n M e w a d a

Root file system


B y H i r e n M e w a d a

Root file system


 Bin:-
 Busybox: a stand alone binary that supports many command
M e w a d a

line utilities.
 Commands enabled in busybox are avaibale to the users.
 sh : shell file

 Lib:
H i r e n

 glibc – standard c library functions


 linux dynamic loader : load binary executable files into
memory & perform dynamic linking
B y

 Challenge: fitting root file system into given storage


space.
Kernel’s last boot step
M e w a d a
H i r e n
B y
Bootloader challenges
 Execution context: zero resources available when
sequence of instruction starts executing.
M e w a d a

 Default values designed into the hardware ensures


that fetches from the flash memory are proper.
 First task of bootloader is to initialize at least
H i r e n

minimal amount of memory(DRAM).


B y
Das U-boot
 Interact with user through serial port (no flash
programming)
M e w a d a

 Open source universal bootloader


 Support many processor architectures i.e. ARM, x86
 Easy to port to new architectures
H i r e n

 Used for interacting with users and updating images


and loading the kernel
B y

 Available at “denx” server.


Das U-boot
 Configuring U-Boot:make <plateform>_config
M e w a d a
H i r e n
B y
B y H i r e n M e w a d a

Das U-boot
Das U-boot
 Configuring U-Boot: make <platform>_config
Edit configure file specific to the hardware
M e w a d a


(…/inlcude/configs/<platform>.h)
 Configuration variable have two forms:
 Config_xxxx : user configurable and enable specific U-
H i r e n

Boot operation
 Config_sys_xxx: hardware specific and need
knowledge of hardware platform.
B y
Das U-boot
 U-Boot monitor command:
 CONFIG_CMD_FLASH :Flash memory commands
M e w a d a

 CONFIG_CMD_MEMORY: Memory dump, fill, copy,


compare, and so on
 CONFIG_CMD_DHCP: DHCP support
H i r e n

 CONFIG_CMD_PING: Ping support

 CONFIG_CMD_EXT2: EXT2 file system support

 To enable these command, macros are defined in


B y

the board directory.


Das U-boot
 Network operation: include support for the
 Bootstrap Protocol (BOOTP)
M e w a d a

 Dynamic Host Configuration Protocol (DHCP)


 Trivial File Transfer Protocol (TFTP).

 BOOTP and DHCP  enable a target device with


an Ethernet port to obtain an IP address and other
H i r e n

network-related configuration information from a


central server
TFTP: allows the target device to download files
B y


(such as a Linux kernel image) from a TFTP server.
B y H i r e n M e w a d a

IP add
Booting from Disk
 Booting a kernel image from disk
diskboot 0x400000 0:0
M e w a d a

 U-Boot provides numbering to disk devices i.e. 0:0


 Load image files from disk to system memory.
Bootm command is used to boot the kernel.
H i r e n


B y
Porting U-Boot
 More than 460 different board config files.
Each board has board-specific file in
M e w a d a

../board/vendor/<boardname>
 For a new board: modify the existing one
 Include directory:
H i r e n

 Config/<boardname>.h  include hardware


configuration for memory map and peripherals.
<core>.h for example arm926ejs.hh
B y

 contains the processor specific , register definitions


Porting U-Boot
 Include directory:
 Config/<boardname>.h  include hardware
M e w a d a

configuration for memory map and peripherals.


 <core>.h for example arm926ejs.hh
 contains the processor specific , register definitions
H i r e n
B y
 The CPU directory:
 <core>/cpu.c : contains CPU specific files
M e w a d a

 <core>/interrupt.c : contains function related to


interrupt and timer.
 <core>/starts.s :
H i r e n

 contains startup code for cpu core, clear and starts some
registers.
B y
 The lib_<arch> directory:
 Board.c : memory map initialization, u-Boot pepripheal
M e w a d a

initialization (i.e. LED functionality)


 Div0.c : contains division by 0 handler
H i r e n
B y
 To specify the new configuration : modify the top
level make file
M e w a d a

<boardname>_config : unconfig
@./mkconfig $(@:_config=) <architecture> <core> <boardname>
H i r e n
B y
U-boot image format
 Mkimage utility is utilized to create header file for U-
Boot loader and prepend to supplied kernel.
i r e n M e w a d a

 -T specifies the target image type—in this case, a kernel.


 -C specifies the target image compression type—in this
case, gzip.
 -a sets the U-Boot loadaddress to the value specified.
y H Mewada

 -e sets the U-Boot image entry point to the supplied value.


 -n is a text field used to identify the image to the human
ByB Hiren

user (supplied in the uboot_version variable).


 -d is the executable image file to which the header is
prepended

B y H i r e n M e w a d a

Anda mungkin juga menyukai