embedded linux

26
1 Abhishek Srivastava (07/MCA/12) Presented By : Term Paper Report on

Upload: national-institute-of-technology

Post on 25-May-2015

3.436 views

Category:

Education


3 download

DESCRIPTION

In this slide i am explaining (not in detail)about the MMU Less Embedded Operating Systems and Memory Conversion algorithm.

TRANSCRIPT

Page 1: Embedded Linux

1

Abhishek Srivastava (07/MCA/12)

Presented By :

Term Paper Report on

Page 2: Embedded Linux

INTRODUCTION

In case of embedded systems, the rise in processing speeds of embedded

processors and microcontroller evolution has lead to the possibility of running

computation and data intensive applications on small embedded devices that

earlier only ran on desktop-class systems. From a memory stand point, there is a

similar need for running larger and more data intensive applications on

embedded devices.However, support for large memory address spaces,

specifically, virtual memory, for MMU-less embedded systems is always lacking.

But by implementing virtual memory scheme for MMU-less systems as a software

, based on an application level virtual memory library and a virtual memory aware

assembler. This type of implementation is open to programmer and always

available for changes. 2

Page 3: Embedded Linux

Many software developers in recent years have turned to Linux as their

operating system of choice. Until the advent of uClinux developers of smaller

embedded systems, usually incorporating microprocessors with no memory

management unit could not take advantage of Linux in their designs. UClinux is

a variant of mainstream Linux that runs on 'MMU-less' processor architectures.

Component costs are of primary concern in embedded systems, which are

typically required to be small and inexpensive. Microprocessors with on-chip

memory management unit (MMU) hardware tend to be complex and

expensive, and as such are not typically selected for small, simple embedded

systems which do not require them. With many advantages of MMU less

Systems (like : speed and cost efective ness) use of them is increasing day by

day and a proper , stable and real time Operating system is required , and in

this paper i am going to study this type of operating systems and schemes of

implementing Virtual memory using software. 3

Page 4: Embedded Linux

KEY POINTS Embedded Systems

Embedded Operating System

MMU(Memory Management Unit)

Virtual Memory

Kernel

4

Page 5: Embedded Linux

What is an Embedded System ?

1.An embedded system is a computer system designed to perform one or a few

dedicated functions, with real-time computing constraints.

2.Embedded system is application-oriented special computer system which is

scalable on both software and hardware.

3.embedded system as a computer system designed to perform one or a few

dedicated functions, with real-time computing constraints.

4.Embedded systems are controlled by a main processing core that is either a

micorocontroller or a digital signal processor.

5.Embedded systems range from portable devices such as digital watches and

MP3 players, to large stationary installations like traffic lights, factory controllers,

or the systems controlling nuclear power plants. 5

Page 6: Embedded Linux

Why use an operating system?

Memory management

Thread/process management

Drivers for input devices such as keyboards, mouse

Drivers for output devices such as screens, sound, printers

File system management on disks/flash memory

Security

Perform Virtual memory addressing

6

Page 7: Embedded Linux

What is an embedded operating system?

An embedded operating system is an operating system for embedded computer

systems, designed to be very compact and efficient, forsaking many

functions that non-embedded computer operating systems provide, and

which may not be used by the specialized applications they run and

frequently also called real-time operating systems.

Runs on small inexpensive microprocessors

Runs in memory restricted environments even without MMU.

Often no hard drive or disk drive – uses flash based disk

Can run without any screen output or keyboard/mouse input.

Example : Redhat ecos , uClinux, MontaVista Linux,

7

Page 8: Embedded Linux

Embedded Linux operating system

8

Linux has become popular on embedded devices—especially consumer

gadgets, telecom routers and switches, Internet appliances and automotive

applications. Because,

1.Modular nature of Linux, it is easy to slim down the operating environment by

removing utility programs, tools, and other system services that are not needed in

an embedded environment.

2.Linux is a fully functional OS, with support for network that is becoming a very

important requirement in embedded systems because people need to "compute

anywhere, anytime".

3. We can add or unload modules from the kernel at runtime, this

makes embedded Linux very flexible.

4.Linux code is open source, portable to any processor, scalable and stable.

Page 9: Embedded Linux

Advantages/disadvantages of using Linux for embedded system

1.A fully featured Linux kernel requires much less memory (approx 1MB or less)

2.Benefit of using an open source operating system like Embedded Linux over a traditional real-time operating system (RTOS), is that the Linux development community tends to support new IP and other protocols faster than RTOS vendors do.

3.This provides a highly modular building-block approach to constructing a custom embeddable system, which typically uses a combination of custom drivers and application programs to provide the added functionality.

4.Linux can run on most microprocessors with a wide range of peripherals and has a ready inventory of off-the-shelf applications.

5.Linux is also well-suited for embedded Internet devices, because of its support of multiprocessor systems, which lends it scalability.

9

Page 10: Embedded Linux

Memory Management and Memory Management Unit

Memory management is the act of managing computer memory. In its

simpler forms, this involves providing ways to allocate portions of memory to

programs at their request, and freeing it for reuse when no longer needed. The

management of main memory is critical to the computer system.

A memory management unit (MMU), sometimes called paged memory

management unit (PMMU), is a computer hardware component responsible for

handling accesses to memory requested by the central processing unit (CPU). Its

functions include translation of virtual addresses to physical addresses (i.e.,virtual

memory management ) , memory protection, cache control, bus arbitration etc.

10

Page 11: Embedded Linux

Features of MMU

1.Relocation

2.Protection

3.Sharing

4.Logical Organization

5.Physical Organization

6.Memory Compaction

11

Page 12: Embedded Linux

Why create an MMU-less Linux?

Linux has become popular on embedded devices—especially consumer

gadgets, telecom routers and switches, Internet appliances and automotive

applications. Because of the modular nature of Linux, it is easy to slim down

the operating environment by removing utility programs, tools, and other system

services that are not needed in an embedded environment.

Advantages of Linux is that it is a fully functional OS, with support for

network that is becoming a very important requirement in embedded systems. We

can add or unload modules from the kernel at runtime, this makes embedded Linux

very flexible. It is more encouraging that the Linux code is widely available, portable

to any processor, scalable and stable.

12

Page 13: Embedded Linux

Technical details and System Architecture

The target system considered here, consisting of

1.A MMU less MIPS R3000 processor simulator, having a fixed amount of RAM(local

memory : fast access time and small in size).

2.The processor is connected to a secondary storage device(slow access time and

large size) using an I/O interface.

3.Two possible types of I/O interfaces are, namely, serial and parallel.

4.For our experimental results, we have considered two kinds of secondary storage,

namely, EEPROM and Flash.

13

Page 14: Embedded Linux

Diagram Below shows the data flow towards target system ,

The application source code. Important is Application’s view of address space is as large as the secondary storage i.e., the virtual address space.

The virtual memory library. This library consists of an implementation of virtual to physical address translation (vm.c). It also includes a header file (vm.h) with configurable parameters (page size, ram size etc.)

14

Page 15: Embedded Linux

Methodology

The underlying idea behind any virtual memory scheme is ,

1.Compilers generate code with memory operations (loads and stores) for a virtual

address space.

2.A virtual address, generated out of the processor during runtime, is translated to a

valid, physical address.

3.In systems that have an MMU, this translation is done by the MMU at runtime. But

Here it is done by this translation in software.

4.The vm-assembler, intercepts memory operations in the assembly code (loads and

stores) and replaces them by a call to a virtual-to-physical translation function (from

vm library), invoked during runtime.

15

Page 16: Embedded Linux

Let , RAM = 2^M Sec. Storage = 2^N Page Size = 2^K

Thus P=2^K=2^M pages of RAM is available for paging.

As, according to our setup a page can map only to one unique entry in page table (direct mapped), total entries in page table is P.

Each page table entry will contain ,

1.Page , pointing to a unique page in RAM

2.Tag , used for comparing tag generated

out of virtual address.

3.V, validity bit

4.D, dirty bit

16

Page 17: Embedded Linux

Implementation approaches

2 popular approaches are :

1.Virtual Memory MMU Virtualization Approach

2.Hash-TLB MMU Virtualization Approach

Among these two mentioned I had studied Virtual Memory Implementation because

of its hardware support and community acceptability. Also as I am modeling uClinux

in my study, as MMU less operating System, it also uses the Virtual Memory

approach for implementing the MMU on any architecture.

17

Page 18: Embedded Linux

Virtual Memory Approach Algorithm for Virtual to Physical memory Address Translation 1: function virtual-to-physical2: Input va : virtual address, wr : 1 => write;0 => read3: Output pa : physical address4: Decompose va into (tag; page; off set) 5: pte PTE[page]6: if pte.tag = va.tag and pte.valid = 1 then7: if wr = 1 then8: pte:dirty 19: end if10: return pa = page * sizeof(page) + offset11: end if12: if pte.valid = 1 and pte.dirty = 1 then13: write RAM[page] to secondary store14: end if15: Read newpage|va (belongs to) newpage from secondary store16: Update pte.tag, pte.page, pte.valid17: if wr = 1 then18: pte.dirty 119: end if20: return pa = page * sizeof (page) + offset 18

Page 19: Embedded Linux

Approach 1 - Pure VM               In application every memory access is in a virtual address space which is

translated to physical address during runtime using a predesigned algorithm. This

is a transparent approach towards application where they access memory

directly and have full control on it.

Drwaback : When every memory address is virtualized algorithm(function) to

change virtual address to physical address is called which is an extra load on the

system.

19

Page 20: Embedded Linux

Approach 2 - Fixed Address VM               In this approach, a region of the memory is marked as virtualized. Any

memory access (load/store) that belongs to this marked region is translated. This

approach requires the programmer to indicate to the vm-assembler the region

marked as virtual. As opposed to the previous approach, in this case, the overhead

of translation from virtual to physical address is reduced to only the memory

region marked as virtual. This however, requires a runtime check to be made at

every load/store to determine if the address is virtualized.This is achieved by

modifying the vm-assembler so that it inserts code that does runtime check on

every memory access and translates only those addresses that are virtualized. In

our experiments, we tested this approach by marking all the data region belonging

to global variables as belonging to virtual address space.

20

Page 21: Embedded Linux

Approach 3 - Selective VM Selective VM is similar to the previous approach, but is more fine-grained

in terms of memory that is virtualized. Note that in the previous approach, a

runtime check was required on every memory access to determine if the address is

virtualized. Selective VM avoids this runtime check overhead by annotating data

structures at source level. It requires the programmer to tag individual data

structures as belonging to virtual address space (as opposed to an entire region).

This annotation is done at variable declaration, using a #pragma directive. Any use

or def of annotated data structure in the source is modified to a call to the virtual-

to-physical function. This approach significantly reduces the runtime overhead by

restricting the translation only to large data structures that can reap benefit out of

virtualization. It gives the embedded programmer more control on what is

virtualized. However, this approach is the least transparent to the application

programmer compared to the other two approaches. 21

Page 22: Embedded Linux

uClinux

1.Original uClinux was a derivative of Linux 2.0 kernel intended for microcontrollers

without Memory Management Units (MMUs).

2.Today's uClinux as an operating system includes Linux kernel releases for 2.0 2.4

and 2.6 as well as a collection of user applications, libraries and tool chains.

3.Originally created by D. Jeff Dionne and Kenneth Albanowski in 1998. Initially

targeted the Motorola DragonBall family of embedded 68kprocessors (specifically

the 68328 series) on a 2.0.33 Linux kernel.

4.Later developer community soon sprang up to extend their work to newer

kernels and other microprocessor architectures.

5.In early 1999 support was added for the Motorola (now

Freescale) ColdFire family of embedded microprocessors. Some Popular Supported Architecture: Hitachi H8, Intel i960, MIPS, ARM, Fujitsu FR-V 22

Page 23: Embedded Linux

uClinux vs. Linux : Comparison

1.Linux is a monolithic, multitasking, multiuser operating system (OS) which is a

UNIX work alike. Where is uClinux is a derivative of Linux Kernel (originally of

version 2.0) designed for embedded systems.

2.Internally Linux have separate virtual address space for each process. But in case

of uClinux there is a single shared space for all process.

3.Its required to recover address space on context switching, whereas in case of

uClinux recovery of address space on context switching doesn't required.

4.Another difference between Linux and uClinux is the lack of the fork() system call.

The only option under uClinux is to use vfork().

5.One more important difference between uClinux and other Linux systems is the

lack of memory management. 23

Page 24: Embedded Linux

Future Perspective

My future work will focus on optimizing the virtual to physical translation

that can lead to reduction in execution time cycles. I had also planned to focus on

considering additional caching techniques, such as associative schemes.

I am also trying to find some way of implementing software MMU for

normal systems (Laptops or Desktops) so that the interaction of Memory can be

reduced and hence increase in the speed of the system.

24

Page 25: Embedded Linux

Conclusion

Right now my study is towards a software virtual memory scheme for

MMU-less embedded systems. I am trying this using a vm-aware assembler and a

virtual memory library.The virtual memory system that is presented can be

customized by adjusting two configuration parameters, namely, RAM size and Page

size.

My future work will focus on optimizing this virtual memory

implementation that can lead to reduction in execution time cycles. Also i want to

extend and use this project for reducing the energy consuption for Systems

contaning MMU (CPU's , Laptops and other Embedded Devices).

25

Page 26: Embedded Linux

 

1. http://www.embedded.com/ 2. Two most important sites, www.wikipedia.com , www.google.com 3. M. David. uClinux for Linux Programmers. In Linux Journal, July 2000. 4. Gartner. Gartner research. http://www3.gartner.com. 5. Intell i960 Processor Overview. http://developer.intel.com/design/i960/family.htm. 6. Lynuxworks. Lynx OS. http://www.lynxworks.com/. 7. Microchip. PIC18F4320 Device Datasheet. http://www.microchip.com. 8. RedHat. ecos. http://sources.redhat.com/ecos/. 9. A. Silberschatz, P. Galvin, and G. Gagne. Operating System Concepts, sixth edition. John

Wiley and Sons, Inc., 2003. 10. ST. Stmicroelectronics. http://www.st.com. 11. uClinux. uclinux. http://www.uclinux.com. 12. Windows CE. Microsoft Windows Embedded. http://www.microsoft.com/windowsce. 13. Windriver. VxWorks Real Time OS. http://www.windriver.com. 14. Xilinx. Microblaze Soft Core. http://www.xilinx.com/microblaze/ 15. Building Embedded Linux Systems, Karim Yaghmour ,O’Reilly 3rd Edition 16. Articles on Embedded Devices , http://www.linuxfordevices.com 17. Mailing List uClinux , http://mailman.uclinux.org/ 26