1 / 58

Subject Teacher : Mrs. Nalini Yadav Unit No: 3 Embedded Linux

Subject Teacher : Mrs. Nalini Yadav Unit No: 3 Embedded Linux. 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.

koch
Download Presentation

Subject Teacher : Mrs. Nalini Yadav Unit No: 3 Embedded Linux

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Subject Teacher : Mrs. NaliniYadav Unit No:3 EmbeddedLinux

  2. LSB, OSDL, OSDLMLI • Linuxbackground • BIOS Vsbootloader • Anatomy of embeddedsystem • Busybox • Cross developmentenvironment • Embedded Linuxdistribution • Do-it-yourself Linuxdistribution • Initthread

  3. Linux supports a vast variety of hardware devices, probably more thananyother 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 androuters. • Linux can be deployed without the royalties required by • traditional proprietary embedded operatingsystems. • Linux has attracted a huge number of active developers, enabling rapid support of new hardware architectures, platforms, anddevices.

  4. PortingtheLinuxkerneltorunonaparticularCPUandboard which will be put into an embeddeddevice. There are many companies that sell embedded Linuxsolutions. These usually include a ported Linux kernel with cross- development tools, and sometimes with real timeextensions. The APIs and kernel codebase are the same for embeddedLinux as desktopLinux

  5. Royalty-free Strong networkingsupport Has already been ported to many differentCPU architectures Relatively small for its featureset Easy toconfigure Huge applicationbase Modern OS (eg. memory management,kernelmodules, etc.)

  6. Free Versus Freedom • free nature of open source: "free as in freedom“ • GPL guarantees • your freedom to use it, study it, and change it. • It also guarantees these freedoms for anyone to whom you distribute your modified code. • You can download a Linux kernel in a few minutes. • But .... • certain costs are associated with any software to be incorporated into a design. These include the costs of acquisition, integration, modification, maintenance, and support. Add to that the cost of obtaining and maintaining a properly configured toolchain, libraries, application programs, and specialized cross-development tools compatible with your chosen architecture

  7. Standards and Relevant Bodies • Linux Standard Base (LSB) • The goal of the LSB is to establish a set of standards designed to enhance the interoperability of applications among different Linux distributions. • Currently, the LSB spans several architectures, including IA32/64, PowerPC 32- and 64-bit, AMD64, and others. • The standard is broken down into a • core component • individual architecture components. • LSB specifies common attributes of a Linux distribution, including object format, standard library interfaces, minimum set of commands and utilities and their behavior, file system layout, system initialization, and so on.

  8. Standards and Relevant Bodies • Open Source Development Labs • OSDL(2000) Goal :- "to be the recognized center-of-gravityfor the Linuxindustry. • On January 22, 2007, OSDL and the FreeStandards Group merged to form The LinuxFoundation. • OSDL had established four Working Groups since2002: • Mobile Linux Initiative(MLI) • Carrier Grade Linux(CGL) • Data Center Linux(DCL) • Desktop Linux(DTL)

  9. Standards and Relevant Bodies • OSDL: Carrier Grade Linux • A significant number of the world's largest networking and telecommunications equipment • manufacturers are either developing or shipping carrier-class equipment running Linux as the • operating system. • The OSDL Carrier Grade Linux working group has produced a specification defining a set of requirements for carrier-class equipment as follow. • Availability • Clusters • Serviceability • Performance • Standards • Hardware • Security

  10. Standards and Relevant Bodies • OSDL: Mobile Linux Initiative • Its purpose is to accelerate the adoption of Linux on next-generation mobile handsets and other converged voice/data portable devices, according to the OSDL website. • The areas of focus for this working group include • development tools, • I/O and networking, • memory management, • Multimedia, • Performance • Power • management • security, • storage.

  11. Standards and Relevant Bodies • OSDL : Service Availability Forum • If you are engaged in building products for environments in which high reliability, availability, and serviceability (RAS) are important, you should be aware of the Service Availability Forum (SA Forum). • This organization is playing a leading role in defining a common set of interfaces for use in carrier-grade and other commercial equipment for system management. • The SA Forum website is www.saforum.org.

  12. What are the Major Distributions? • Red Hat: One of the earliest players in the game, Red Hat now position itself strongly in the business market. It has created a community-supported distribution, Fedora Core, which is the choice of many for desktop use. • Debian: The most popular community-created distribution. Debian is an excellent choice for server environments. Debian has also been used as the base for many specialist distributions. • Ubuntu: Desktop usability, out of the box. Taglined "Linux for human beings,” Based on Debian. • SUSE: Novell's answer to Red Hat, comes in “enterprise” and a community-based OpenSUSE • All Distributions have their respective strengths.

  13. Embedded or Not? • Contain a processing engine, such as a general-purpose microprocessor • Typically designed for a specific application or purpose • Includes a simple (or no) user interfacean automotive engine ignition controller, for example • Often is resource limitedfor example, has a small memory footprint and no hard drive • Might have power limitations, such as a requirement to operate from batteries • Usually is not used as a general-purpose computing platform • Generally has application software built in, not user selected • Ships with all intended application hardware and software preintegrated • Often is intended for applications without human intervention

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

  15. In a typical embedded system, a bootloader is the softwareIn a typical embedded system, a bootloader is the software program that performs the equivalentfunctions. In custom embedded system, bootloader specificto boardthe developed. There are several good open source bootloaders areavailable. The bootloader provides the foundation from which theprimary system software isspawned. Refer Chapter 7 ofHallinan

  16. Initializes critical hardware components, such as theSDRAMcontroller, I/O controllers, and graphicscontrollers. • Initializes system memory in preparation for passing control totheoperatingsystem. • Allocates system resources such as memory and interrupt circuitstoperipheral controllers, asnecessary. • Provides a mechanism for locating and loading your operating systemimage. • 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 configurationdata.

  17. Figure is a commonarrangement. It shows a host development system, running desktop Linux distribution, such as Red Hat, UbuntuLinux. The embedded Linux target board is connected to the development host via an RS-232 serialcable. 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 Linuxdistribution.

  18. Starting the Target Board • When power is first applied, a bootloader supplied with your target board takes immediate control of the processor. • It performs some very low-level hardware initialization, including processor and memory setup, initialization of the UART controlling the serial port, and initialization of the Ethernet controller.

  19. Booting theKernel 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 Linuxkernel. All bootloaders have a command to load and execute an operating systemimage. Figure shows one of the more common ways U-Boot is used to manually load and boot a Linuxkernel.

  20. Booting theKernel

  21. Booting theKernel • The tftp command at the start of coding instructs U-Boot to load the kernel image uImage into memory over the network using the TFTPprotocol. • 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 beloaded. • The second invocation of the tftp command loads a board configuration file called a device tree. It is also referred as device tree binary ordtb. • 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 theboard.

  22. Booting theKernel 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 tftpcommand. It instruct U-Boot to load the kernel at 0x600000 and pass the device tree binary (dtb) at 0xc00000 to thekernel. This command transfers control to the Linuxkernel. The bootm command is the death knell forU-Boot. The only way to pass control back to the bootloader is to reboot theboard. The kernel claims any memory and system resources that the bootloader previouslyused.

  23. Kernel Initialization: Overview • Linux goes through the steps required to mount its root file system remotely (via Ethernet) from an NFS[3] server on a machine with the IP address 192.168.0.9. Usually, this is your development workstation. The root file system contains the application programs, system libraries, and utilities that make up a GNU/Linux system. • Linux requires a file system. Many legacy embedded operating systems did not require a file system

  24. First User Space Process: init • Until this point, the kernel itself was executing code, performing the numerous initialization steps in a context known as kernel context. In this operational state, the kernel owns all system memory and operates with full authority over all system resources. The kernel has access to all physical memory and to all I/O subsystems. • When the Linux kernel has completed its internal initialization and mounted its root file system, the default behavior is to spawn an application program called init. When the kernel starts init, it is said to be running in user space or user space context. • These user space processes, or programs, operate in a virtual memory space picked at random[4] and managed by the kernel. The kernel, in cooperation with specialized memory-management hardware in the processor, performs virtual-to-physical address translation for the user space process.

  25. Bootloader • U-boot • GRUB • ◦… • Kernel • Filesystem • Manytypes

  26. When the Linux kernel begins execution, it spews out numerousWhen the Linux kernel begins execution, it spews out numerous status messagesduringits bootprocess. The Linux kernel displayed approximately 200 printk lines before it issues the loginprompt. Shortly before issuing a login prompt on the serial terminal, Linux mounts a root filesystem. 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 filesystem. Linux can mount a root file system from otherdevices. Refer chapter 5 ofHallinan

  27. The Linux kernel spawn an application program called init after its internal initialization and mounted its root filesystem, When the kernel starts init, it is said to be running in user space or user spacecontext. 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 fileI/O. These user space processes, or programs, operate in a virtual memory space picked at random and managed by thekernel. The kernel, in cooperation with specialized management hardware in the processor, performs physical address translation for the user spaceprocess. Refer chapter 6 ofHallinan memory- virtual-to-

  28. Cross-DevelopmentEnvironment 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 wascompiled. 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 tosucceed. e.g.:- gcc -Wall -o hellohello.c

  29. Cross-DevelopmentEnvironment Refer chapter 12 ofHallinan

  30. Embedded Linuxdistributions • Root filesystem. • 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’sapplications. • All programs has specific requirements (often called dependencies) that mustbe • satisfied by other components in thesystem. • Small embedded Linux system needs many dozens of files populated in an appropriate directory structure on a root filesystem. • Packages that are usually grouped byfunctionality. • Package manager. Red Hat’s Package Manager(rpm) • For RedHat,and Fedoraseries, • $ rpm–qa • $dpkg -l forUbauntu

  31. Embedded Linuxdistributions • A package can consist of manyfiles • e.g. :- Packages you might find on an embedded Linux distribution, and theirpurpose: • initscripts :- contains basic system startup and shutdownscripts. • apache :- implements the popular Apache webserver. • telnet-server :- contains files necessary to implement telnet server functionality, which allows you to establish telnet sessions to your embeddedtarget. • glibc: - implements the Standard Clibrary. • busybox:- contains compact versions of dozens of popular command-line utilities commonly found on UNIX/Linuxsystems.

  32. Embedded Linuxdistributions • The executable target binaries from an embedded distribution will not run on your PC, but are targeted to the architecture and processor of your embeddedsystem. • •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 nativetools. • 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 similarlyconfigured.

  33. Commercial Linuxdistributions • The leading embedded Linux vendors have been shippingembedded http://elinux.org/Embedded_Linux_Distributions. • Do-It-Yourself LinuxDistributions • You can choose to assemble all the components you need for embedded project on yourown. • You have to decide whether the risks are worth theeffort. • This approach might be a good one for academicproject. • Spend a significant amount of time assembling all the tools and • utilities your project needs and making sure they allinteroperate.

  34. Toolchain You need a toolchain. gcc and binutils are available from www.fsf.org and other mirrors around theworld. Both are required to compile the kernel and user-space applications for yourproject. Patches are often required to the most recent ―stable‖ source trees of these utilities, especially when they will be used beyond the x86/IA32architecture.

  35. It even includes a webserver! • Sizes less than < 500 KB (statically compiled with uClibc) or • less than 1 MB (statically compiled withglibc). • Easy to configure which features to include. • The best choice for • Initramfs / initrd with complexscripts • Small and medium size embeddedsystems • Seehttp://www-128.ibm.com/developerworks/linux/library/l- • busybox/ • for a niceintroduction.

  36. Storageconsiderations

  37. 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 eraseblocks.

  38. •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 data- storagelayouts. •These are called boot block or boot sector Flashchips. •The bootloader is stored in the smaller blocks, and the kernel and other required data are stored in the largerblocks. Boot block Flasharchitecture

  39. 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 andrewritten. Flash block sizes are relatively large compared to traditional hard- drive sectorsizes. Write times for updating data in Flash memory can be many times that of a harddrive. Flash memory cell write lifetime. A NOR Flash memory cell has a limited number of write cycles before failure. (100,000 cycles per block)

  40. NAND Flash is a relatively new Flashtechnology. 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 associatedcontroller. Data is accessed in serial bursts, which are far smaller than NOR Flash blocksize. Write cycle lifetime for NAND Flash is an order of magnitude greater than for NOR Flash, although erase times are significantly smaller.

  41. An embedded system designer has many options in the layout and use of Flashmemory. 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 fromRAM. 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.

  42. The bootloader is often placed in the top or bottom of the Flash memoryarray. Following the bootloader, space is allocated for the Linux kernel image and the ramdisk file system image, which holds the root filesystem. The Linux kernel and ramdisk file system images are compressed, and the bootloader handles the decompression task during the bootcycle. Typical Flash memorylayout

  43. 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 harddrive. The enhancements to Flash file systems was the incorporation of wearleveling. 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 memorychip. JFFS2(Journaling Flash File System 2) has improved wearleveling and reduced dataloss.

  44. MemorySpace 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.

  45. How Linux boots

  46. 1. BIOS BIOS stands for Basic Input/Output System Performs some system integrity checks Searches, loads, and executes the boot loader program. It looks for boot loader in floppy, cd-rom, or hard drive. You can press a key (typically F12 of F2, but it depends on your system) during the BIOS startup to change the boot sequence. Once the boot loader program is detected and loaded into the memory, BIOS gives the control to it. So, in simple terms BIOS loads and executes the MBR boot loader. 2. MBR MBR stands for Master Boot Record. It is located in the 1st sector of the bootable disk. Typically /dev/hda, or /dev/sda MBR is less than 512 bytes in size. This has three components 1) primary boot loader info in 1st 446 bytes 2) partition table info in next 64 bytes 3) mbr validation check in last 2 bytes. It contains information about GRUB (or LILO in old systems). So, in simple terms MBR loads and executes the GRUB boot loader.

  47. 3. GRUB GRUB stands for Grand Unified Bootloader. If you have multiple kernel images installed on your system, you can choose which one to be executed. GRUB displays a splash screen, waits for few seconds, if you don’t enter anything, it loads the default kernel image as specified in the grub configuration file. GRUB has the knowledge of the filesystem (the older Linux loader LILO didn’t understand filesystem). Grub configuration file is /boot/grub/grub.conf (/etc/grub.conf is a link to this). The following is sample grub.conf of CentOS. As you notice from the above info, it contains kernel and initrd image. So, in simple terms GRUB just loads and executes Kernel and initrd images.

  48. 4. Kernel • Mounts the root file system as specified in the “root=” in grub.conf • Kernel executes the /sbin/init program • Since init was the 1st program to be executed by Linux Kernel, it has the process id (PID) of 1. Do a ‘ps -ef | grep init’ and check the pid. • initrd stands for Initial RAM Disk. • initrd is used by kernel as temporary root file system until kernel is booted and the real root file system is mounted. It also contains necessary drivers compiled inside, which helps it to access the hard drive partitions, and other hardware. • 5. Init • Looks at the /etc/inittab file to decide the Linux run level. • Following are the available run levels • 0 – halt 1 – Single user mode 2 – Multiuser, without NFS • 3 – Full multiuser mode 4 – unused 5 – X11 6 – reboot • Init identifies the default initlevel from /etc/inittab and uses that to load all appropriate program. • Execute ‘grepinitdefault /etc/inittab’ on your system to identify the default run level • If you want to get into trouble, you can set the default run level to 0 or 6. Since you know what 0 and 6 means, probably you might not do that. • Typically you would set the default run level to either 3 or 5.

More Related