Porting Operating Systems Phan Duy Hùng (PhD) ES Lecturer – Hanoi FPT University.

Slides:



Advertisements
Similar presentations
Operating Systems Components of OS
Advertisements

Operating System.
Program Development Tools The GNU (GNU’s Not Unix) Toolchain The GNU toolchain has played a vital role in the development of the Linux kernel, BSD, and.
9.0 EMBEDDED SOFTWARE DEVELOPMENT TOOLS 9.1 Introduction Application programs are typically developed, compiled, and run on host system Embedded programs.
Linux Booting Procedure
Linux can be generally divided into four major components: 1. KERNEL – OS, ultimate boss The kernel is the core program that runs programs and manages.
Chap 2 System Structures.
Operating System Structure
Operating-System Structures
Lab 4 Department of Computer Science and Information Engineering National Taiwan University Lab4 - Bootloader 2014/10/14/ 13 1.
Phones OFF Please Operating System Introduction Parminder Singh Kang Home:
The Boot process. Booting on a PC POST –Hardware test – may not run CPU ie fan not working CPU start-up –Jumps to fixed location to execute BIOS code.
Cs238 Lecture 3 Operating System Structures Dr. Alan R. Davis.
Common System Components
Os31 Chapter 3 Operating-System Structures. os32 Outlines System Components Operating System Services System Calls System Programs System Structure Virtual.
CCNA 2 v3.1 Module 2.
Software Development and Software Loading in Embedded Systems.
Operating Systems.
Embedded Systems Programming Introduction to the course.
COMPUTER SYSTEM LABORATORY Lab4 - Bootloader. Lab 4 Experimental Goal Learn how to build U-Boot bootloader for PXA /10/8/ 142.
1 Introduction to Tool chains. 2 Tool chain for the Sitara Family (but it is true for other ARM based devices as well) A tool chain is a collection of.
Embedded Systems Principle of Debugger. Reference Materials kl.de/avr_projects/arm_projects/#winarmhttp://
Lab 3 Department of Computer Science and Information Engineering National Taiwan University Lab3 - Cross Tools 2014/10/7/ 20 1.
Operating Systems What do you have left on your computer after you strip away all of the games and application programs you bought and installed? Name.
Computer Organization
hardware and operating systems basics.
System Calls 1.
UNIX System Administration OS Kernal Copyright 2002, Dr. Ken Hoganson All rights reserved. OS Kernel Concept Kernel or MicroKernel Concept: An OS architecture-design.
Embedded Linux Systems Presented By: Kitrek Riese.
AT91RM9200 Boot strategies This training module describes the boot strategies on the AT91RM9200 including the internal Boot ROM and the U-Boot program.
Chapter 3: Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual Machines System.
CIS 191 – Lesson 2 System Administration. CIS 191 – Lesson 2 System Architecture Component Architecture –The OS provides the simple components from which.
Lab 11 Department of Computer Science and Information Engineering National Taiwan University Lab11 - Porting 2014/12/9/ 26 1.
OS provide a user-friendly environment and manage resources of the computer system. Operating systems manage: –Processes –Memory –Storage –I/O subsystem.
Chapter 2: Operating-System Structures. 2.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 2: Operating-System Structures Operating.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
UNIX (Linux) Introduction Module-1. OS Kernel In computing, the kernel is the central component of OS. It is a bridge between applications and the actual.
 Virtual machine systems: simulators for multiple copies of a machine on itself.  Virtual machine (VM): the simulated machine.  Virtual machine monitor.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
3.1 Operating System Chapter 3: Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual.
Linux Overview Why Linux ? Not-so-ancient history –Torvalds, Linus Torvalds, 002 the Helsinki University, as a student, low budget, work home –rapid and.
1 Lecture 1: Computer System Structures We go over the aspects of computer architecture relevant to OS design  overview  input and output (I/O) organization.
Implementation of Embedded OS Lab3 Porting μC/OS-II.
졸업 프로젝트 발표 1/74 Trinity Snapshot Boot 날 짜: 팀 명: Trinity
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
Chap. 4 ARM Boot Loader Internals. 2 S3C2500 ARM940T Core module ARM9TDMI CoreIC.
1 © 2004, Cisco Systems, Inc. All rights reserved. CCNA 2 v3.1 Module 2 Introduction to Routers.
1 Free Electrons. Kernel, drivers and embedded Linux development, consulting, training and support. http//free-electrons.com Embedded Linux system development.
By Ganesan Alagu Ganesh Feb 26, 2008
Implementation of Embedded OS
Module 3: Operating-System Structures
Chapter 1: A Tour of Computer Systems
Welcome to Linux Chap#1 Hanin Abdulrahman.
Chapter 2: System Structures
Structure of Unix OS.
AT91RM9200 Boot strategies This training module describes the boot strategies on the AT91RM9200 including the internal Boot ROM and the U-Boot program.
Computers: Hardware and Software
Operating Systems Lecture 4.
Chapter 3: Operating-System Structures
9.0 EMBEDDED SOFTWARE DEVELOPMENT TOOLS
Chapter 2: Operating-System Structures
Introduction to Operating Systems
Introduction to Microprocessor Programming
Computer System Laboratory
Computer System Laboratory
Welcome to Linux Chap#1 Hanin Abdulrahman.
Welcome to Linux Chap#1.
Chapter 2: Operating-System Structures
Presentation transcript:

Porting Operating Systems Phan Duy Hùng (PhD) ES Lecturer – Hanoi FPT University

Bootloader Kernel Filesystem Bootloader (again) 2 Content

Embedded Linux Introduction Linux Support CPU: x86, ARM, MIPS, SH, i960, PowerPC, …etc Open Source Powerful Network Functions Easy Software Porting GNU Complier and Debugger

4 Cross-Development Environment Target has limited resource (memory, storage, low speed processor). Host and Target are different architecture Cross-platform Development Environment Host Bootloader Kernel Root Filesystem Target

Ways of Hardware Connection

Linux Architecture Applications Bash Shell Linux Kernel hardware

Linux Architecture Hardware BootloaderDrivers Kernel File System Protocol Stacks Kernel System Call Interface GLIBCOther Libraries Java GUI Applications

8 All the things we need Cross-Platform development toolchain Bootloader Usually provided by the vendor Linux kernel Linux kernel + some patches if needed Filesystem Busybox Device node Configuration

9 Bootloader Concepts (cont`) Typical space allocation

10 Bootloader Concepts What is bootloader ? Load kernel and filesystem Initialize hardware elements Many bootloaders for each architecture LILO and GRUB for x86 LILO: GRUB: U-Boot for x86, ARM, PowerPC U-Boot:

11 Bootloader Concepts (cont`) Bootloader also depends on various hardware All type CPU will execute the instructions from the defined address when power on Normally, there exists some solid storage devices mapped to defined address ROM, EEPROM, FLASH, etc

12 The Bootloader's Job One main mission: load the operating system(s). Tasks: Initialize the machine properly (the kernel can do this later too). Access the kernel and initrd files in their storage medium (need to support the corresponding filesystem too) Because of the above 2 tasks, bootloaders may platform specific! Load the kernel and initrd files Execute the kernel file with the right command line

bootloader

14 Some Bootloaders LILO: LInux LOad. Original Linux bootloader. Still in use! Supports: x86 GRUB: GRand Unified Bootloader from GNU. More powerful. Supports: x86 LinuxBIOS: Linux based BIOS replacement Supports: x86

15 Some Bootloaders (cont.) UBoot: Universal Bootloader. The most used on arm. Supports: arm, ppc, mips, x86 RedBoot: eCos based bootloader from RedHat Supports: x86, arm, ppc, mips, sh, m68k...

16 Why Use Linux Open Source Reliability Salability Secure Supports Virtually All Network Communication Protocols

17 GCC Cross Compiler creates executables for another platform (such as ARM), the output form can be ELF (Executable and Linking Format) If you build a Linux Kernel, you have to use Cross Compiler, i.e. GCC for most cases

18 GCC = GNU Compiler Collection Features Portable Cross-compiling Support different language C, C++, Objective-C, Fortran, Java, and Ada Free Software Compiler: arm-linux-gcc compiling source codes to run on arm platforms $ arm-linux-gcc hello.c –o hello /usr/local/arm/include/asm,linux

System Boot Flow

20 System Storage The storage devices used in embedded systems are often quite different from those used in workstations and servers. Embedded systems tend to use solid-state storage devices such as flash chips and flash disks. Need the MTD subsystem to support bootloader boot parameters kernel root filesystem

Kernel Considerations Kernel Configuration Kernel Compiling

22 Root File System Content

Root File System / /bin /boot /grub /dev /etc /home /lib /mnt /proc /sbin /tmp /usr /src /bin /sbin /var /log /spool

24 Building Root Filesystem Download the BusyBox source code from Building BusyBox make clean make all make install After make complete, the busybox will be at./path/to/busybox_src/_install/

25 Graphic User Interface Window System X Window (TinyX) QPE (Qt Plamtop Environment) / Qtopia GPE (GPE Palmtop Environment) Microwindows MiniGUI

Development Tools Editor (VIM) Toolchains

27 Bootloader Concepts What is bootloader ? Load kernel and filesystem Initialize hardware elements Many bootloaders for each architecture LILO and GRUB for x86 LILO: GRUB: U-Boot for x86, ARM, PowerPC U-Boot:

28 Linux-capable open source bootloaders

29 Bootloader Concepts (cont`) Bootloader also depends on various hardware All type CPU will execute the instructions from the defined address when power on Normally, there exists some solid storage devices mapped to defined address ROM, EEPROM, FLASH, etc

30 Bootloader Concepts (cont`) Typical space allocation

31 Bootloader Concepts (cont`) Single stage or Multi-stage ? Multi-stage bootloader can provide more complex capability and better ability to cross platform Bootloader booted from solid storage device can be divided into two stages Stage1 –Written by assembly language –Fast and simple Stage 2 –Written by C –more complex capability –Easy to read and modify

32 Bootloader Concepts (cont`) Two operation modes Boot loading mode (autonomous mode) Normal working mode Downloading mode Bootloader can download images from host end through UART or network

33 Bootloader Concepts (cont`) Communication equipment and protocol UART (Universal Asynchronous Receiver/Transmitter) and network UART protocol: xmodem, ymodem, zmodem slower Network protocol: TFTP protocol TFTP service required

34 Bootloader’s task and structure Stage1 and stage2 Stage1 Execute from flash Copy stage2 to RAM Stage2 Execute from RAM Copy kernel & Root file system to RAM Load kernel & Root file system

35 Bootloader’s task and structure (cont`) Steps of stage1 (according to implement order) Hardware initialization Prepare memory space for loading stage2 Copy stage2 to memory Set stack Go to starting address of stage2

36 Bootloader’s task and structure (cont`) Fundamental hardware initialization Mask all interrupts through CPU’s interrupt mask register or state register Set CPU speed and clock Initialize memory Initialize LED Ensure hardware are initialized correctly Initialize CPU internal instruction/data cache

37 Bootloader’s task and structure (cont`) Prepare memory space for loading stage2 Determine start and end address for stage2 in RAM Stage2_start, stage2_end Take stack space into consideration –Stage2 is written in C Stage2 is placed in upper part of bootloader memory space

38 Bootloader’s task and structure (cont`) Copy stage2 to memory Set stack pointer (sp) In order to execute C code of stage2 sp points to the location before stage2 end (sp=stage2_end – 4) Jump to the start address of stage2

39 Bootloader’s task and structure (cont`) mem_st art

40 Bootloader’s task and structure (cont`) Steps of stage2 (according to implement order) Initialize the hardware devices used in stage2 Check system memory mapping Copy kernel image and root filesystem to memory Set boot parameters Load kernel and root filesystem

41 Bootloader’s task and structure (cont`) Initialize the hardware devices used in stage2 Initialize one UART at least Initialize timer Check system memory mapping We should know which virtual memory space is really mapped to physical memory

42 Bootloader’s task and structure (cont`) Copy kernel image and root filesystem Memory allocation mapping Memory range of kernel image –Normally, locate in memory_start + 0x8000 0x8000 (32k) is used to store boot parameter and kernel page table Memory range of root filesystem –Normally, locate in memory start + 0x Copy from flash

43 Bootloader’s task and structure (cont`) Set boot parameters In U-boot, boot parameters are defined in the header file of target board Boot parameters: boot command root device root filesystem type console memory size network configuration etc.

44 Bootloader’s task and structure (cont`) Load kernel and root filesystem Jump to memory_start + 0x8000 CPU mode Disable interrupts (IRQs and FIQs) In SVC mode (supervisor)

45 Bootloader’s task and structure (cont`) After loading kernel Bootloader is replaced with operating system