Linux OS Porting on Create XScalePXA 270 Linux

  • Slides: 39
Download presentation
Linux OS Porting on Create XScale-PXA 270 Linux kernel porting

Linux OS Porting on Create XScale-PXA 270 Linux kernel porting

Outline v. History and Evolution v. Operating system Concepts v. Linux versus other Unix-like

Outline v. History and Evolution v. Operating system Concepts v. Linux versus other Unix-like kernels v. Differences with User Application v. Linux versions v. Steps of porting v. Reference 2

History of Linux v. First time, the Linux kernel is published at 1991/10/5 Ø

History of Linux v. First time, the Linux kernel is published at 1991/10/5 Ø “Free minix-like kernel sources for 386 -AT” v Linus Torvalds studied MINIX OS first, and learned about hardware knowledge of Intel 80386 process Ø hacking the kernel, trying to port some GNU software (gcc, bash, . . ) on MINIX-386 3

History of Linux (cont’) v. Linus named his operating system “FREAX” and upload it

History of Linux (cont’) v. Linus named his operating system “FREAX” and upload it to the server ‘ftp. funet. fi’ v. Ari Lemke, the server administrator, doesn’t like this name and changed the directory name to “Linux” Ø for the homophonic of the inventor, Linus 4

Evolution of Linux v. Linux is a member of the large family of UNIX-like

Evolution of Linux v. Linux is a member of the large family of UNIX-like operating system Ø Unix is simple and well-designed Ø Unix consider all the things as ‘files’ in system Ø Kernel and system utilities are written by C language which is portable Ø very short time to create process Ø easy and stableness inter-process communication 5

Evolution of Linux (cont’) v. The kernel aims to be compliant with the IEEE

Evolution of Linux (cont’) v. The kernel aims to be compliant with the IEEE POSIX (Portable Operating System Interface for Computing Systems) Øa standard to describe API of operating system Ø to promise the applications could porting to many operating systems without changing the source Ø based on practice and experience of Unix 6

Evolution of Linux (cont’) v. Linux isn’t a commercial operating system Ø its source

Evolution of Linux (cont’) v. Linux isn’t a commercial operating system Ø its source code under GNU General Public License which is open and available to anyone to study Ø basic software on Linux is produce from GNU projects v. Internet brings Linux to the world Ø hackers from different countries devote their life to progress Linux on Internet 7

Operating system Concepts v. An operating system can roughly explain to some components of

Operating system Concepts v. An operating system can roughly explain to some components of system Ø ‘system’ contains operating system and any applications working on the operating system v. These components include kernel, device drivers, boot loader, command shell or other user interfaces, and some basic file and system utility tools 8

Operating system Concepts (cont’) v. Here talks only ‘kernel’, the deepest of an operating

Operating system Concepts (cont’) v. Here talks only ‘kernel’, the deepest of an operating system v. A kernel needs to provide root services for other parts in system v. Kernel also have to manage hardware and allocate system resources v. Sometimes a kernel can be explained as ‘supervisor of OS’ or ‘core’ 9

Operating system Concepts (cont’) v. Some special elements of kernel are: Ø interrupt handlers,

Operating system Concepts (cont’) v. Some special elements of kernel are: Ø interrupt handlers, used to services interrupt requests Ø scheduler, let many processes to share CPU slices Ø memory manage system, handle process address space Ø system utilities like network services or interprocess communication protocol 10

Operating system Concepts (cont’) v. In modern system, which has protected memory management units,

Operating system Concepts (cont’) v. In modern system, which has protected memory management units, a kernel program will have higher system state Ø kernel programs have un-limited hardware access rights and work in a protected memory space named kernel-space Ø user programs could only access some parts of system resources and could not control hardware directly Ø user programs are working in user-space 11

Operating system Concepts (cont’) v. If a user program has to access some kind

Operating system Concepts (cont’) v. If a user program has to access some kind of hardware, it use system call to ask kernel handle the request action v. Almost all the architectures that Linux supported provide the concept of interrupts Ø when hardware want to communicate with system, it will send a interrupt to let kernel stop and handle it’s request Ø kernel will use interrupt numbers to choose a specific interrupt handler 12

Operating system Concepts (cont’) v. In fact, we can induce that CPU are doing

Operating system Concepts (cont’) v. In fact, we can induce that CPU are doing one of three things: Ø execute specific process in kernel space Ø handle interrupt request in interrupt context which independent with other process in kernel space Ø execute user program process in user space 13

Operating system Concepts (cont’) v. Here shows the sketch map of transitions between user

Operating system Concepts (cont’) v. Here shows the sketch map of transitions between user and kernel mode (space) 14

Linux versus other Unix-like kernels v. Linux support kernel modules to load and unload

Linux versus other Unix-like kernels v. Linux support kernel modules to load and unload dynamically v. Linux support symmetrical multiprocessor, which most traditional Unix variants do not support this mechanism v. Linux kernel is preemptive v. Kernel do not separate thread and process, each procedures are the same Ø just some procedures may share resources 15

Linux versus other Unix-like kernels (cont’) v. Linux is fully customizable in all its

Linux versus other Unix-like kernels (cont’) v. Linux is fully customizable in all its components v. Linux kernel can be very small and compact Ø you can fit both a kernel image and full root filesystem, including all fundamental system programs, on just one 1. 4 MB floppy disk v. Linux runs on low-end, cheap hardware platforms 16

Differences with User Application v. Kernel program do not link C library Ø major

Differences with User Application v. Kernel program do not link C library Ø major reason is execution speed and size Ø but also some in common use functions are implement in kernel source code v. Kernel developer use GNU C and ISO C 99 to compose kernel Ø the use of inline function and inline assembly is feasible 17

Differences with User Application (cont’) v. There is no memory protection mechanism Ø destroy

Differences with User Application (cont’) v. There is no memory protection mechanism Ø destroy memory data by kernel occurs ‘oops’ Ø kernel memory could not be paged v. Uneasy to use floating point numbers in kernel Ø you have to access the floating point registers and handle your operation by hand v. Small and static stack in kernel Ø in 32 bit architecture only 8 KB in size 18

Differences with User Application (cont’) v. Race conditions in kernel: Ø use concurrence control

Differences with User Application (cont’) v. Race conditions in kernel: Ø use concurrence control to prevent it Ø care if SMP to access the same resources Ø care if interrupt will access the same resources with the executing process Ø care if preemptive condition comes true Ø classic ways to prevent these situations are the use of spinlocks and semaphores 19

Linux versions v. Linux distinguish stable kernels from development kernels through a simple numbering

Linux versions v. Linux distinguish stable kernels from development kernels through a simple numbering scheme Ø each version is characterized by three numbers, separated by periods Ø first two numbers identify the version Ø third number identifies the release Ø new release of a stable version come out mostly to fix bugs reported by users 20

Linux versions (cont’) v. If the second number is even, it denotes a stable

Linux versions (cont’) v. If the second number is even, it denotes a stable kernel; otherwise it denotes a development kernel Ø development versions may differ quite significantly from one another Ø kernel developers experiment with different solutions which occasionally lead to drastic kernel changes 21

Steps of porting v. System requirements: Ø Linux host: n used to compile Linux

Steps of porting v. System requirements: Ø Linux host: n used to compile Linux kernel image, root filesystem, device driver, user applications, and so on n ARM cross-compiler 4. 0. 2 is needed Ø Windows host: n download and exam your project on Creator n Domingo for Linux is needed Ø Target: n Microtime Creator mother board, Creator-XScale. PXA 270 CPU board 22

Steps of porting (cont’) v. To build a Linux kernel for running on Creator-XSCALE-PXA

Steps of porting (cont’) v. To build a Linux kernel for running on Creator-XSCALE-PXA 270, you need: Ø source code of Linux kernel (mt-linux 2. 6. 15. 3. tar. gz ) Ø patch (linux-2. 6. 15. 3 -creator-pxa 270. patch) Ø cross compiler (arm-linux-toolchain-bin 4. 0. 2. tar. gz ) v. Then install the cross compiler into your Linux host system 23

Steps of porting (cont’) v. After install the cross compiler into your system, don’t

Steps of porting (cont’) v. After install the cross compiler into your system, don’t forget to update your PATH environment variable v. When the cross compiler is ready, extract your kernel source and patch it by: Ø cp linux-2. 6. 15. 3 -creator-pxa 270. patch /pxa 270/pro/devkit/lsp/create-pxa 270 Ø patch –p 0 < linux-2. 6. 15. 3 -creatorpxa 270. patch 24

Steps of porting (cont’) v. Enter the Linux kernel directory, and type “make menuconfig”

Steps of porting (cont’) v. Enter the Linux kernel directory, and type “make menuconfig” to configure your kernel 25

Steps of porting (cont’) v. Here we use a default configuration file for the

Steps of porting (cont’) v. Here we use a default configuration file for the Creator XScale-PXA 270 board v. Choose “Load an Alternate Configuration File” and type “Enter” to select one v. The default configuration file is located in “pxa 270/linux/arch/arm/configs” and named “creator_pxa 270_defconfig” 26

Steps of porting (cont’) v. After configured the kernel, it’s time to make your

Steps of porting (cont’) v. After configured the kernel, it’s time to make your kernel image by typing: Ø make dep Ø make clean Ø make z. Image v. The kernel image could be find at “pxa 270/linux/arch/arm/boot/” v. To verify the kernel image, you need to copy this image to a Windows host 27

Steps of porting (cont’) v. Before download and verify your Linux kernel, check the

Steps of porting (cont’) v. Before download and verify your Linux kernel, check the connections between the Creator and your host PC: 28

Steps of porting (cont’) v. To verify your Linux kernel on PXA 270, you

Steps of porting (cont’) v. To verify your Linux kernel on PXA 270, you need “Domingo for Linux” on Windows system v. Check you must have your kernel image in the Windows system v. Execute the Domingo on your Windows, and select “No project” to enter a hardware setting page 29

Steps of porting (cont’) 30

Steps of porting (cont’) 30

Steps of porting (cont’) v. Press the “Config PCM…” to configure the peripheral of

Steps of porting (cont’) v. Press the “Config PCM…” to configure the peripheral of XScale PXA 270 v. Choose “Import” to select default one: 31

Steps of porting (cont’) v. After setting the hardware configuration, you can download your

Steps of porting (cont’) v. After setting the hardware configuration, you can download your Linux kernel on PXA 270 board to see if it work correctly 32

Steps of porting (cont’) v. Load your kernel into memory addressed 0 xa 0008000

Steps of porting (cont’) v. Load your kernel into memory addressed 0 xa 0008000 33

Steps of porting (cont’) 34

Steps of porting (cont’) 34

Steps of porting (cont’) v. Change the PC register value to A 0008000, which

Steps of porting (cont’) v. Change the PC register value to A 0008000, which the kernel image’s address in RAM v. Before click RUN in Domingo, set up your Hyper terminal for receiving Linux kernel debug message and be the shell interface of it 35

Steps of porting (cont’) 36

Steps of porting (cont’) 36

Steps of porting (cont’) 37

Steps of porting (cont’) 37

Reference v. Web site references: Ø 鳥哥的私房菜 Ø Debian 無痛起步 Ø Linux kernel Archives

Reference v. Web site references: Ø 鳥哥的私房菜 Ø Debian 無痛起步 Ø Linux kernel Archives Ø Embedded Linux Training Ø Linux kernel wiki Ø The Linux kernel Ø Kernel trap Ø… 38

Reference (cont’) v. Book references: Ø Understanding the Linux Kernel, 2/e, O’Reilly Ø Linux

Reference (cont’) v. Book references: Ø Understanding the Linux Kernel, 2/e, O’Reilly Ø Linux 核心開發指南, 2. 6版, 維科 Ø Linux Kernel 完全剖析, 博碩文化 Ø… 39