Unit No: 3 Embedded Linux Prepared by: Dr. Sachin R Sakhare Pavan R Jaiswal

LSB, OSDL, OSDL MLI  Linux background  BIOS Vs bootloader  Anatomy of embedded system  Busy box  Cross development environment  Embedded Linux distribution  Do-it-yourself Linux distribution  Init thread 

Embedded Linux

2

Linux Standard Base 

  



The goal of the LSB is to establish a set of standards designed to enhance the interoperability of applications among different Linux distributions. The LSB spans several architectures, including IA32/64, Power Architecture 32- and 64-bit, AMD64, and others. The standard is divided into a core component and the individual architectural components. The LSB specifies common attributes of a Linux distribution, including object format, standard library interfaces, a minimum set of commands and utilities and their behavior, file system layout, system initialization, and so on. http://www.linuxfoundation.org/

Embedded Linux

3

Open Source Development Labs  OSDL(2000) Goal :- "to be the recognized center-of-gravity for the Linux industry.  On January 22, 2007, OSDL and the Free Standards Group merged to form The Linux Foundation. OSDL had established four Working Groups since 2002: 1. Mobile Linux Initiative (MLI) 2. Carrier Grade Linux (CGL) 3. Data Center Linux (DCL) 4. Desktop Linux (DTL) Embedded Linux

4

Embedded Linux

5

Figure is a common arrangement. It shows a host development system, running desktop Linux distribution, such as Red Hat, Ubuntu Linux. The embedded Linux target board is connected to the development host via an RS-232 serial cable. You plug the target board’s Ethernet interface into a local Ethernet hub or switch, to which your development host is also attached via Ethernet. The development host contains your development tools and utilities along with target files, which normally are obtained from an embedded Linux distribution. Embedded Linux

6

 Linux supports a vast variety of hardware devices, probably more than any other OS.  Linux supports a huge variety of applications and networking protocols.

 Linux is scalable, from small consumer-oriented devices to large, heavy-iron, carrier-class switches and routers.  Linux can be deployed without the royalties required by traditional proprietary embedded operating systems.  Linux has attracted a huge number of active developers, enabling rapid support of new hardware architectures, platforms, and devices. Embedded Linux

7



Porting the Linux kernel to run on a particular CPU and board which will be put into an embedded device.



There are many companies that sell embedded Linux solutions.



These usually include a ported Linux kernel with crossdevelopment tools, and sometimes with real time extensions.



The APIs and kernel codebase are the same for embedded Linux as desktop Linux

Embedded Linux

8

     



Royalty-free Strong networking support Has already been ported to many different CPU architectures Relatively small for its feature set Easy to configure Huge application base Modern OS (eg. memory management, kernel modules, etc.) Embedded Linux

9



Boot loader ◦ U-boot ◦ GRUB ◦ …





Kernel File system ◦ Many types

Embedded Linux

10



 



BIOS takes control of the processor, when power is applied to PC. The BIOS might actually be stored in Flash memory. The BIOS is a complex set of system-configuration software routines that have knowledge of the low-level details of the hardware architecture. Its primary responsibility is to initialize the hardware, especially the memory subsystem, and load an operating system from the PC’s hard drive.

Embedded Linux

11





 

In a typical embedded system, a bootloader is the software program that performs the equivalent functions. In custom embedded system, bootloader specific to board the developed. There are several good open source bootloaders are available. The bootloader provides the foundation from which the primary system software is spawned. Refer Chapter 7 of Hallinan

Embedded Linux

12

 Initializes critical hardware components, such as the SDRAM  controller, I/O controllers, and graphics controllers.  Initializes system memory in preparation for passing control to the  operating system.  Allocates system resources such as memory and interrupt circuits to  peripheral controllers, as necessary.  Provides a mechanism for locating and loading your operating system image.  Loads and passes control to the OS, passing any required startup information. This can include total memory size, clock rates, serial port speeds, and other low-level hardware-specific configuration data. Embedded Linux

13

Booting the Kernel 

Now that U-Boot has initialized the hardware, serial port, and Ethernet network interfaces, it has only one job left in its short but useful life span: to load and boot the Linux kernel.



All bootloaders have a command to load and execute an operating system image.



Figure shows one of the more common ways U-Boot is used to manually load and boot a Linux kernel.

Embedded Linux

14

Booting the Kernel

Embedded Linux

15

Booting the Kernel The tftp command at the start of coding instructs U-Boot to load the kernel image uImage into memory over the network using the TFTP protocol. The kernel image, in this case, is located on the development workstation.  The tftp command is passed an address that is the physical address in the target board’s memory where the kernel image will be loaded. The second invocation of the tftp command loads a board configuration file called a device tree. It is also referred as device tree binary or dtb. This file contains board-specific information (such as memory size, clock speeds, onboard devices, buses, and Flash layout), that the kernel requires in order to boot the board. Embedded Linux

16

Booting the Kernel Next, the bootm (boot from memory image) command is issued, to instruct U-Boot to boot the kernel just loaded from the address specified by the tftp command. It instruct U-Boot to load the kernel at 0x600000 and pass the device tree binary (dtb) at 0xc00000 to the kernel. This command transfers control to the Linux kernel. The bootm command is the death knell for U-Boot. The only way to pass control back to the bootloader is to reboot the board. The kernel claims any memory and system resources that the bootloader previously used.

Embedded Linux

17

Embedded Linux

18

    



When the Linux kernel begins execution, it spews out numerous status messages during its boot process. The Linux kernel displayed approximately 200 printk lines before it issues the login prompt. Shortly before issuing a login prompt on the serial terminal, Linux mounts a root file system. Many legacy embedded operating systems did not require a file system. A file system consists of a predefined set of system directories and files in a specific layout on a hard drive or other medium that the Linux kernel mounts as its root file system. Linux can mount a root file system from other devices.

Refer chapter 5 of Hallinan Embedded Linux

19











The Linux kernel spawn an application program called init after its internal initialization and mounted its root file system, When the kernel starts init, it is said to be running in user space or user space context. In this operational mode, the user space process has restricted access to the system and must use kernel system calls to request kernel services such as device and file I/O. These user space processes, or programs, operate in a virtual memory space picked at random and managed by the kernel. The kernel, in cooperation with specialized memorymanagement hardware in the processor, performs virtual-tophysical address translation for the user space process. Refer chapter 6 of Hallinan Embedded Linux

20

Storage considerations

Embedded Linux

21

Flash memory technology, can be thought of as solid-state hard drives, capable of storing many megabytes—and even gigabytes—of data in a tiny footprint. They contain no moving parts, are relatively rugged, and operate on a single common power supply voltage. Flash memory can be written to and erased under software control. Rotational hard drive technology remains the fastest writable medium. Flash write and erase time is still considerably slower. Flash memory is divided into relatively large erasable units, referred to as erase blocks.

Embedded Linux

22

Boot block Flash architecture

•A typical NOR Flash memory device contains many erase blocks. e.g. 4MB Flash chip might contain 64 erase blocks of 64KB each. Flash memory is also available with nonuniform erase block sizes, to facilitate flexible datastorage layouts. •These are called boot block or boot sector Flash chips. •The bootloader is stored in the smaller blocks, and the kernel and other required data are stored in the larger blocks. Embedded Linux

23

To modify data stored in a Flash memory array, the block in which the modified data resides must be completely erased. Even if only 1 byte in a block needs to be changed, the entire block must be erased and rewritten. Flash block sizes are relatively large compared to traditional harddrive sector sizes. Write times for updating data in Flash memory can be many times that of a hard drive. Flash memory cell write lifetime. A NOR Flash memory cell has a limited number of write cycles before failure. (100,000 cycles per block ) Embedded Linux

24

NAND Flash is a relatively new Flash technology. NAND Flash offers smaller block sizes, resulting in faster and more efficient writes and generally more efficient use of the Flash array. NAND devices present an operational model more similar to that of a traditional hard drive and associated controller. Data is accessed in serial bursts, which are far smaller than NOR Flash block size. Write cycle lifetime for NAND Flash is an order of magnitude greater than for NOR Flash, although erase times are significantly smaller.

Embedded Linux

25

An embedded system designer has many options in the layout and use of Flash memory. In the simple systems, raw binary data can be stored on the Flash device. When booted, a file system image stored in Flash is read into a Linux ramdisk block device, mounted as a file system, and accessed only from RAM. Following Figure illustrates a common Flash memory organization that is typical of a simple embedded system in which nonvolatile storage requirements of dynamic data are small and infrequent.

Embedded Linux

26

The bootloader is often placed in the top or bottom of the Flash memory array. Following the bootloader, space is allocated for the Linux kernel image and the ramdisk file system image, which holds the root file system. The Linux kernel and ramdisk file system images are compressed, and the bootloader handles the decompression task during the boot cycle. Typical Flash memory layout Embedded Linux

27

The limitations of the simple Flash layout scheme can be overcome by using a Flash file system to manage data on the Flash device in a manner similar to how data is organized on a hard drive. The enhancements to Flash file systems was the incorporation of wear leveling.

Wear-leveling algorithms are used to distribute writes evenly over the physical erase blocks of the Flash memory in order to extend the life of the Flash memory chip. JFFS2(Journaling Flash File System 2) has improved wear leveling and reduced data loss. Embedded Linux

28

Memory Space All embedded operating systems view and manage system memory as a single large, flat address space. e.g. a microprocessor’s address space exists from 0 to the top of its physical address range. Microprocessor had 24 physical address lines, its top of memory would be 16MB. Therefore, its hexadecimal address would range from 0x00000000 to 0x00ffffff. Hardware designs commonly place DRAM starting at the bottom of the range, and Flash memory from the top down. Unused address ranges between the top of DRAM and bottom of Flash would be allocated for addressing of various peripheral chips on the board. This design approach is often dictated by the choice of microprocessor. Figure shows a typical memory layout for a simple embedded system. Embedded Linux

29

Cross-Development Environment Cross-development environment requires that the compiler running on your development host, output a binary executable that is incompatible with the desktop development workstation on which it was compiled. The primary reason these tools exist is that it is often impractical or impossible to develop and compile software natively on the embedded system because of resource (typically memory and CPU horsepower) constraints. When a given program is compiled, the compiler often knows how to find include files, and where to find libraries that might be required for the compilation to succeed. e.g. :-

gcc -Wall -o hello hello.c Embedded Linux

30

Cross-Development Environment

Refer chapter 12 of Hallinan Embedded Linux

31

Embedded Linux distributions Root file system.  Startup scripts launch a number of programs and utilities that the system requires. These programs often invoke other programs to do specific tasks, such as spawn a login shell, initialize network interfaces, and launch a user’s applications. All programs has specific requirements (often called dependencies) that must be satisfied by other components in the system. Small embedded Linux system needs many dozens of files populated in an appropriate directory structure on a root file system. Packages that are usually grouped by functionality. Package manager. Red Hat’s Package Manager (rpm) For Red Hat, and Fedora series, $ rpm –qa $dpkg -l for Ubauntu Embedded Linux

32

Embedded Linux distributions A package can consist of many files e.g. :- Packages you might find on an embedded Linux distribution, and their purpose: • initscripts :- contains basic system startup and shutdown scripts. • apache :- implements the popular Apache web server. • telnet-server :- contains files necessary to implement telnet server functionality, which allows you to establish telnet sessions to your embedded target. • glibc: - implements the Standard C library. • busybox:- contains compact versions of dozens of popular command-line utilities commonly found on UNIX/Linux systems. Embedded Linux

33

Embedded Linux distributions • The executable target binaries from an embedded distribution will

not run on your PC, but are targeted to the architecture and processor of your embedded system. •A desktop Linux distribution tends to have many GUI tools . •An embedded Linux distribution typically omits these components. •An embedded distribution typically contains cross tools, as opposed to native tools. e.g. The gcc toolchain that ships with an embedded Linux distribution runs on your x86 desktop PC but produces binary code that runs on your target system, often a non-x86 architecture. Many of the other tools in the toolchain are similarly configured. Embedded Linux

34

Commercial Linux distributions The leading embedded Linux vendors have been shipping embedded http://elinux.org/Embedded_Linux_Distributions. • Do-It-Yourself Linux Distributions

You can choose to assemble all the components you need for you embedded project on your own. You have to decide whether the risks are worth the effort. This approach might be a good one for academic project. Spend a significant amount of time assembling all the tools and utilities your project needs and making sure they all interoperate.

Embedded Linux

35

Toolchain You need a toolchain. gcc and binutils are available from www.fsf.org and other mirrors around the world. Both are required to compile the kernel and user-space applications for your project. Patches are often required to the most recent “stable” source trees of these utilities, especially when they will be used beyond the x86/IA32 architecture.

Embedded Linux

36

http://www.busybox.net/  Most Unix command line utilities within a single executable! It even includes a web server!  Sizes less than < 500 KB (statically compiled with uClibc) or less than 1 MB (statically compiled with glibc).  Easy to configure which features to include.  The best choice for ◦ Initramfs / initrd with complex scripts ◦ Small and medium size embedded systems See http://www-128.ibm.com/developerworks/linux/library/lbusybox/ for a nice introduction.

Embedded Linux

37

 Device driver isolate the user programs from ready access to critical kernel data structures and hardware devices.  A well-written device driver hides from the user the complexity and variability of the hardware device.  The device driver handles the details and isolates the user from the complexities and perils of hardware device programming.  The device driver provides a consistent user interface to a large variety of hardware devices.  It provides the basis for the familiar UNIX/Linux convention that everything must be represented as a file. Embedded Linux

38

Linux lets you add and remove kernel components at runtime.

Linux is structured as a monolithic kernel with a well-defined interface for adding and removing device driver modules dynamically after boot time.

This feature not only provides flexibility for the user, but it also has proven valuable to the device driver developer. You can insert and remove the device driver from a running kernel during the development cycle instead of rebooting the kernel every time you want to test a change. Embedded Linux

39

The minimum infrastructure to load a device driver is only a few lines of code. Device drivers configured as loadable modules can be inserted into and removed from a running kernel after kernel boot.

Module utilities are used to manage the insertion, removal, and listing of device driver modules.

Embedded Linux

40

Device nodes on your file system provide the glue between your user space application and the device driver. Driver methods implement the familiar open, read, write, and

close functionality commonly found in UNIX/Linux device drivers.

Embedded Linux

41

1. Lyla B. Das, “Embedded Systems: An Integrated Approach” Pearson, ISBN:978-81-317-8766-3 (Chapters 8,10,11) 2. Christopher Hallinan, “Embedded Linux Primer”, Prentice Hall, ISBN-10: 0-13-167984-8,ISBN-13: 978-0-13-167984-9 3. Alessandro Rubini and Jonathan Corbet “Linux Device Drivers”, 3rd Edition O’Reilly Publishing, 2005 4. Sreekrishnan Venkateswaran “Essential Linux Device Drivers” Prentice Hall, 2008 5. Robert Love “Linux Kernel Development”, 3rd Edition Addison-Wesley, 2010 Embedded Linux

42

Online Book:-

www.informit.com/safarifree ARM-related Linux Development

www.arm.linux.org.uk Open Source Projects

http://sourceforge.net Kernel :-

www.kernel.org Bootloader:-

www.uboot.com

Embedded Linux

43

Thank You http://www.pavanjaiswal.com/

Embedded Linux

44

EOS Unit 3 - Embedded Linux.pdf

Data Center Linux (DCL). 4. Desktop Linux (DTL). Open Source Development Labs. Embedded Linux 4. Page 4 of 44. EOS Unit 3 - Embedded Linux.pdf.

3MB Sizes 4 Downloads 197 Views

Recommend Documents

EOS Unit 1 - RTOS.pdf
To learn and use real time systems. ◦ To differentiate various real time systems. ◦ To understand real time operating system. Real Time OS 2. Page 2 of 53 ...

EOS Unit 2 - ARM.pdf
integrated processors. ◦ To understand ARM processor architecture. ◦ To learn and execute ARM instruction set. ◦ To learn ARM 9 and Cortex M3 architecture.

Embedded databases 3 Embedded Firebird - Free Pascal
Jan 28, 2006 - The Firebird SQL server (currently at version 1.5.3) was started from the open source ... The DBExpress components from Delphi offer a fast and simple way to ... The actual interface returned by the GetGDSLibrary call can be ...

Unit 6 Embedded Android.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item.

Unit 6 Embedded Android.pdf
Page 2 of 60. Contents. Porting Linux. Linux and real time. Kernel preemption. Creating real time processes. Embedded Android bootloader.

UNIT 3 - eGyanKosh
the capital is bound to change correspondingly. It is totally based on Double Entry. System principles. The effect of transactions on Accounting Equation. 1. ... information. The procedure for large number is followed for a form, which is called the

Unit 3 - eGyanKosh
technology has evolved in business applications for the process of strategic ... One of the major advantages a data warehouse offers is that it allows a large ...

UNIT 3 - eGyanKosh
Assets = Total Claims. Assets = Liabilities + Capital. If there is any change in the amount of assets, or of the liability, the owner‟s claim or the capital is bound to change correspondingly. It is totally based on Double Entry. System principles.

Unit 3 - eGyanKosh
The data warehousing, online analytical processing (OLAP) and data ... For example, an electric billing company, by analysing data of a data warehouse can.

Grammar unit 3
Mar 20, 2013 - scientists / clone smoking / damage. Could doctors operate before the development of anaesthetic? Yes, but the patients suffered terrible pain!

UNIT 3 - eGyanKosh
Mar 27, 2004 - Workplace-I. 3.2 READING. You are Sudhir Taneja, Personnel officer at XYZ Company. You've received a. Memo from your Manager Ms. Renu Bhardwaj, giving you guidelines for screening the application letters you have received. Read Salil M

UNIT 2 ACTIVITY 3
Can move many passengers plus cargo. Used mostly for fun. 82 ... 6. The has wings and no. 5. The has a motor and no motor. A towplane helps it become airborne. wings. Only a few of ..... Lift Versus Weight 2" x 10" paper strips. Grades 1-3.

unit 3.pdf
faster than AWT )nets. ... iq,i .rze and arc raid out using the square ofa grid. .... A rir.rl-Lokshmonon A.P-CSE. Page 3 of 42. unit 3.pdf. unit 3.pdf. Open. Extract.

unit 3.pdf
things, the assembler may find out syntax errors. The logical errors or other. programming errors are not found out by the assembler. For completing all these.

Course 1 Unit 3 Practice
Feb 19, 2015 - than her brother Dyami. The sum of their ages is. 23 years. How old is Dyami? 25. Corrine and Elizabeth went out for dinner. The check for their dinner was $32.75. Corrine knows her dinner cost $18.95. How much did Elizabeth's dinner c

UNIT 3 EXTENSION.pdf
There are more words than you need. take risks • steep • hurt myself • fascinated • give me a thrill • go trekking. breathtaking • thrilled • lose our way • challenging.

unit 3.pdf
for the mnemonics and data in the assembly language program. ... data type that may be a constant, variable, string, etc. Another option of ... DW: Define Word.

unit 3 bonded labour - eGyanKosh
Feb 9, 1976 - The agent would beat me with a stick if I was not there on time, he beats .... accurate, authentic and up-to-date data about the magnitude of the problem. A .... be instituted in any Civil Court for the recovery of any bonded debt,.

UNIT –3 PARALLEL PROGRAMMING
Page 24. Parallel Algorithms &. Parallel Programming. Check Your Progress 3. 1) (a) syntax for parallel directive : #pragma omp parallel [set of clauses].

UNIT –3 PARALLEL PROGRAMMING
In the following code fragment, the directives indicate that the outer two loops are ... iii) Using a completely new programming language for parallel programming (e.g. Ada). ... execution of the user code beyond the end of the parallel construct.

EOS : Unstoppable Stateful PHP
managed in the database or in transactional queues [4, 7, etc.], but this entails a ... spinlock-based shared/exclusive latches. 1.1 Review of Interaction Contracts. The framework considers a set of interacting components of three different types. (i

Unit 3 - Slideshow 3 - 2013 DistanceTimeGraphs.pdf
THE GRAPH when plotting points. Page 4 of 17. Unit 3 - Slideshow 3 - 2013 DistanceTimeGraphs.pdf. Unit 3 - Slideshow 3 - 2013 DistanceTimeGraphs.pdf.

Unit 10 Math 3 CP Worksheet 3.pdf
Connect more apps... Try one of the apps below to open or edit this item. Unit 10 Math 3 CP Worksheet 3.pdf. Unit 10 Math 3 CP Worksheet 3.pdf. Open. Extract.

Unit 3 - Lesson 3 - Rigid Transformations.pdf
Unit 3 - Lesson 3 - Rigid Transformations.pdf. Unit 3 - Lesson 3 - Rigid Transformations.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying Unit 3 ...