Embedded Operating Systems (Subject Code: 310250) (Class: TE Computer Engineering)

Unit No: 6 Linux Porting & Android Overview 1

Contents  



 

Porting Linux Linux and real time  Kernel preemption  Creating real time processes Embedded Android bootloader Android boot process Android applications  Calculator  Swipe screen 2

Why Linux port anyway? 

Linux is very portable



Supports 23 architectures in the upstream “mainline” kernel tree of Linus Torvalds



Kernel is mostly written in C, with some assembly instructions

3

Why Linux port anyway? 

Linux is competitive



The number of Linux kernel developers contributing to the official kernel has tripled since 2005



Feature growth continues with an average of 10K new lines of source code added every day



In an hour you spend here, 5.45 patches will on average

be added to the upstream Linux kernel 4

Why Linux port anyway? 

Linux is cost effective.



A large amount of code to build upon.



Large (growing) community of developers.



I think we all know the rest.

5

Background pre-requisite 

Hardware  Development board or simulator  Optional debugger, some kind of UART  Boards range in value from $200-$crazy  Implement the same architecture and platform as the final design but maybe with a number of hacks.  Simulator can be cheap and flexible (e.g. Android/OpenMoko/OLPC using QEMU). 6

Background pre-requisite 

Software 

Toolchain (GCC, binutils, etc.) 



Some kind of IDE 



PTXdist/crosstool/project specific

Likely to be Eclipse based, e.g. all the vendors.

You can get all of this from a vendor.

7

Early board work 



Test the board actually works  Write a simple LED flasher, print messages to the UART, have an idea that it does something. ●If examples have been supplied by a board vendor, run them to make sure the board isn't defective. Test the debugger whether it actually works or not

8

Bootloader bringup 

Many Open Source friendly projects use U-Boot  Das U-Boot written by Wolfgang Denk, and maintained by many “custodians”.  http://www.denx.de/wiki/U-Boot  Supports ARM, AVR32, Blackfin, Microblaze, MIPS, and more.  Typically stored in on-board NOR or NAND.  Relocates itself into RAM, loads a kernel (and root filesystem in an initramfs). 9

Bootloader bringup 

U-Boot design principles 

“Keep it small”



“Keep it simple”



“Keep it fast”



“Keep it portable”

10

Linux and real time • Real-time systems are characterized by deadlines. When a missed deadline results in inconvenience or a diminished customer experience, this is called soft real time. In contrast, hard real-time systems are considered failed when a deadline is missed. • Kernel preemption was the first significant feature in the Linux kernel that addressed system-wide latency. • Recent Linux kernels support several preemption modes, ranging from no preemption to full real-time preemption. • The real-time patch adds several key features to the Linux kernel, resulting in reliable low latencies. • The real-time patch includes several important measurement tools to aid in debugging and characterizing a real-time Linux implementation. 11

Latency • Real-time processes are often associated with a physical event, such as an interrupt arriving from a peripheral device. • Latency measurement begins upon receipt of the interrupt we want to process. This is indicated by time t0. • Recognizing the interrupt and control is passed to the interrupt service routine (ISR), as indicated by time t1. • Interrupt latency is almost entirely dictated by the maximum interrupt off time1—the time spent in a thread of execution that has hardware interrupts disabled.

12

Latency • It is considered good design practice to minimize the processing done in the actual ISR. • Therefore, it is desirable to simply service the hardware device and leave the data processing to a Linux bottom half, also called softirqs. • When the ISR/bottom half has finished its processing, the usual case is to wake up a user space process that is waiting for the data. This is indicated by time t2. • Some time later, the scheduler selects the realtime process to run, and the process is given the CPU. This is indicated by time t3. 13

Latency • Scheduling latency is affected primarily by the number of processes waiting for the CPU and the priorities among them. • Setting the Real Time attribute on a process (SCHED_FIFO or SCHED_RR) gives it higher priority over normal Linux processes and allows it to be the next process selected to run, assuming that it is the highest-priority real-time process waiting for the CPU. • The highest-priority real-time process that is ready to run (not blocked on I/O) will always run. 14

Scheduling real time processes & latency components in Linux •

Running process in real time os which is, responsible for timely completion of real time operation is called real time process



Real time process should not wait once it is ready to run, priority should be higher for such process compare to other no real time processes



If there is latency in real time process then that should be well calculated



Real time process are associated with physical events in the system



Immediate respond to arrival of interrupt from hardware



Process waits and execution starts for the interrupt service routine code

15

Kernel preemption • Kernel preemption means to making it possible to run a process by preempting another process, which is already running and not yet completed

• In some cases preemptions should not happen, for ex. Critical section • Real time system must ensure and implement the kernel preemption model so that can detect where kernel preemption should not happen/happen • So these patches were implemented on Linux kernel to design it for real time system 16

Kernel preemption • The challenge in making the kernel fully preemptable is to identify all the places in the kernel that must be protected from preemption. These are the critical sections within the kernel where preemption cannot be allowed to occur • Locking Critical Sections ... preempt_disable(); ... /* Critical section */ update_shared_data(); ... preempt_enable(); 17

Preemption models • The first solution to kernel preemption was to place checks at strategic locations within the kernel code where it was known to be safe to preempt the current thread of execution. • These locations included entry and exit to system calls, release of certain kernel locks, and return from interrupt processing.

18

Preemption models • The Linux kernel was fundamentally nonpreemptable. • Preemption checks were sprinkled around the kernel at strategic locations known to be safe for preemption. • Preemption was enabled only at these knownsafe points. • Further improvements : • The Linux kernel is fully preemptable everywhere. • Preemption is disabled only around critical sections. 19

Real time kernel patch • To enable hard real time, a patch must be applied. The real-time kernel patch is the cumulative result of several initiatives to reduce Linux kernel latency. The patch had many contributors, and it is currently maintained by Ingo Molnar; • www.kernel.org/pub/linux/kernel/projects/rt/ • The real-time patch adds several important features to the Linux kernel.

20

Four preemption mode 1. PREEMPT_NONE—No forced preemption. Overall latency is good on average, but some occasional long delays can occur. Best suited for applications for which overall throughput is the top design criterion. 2. PREEMPT_VOLUNTARY—First stage of latency reduction. Additional explicit preemption points are placed at strategic locations in the kernel to reduce latency. Some loss of overall throughput is traded for lower latency. 3. PREEMPT_DESKTOP—This mode enables preemption everywhere in the kernel except when processing within critical sections. This mode is useful for soft real-time applications such as audio and multimedia. Overall throughput is traded for further reductions in latency. 21

Four preemption mode 4 PREEMPT_RT—Features from the real-time patch are added, including replacing spinlocks with preemptable mutexes. This enables involuntary preemption everywhere within the kernel except for areas protected by preempt_disable(). This mode significantly smoothes out the variation in latency (jitter) and allows a low and predictable latency for timecritical real-time applications. If kernel preemption is enabled in kernel configuration, disable it at boot time by adding the following kernel parameter to the kernel command line: preempt=0 22

Creating real time processes • Process can be designated as real time by setting a process attribute that the scheduler uses as part of its scheduling algorithm. • Sched_setscheduler(0,SCHED_RR,&my_params) • Linux supports three scheduling policies: 1 SCHED_OTHER—Normal Linux process, fairness scheduling. 2 SCHED_RR—Real-time process with a time slice. In other words, if it does not block, it is allowed to run for a given period of time determined by the scheduler. 3 SCHED_FIFO—Real-time process that runs until it either blocks or explicitly yields the processor, or until another higher-priority SCHED_FIFO process becomes runnable. 23

Embedded Android bootloader • A program that loads an OS • Configures device to an initial known state • May allow to start alternative Linux kernel or others • For Android devices: bootloader starts either Android or Recovery (Initially Firmware detects special key pressed or not)

24

Android kernel During kernel initialization: Core kernel is initialized Memory & I/O areas are initializes Interrupts are started Process table initialized

Drivers initialized Kernel daemons (threads) are started Root file system is mounted The first user space process is started (/init) 25

Android boot process

Powered on and boot ROM execution

26

Android boot process

Bootloader

27

Android boot process

Linux kernel

28

Android boot process

Init process

29

Android boot process

Zygote and Dalvik

30

Android boot process

System server

31

Zygote • A daemon whose goal is to launch Apps • Parent of all the app processes • Process starts when init executes C++ program from /system/bin/app_process • service zygote /system/bin/app_process -Xzygote /system/bin -zygote --start-system-server

• Once launched, creats Dalvik VM & calls Zygote’s main() method • Once started, • it preloads all necessary Java classes and resources • Starts ‘System Server’ and • Opens a socket /dev/socket/zygote to listen for request for starting applications 32

System server • The System Services is a set of about 60-80 services that provide the user applications with the information and capabilities necessary to work. • It is the ruler of the system • This service starts all the other services

33

Activity manager • • • • •

Zygote: Launch application Necessity of request Tap on App icon from home screen Home Screen- application listening for onClick() When this happens launcher contact the ActivityManager i.e. request a handler through Binder & call startActivity() method from Activity Manager • After this, Activity Manager contacts Zygote to fork itself and start new VM to run the application via startViaZygote() method. 34

Launcher (Home) • It is used to accept request from user. • The home screen is an application and the only one listening for onClick(). • By tapping App icon user can send request. • Embedded Android Applications : • Calculator • Tweeter Search App • Slide Show App • Reference : Embedded Android, Porting Extending Customizing, Karim Yaghmour. O’Reilly. 35

Why mobile app development? 

Mobile platform is the platform of the future 

 

Double-digit growth in world-wide smartphone ownership

Job market is hot Students (and faculty!) are naturally interested!

36

Why Android? 



Transferring app to phone is trivial  Can distribute by putting it on the web  Android Market (now Google Play) for wider distribution

It’s not 1995

37

Types of Android devices

38

Various Android phones

39

Galaxy Note 3

40

Galaxy Tablet

41

Android-powered microwave

By Touch Revolution – at CES 2010 http://www.pocket-lint.com/news/30712/android-powered-microwave-cooking-google 42

Android-powered watch

43

Android-powered camera

44

Android-powered TV

45

Android-powered car radio

46

Android-powered washing machine

47

Android-powered PC

48

Brief history 

2011 

SDK 3.0/3.1/3.2 (Honeycomb) for tablets only 



New UI for tablets, support multi-core processors

SDK 4.0/4.0.1/4.0.2/4.0.3 (Ice Cream Sandwich)  Changes to the UI, Voice input, NFC

Ice cream Sandwich Android 4.0+

Jelly Bean Android 4.1.1

49

What is Google Android? 

A software stack for mobile devices that includes   



An operating system Middleware Key Applications

Uses Linux to provide core system services     

Security Memory management Process management Power management Hardware drivers 50

Android architecture

51

More details at: http://developer.android.com/guide/basics/what-is-android.html

Mobile devices: advantages  

  

Always with the user Typically have Internet access Typically GPS enabled Most have cameras & microphones Many apps are free or low-cost

52

Mobile devices: disadvantages  

    

Limited screen size Limited battery life Limited processor speed Limited and sometimes slow network access Limited or awkward input: soft keyboard, phone keypad, touch screen, or stylus Limited web browser functionality Range of platforms & configurations across devices 53

Android apps 





Built using Java and new SDK libraries  No support for some Java libraries like Swing & AWT Java code compiled into Dalvik byte code (.dex)  Optimized for mobile devices (better memory management, battery utilization, etc.) Dalvik VM runs .dex files

54



Development process for an Android app

55

http://developer.android.com/guide/developing/index.html

Building and running Compiled resources (xml files)

Android Debug Bridge





ADB is a client server program that connects clients on developer machine to devices/emulators to facilitate development. An IDE like Eclipse handles this entire process for you.

http://developer.android.com/guide/developing/building/index.html#detailed-build

56

Android architecture

57

Android design philosophy 

Applications should be:  Fast 



Responsive 



Apps must respond to user actions within 5 seconds

Secure 



Resource constraints: <200MB RAM, slow processor

Apps declare permissions in manifest

Seamless  

Usability is key, persist data, suspend services Android kills processes in background as needed

http://developer.android.com/design/index.html

58

Important questions 1.

What do you mean by porting Linux? What are the prerequisites needed to do it?

2.

What is embedded Android? How it can be differentiated from embedded Linux?

3.

Explain in detail the latency components of Linux operating system

4.

Which scheduling policies Linux uses to schedule real time processes? Explain them with example.

5.

List and explain Linux kernel’s four preemption modes.

6.

List and explain design principles of embedded android bootloader. 59

Important questions 7.

Draw a neat diagram and explain Android architecture.

8.

Explain with the help of diagram Android boot process.

9.

Explain in detail the development process of Android application.

10.

Explain sequence of steps involved in building and running Android application.

11.

Write a source code to develop Android application – calculator. You may consider Eclipse IDE’s project hierarchy.

12.

List and explain advantages and disadvantages of using Android Operating system. 60

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.

2MB Sizes 4 Downloads 122 Views

Recommend Documents

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 6 APRT - eGyanKosh
conducting refresher courses on fire fighting rescue services. During Ninth ... kliders and winches, and (13) type certification ofaircraft DGCA also coordinates all.

UNIT 6 | Celebrations - encarnara
ljlt'litllfln'l have bt't'l'tcould I be] better - they played great music, and everyone danced until 3.00! By the ... There may is a solution to this problem. -T“."L".-) qu.

Math 6+ Unit 6 Overview.pdf
Whoops! There was a problem loading more pages. Whoops! There was a problem previewing this document. Retrying... Download. Connect more apps.

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.

Unit 6 Review.pdf
A sledgehammer is used to drive a wedge into a log to split it. When the wedge is driven 0.2 m into. the log, the log is separated by a distance of 5 cm. A force of 19000 N is needed to split the log and the. sledgehammer exerts a force of 9800 N. a.

Unit 6 Grammar Past tense
verbs. Be – Past Tense. Be - Past Tense Negative. Subject + Verb. Subject + Verb + not. Singular. Plural. Singular. Plural. I was. We were. I was not. We were not.

Unit 6 Grammar Past tense
not in school last week because their family visited Australia. 4. The girls' mother ______ furious because they were playing rowdily. 5. My teachers. very satisfied with my results. 6. Florence and her brother ... The basic form of a verb changes to

UNIT 6 APRT
standards of airworthiness and grant of certificates of air worthiness to civil aircrafts registered in India ...... 7.7.1 The Mechanics of Registration ! I. 7.7.2 Alteration ...

SC-UNIT-6.pdf
'le"1ufred, colnhan "lF&e BanJ 'TNr. amPtf$eg c}re uged Sc)ch atrotnl/tn?^f .... E^. ob- hv br,Zs a-'F. Page 3 of 12. Main menu. Displaying SC-UNIT-6.pdf. Page 1 ...

Math 6 Unit 4 Overview.pdf
Finding the Least Common Multiple. Finding the Greatest Common Factor. Multiplication Facts (0-12). This unit builds to the following future skills and. concepts: Solving Formulas. Distributive Property. Converting Fractions, Decimals, and Percent. A

IADIS Conference Template - Research Unit 6
consuming applications), the sensitiveness to packet delays (latency and jitter) .... represents the multimedia server, the proxy which is located at the edge of the .... Wireless Network Measurement: This module is responsible of monitoring the ...

Math 6+ Unit 13 Overview.pdf
the context in which the data was gathered. d. Relating the choice of measures of center and variability to. the shape of the data distribution and the context in ...

Unit 6 16th century.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 16th ...

Math 6 Unit 11 Overview.pdf
If you have feedback or suggestions on improvement, please feel free to contact [email protected]. Page 2 of 2. Math 6 Unit 11 Overview.pdf. Math 6 Unit ...

EM4 Unit 6 Study Guide.pdf
Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. EM4 Unit 6 Study Guide.pdf. EM4 Unit 6 Study Guide.pdf. Open.

Unit 6 Chemistry Vocabulary.pdf
Proton. Reactant. Reactivity. Subscript. Valence electron. Page 1 of 1. Unit 6 Chemistry Vocabulary.pdf. Unit 6 Chemistry Vocabulary.pdf. Open. Extract.

IADIS Conference Template - Research Unit 6
Research Academic Computer Technology Institute and Computer ... Cross layer adaptation, Multimedia transmission, Wireless and Mobile Networking. 1.

UNIT 6 TE S.OF PA
various aspects of export import documentation, the electronic data interchange system and ... In this method, the payment is made eitlier at tlie time of acceptance of the ..... There was an absence of signatures of witnesses, when required, ...

Math 6+ Unit 3 Overview.pdf
Page 1 of 1. Math 6+ Unit 3 Overview.pdf. Math 6+ Unit 3 Overview.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying Math 6+ Unit 3 Overview.pdf.

Math 6 Unit 7 Overview.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. Math 6 Unit 7 ...

Math 6+ Unit 7 Overview.pdf
Page 1 of 1. Middle School Programs. Building Healthy Core Learning. Math 6 Plus, Unit 7. Math 6 Plus UNIT 7 OVERVIEW: Equations and Inequalities. Unit Outcomes. At the end of this unit, your student should be able to: Key Vocabulary. Terms to deepen

Math 6 Unit 10 Overview.pdf
Reflecting Points Video and Practice – Khan. Academy. Catch the Fly Game. Coordinate Plane Jeopardy. Coordinate Plane Word Problems – Khan ...

Math 6+ Unit 10 Overview.pdf
Page 2 of 2. Middle School Programs. Building Healthy Core Learning. Math 6 Plus, Unit 10. Math 6 Plus UNIT 10 OVERVIEW: Coordinate Plane. and times, and ...