+ All Categories
Home > Technology > Building

Building

Date post: 22-Jan-2015
Category:
Upload: satpal-parmar
View: 2,711 times
Download: 1 times
Share this document with a friend
Description:
Embedded Linux System
37
1 Building Embedded Linux System on Samsung 2410 Platform
Transcript
Page 1: Building

1

Building Embedded Linux System on Samsung 2410

Platform

Page 2: Building

2

AgendaBasic ConceptsKernel ConsiderationsRoot Filesystem ContentDevice DriverApplication and GUI

Page 3: Building

3

BasicConcepts

Page 4: Building

4

Cross-Development Environment

Target has limited resource (memory, storage, low speed processor) .Host and Target are different architecture

Cross-platformDevelopmentEnvironment

Host•Bootloader•Kernel•Root Filesystem

Target

Page 5: Building

5

Hardware Connection

Page 6: Building

6

ARM Cross-Development Toolkit

C Source

Assembler

C Libraries ASM Source

.aof

Object Libraries

.aif debug

ARMsd

Developmentboard

ARMulator

System model

C Compiler

Linker

Page 7: Building

7

Development EnvironmentGUN development toolchains

A compiler that runs on one computer but produces object code for a different type of computer.Cross compilers are used to generate software that can run on computers with a new architecture or on special-purpose devices that cannot host their own compilers. Cross-compiler for ARM

gcc : arm-linux-gccg++ : arm-linux-g++ar : arm-linux-arstrip : arm-linux-strip

Page 8: Building

8

Create Target Linux SystemA target Linux system is created by configuring and bundling together the appropriate system components. Programming and development aspects are a separate subject

There are four main steps to creating a target Linux system:

Determine system componentsConfigure and build the kernelBuild root filesystemSet up boot software and configuration

Page 9: Building

9

System Boot FlowExtract and decompress the

Kernel Image and RAMDISK

Launch kernel

Initialize Memory and Hardware

Mount Root Filesystem (RAMDISK)

Run /sbin/init

User Programs

Bootloader

Kernel

Page 10: Building

10

All the things we needCross-Platform development toolchainBootloader

Provide by vendorLinux kernel

Linux kernel + some patches if neededFilesystem

BusyboxDevice nodeConfiguration

Page 11: Building

11

Build the GNU Cross-Platform Development Toolchain

We can download the cross-platform (toolchains) from ftp://ftp.arm.linux.org.uk/pub/The toolchain do not need recompile, just decompress it and set the system path.GNU Toolchain’s Component

Binutilsincluding AS, LD and other binary file tools

GCCthe well known C,C++ complier supported variable platform

GLIBCthe C runtime library

GDBthe command line source debugger, including remote debugging

Page 12: Building

12

Bootloader

Page 13: Building

13

ARM Linux KernelARM Linux is a port of the successful Linux Operating System to ARM processor based machines mainly by Russell King with contributions from others.The patch change log can be found at http://www.arm.linux.org.uk/developer/release-2.4.0.shtmlThe Linux Kernel and most of the programs that make up the Linux system are "open source", using the GNU tools provided by the Free Software Foundation. ARM Linux is being ported, or has been ported to more than 100 different machine variations, including complete computers, network computers and evaluation boards. There are also projects for

Page 14: Building

14

Filesystem - initrdinitrd provides the capability to load a RAM disk by the boot loader.This RAM disk can then be mounted as the root file system and programs can be run from it.Afterwards, a new root file system can be mounted from a different device. The previous root (from initrd) is then moved to a directory and can be subsequently unmounted.initrd is mainly designed to allow system startup to occur in two phases, where the kernel comes up with a minimum set of compiled-in drivers, and where additional modules are loaded from initrd.

Page 15: Building

15

Filesystem - BusyBox

Combine tiny versions of many common UNIX into a single small executable.Provide a fairly complete environment for any small or embedded system.BusyBox has been written with size-optimization and limited resources in mind. It is also extremely modular so you can easily include or exclude commands (or features) at compile time. This makes it easy to customize your embedded systems

Page 16: Building

16

KernelConsiderations

Page 17: Building

17

Make Linux KernelDownload Linux kernel source from http://www.kernel.org/

Building Kernelmake cleanmake menuconfigmake dep (this step is no needed in version 2.6)make bzImagemake modulesmake modules_installmake install

Additional Options:ARCH=arm CROSS_COMPILE=arm-linux-

make cleanmake menuconfigmake ARCH=arm CROSS_COMPILE=arm-linux depmake ARCH=arm CROSS_COMPILE=arm-linux zImagemake ARCH=arm CROSS_COMPILE=arm-linux modulesmake ARCH=arm CROSS_COMPILE=arm-linuxmodules_installmake ARCH=arm CROSS_COMPILE=arm-linux install

Page 18: Building

18

After make bzImage, the kernel image will be at ./path/to/linux_src/arch/i386/boot/bzImage

The "bzImage" name stands for "big zImage," and has nothing to do with the bzip2 compression utility. In fact, both the bzImage and zImage Makefiletargets rely on the gzip algorithm.The difference between the two Makefile targets is that the compressed kernel images generated using zImage cannot be larger than 512 KB, while those generated using bzImage are not bound by this limit.

Make Linux Kernel

Page 19: Building

19

Root FilesystemContent

Page 20: Building

20

Building Root FilesystemDownload the BusyBox source code from http://www.busybox.net/

Building BusyBoxmake cleanmake allmake install

After make complete, the busybox will be at ./path/to/busybox_src/_install/

Page 21: Building

21

Building Root FilesystemThe BusyBox has all needed utilities, such as, ls, kill, chroot, mount, …,etc.

Building the Root FilesystemCreate a directory ~/root-fsCopy all files in busybox/_install to ~/root-fs/Create some standard directory, such as, /dev, /etc /proc /mnt /tmp /varMake some device nodeWrite some boot shell scriptsMake directory ~/root-fs to a initrd image

Page 22: Building

22

Create Device Nodescd ~/root-fs/dev/mknod tty c 5 0 mknod console c 5 1mknod tty0 c 4 0mknod ttyS0 c 4 64mknod ttyS0 c 4 64mknod ram0 b 1 0 mknod null c 1 3

Page 23: Building

23

Write Shell Script

/etc/inittab::sysinit:/etc/rc.S::askfirst:/bin/sh

/etc/rc.S#!/bin/shmount -t proc proc /proc

Page 24: Building

24

Make INITRD imagedd if=/dev/zero of=/home/initrd.img bs=1k count=8192 su rootmke2fs -F -v -m0 /home/initrd.imgmkdir tmpmount -o loop initrd.img tmp/cp ~/root-fs/* /home/tmp/ -dpRrfumount tmp/gzip -9 < initrd.img > initrd.bin

8MB fileis null

~/root-fs

mount

Write DATA

8MB filewith data

unmount

Page 25: Building

25

Customize Application and Configuration

In order to meet the system requirement, we must write some applications base on some drivers.

Maybe we’ll setting up the Ethernet or Wireless network or build up some Internet Protocol.

Customize the GUI or MMI

Page 26: Building

26

DeviceDriver

Page 27: Building

27

Major and Minor NumbersSpecial files under /dev “c” for char & “b” for blockMajor number identifies driver use at open timeMinor number is used only by driver to control several devicescrw-rw-rw- 1 root root 1, 3 Feb 23 1999 null crw------- 1 root root 10, 1 Feb 23 1999 psaux crw------- 1 rubini tty 4, 1 Aug 16 22:22 tty1 crw-rw-rw- 1 root dialout 4, 64 Jun 30 11:19 ttyS0 crw-rw-rw- 1 root dialout 4, 65 Aug 16 00:00 ttyS1 crw------- 1 root sys 7, 1 Feb 23 1999 vcs1crw------- 1 root sys 7, 129 Feb 23 1999 vcsa1 crw-rw-rw- 1 root root 1, 5 Feb 23 1999 zero

Page 28: Building

28

Major NumberAdding a new driver at module initialization

int register_chrdev(unsigned int major, const char *name, struct file_operations *fops);

fops point to a global structure which kernel findsTo create device node : mknod /dev/scull0 c 254 0If major is 0, the register_chrdev return a free numberFor dynamic allocation, script to extract /proc/devices device number, then invoke mknod to create device fileint unregister_chrdev(unsigned int major, const char *name);

Page 29: Building

29

Register a Character Device Driver Kernel

Major 0 Major 255Major 98 Major 99… …

Driver 1

Major 98

1

2(1)Insmod module, Driver (1)Insmod module, Driver registerregister a Major number to a Major number to KernelKernel

(2)Kernel know the Major (2)Kernel know the Major num,num,Kernel will link the major Kernel will link the major num tonum to The Driver ModuleThe Driver Module

Driver 2

Major 99

Page 30: Building

30

Major and Minor

Driver 1

Major 98

Driver 2

Major 99Device A

Major 98Minor 1

23

1

User Program

(1) Open(1) Open、、ReadRead、、WriteWrite(2) Pass Major&Minor (2) Pass Major&Minor

to Kernelto Kernel(3) Kernel Passes Minor (3) Kernel Passes Minor

to Driverto Driver

Kernel

Major 0 Major 255Major 98 Major 99… …

Page 31: Building

31

Application andGraphic User

Interface

Page 32: Building

32

Console Application

Write C/C++ programs and compile it as static link or dynamic link executable files.

StaticCopy the executable file to Root FilesystemExecute it.

DynamicCopy the executable file and needed libraries to Root FilesystemSet the library path by using “export LD_LIBRARY”Execute it

Page 33: Building

33

Graphic User InterfaceWindow System

X Window (TinyX)http://www.xfree86.org/

QPE (Qt Plamtop Environment) / Qtopiahttp://www.trolltech.com/products/qtopia/index.html

GPE (GPE Palmtop Environment)http://gpe.handhelds.org/

Microwindowshttp://microwindows.org/

MiniGUIhttp://www.minigui.org/

Page 34: Building

34

Programming with QT

Page 35: Building

35

Building the QT/Embedded Environment

Step1:# tar zxvf qt-embedded-3.3.1.tar.gz

Step2:# export QTDIR=home/qt-embedded-3.3.1# export LD_LIBRARY_PATH=home/qt-embedded-3.3.1/lib:$LD_LIBRARY_PATH# cp /usr/bin/uic /qt-embedded-3.3.1/bin# cd qt-embedded-3.3.1# ./configure -embedded arm -shared –debug# gmake

Page 36: Building

36

Building the QT/Embedded Environment

Page 37: Building

37

Programming QT Applications

/ **Import** check your environment variables QTDIR=/qt-embedded-3.3.1LD_LIBRARY_PATH=/qt-embedded-3.3.1/lib:LD_LIBRARY_PATH */

[command#]cd ~/test /* go to your project directory */[command#test]qmake –o Makefile test.pro[command#test]make

1. [root@locahost ]# mkdir busybox/qt-embedded-3.3.1/lib/fonts2. [root@locahost ]# cp /qt-embedded/lib/fonts/*

/home/busybox/qt-embedded-3.3.1/lib/fonts/


Recommended