Building

  • 2,701 views
Uploaded on

Embedded Linux System

Embedded Linux System

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,701
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
130
Comments
0
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Building Embedded Linux System on Samsung 2410 Platform 1
  • 2. Agenda Basic Concepts Kernel Considerations Root Filesystem Content Device Driver Application and GUI 2
  • 3. Basic Concepts 3
  • 4. Cross-Development Environment Target has limited resource (memory, storage, low speed processor) . Host and Target are different architecture Target Host •Bootloader Cross-platform •Kernel Development •Root Filesystem Environment 4
  • 5. Hardware Connection 5
  • 6. ARM Cross-Development Toolkit ASM Source C Source C Libraries C Compiler Assembler .aof Object Linker Libraries .aif debug System model ARMsd Development ARMulator board 6
  • 7. Development Environment GUN 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-gcc g++ : arm-linux-g++ ar : arm-linux-ar strip : arm-linux-strip 7
  • 8. Create Target Linux System A 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 components Configure and build the kernel Build root filesystem Set up boot software and configuration 8
  • 9. System Boot Flow Bootloader Extract and decompress the Kernel Image and RAMDISK Launch kernel Kernel Initialize Memory and Hardware Mount Root Filesystem (RAMDISK) Run /sbin/init User Programs 9
  • 10. All the things we need Cross-Platform development toolchain Bootloader Provide by vendor Linux kernel Linux kernel + some patches if needed Filesystem Busybox Device node Configuration 10
  • 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 Binutils including AS, LD and other binary file tools GCC the well known C,C++ complier supported variable platform GLIBC the C runtime library GDB the command line source debugger, including remote 11 debugging
  • 12. Bootloader 12
  • 13. ARM Linux Kernel ARM 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.shtml The Linux Kernel and most of the programs that make up the Linux system are quot;open sourcequot;, 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 13 and evaluation boards. There are also projects for
  • 14. Filesystem - initrd initrd 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 14 where additional modules are loaded from initrd.
  • 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 15
  • 16. Kernel Considerations 16
  • 17. Make Linux Kernel Download Linux kernelOptions: from Additional source http://www.kernel.org/ CROSS_COMPILE=arm-linux- ARCH=arm make clean make menuconfig Building Kernel CROSS_COMPILE=arm-linux dep make ARCH=arm make clean make ARCH=arm CROSS_COMPILE=arm-linux zImage make menuconfig make ARCH=arm CROSS_COMPILE=arm-linux modules make ARCH=arm CROSS_COMPILE=arm-linux make dep (this step is no needed in version 2.6) modules_install make bzImage make ARCH=arm CROSS_COMPILE=arm-linux install make modules make modules_install make install 17
  • 18. Make Linux Kernel After make bzImage, the kernel image will be at ./path/to/linux_src/arch/i386/boot/bzImage The quot;bzImagequot; name stands for quot;big zImage,quot; and has nothing to do with the bzip2 compression utility. In fact, both the bzImage and zImage Makefile targets 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.18
  • 19. Root Filesystem Content 19
  • 20. Building Root Filesystem Download the BusyBox source code from http://www.busybox.net/ Building BusyBox make clean make all make install After make complete, the busybox will be at ./path/to/busybox_src/_install/ 20
  • 21. Building Root Filesystem The BusyBox has all needed utilities, such as, ls, kill, chroot, mount, …,etc. Building the Root Filesystem Create a directory ~/root-fs Copy all files in busybox/_install to ~/root-fs/ Create some standard directory, such as, /dev, /etc /proc /mnt /tmp /var Make some device node Write some boot shell scripts Make directory ~/root-fs to a initrd image 21
  • 22. Create Device Nodes cd ~/root-fs/dev/ mknod tty c 5 0 mknod console c 5 1 mknod tty0 c 4 0 mknod ttyS0 c 4 64 mknod ttyS0 c 4 64 mknod ram0 b 1 0 mknod null c 1 3 22
  • 23. Write Shell Script /etc/inittab ::sysinit:/etc/rc.S ::askfirst:/bin/sh /etc/rc.S #!/bin/sh mount -t proc proc /proc 23
  • 24. Make INITRD image dd if=/dev/zero of=/home/initrd.img bs=1k count=8192 su root mke2fs -F -v -m0 /home/initrd.img mkdir tmp mount -o loop initrd.img tmp/ cp ~/root-fs/* /home/tmp/ -dpRrf umount tmp/ gzip -9 < initrd.img > initrd.bin file 8MB mount is null Write DATA ~/root-fs file 8MB unmount with data 24
  • 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 25
  • 26. Device Driver 26
  • 27. Major and Minor Numbers Special files under /dev “c” for char & “b” for block Major number identifies driver use at open time Minor number is used only by driver to control several devices crw-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 vcs1 crw------- 1 root sys 7, 129 Feb 23 1999 vcsa1 crw-rw-rw- 1 root root 1, 5 Feb 23 1999 zero 27
  • 28. Major Number Adding 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 finds To create device node : mknod /dev/scull0 c 254 0 If major is 0, the register_chrdev return a free number For dynamic allocation, script to extract /proc/devices device number, then invoke mknod to create device file int unregister_chrdev(unsigned int major, const char *name); 28
  • 29. Register a Character Device Driver Kernel Major 0 … Major 98 Major 99 … Major 255 Driver 2 2 (1)Insmod module, Driver Major 99 register a Major number to 1 Kernel Driver 1 (2)Kernel know the Major num, Major 98 Kernel will link the major num to The Driver Module 29
  • 30. Major and Minor Kernel Major 0 … Major 98 Major 99 … Major 255 2 Driver 2 Device A 3 Major 99 Major 98 Minor 1 (1) Open、Read、 Write Driver 1 (2) Pass Major&Minor 1 Major 98 to Kernel (3) Kernel Passes Minor User Program to Driver 30
  • 31. Application and Graphic User Interface 31
  • 32. Console Application Write C/C++ programs and compile it as static link or dynamic link executable files. Static Copy the executable file to Root Filesystem Execute it. Dynamic Copy the executable file and needed libraries to Root Filesystem Set the library path by using “export LD_LIBRARY” Execute it 32
  • 33. Graphic User Interface Window System X Window (TinyX) http://www.xfree86.org/ QPE (Qt Plamtop Environment) / Qtopia http://www.trolltech.com/products/qtopia/index.html GPE (GPE Palmtop Environment) http://gpe.handhelds.org/ Microwindows http://microwindows.org/ MiniGUI http://www.minigui.org/ 33
  • 34. Programming with QT 34
  • 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 35
  • 36. Building the QT/Embedded Environment 36
  • 37. Programming QT Applications / **Import** check your environment variables QTDIR=/qt-embedded-3.3.1 LD_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/fonts 2. [root@locahost ]# cp /qt-embedded/lib/fonts/* /home/busybox/qt-embedded-3.3.1/lib/fonts/ 37