Linux for embedded_systems

16
Linux for Embedded Systems

description

Introduction to Linux kernel and embedded systems

Transcript of Linux for embedded_systems

Page 1: Linux for embedded_systems

Linux for Embedded Systems

Page 2: Linux for embedded_systems

Linux operating system•Linux was initially developed by Linus Torvalds in 1991 as an operating system for IBM compatible personal computers based on the Intel 80386 microprocessor.•Linus remains deeply involved with improving Linux, keeping it up-to-date with various hardware developments and coordinating the activity of hundreds of Linux developers around the world. •Over the years, developers have worked to make Linux available on other architectures, including Alpha, SPARC, PowerPC, and ARM.•Now it has been matured into a solid unix-like operating system for workstations, networking and storage servers, data centers, clusters and embedded systems.

Page 3: Linux for embedded_systems

What is Linux• Linux is interchangeably used in reference to the Linux

kernel, a Linux system, or a Linux distribution.• Strictly speaking, Linux refers to the kernel maintained by

Linus Torvalds and distributed under the same name through the main repository and various mirror sites.

• The kernel provides the core system facilities. It may not be the first software to run on the system, as a bootloader may have preceded it, but once it is running, it is never swapped out or removed from control until the system is shutdown.

• In effect, it controls all hardware and provides higher-level abstractions such as processes, sockets, and files to the different software running on the system.

Page 4: Linux for embedded_systems

• Linux can also be used to designate a hardware system running the Linux kernel and various utilities running on the kernel. – If a friend mentions that his development team is using Linux in their

latest product, he probably means more than the kernel. – A Linux system certainly includes the kernel, but most likely includes a

number of other software components that are usually running with the Linux kernel.

– Often, these will be composed of a subset of the software such as the C library and binary utilities. It may also include the X window system

• Finally, Linux may also designate as a Linux distribution. Red Hat, Mandrake, SuSE, Debian, Slackware, Caldera, MontaVista, BlueCat, and others are all Linux distributions. – They may vary in purpose, size, and price, but they share a common

purpose: to provide the user with a set of files and an installation procedure to get the kernel and various overlaid software installed on a certain type of hardware for a certain purpose

Page 5: Linux for embedded_systems

Linux kernel key features• One of the more appealing

benefits to Linux is that it isn't a commercial operating system: its source code under the GNU Public License is open and available to everyone.

• Portable and hardware support . Runs on most hardware

• Scalability, Can run on super computers as well as on tiny embedded devices.(4MB of RAM is enough)

• Security, it can’t hide its flaws. It code is reviewed by many experts.

• Modularity, can include only what a system needs even at run time

• Exhaustive networking support

• Easy to program, you can learn from existing code. Many useful resources on the net.

Page 6: Linux for embedded_systems

• Linux is powerfulLinux systems are very fast, since they fully exploit the features of the hardware components

• High standard for code quality

Linux systems are usually very stable; they have a very low failure rate and system maintenance time

• Linux is highly compatible with many common operating systems It lets you directly mount file systems for all versions on MS-DOS, MS Windows, Mac OS, Solaris, many BSD variants and so on.It also provides supports for various networking protocols and layers such as ethernet, fibre channel, IBM’s Token ring and so forth.

Page 7: Linux for embedded_systems

Embedded systems

• Embedded systems are everywhere in our lives, from mobile phones to medical equipment, including air navigation systems, automated bank tellers, MP3 players, printers, cars, and a slew of other devices about which we are often unaware.

• Every time you look around and can identify a device as containing a microprocessor, you've most likely found another embedded system.

Page 8: Linux for embedded_systems

• An embedded system is a special purpose computer system that is designed to perform very small sets of designated activities.• Not meant to be traditional, general purpose computers• Examples : mobile phones, cameras, home multimedia, network appliances,

transportation, industrial control, medical instrumentation, personal and air navigation systems

• Uses application specific processors such as • ARM • x86• PowerPc• Even simpler microcontrollers

• An embedded systems is designed from both hardware and software perspective, taking into account a specific application or set of applications. For e.g. your MP3 player will have a separate hardware unit for MP3 decoding

• Embedded systems are usually cost effective

Page 9: Linux for embedded_systems

Embedded Linux system architecture

Bootloader

Linux Kernel

C library

LibraryLibraryLibrary

Application Application

Embedded Systems

ToolsCompilerDebugger

….

DevelopmentHostPC

Page 10: Linux for embedded_systems

Software components• Cross-compilation tool chain

– Compilers that runs on the development machines but generates code for the target machine

• Boot loader– Started by the hardware, responsible for basic hardware

initialization, loading and executing the kernel• Kernel

– Contains the process and memory management, network stack, device drivers and services to user space

• C Library– The interface between the kernel and user space applications

• Libraries and applications– All user space components, open source, 3rd party or in-house

Page 11: Linux for embedded_systems

Introduction to Linux kernel

• User/Application space, where applications are executed.

• Kernel Space, where the kernel exist

• GNU C library, this provides the system call interface, a mechanism to communicate between user space application and kernel

Page 12: Linux for embedded_systems

Kernel subsystem

• Kernel subsystem

Page 13: Linux for embedded_systems

• System call interface: provides the means to perform function calls from user space into the kernel.

• Process Management– Kernel in-charge of process creation and termination.– Communication among different processes (signals, IPC primitives)– Process scheduling, how processes share the CPU

• Memory management– The kernel builds up the virtual address space for all the processes.

• File systems– Linux is heavily based on file system concepts; almost everything is

treated as file.– Linux supports multiple file systems types, i.e different ways of

organizing data on the physical medium.– E.g. Ext2, ext3,– Virtual File system(VFS) provides a common interface abstraction for

the various file systems supported by the kernel.

Page 14: Linux for embedded_systems

• Networking– The network stack is part of the kernel.– It is in charge of delivering data packets across applications and

network interfaces.– All routing and address resolution issues are implemented

within the kernel.• Device control

– Almost every system operations eventually maps to the physical device. Few exceptions such as CPU, memory, etc,

– All device control operations are performed by the code, called as Device Driver.

• IPC– The interprocess communication on Linux includes signals, pipes and

sockets, shared memory and message queues.

Page 15: Linux for embedded_systems

Device driver development using kernel modules

• Linux kernel has the ability to extend at runtime the set of features offered by the kernel. This means that you can add functionality to the kernel while the system is up and running.

• Each piece of code that can be loaded and unloaded into the kernel at runtime is called a module.

• Module extends the functionality of the kernel without the need to reboot the system.

• The Linux kernel offers support for quite a few different types (or classes) of modules, including, but not limited to, device drivers.

• Each module is made up of object code (not linked into a complete executable) that can be dynamically linked to the running kernel.

• Device drivers are developed for various hardware such hard disks, network controllers, USB devices, serial devices, display devices, printers

Page 16: Linux for embedded_systems

Advantages of modules• Modules make it easy to develop drivers without

rebooting: load, test, unload, rebuild & again load and so on.

• Useful to keep the kernel size to the minimum (essential in embedded systems). Without modules , would need to build monolithic kernel and add new functionality directly into the kernel image.

• Also useful to reduce boot time, you don’t need to spend time initializing device that may not be needed at boot time.

• Once loaded, modules have full control and privileges in the system. That’s why only the root user can load and unload the modules.