Embedded Linux on
              ARM




                                 Chia Che Lee
                                    ...
Tool chains
OUTLINE
               Bootloader
               Building Linux kernel
               Linux device driver
    ...
A collection of tools used to develop for
Tool chains
                  a particular hardware target (e.g.
               ...
The Advantage of understanding
Tool chains
                  tool-chain :
                      Any project that requires ...
Tool chains

 The role of
  toolchain




                Department of Computer Science and Information Engineering
     ...
Source              Source              Source
Tool chains            code                code                code


Compi...
GNU is a complete, Unix-like operating
Tool chains
                    system that has been in development
 Why using the ...
The GNU toolchain consists :
Tool chains
                      Compiler – gcc
                      Assembler – binutils :...
gcc is a full-featured ANSI C compiler
Tool chains
                  with support for C, C++, Objective C,
 gcc - GNU     ...
The GNU Compiler for Java is now
Tool chains
                  integrated and supported: GCJ can
 gcc - GNU        compile...
Binutils are a collection of binary tools
Tool chains
                  like assembler, linker, disassembler … .
GNU Binut...
Any Unix-like operating system needs a
Tool chains        C library ( defines the ‘’system calls''
GNU C Library
         ...
Tool chains
                  GDB : The GNU Project Debugger
What is GDB       Allows you to see what is going on
        ...
Supported Languages
Tool chains
                          C
   GDB                    C++
                          Pascal...
Bootloader is mainly responsible for
Bootloader
                 loading the kernel, it is an very
                 import...
Bootloader




              Department of Computer Science and Information Engineering
      HANEL   National Cheng Kung ...
The simple code will be execute after
Bootloader
                 you power on your target ( Sometimes
                 we...
Bootloader




              Department of Computer Science and Information Engineering
      HANEL   National Cheng Kung ...
Bootloader
                             Boot Loader
                 reset;
                 ;Reset Code
                 ...
Part1
                    Jump 0x00900000
Bootloader       Part2
                    Initialize the actual hardware
      ...
Bootloader




              Department of Computer Science and Information Engineering
      HANEL   National Cheng Kung ...
Three different host/target
Building Linux
    kernel
                    architectures are available for the
            ...
The target and the host are
Building Linux
    kernel
                    permanently linked together using a
            ...
The kernel could be available via Trivial
Building Linux      File Transfer Protocol (TFTP)
    kernel
                   ...
A storage device is written by the host,
Building Linux
    kernel
                    is then transferred into the target...
The target contains only a minimal
Building Linux      bootloader
    kernel
                        The rest of the compo...
This setup is mostly popular during the
Building Linux
    kernel
                    initial phases of embedded system
  ...
The target is a self-contained
Building Linux
    kernel
                    development system and includes all
         ...
This type of setup is quite popular with
Building Linux      developers building high-end PC-based
    kernel
            ...
There are some broad characteristics
Building Linux
    kernel
                      expected from the hardware to run a
 ...
There are three different setups used
Building Linux
    kernel
                    to bootstrap an embedded Linux
       ...
Solid state storage media
Building Linux
    kernel                Boot
                       parameter




             ...
Building Linux       Disk
    kernel




                 Department of Computer Science and Information Engineering
     ...
Building Linux
    kernel




                 Department of Computer Science and Information Engineering
        HANEL   ...
Network
Building Linux
    kernel              the kernel resides on a solid state storage
                        media o...
U ser program s


Building Linux
    kernel
                                                              L ibraries

    ...
Device Driver




                Department of Computer Science and Information Engineering
        HANEL   National Chen...
Classes of Devices and Modules
Device driver
                       Character devices
                       Block devices...
A character (char) device is one that
Device driver
                      can be accessed as a stream of bytes
Character d...
Like char devices, block devices are
Device driver
                   accessed by filesystem nodes in the
Block devices   ...
Any network transaction is made
Device driver
                   through an interface, that is, a device
   Network       ...
Hello World




              Department of Computer Science and Information Engineering
      HANEL   National Cheng Kung...
Whereas an application performs a
Kernel module     single task from beginning to end, a
      vs          module register...
Department of Computer Science and Information Engineering
HANEL   National Cheng Kung University                         ...
Init_module()
Init_module()
                   for each facility, there is a specific
                   kernel function t...
cleanup_module()
cleanup_modu
      le          To unload a module, use the rmmod
                  command. Its task is m...
The job of a typical driver is, for the
I/O Regions
                 most part, writing and reading I/O
                 p...
A typical /proc/ioports file on a recent PC that is running
               version 2.4 of the kernel will look like the fo...
I/O memory information is available in
I/O Memory
                 the /proc/iomem file.




              Department of C...
Major and Minor Numbers
Chars Drivers     Special files for char drivers are Major
                  and Minor Numbers ide...
The kernel uses the major number at
Chars Drivers
                  open time to dispatch execution to the
               ...
QT & QT Embedded
GUI
             DirectFB




          Department of Computer Science and Information Engineering
  HANE...
Qt is a C++ class library for writing GUI
  GUI
                applications that run on UNIX, Windows
 QT & QT        95/...
GUI

 QT & QT
Embedded




             Department of Computer Science and Information Engineering
     HANEL   National C...
GUI

DirectFB




             Department of Computer Science and Information Engineering
     HANEL   National Cheng Kung...
GUI

DirectFB




             Department of Computer Science and Information Engineering
     HANEL   National Cheng Kung...
Upcoming SlideShare
Loading in...5
×

Embedded Linux On A R M

8,115

Published on

Published in: Technology
0 Comments
10 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
8,115
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
675
Comments
0
Likes
10
Embeds 0
No embeds

No notes for slide

Embedded Linux On A R M

  1. 1. Embedded Linux on ARM Chia Che Lee 李嘉哲 Home Automation, Networking, and Entertainment Lab Dept. of Computer Science and Information Engineering National Cheng Kung University
  2. 2. Tool chains OUTLINE Bootloader Building Linux kernel Linux device driver GUI Department of Computer Science and Information Engineering HANEL National Cheng Kung University 2
  3. 3. A collection of tools used to develop for Tool chains a particular hardware target (e.g. embedded system) Often used in the context of building software on one system which will be installed or run on some other device (e.g. embedded system) the chain of tools usually consists of such items as a particular version of a compiler, libraries, assembler, special headers, etc. Department of Computer Science and Information Engineering HANEL National Cheng Kung University 3
  4. 4. The Advantage of understanding Tool chains tool-chain : Any project that requires an embedded processor also requires software- development tools. Be advantage to develop new embedded system by developing own tool-chain Department of Computer Science and Information Engineering HANEL National Cheng Kung University 4
  5. 5. Tool chains The role of toolchain Department of Computer Science and Information Engineering HANEL National Cheng Kung University 5
  6. 6. Source Source Source Tool chains code code code Compile flow compiler compiler compiler chart Assembly Assembly Assembly code code code Assembler Assembler Assembler object object object code code code Executabl Libraries Linker e code code Department of Computer Science and Information Engineering HANEL National Cheng Kung University 6
  7. 7. GNU is a complete, Unix-like operating Tool chains system that has been in development Why using the for just over twenty years GNU Tool-chain GNU software is known for it's stability and standard compliance GNU tool-chain is open source which be easy to modify Department of Computer Science and Information Engineering HANEL National Cheng Kung University 7
  8. 8. The GNU toolchain consists : Tool chains Compiler – gcc Assembler – binutils : as Linker-- binutils : ld Library– glibc Debugger-- gdb Department of Computer Science and Information Engineering HANEL National Cheng Kung University 8
  9. 9. gcc is a full-featured ANSI C compiler Tool chains with support for C, C++, Objective C, gcc - GNU Java, and Fortran Compiler Collection GCC provides many levels of source code error checking , produces debugging information, and can perform many different optimizations to the resulting object code Department of Computer Science and Information Engineering HANEL National Cheng Kung University 9
  10. 10. The GNU Compiler for Java is now Tool chains integrated and supported: GCJ can gcc - GNU compile Java source or Java bytecodes Compiler to either native code or Java class files Collection GCC now supports the Intel IA-64 processor, so completely free software systems will be able to run on the IA- 64 architecture as soon as it is released. Department of Computer Science and Information Engineering HANEL National Cheng Kung University 10
  11. 11. Binutils are a collection of binary tools Tool chains like assembler, linker, disassembler … . GNU Binutils Binutils is to create and manipulate binary executable files. The main tools for Binutils ld - the GNU linker. as - the GNU assembler. Department of Computer Science and Information Engineering HANEL National Cheng Kung University 11
  12. 12. Any Unix-like operating system needs a Tool chains C library ( defines the ‘’system calls'' GNU C Library and other basic facilities such as open, malloc, printf, exit... ) The GNU C library is used as the C library in the GNU system and most systems with the Linux kernel. The GNU C library is a large blob of glue code, which tries to give it's best to hide kernel specific functions from you. (e.g. You can use the same function name and do not care the difference between different kernel ) Department of Computer Science and Information Engineering HANEL National Cheng Kung University 12
  13. 13. Tool chains GDB : The GNU Project Debugger What is GDB Allows you to see what is going on `inside' another program while it executes Allows you to see what another program was doing at the moment it crashed GDB can run on most popular UNIX and Microsoft Windows variants. Department of Computer Science and Information Engineering HANEL National Cheng Kung University 13
  14. 14. Supported Languages Tool chains C GDB C++ Pascal Objective-C Many other languages Department of Computer Science and Information Engineering HANEL National Cheng Kung University 14
  15. 15. Bootloader is mainly responsible for Bootloader loading the kernel, it is an very important component Many bootloaders can be used with Linux on various hardware LOIO GRUB LinuxBIOS Redboot U-boot …… Department of Computer Science and Information Engineering HANEL National Cheng Kung University 15
  16. 16. Bootloader Department of Computer Science and Information Engineering HANEL National Cheng Kung University 16
  17. 17. The simple code will be execute after Bootloader you power on your target ( Sometimes we call it “boot monitor” ) Embedded System bootloader should do: 1. Initialize Hardware: processor and memory 2. Loading kernel image and execute kernel (sometimes it need to transfer parameter to linux kernel) Department of Computer Science and Information Engineering HANEL National Cheng Kung University 17
  18. 18. Bootloader Department of Computer Science and Information Engineering HANEL National Cheng Kung University 18
  19. 19. Bootloader Boot Loader reset; ;Reset Code ;(in assembly) Jmp hw_init Hw_init ;Hardware Main() ;Initialization { ;(in assembly) /*The C/C++ program start here*/ …. } Jmp startup Startup; ;startup code NoOS/OS Code ;(in assembly) …… Call main Department of Computer Science and Information Engineering HANEL National Cheng Kung University 19
  20. 20. Part1 Jump 0x00900000 Bootloader Part2 Initialize the actual hardware Set cpu mode Part3 Disable all interrupts Copy any initialized data from ROM to RAM Zero the uninitialized data area Allocation space for and initialize the stack Initialize the processor’s stack pointer Create and initialize the heap Execute the constructors and initializers for all global variables (C++) Enable interrupts Call main Part4 Program C/C++ code Department of Computer Science and Information Engineering HANEL National Cheng Kung University 20
  21. 21. Bootloader Department of Computer Science and Information Engineering HANEL National Cheng Kung University 21
  22. 22. Three different host/target Building Linux kernel architectures are available for the development of embedded Linux systems: Linked setup Removable storage setup Standalone setup Your actual setup may belong to more than one category or may even change categories over time, depending on your requirements and development methodology Department of Computer Science and Information Engineering HANEL National Cheng Kung University 22
  23. 23. The target and the host are Building Linux kernel permanently linked together using a physical cable Linked Setup This link is typically a serial cable or an Ethernet link All transfers occur via the link Host Target *Cross-platform *Bootloader development *Kernel environment *Root filesystem Department of Computer Science and Information Engineering HANEL National Cheng Kung University 23
  24. 24. The kernel could be available via Trivial Building Linux File Transfer Protocol (TFTP) kernel The root filesystem could also be NFS Linked Setup mounted instead of being on a storage (cont’) media in the target Using an NFS-mounted root filesystem is actually perfect during development, because it avoids having to constantly copy program modifications between the host and the target The physical link can also be used for debugging purposes Many embedded systems provide both Ethernet and RS232 link capabilities Department of Computer Science and Information Engineering HANEL National Cheng Kung University 24
  25. 25. A storage device is written by the host, Building Linux kernel is then transferred into the target, and is used to boot the device Removable Storage Setup Host Target *Cross-platform development *Bootloader environment *Secondary bootloader *Kernel *Root filesystem Department of Computer Science and Information Engineering HANEL National Cheng Kung University 25
  26. 26. The target contains only a minimal Building Linux bootloader kernel The rest of the components are stored on a Removable removable storage media, such as a Storage Setup CompactFlash IDE device or any other type (cont’) of drive Instead of a fixed flash chip, the target could contain a socket where a flash chip could be easily inserted and removed The chip would be programmed by a flash programmer on the host and inserted into the socket in the target for normal operation Department of Computer Science and Information Engineering HANEL National Cheng Kung University 26
  27. 27. This setup is mostly popular during the Building Linux kernel initial phases of embedded system development Removable You may find it more practical to move on Storage Setup to a linked setup once the initial (cont’) development phase is over you can avoid the need to physically transfer a storage device between the target and the host every time a change has to be made to the kernel or the root filesystem Department of Computer Science and Information Engineering HANEL National Cheng Kung University 27
  28. 28. The target is a self-contained Building Linux kernel development system and includes all the required software to boot, operate, Standalone and develop additional software Setup This setup is similar to an actual workstation, except the underlying hardware is not a conventional workstation but rather the embedded system itself Target *Bootloader *Kernel *Full root filesystem *Native development environment Department of Computer Science and Information Engineering HANEL National Cheng Kung University 28
  29. 29. This type of setup is quite popular with Building Linux developers building high-end PC-based kernel embedded systems, such as high- Standalone availability systems Setup They can use standard off-the-shelf Linux (cont’) distributions on the embedded system Once development is done, they then work at trimming down the distribution and customizing it for their purposes This gets developers around having to build their own root filesystems and configure the systems' startup It requires that they know the particular distribution they are using inside out Department of Computer Science and Information Engineering HANEL National Cheng Kung University 29
  30. 30. There are some broad characteristics Building Linux kernel expected from the hardware to run a Linux system: 1. Linux requires at least a 32-bit CPU containing a memory management unit (MMU) 2. a sufficient amount of RAM must be available to accommodate the system. 3. minimal I/O capabilities are required if any development is to be carried out on the target with reasonable debugging facilities. Department of Computer Science and Information Engineering HANEL National Cheng Kung University 30
  31. 31. There are three different setups used Building Linux kernel to bootstrap an embedded Linux system: Solid state storage media Disk Network Department of Computer Science and Information Engineering HANEL National Cheng Kung University 31
  32. 32. Solid state storage media Building Linux kernel Boot parameter Kernel Root file system Bootloader Department of Computer Science and Information Engineering HANEL National Cheng Kung University 32
  33. 33. Building Linux Disk kernel Department of Computer Science and Information Engineering HANEL National Cheng Kung University 33
  34. 34. Building Linux kernel Department of Computer Science and Information Engineering HANEL National Cheng Kung University 34
  35. 35. Network Building Linux kernel the kernel resides on a solid state storage media or a disk, and the root filesystem is mounted via NFS only the bootloader resides on a local storage media. The kernel is then downloaded via TFTP, and the root filesystem is mounted via NFS Department of Computer Science and Information Engineering HANEL National Cheng Kung University 35
  36. 36. U ser program s Building Linux kernel L ibraries U ser Level K ernel L evel System C all Interface file subsystem IPC buffer Scheduler cache L inux M em ory m anagem ent character block device drivers H ardw are control (H A L ) K ernel Level H ardw are Level Department of Computer Science and Information Engineering HANEL H ardw are National Cheng Kung University 36
  37. 37. Device Driver Department of Computer Science and Information Engineering HANEL National Cheng Kung University 37
  38. 38. Classes of Devices and Modules Device driver Character devices Block devices Network interfaces Department of Computer Science and Information Engineering HANEL National Cheng Kung University 38
  39. 39. A character (char) device is one that Device driver can be accessed as a stream of bytes Character devices (like a file) Driver usually implements at least the open, close, read, and write system calls. The text console (/dev/console) and the serial ports (/dev/ttyS0) are examples of char devices. char devices are just data channels, which you can only access sequentially. Department of Computer Science and Information Engineering HANEL National Cheng Kung University 39
  40. 40. Like char devices, block devices are Device driver accessed by filesystem nodes in the Block devices /dev directory. A block device is something that can host a filesystem, such as a disk. Department of Computer Science and Information Engineering HANEL National Cheng Kung University 40
  41. 41. Any network transaction is made Device driver through an interface, that is, a device Network that is able to exchange data with interfaces other hosts. Network interface was look as a Queue The Unix way to provide access to interfaces is still by assigning a unique name to them (such as eth0). Department of Computer Science and Information Engineering HANEL National Cheng Kung University 41
  42. 42. Hello World Department of Computer Science and Information Engineering HANEL National Cheng Kung University 42
  43. 43. Whereas an application performs a Kernel module single task from beginning to end, a vs module registers itself in order to serve Application future requests, and its “main” function terminates immediately. the task of the function init_module (the module’s entry point) is to prepare for later invocation of the module’s functions.The second entry point of a module, cleanup_module, gets invoked just before the module is unloaded. Department of Computer Science and Information Engineering HANEL National Cheng Kung University 43
  44. 44. Department of Computer Science and Information Engineering HANEL National Cheng Kung University 44
  45. 45. Init_module() Init_module() for each facility, there is a specific kernel function that accomplishes this registration. The arguments passed to the kernel registration functions are usually a pointer to a data structure describing the new facility and the name of the facility being registered. Department of Computer Science and Information Engineering HANEL National Cheng Kung University 45
  46. 46. cleanup_module() cleanup_modu le To unload a module, use the rmmod command. Its task is much simpler than loading, since no linking has to be performed. The command invokes the delete_module system call, which calls cleanup_module in the module itself if the usage count is zero or returns an error otherwise. Department of Computer Science and Information Engineering HANEL National Cheng Kung University 46
  47. 47. The job of a typical driver is, for the I/O Regions most part, writing and reading I/O ports and I/O memory. Access to I/O ports and I/O memory (collectively called I/O regions) happens both at initialization time and during normal operations. Department of Computer Science and Information Engineering HANEL National Cheng Kung University 47
  48. 48. A typical /proc/ioports file on a recent PC that is running version 2.4 of the kernel will look like the following: 0000-001f : dma1 I/O Port 0020-003f : pic1 0040-005f : timer 0060-006f : keyboard 0080-008f : dma page reg 00a0-00bf : pic2 00c0-00df : dma2 00f0-00ff : fpu 0170-0177 : ide1 01f0-01f7 : ide0 02f8-02ff : serial(set) 0300-031f : NE2000 0376-0376 : ide1 03c0-03df : vga+ 03f6-03f6 : ide0 03f8-03ff : serial(set) 1000-103f : Intel Corporation 82371AB PIIX4 ACPI 1000-1003 : acpi 1004-1005 : acpi 1008-100b : acpi 100c-100f : acpi 1100-110f : Intel Corporation 82371AB PIIX4 IDE 1300-131f : pcnet_cs 1400-141f : Intel Corporation 82371AB PIIX4 ACPI 1800-18ff : PCI CardBus #02 1c00-1cff : PCI CardBus #04 5800-581f : Intel Corporation 82371AB PIIX4 USB d000-dfff : PCI Bus #01 d000-d0ff : ATI Technologies Inc 3D Rage LT Pro AGP-133 Department of Computer Science and Information Engineering HANEL National Cheng Kung University 48
  49. 49. I/O memory information is available in I/O Memory the /proc/iomem file. Department of Computer Science and Information Engineering HANEL National Cheng Kung University 49
  50. 50. Major and Minor Numbers Chars Drivers Special files for char drivers are Major and Minor Numbers identified by a “c” in the first column of the output of ls –l. Block devices appear in /dev as well, but they are identified by a “b.” Use ls –l /dev commend to check. Department of Computer Science and Information Engineering HANEL National Cheng Kung University 50
  51. 51. The kernel uses the major number at Chars Drivers open time to dispatch execution to the appropriate driver The minor number is used only by the driver specified by the major number mknod /dev/scull0 c 254 0 creates a char device (c) whose major number is 254 and whose minor number is 0. Department of Computer Science and Information Engineering HANEL National Cheng Kung University 51
  52. 52. QT & QT Embedded GUI DirectFB Department of Computer Science and Information Engineering HANEL National Cheng Kung University 52
  53. 53. Qt is a C++ class library for writing GUI GUI applications that run on UNIX, Windows QT & QT 95/98, and Windows NT platforms Embedded Qt/Embedded, the embedded Linux port of Qt, is a complete and self- contained C++ GUI and platform development tool for Linux-based embedded development. Department of Computer Science and Information Engineering HANEL National Cheng Kung University 53
  54. 54. GUI QT & QT Embedded Department of Computer Science and Information Engineering HANEL National Cheng Kung University 54
  55. 55. GUI DirectFB Department of Computer Science and Information Engineering HANEL National Cheng Kung University 55
  56. 56. GUI DirectFB Department of Computer Science and Information Engineering HANEL National Cheng Kung University 56
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×