SlideShare uma empresa Scribd logo
1 de 28
Baixar para ler offline
Linux Porting
for new ARM platform

Champ Yen
http://champyen.blogspot.com
champ.yen@gmail.com
OutLine

GNU Toolchain
Linux Kernel Prerequisites and Assumptions
Images
Boot Sequence
Kernel Configuration & Compilation
Kernel Porting
Device Drivers
Boot Options
initramfs vs initrd
References
GNU Toolchains

   CodeSourcery gnu toolchain
    http://www.codesourcery.com/sgpp/lite/arm/download.html
   Buildroot
    http://buildroot.uclibc.org/
   Scratchbox
    http://www.scratchbox.org/
   OpenEmbedded
    http://wiki.openembedded.net/index.php/Main_Page
   Ptxdist
    http://www.pengutronix.de/software/ptxdist/index_en.html
GNU Toolchains - buildroot
   linux kernel like configuration interface
    ncurse UI, .config file
   uClibc generate linux 2.6 compatible small footprint
    applications
   for most platform remember to enable software float
   output: toolchain/uClibc/busybox/rootfs
Linux Kernel Prerequisites and Assumptions


   DRAM is initialized
   Hardware-related initialization tasks are done
   MMU/Cache is disabled
   specific values should be saved in registers
    r1: Machine ID, r2: pointer of ATAG list (optional)
Images and intermediate files




                                                                       piggy.o
                             image
  vmlinuz       objcopy      (binary    gzip     piggy.gz      asm
 (ELF object)                 object)
                                                                        misc.o

                                               compressed              head.o
                          stripped image       binary kernel
                           binary kernel                               bootable
                                                                     kernel image
kernel proper                                                          (zImage)
Boot Sequence


   start

       arch/arm/boot/   start
        compressed/
          head.S                              start_kernel
                           arch/arm/kernel/
                               head.S

    bootstrap loader                               init/main.c
     (uncompress)
                          ARM-specific
                           kernel code
                                                 kernel code




detail boot sequence is listed in [9]
Kernel Porting – Kernel Memory Map

                                                     0xFFFF_FFFF
CPU vector page/copy_user_page(),clear_user_page()

                                                     0xFFFF_0000
          DMA memory mapping
                                                     0xFF00_0000
           free for platform use
                                                     VMALLOC_END
        vmalloc()/ioremap() space
                                                     VMALLOC_START
   kernel direct-mapped RAM region
                                                     PAGE_OFFSET
           kernel module space
                                                     TASK_SIZE
           user space mapping
                                                     0x0000_1000
   CPU vector page/null pointer trap
                                                     0x0000_0000
Kernel Porting – Directories

   mm/
    memory-handling related code
   boot/
    bootstrap loader code
   kernel/
    ARM architecture dependent code
   mach-XXXXXX/
    specific machine dependent code
   configs/
    each machine’s default kernel configurations
Kernel Porting – new machine items

refer to other machine to create or modify items(ex: foo, fxx)
  register the new machine
    arch/arm/tools/mach-types
   Create machine folder
    arch/arm/mach-fxx
    arch/arm/mach-fxx/include/mach
   Modify or Create Kconfig & Makefile
    arch/arm/Kconfig (usually add config ARCH_FXX for architecture)
    arch/arm/Makefile
    arch/arm/mm/Kconfig
    arch/arm/mach-fxx/Kconfig (config MACH_FOO for machine)
    arch/arm/mach-fxx/Makefile
    arch/arm/mach-fxx/Makefile.boot (set zreladdr-y for image location)
Kernel Porting – new machine items
        register the new machine


   Add an entry in arch/arm/tools/mach-types
    ex: foo MACH_FOO FOO                65535
   For official registration, should register here, also.
    http://www.arm.linux.org.uk/developer/machines/
Kernel Porting – new machine items
        create machine folders


     arm/arch/mach-fxx
      for machine dependent source code
     arm/arm/mach-fxx/include/mach
      for machine dependent headers/assembly

debug-macro.S: adduart, senduart, busyuart, waituart
dma.h
entry-macro.S: macro get_irqnr_and_base
hardware.h                        system.h: arch_idle(), arch_reset()
io.h                              timex.h: CLOCK_TICK_RATE
irqs.h: NR_IRQS                   uncompress.h: putc()
memory.h: PHYS_OFFSET             vmalloc.h: VMALLOC_END
Kernel Porting – new machine items
        modify or create Kconfig & Makefile

   arch/arm/Kconfig
    config ARCH_FXX
       bool “FXX family processors“
       help
         This enables support for systems based on the fxx processors.
    ………
    source "arch/arm/mach-fxx/Kconfig"
   arch/arm/Makefile
    machine-$(CONFIG_ARCH_FXX)        := fxx
   arch/arm/mm/Kconfig (ex: ARM926-based)
    config CPU_ARM926T
         bool "Support ARM926T processor"
          depends on ARCH_INTEGRATOR || ARCH_VERSATILE_PB || 
                   … || ARCH_FXX
          default y if ARCH_VERSATILE_PB || ARCH_VERSATILE_AB || 
                   … || ARCH_FXX
Kernel Porting – new machine items
        modify or create Kconfig & Makefile

   arch/arm/mach-fxx/Kconfig
    menu "FXX platform type“
     depends on ARCH_FXX
    config MACH_FOO
      bool "Support FOO platform"
      default y
      help
    Include support for the FOO platform.
    endmenu
   arch/arm/mach-fxx/Makefile
    # Common support (must be linked before board specific support)
    obj-y :=                                                    architecture depend code
    # Specific board support
    obj-$(CONFIG_MACH_FOO) += core.o                            machine depend code
   arch/arm/mach-fxx/Makefile.boot
    zreladdr-y := 0x01008000
Kernel Porting – description structure

MACHINE_START(FOO, "FOO processor")
   /* Maintainer: Champ Yen */
   .map_io = foo_map_io,
   .init_irq = foo_init_irq,
   .init_machine = foo_init,
   .timer = &foo_timer,
   /* for ATAG list is optional */
   .boot_params = 0x01000100,
MACHINE_END
Kernel Porting – Initialization code

   I/O Memory Mapping Table
   IRQ
   Timer
    struct sys_timer
   Initial order: .map_io .initrq .timer .init_machine
Kernel Porting – I/O Memory Map

static struct map_desc foo_io_desc[] __initdata =
{
     {
     /* address after mapping */
     .virtual       = IO_ADDRESS(CPU_DEV_PHY_BASE),
     /* page index of physical address */
     .pfn = __phys_to_pfn(CPU_DEV_PHY_BASE),
     .length        = CPU_DEV_IO_LEN,             /* address mapping range */
     .type          = MT_DEVICE        /* I/O type */
     },
    ……
};
….
static void __init foo_map_io(void)
{
     iotable_init(foo_io_desc, ARRAY_SIZE(foo_io_desc));
}
Kernel Porting – IRQ

       arch/arm/mach-fxx/include/mach/entry-macro.S
        get_irqnr_and_base: after calling irqnr: irq number, not equal
        condition should be set.
       arch/arm/mach-fxx/include/mach/irqs.h
        NR_IRQS (number of irq types) should be defined
       struct irq_chip, irqaction
        set_irq_chip(), set_irq_flags(), set_irq_handler(), setup_irq()

                                          ………
static struct irq_chip foo_irq_chip = {
                                          for(i = o; i < NR_IRQS; i++){
      .ack = foo_int_ack,
                                                       set_irq_handler(i, handle_level_irq);
      .mask = foo_int_mask,
                                                       set_irq_chip(i, &foo_irq_chip);
      .unmask = foo_int_unmask,
                                                       set_irq_flags(i, IRQF_VALID);
};
                                          }
                                          ………
Kernel Porting - Timer


struct sys_timer foo_timer = {
     .init      = foo_timer_init,
     .offset      = foo_gettimeoffset,
};
Kernel Porting – DMA memory (optional)


   Influence to dma_alloc_coherent() usage
   In arch/arm/mach-fxx/include/mach/dma.h
      MAX_DMA_ADDRESS


   In arch/arm/mach-fxx/include/mach/memory.h
      CONSISTENT_DMA_SIZE


       ISA_DMA_THRESHOLD
Boot Options – static string

   Boot options -> Default kernel command string
    ex: mem=8M@0x01000000 initrd=0x01180000,145762
Boot Options – ATAG lists

   ATAG provides dynamic boot option passing
   There are two way to pass pointer of ATAG lists
    r2 value passed by bootloader, .boot_params in machine descriptor
   refer to arch/arm/include/asm/setup.h

      struct tag_header {
           __u32 size;                                           ATAG_CORE
           __u32 tag;
      };




                                                                        ……
      struct tag {
           struct tag_header hdr;
           union {
                 struct tag_core    core;
                 struct tag_mem32     mem;
                 …
           } u;                                                  ATAG_NONE
      };
Device Drivers

   platform_device_register(), platform_driver_register()
    for some on-chip devices(ex: clock/power control)
   UART subsystem in driver/serial
    for startup message, console ,and shell
   Framebuffer subsystem in driver/video
initramfs vs initrd

                  initrd               initramfs
image             ext2 image + gzip    cpio + gzip
implementation block device            tmpfs
first execution   /linuxrc             /init
mount rootfs      pivot_root           switch_root

initrd requires ext2 and block devices support. It adds 150KB+
to kernel size.
initramfs

   create an initramfs image by command:
    find . | cpio -o -H newc | gzip > ../initramfs.cpio.gz

   take care of the distance between image and kernel,
    otherwise image will be overwritten by kernel.
   /init
    ex:
    #!/bin/busybox sh
    #/bin/busybox --install
    mount -t proc proc /proc
    exec /bin/busybox sh
Debug

   decompression: putc() definiition in include/mach/uncompress.h
   kernel debugging features in kernel hacking of kernel options (and
    CONFIG_DEBUG_LL option for low level debugging)
   early debug: printascii/printhex(2,4,8) make use of uart macros in
    include/mach/debug-macro.S
   printk()
   CONNFIG_KGDB
References

   Embedded Linux Primer, Christopher Hallinan, Prentice Hall
   Building Embedded Linux Systems 2/e, Karim Yaghmour, Oreilly
   linux-2.6.2x-xx/Documentation/arm
   http://heaven.branda.to/~thinker/GinGin_CGI.py/get_afile/166/porting_to_arm.pdf
   http://www.glomationinc.com/PortingLinuxKernel.pdf
   http://www.ens-lyon.fr/LIP/Pub/Rapports/RR/RR2006/RR2006-08.pdf
   http://glt08.linuxtage.at/slides/glt08-kvas_linuxonarm.pdf
   http://www.linux-arm.org/LinuxKernel/LinuxNewPlatformPort
   http://gicl.cs.drexel.edu/people/sevy/linux/ARM_Linux_boot_sequence.html
   http://www.simtec.co.uk/products/SWLINUX/files/booting_article.html
   http://www.ibm.com/developerworks/linux/library/l-initrd.html
   http://blog.linux.org.tw/~jserv/archives/001954.html
Q&A

Mais conteúdo relacionado

Mais procurados

U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoCMacpaul Lin
 
I2C Subsystem In Linux-2.6.24
I2C Subsystem In Linux-2.6.24I2C Subsystem In Linux-2.6.24
I2C Subsystem In Linux-2.6.24Varun Mahajan
 
Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)Macpaul Lin
 
Understanding a kernel oops and a kernel panic
Understanding a kernel oops and a kernel panicUnderstanding a kernel oops and a kernel panic
Understanding a kernel oops and a kernel panicJoseph Lu
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)shimosawa
 
Linux Kernel MMC Storage driver Overview
Linux Kernel MMC Storage driver OverviewLinux Kernel MMC Storage driver Overview
Linux Kernel MMC Storage driver OverviewRajKumar Rampelli
 
Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_BootingRashila Rr
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)shimosawa
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchlinuxlab_conf
 
20111015 勉強会 (PCIe / SR-IOV)
20111015 勉強会 (PCIe / SR-IOV)20111015 勉強会 (PCIe / SR-IOV)
20111015 勉強会 (PCIe / SR-IOV)Kentaro Ebisawa
 
Physical Memory Models.pdf
Physical Memory Models.pdfPhysical Memory Models.pdf
Physical Memory Models.pdfAdrian Huang
 
Linux Kernel - Virtual File System
Linux Kernel - Virtual File SystemLinux Kernel - Virtual File System
Linux Kernel - Virtual File SystemAdrian Huang
 
from Binary to Binary: How Qemu Works
from Binary to Binary: How Qemu Worksfrom Binary to Binary: How Qemu Works
from Binary to Binary: How Qemu WorksZhen Wei
 
Interrupt Affinityについて
Interrupt AffinityについてInterrupt Affinityについて
Interrupt AffinityについてTakuya ASADA
 
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...Adrian Huang
 
Qemu device prototyping
Qemu device prototypingQemu device prototyping
Qemu device prototypingYan Vugenfirer
 
QEMU - Binary Translation
QEMU - Binary Translation QEMU - Binary Translation
QEMU - Binary Translation Jiann-Fuh Liaw
 
Debugging linux kernel tools and techniques
Debugging linux kernel tools and  techniquesDebugging linux kernel tools and  techniques
Debugging linux kernel tools and techniquesSatpal Parmar
 
Decompressed vmlinux: linux kernel initialization from page table configurati...
Decompressed vmlinux: linux kernel initialization from page table configurati...Decompressed vmlinux: linux kernel initialization from page table configurati...
Decompressed vmlinux: linux kernel initialization from page table configurati...Adrian Huang
 

Mais procurados (20)

U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoC
 
I2C Subsystem In Linux-2.6.24
I2C Subsystem In Linux-2.6.24I2C Subsystem In Linux-2.6.24
I2C Subsystem In Linux-2.6.24
 
Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)
 
Understanding a kernel oops and a kernel panic
Understanding a kernel oops and a kernel panicUnderstanding a kernel oops and a kernel panic
Understanding a kernel oops and a kernel panic
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
 
Linux Kernel MMC Storage driver Overview
Linux Kernel MMC Storage driver OverviewLinux Kernel MMC Storage driver Overview
Linux Kernel MMC Storage driver Overview
 
Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_Booting
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratch
 
20111015 勉強会 (PCIe / SR-IOV)
20111015 勉強会 (PCIe / SR-IOV)20111015 勉強会 (PCIe / SR-IOV)
20111015 勉強会 (PCIe / SR-IOV)
 
Physical Memory Models.pdf
Physical Memory Models.pdfPhysical Memory Models.pdf
Physical Memory Models.pdf
 
Linux Kernel - Virtual File System
Linux Kernel - Virtual File SystemLinux Kernel - Virtual File System
Linux Kernel - Virtual File System
 
from Binary to Binary: How Qemu Works
from Binary to Binary: How Qemu Worksfrom Binary to Binary: How Qemu Works
from Binary to Binary: How Qemu Works
 
Interrupt Affinityについて
Interrupt AffinityについてInterrupt Affinityについて
Interrupt Affinityについて
 
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
qemu + gdb: The efficient way to understand/debug Linux kernel code/data stru...
 
Qemu device prototyping
Qemu device prototypingQemu device prototyping
Qemu device prototyping
 
QEMU - Binary Translation
QEMU - Binary Translation QEMU - Binary Translation
QEMU - Binary Translation
 
Debugging linux kernel tools and techniques
Debugging linux kernel tools and  techniquesDebugging linux kernel tools and  techniques
Debugging linux kernel tools and techniques
 
Decompressed vmlinux: linux kernel initialization from page table configurati...
Decompressed vmlinux: linux kernel initialization from page table configurati...Decompressed vmlinux: linux kernel initialization from page table configurati...
Decompressed vmlinux: linux kernel initialization from page table configurati...
 

Destaque

Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBshimosawa
 
Mainline U-BOOT for iMX6 (AR6MX)
Mainline U-BOOT for iMX6 (AR6MX)Mainline U-BOOT for iMX6 (AR6MX)
Mainline U-BOOT for iMX6 (AR6MX)Frodo Lai
 
Linux fundamental - Chap 11 boot
Linux fundamental - Chap 11 bootLinux fundamental - Chap 11 boot
Linux fundamental - Chap 11 bootKenny (netman)
 
Renesas DevCon 2010: Starting a QT Application with Minimal Boot
Renesas DevCon 2010: Starting a QT Application with Minimal BootRenesas DevCon 2010: Starting a QT Application with Minimal Boot
Renesas DevCon 2010: Starting a QT Application with Minimal Bootandrewmurraympc
 
政黨票的故事
政黨票的故事政黨票的故事
政黨票的故事Macpaul Lin
 
Porting linux to a new architecture
Porting linux to a new architecturePorting linux to a new architecture
Porting linux to a new architectureKALRAY
 
Porting a new architecture (NDS32) to open wrt project
Porting a new architecture (NDS32) to open wrt projectPorting a new architecture (NDS32) to open wrt project
Porting a new architecture (NDS32) to open wrt projectMacpaul Lin
 
Kernel init
Kernel initKernel init
Kernel initgowell
 
U boot source clean up project how-to
U boot source clean up project how-toU boot source clean up project how-to
U boot source clean up project how-toMacpaul Lin
 
U boot 程式碼打掃計畫
U boot 程式碼打掃計畫U boot 程式碼打掃計畫
U boot 程式碼打掃計畫Macpaul Lin
 
Quickboot on i.MX6
Quickboot on i.MX6Quickboot on i.MX6
Quickboot on i.MX6Gary Bisson
 
How to build a community in a company blue&macpaul coscup2015
How to build a community in a company blue&macpaul coscup2015How to build a community in a company blue&macpaul coscup2015
How to build a community in a company blue&macpaul coscup2015Macpaul Lin
 
Why sending patches back is so important
Why sending patches back is so importantWhy sending patches back is so important
Why sending patches back is so importantMacpaul Lin
 
Module 4 Embedded Linux
Module 4 Embedded LinuxModule 4 Embedded Linux
Module 4 Embedded LinuxTushar B Kute
 
Linux Kernel Booting Process (2) - For NLKB
Linux Kernel Booting Process (2) - For NLKBLinux Kernel Booting Process (2) - For NLKB
Linux Kernel Booting Process (2) - For NLKBshimosawa
 
OpenWRT, A value-add base solution for your product. (2nd, Macpual)
OpenWRT, A value-add base solution for your product. (2nd, Macpual)OpenWRT, A value-add base solution for your product. (2nd, Macpual)
OpenWRT, A value-add base solution for your product. (2nd, Macpual)Macpaul Lin
 
ELC-E 2010: The Right Approach to Minimal Boot Times
ELC-E 2010: The Right Approach to Minimal Boot TimesELC-E 2010: The Right Approach to Minimal Boot Times
ELC-E 2010: The Right Approach to Minimal Boot Timesandrewmurraympc
 

Destaque (20)

Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKB
 
Mainline U-BOOT for iMX6 (AR6MX)
Mainline U-BOOT for iMX6 (AR6MX)Mainline U-BOOT for iMX6 (AR6MX)
Mainline U-BOOT for iMX6 (AR6MX)
 
Micro-controller course lec 01
Micro-controller course lec 01Micro-controller course lec 01
Micro-controller course lec 01
 
Linux fundamental - Chap 11 boot
Linux fundamental - Chap 11 bootLinux fundamental - Chap 11 boot
Linux fundamental - Chap 11 boot
 
Renesas DevCon 2010: Starting a QT Application with Minimal Boot
Renesas DevCon 2010: Starting a QT Application with Minimal BootRenesas DevCon 2010: Starting a QT Application with Minimal Boot
Renesas DevCon 2010: Starting a QT Application with Minimal Boot
 
政黨票的故事
政黨票的故事政黨票的故事
政黨票的故事
 
Porting linux to a new architecture
Porting linux to a new architecturePorting linux to a new architecture
Porting linux to a new architecture
 
Porting a new architecture (NDS32) to open wrt project
Porting a new architecture (NDS32) to open wrt projectPorting a new architecture (NDS32) to open wrt project
Porting a new architecture (NDS32) to open wrt project
 
Kernel init
Kernel initKernel init
Kernel init
 
U boot source clean up project how-to
U boot source clean up project how-toU boot source clean up project how-to
U boot source clean up project how-to
 
U boot 程式碼打掃計畫
U boot 程式碼打掃計畫U boot 程式碼打掃計畫
U boot 程式碼打掃計畫
 
Quickboot on i.MX6
Quickboot on i.MX6Quickboot on i.MX6
Quickboot on i.MX6
 
How to build a community in a company blue&macpaul coscup2015
How to build a community in a company blue&macpaul coscup2015How to build a community in a company blue&macpaul coscup2015
How to build a community in a company blue&macpaul coscup2015
 
Why sending patches back is so important
Why sending patches back is so importantWhy sending patches back is so important
Why sending patches back is so important
 
Module 4 Embedded Linux
Module 4 Embedded LinuxModule 4 Embedded Linux
Module 4 Embedded Linux
 
Qt5 embedded
Qt5 embeddedQt5 embedded
Qt5 embedded
 
Linux Kernel Booting Process (2) - For NLKB
Linux Kernel Booting Process (2) - For NLKBLinux Kernel Booting Process (2) - For NLKB
Linux Kernel Booting Process (2) - For NLKB
 
OpenWRT, A value-add base solution for your product. (2nd, Macpual)
OpenWRT, A value-add base solution for your product. (2nd, Macpual)OpenWRT, A value-add base solution for your product. (2nd, Macpual)
OpenWRT, A value-add base solution for your product. (2nd, Macpual)
 
Porting Android
Porting AndroidPorting Android
Porting Android
 
ELC-E 2010: The Right Approach to Minimal Boot Times
ELC-E 2010: The Right Approach to Minimal Boot TimesELC-E 2010: The Right Approach to Minimal Boot Times
ELC-E 2010: The Right Approach to Minimal Boot Times
 

Semelhante a Linux Porting

Study on Android Emulator
Study on Android EmulatorStudy on Android Emulator
Study on Android EmulatorSamael Wang
 
Linux Kernel Tour
Linux Kernel TourLinux Kernel Tour
Linux Kernel Toursamrat das
 
LCU14 302- How to port OP-TEE to another platform
LCU14 302- How to port OP-TEE to another platformLCU14 302- How to port OP-TEE to another platform
LCU14 302- How to port OP-TEE to another platformLinaro
 
Vmlinux: anatomy of bzimage and how x86 64 processor is booted
Vmlinux: anatomy of bzimage and how x86 64 processor is bootedVmlinux: anatomy of bzimage and how x86 64 processor is booted
Vmlinux: anatomy of bzimage and how x86 64 processor is bootedAdrian Huang
 
I/O, You Own: Regaining Control of Your Disk in the Presence of Bootkits
I/O, You Own: Regaining Control of Your Disk in the Presence of BootkitsI/O, You Own: Regaining Control of Your Disk in the Presence of Bootkits
I/O, You Own: Regaining Control of Your Disk in the Presence of BootkitsCrowdStrike
 
Raspberry Pi tutorial
Raspberry Pi tutorialRaspberry Pi tutorial
Raspberry Pi tutorial艾鍗科技
 
#include avrinterrupt.h The global interrupt flag is maintained.pdf
#include avrinterrupt.h The global interrupt flag is maintained.pdf#include avrinterrupt.h The global interrupt flag is maintained.pdf
#include avrinterrupt.h The global interrupt flag is maintained.pdfarasanlethers
 
[Defcon] Hardware backdooring is practical
[Defcon] Hardware backdooring is practical[Defcon] Hardware backdooring is practical
[Defcon] Hardware backdooring is practicalMoabi.com
 
“Linux Kernel CPU Hotplug in the Multicore System”
“Linux Kernel CPU Hotplug in the Multicore System”“Linux Kernel CPU Hotplug in the Multicore System”
“Linux Kernel CPU Hotplug in the Multicore System”GlobalLogic Ukraine
 
Advanced Root Cause Analysis
Advanced Root Cause AnalysisAdvanced Root Cause Analysis
Advanced Root Cause AnalysisEric Sloof
 
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Vincenzo Iozzo
 
System Booting Process overview
System Booting Process overviewSystem Booting Process overview
System Booting Process overviewRajKumar Rampelli
 
U-Boot presentation 2013
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013Wave Digitech
 
Linuxdd[1]
Linuxdd[1]Linuxdd[1]
Linuxdd[1]mcganesh
 
Bootloaders (U-Boot)
Bootloaders (U-Boot) Bootloaders (U-Boot)
Bootloaders (U-Boot) Omkar Rane
 

Semelhante a Linux Porting (20)

Study on Android Emulator
Study on Android EmulatorStudy on Android Emulator
Study on Android Emulator
 
Linux Kernel Tour
Linux Kernel TourLinux Kernel Tour
Linux Kernel Tour
 
LCU14 302- How to port OP-TEE to another platform
LCU14 302- How to port OP-TEE to another platformLCU14 302- How to port OP-TEE to another platform
LCU14 302- How to port OP-TEE to another platform
 
Vmlinux: anatomy of bzimage and how x86 64 processor is booted
Vmlinux: anatomy of bzimage and how x86 64 processor is bootedVmlinux: anatomy of bzimage and how x86 64 processor is booted
Vmlinux: anatomy of bzimage and how x86 64 processor is booted
 
I/O, You Own: Regaining Control of Your Disk in the Presence of Bootkits
I/O, You Own: Regaining Control of Your Disk in the Presence of BootkitsI/O, You Own: Regaining Control of Your Disk in the Presence of Bootkits
I/O, You Own: Regaining Control of Your Disk in the Presence of Bootkits
 
Raspberry Pi tutorial
Raspberry Pi tutorialRaspberry Pi tutorial
Raspberry Pi tutorial
 
Logging kernel oops and panic
Logging kernel oops and panicLogging kernel oops and panic
Logging kernel oops and panic
 
#include avrinterrupt.h The global interrupt flag is maintained.pdf
#include avrinterrupt.h The global interrupt flag is maintained.pdf#include avrinterrupt.h The global interrupt flag is maintained.pdf
#include avrinterrupt.h The global interrupt flag is maintained.pdf
 
[Defcon] Hardware backdooring is practical
[Defcon] Hardware backdooring is practical[Defcon] Hardware backdooring is practical
[Defcon] Hardware backdooring is practical
 
“Linux Kernel CPU Hotplug in the Multicore System”
“Linux Kernel CPU Hotplug in the Multicore System”“Linux Kernel CPU Hotplug in the Multicore System”
“Linux Kernel CPU Hotplug in the Multicore System”
 
Advanced Root Cause Analysis
Advanced Root Cause AnalysisAdvanced Root Cause Analysis
Advanced Root Cause Analysis
 
Analisis_avanzado_vmware
Analisis_avanzado_vmwareAnalisis_avanzado_vmware
Analisis_avanzado_vmware
 
How to build and load linux to embedded system
How to build and load linux to embedded systemHow to build and load linux to embedded system
How to build and load linux to embedded system
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
 
System Booting Process overview
System Booting Process overviewSystem Booting Process overview
System Booting Process overview
 
U-Boot presentation 2013
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013
 
Driver_linux
Driver_linuxDriver_linux
Driver_linux
 
Linuxdd[1]
Linuxdd[1]Linuxdd[1]
Linuxdd[1]
 
Bootloaders (U-Boot)
Bootloaders (U-Boot) Bootloaders (U-Boot)
Bootloaders (U-Boot)
 

Mais de Champ Yen

Halide tutorial 2019
Halide tutorial 2019Halide tutorial 2019
Halide tutorial 2019Champ Yen
 
Linux SD/MMC Driver Stack
Linux SD/MMC Driver Stack Linux SD/MMC Driver Stack
Linux SD/MMC Driver Stack Champ Yen
 
Simd programming introduction
Simd programming introductionSimd programming introduction
Simd programming introductionChamp Yen
 
Video Compression Standards - History & Introduction
Video Compression Standards - History & IntroductionVideo Compression Standards - History & Introduction
Video Compression Standards - History & IntroductionChamp Yen
 
OpenCL Kernel Optimization Tips
OpenCL Kernel Optimization TipsOpenCL Kernel Optimization Tips
OpenCL Kernel Optimization TipsChamp Yen
 
OpenGL ES 2.x Programming Introduction
OpenGL ES 2.x Programming IntroductionOpenGL ES 2.x Programming Introduction
OpenGL ES 2.x Programming IntroductionChamp Yen
 
Chrome OS Observation
Chrome OS ObservationChrome OS Observation
Chrome OS ObservationChamp Yen
 
Play With Android
Play With AndroidPlay With Android
Play With AndroidChamp Yen
 

Mais de Champ Yen (8)

Halide tutorial 2019
Halide tutorial 2019Halide tutorial 2019
Halide tutorial 2019
 
Linux SD/MMC Driver Stack
Linux SD/MMC Driver Stack Linux SD/MMC Driver Stack
Linux SD/MMC Driver Stack
 
Simd programming introduction
Simd programming introductionSimd programming introduction
Simd programming introduction
 
Video Compression Standards - History & Introduction
Video Compression Standards - History & IntroductionVideo Compression Standards - History & Introduction
Video Compression Standards - History & Introduction
 
OpenCL Kernel Optimization Tips
OpenCL Kernel Optimization TipsOpenCL Kernel Optimization Tips
OpenCL Kernel Optimization Tips
 
OpenGL ES 2.x Programming Introduction
OpenGL ES 2.x Programming IntroductionOpenGL ES 2.x Programming Introduction
OpenGL ES 2.x Programming Introduction
 
Chrome OS Observation
Chrome OS ObservationChrome OS Observation
Chrome OS Observation
 
Play With Android
Play With AndroidPlay With Android
Play With Android
 

Último

How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialJoão Esperancinha
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sectoritnewsafrica
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 

Último (20)

How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorial
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
4. Cobus Valentine- Cybersecurity Threats and Solutions for the Public Sector
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 

Linux Porting

  • 1. Linux Porting for new ARM platform Champ Yen http://champyen.blogspot.com champ.yen@gmail.com
  • 2. OutLine GNU Toolchain Linux Kernel Prerequisites and Assumptions Images Boot Sequence Kernel Configuration & Compilation Kernel Porting Device Drivers Boot Options initramfs vs initrd References
  • 3. GNU Toolchains  CodeSourcery gnu toolchain http://www.codesourcery.com/sgpp/lite/arm/download.html  Buildroot http://buildroot.uclibc.org/  Scratchbox http://www.scratchbox.org/  OpenEmbedded http://wiki.openembedded.net/index.php/Main_Page  Ptxdist http://www.pengutronix.de/software/ptxdist/index_en.html
  • 4. GNU Toolchains - buildroot  linux kernel like configuration interface ncurse UI, .config file  uClibc generate linux 2.6 compatible small footprint applications  for most platform remember to enable software float  output: toolchain/uClibc/busybox/rootfs
  • 5. Linux Kernel Prerequisites and Assumptions  DRAM is initialized  Hardware-related initialization tasks are done  MMU/Cache is disabled  specific values should be saved in registers r1: Machine ID, r2: pointer of ATAG list (optional)
  • 6. Images and intermediate files piggy.o image vmlinuz objcopy (binary gzip piggy.gz asm (ELF object) object) misc.o compressed head.o stripped image binary kernel binary kernel bootable kernel image kernel proper (zImage)
  • 7. Boot Sequence start arch/arm/boot/ start compressed/ head.S start_kernel arch/arm/kernel/ head.S bootstrap loader init/main.c (uncompress) ARM-specific kernel code kernel code detail boot sequence is listed in [9]
  • 8. Kernel Porting – Kernel Memory Map 0xFFFF_FFFF CPU vector page/copy_user_page(),clear_user_page() 0xFFFF_0000 DMA memory mapping 0xFF00_0000 free for platform use VMALLOC_END vmalloc()/ioremap() space VMALLOC_START kernel direct-mapped RAM region PAGE_OFFSET kernel module space TASK_SIZE user space mapping 0x0000_1000 CPU vector page/null pointer trap 0x0000_0000
  • 9. Kernel Porting – Directories  mm/ memory-handling related code  boot/ bootstrap loader code  kernel/ ARM architecture dependent code  mach-XXXXXX/ specific machine dependent code  configs/ each machine’s default kernel configurations
  • 10. Kernel Porting – new machine items refer to other machine to create or modify items(ex: foo, fxx)  register the new machine arch/arm/tools/mach-types  Create machine folder arch/arm/mach-fxx arch/arm/mach-fxx/include/mach  Modify or Create Kconfig & Makefile arch/arm/Kconfig (usually add config ARCH_FXX for architecture) arch/arm/Makefile arch/arm/mm/Kconfig arch/arm/mach-fxx/Kconfig (config MACH_FOO for machine) arch/arm/mach-fxx/Makefile arch/arm/mach-fxx/Makefile.boot (set zreladdr-y for image location)
  • 11. Kernel Porting – new machine items register the new machine  Add an entry in arch/arm/tools/mach-types ex: foo MACH_FOO FOO 65535  For official registration, should register here, also. http://www.arm.linux.org.uk/developer/machines/
  • 12. Kernel Porting – new machine items create machine folders  arm/arch/mach-fxx for machine dependent source code  arm/arm/mach-fxx/include/mach for machine dependent headers/assembly debug-macro.S: adduart, senduart, busyuart, waituart dma.h entry-macro.S: macro get_irqnr_and_base hardware.h system.h: arch_idle(), arch_reset() io.h timex.h: CLOCK_TICK_RATE irqs.h: NR_IRQS uncompress.h: putc() memory.h: PHYS_OFFSET vmalloc.h: VMALLOC_END
  • 13. Kernel Porting – new machine items modify or create Kconfig & Makefile  arch/arm/Kconfig config ARCH_FXX bool “FXX family processors“ help This enables support for systems based on the fxx processors. ……… source "arch/arm/mach-fxx/Kconfig"  arch/arm/Makefile machine-$(CONFIG_ARCH_FXX) := fxx  arch/arm/mm/Kconfig (ex: ARM926-based) config CPU_ARM926T bool "Support ARM926T processor" depends on ARCH_INTEGRATOR || ARCH_VERSATILE_PB || … || ARCH_FXX default y if ARCH_VERSATILE_PB || ARCH_VERSATILE_AB || … || ARCH_FXX
  • 14. Kernel Porting – new machine items modify or create Kconfig & Makefile  arch/arm/mach-fxx/Kconfig menu "FXX platform type“ depends on ARCH_FXX config MACH_FOO bool "Support FOO platform" default y help Include support for the FOO platform. endmenu  arch/arm/mach-fxx/Makefile # Common support (must be linked before board specific support) obj-y := architecture depend code # Specific board support obj-$(CONFIG_MACH_FOO) += core.o machine depend code  arch/arm/mach-fxx/Makefile.boot zreladdr-y := 0x01008000
  • 15. Kernel Porting – description structure MACHINE_START(FOO, "FOO processor") /* Maintainer: Champ Yen */ .map_io = foo_map_io, .init_irq = foo_init_irq, .init_machine = foo_init, .timer = &foo_timer, /* for ATAG list is optional */ .boot_params = 0x01000100, MACHINE_END
  • 16. Kernel Porting – Initialization code  I/O Memory Mapping Table  IRQ  Timer struct sys_timer  Initial order: .map_io .initrq .timer .init_machine
  • 17. Kernel Porting – I/O Memory Map static struct map_desc foo_io_desc[] __initdata = { { /* address after mapping */ .virtual = IO_ADDRESS(CPU_DEV_PHY_BASE), /* page index of physical address */ .pfn = __phys_to_pfn(CPU_DEV_PHY_BASE), .length = CPU_DEV_IO_LEN, /* address mapping range */ .type = MT_DEVICE /* I/O type */ }, …… }; …. static void __init foo_map_io(void) { iotable_init(foo_io_desc, ARRAY_SIZE(foo_io_desc)); }
  • 18. Kernel Porting – IRQ  arch/arm/mach-fxx/include/mach/entry-macro.S get_irqnr_and_base: after calling irqnr: irq number, not equal condition should be set.  arch/arm/mach-fxx/include/mach/irqs.h NR_IRQS (number of irq types) should be defined  struct irq_chip, irqaction set_irq_chip(), set_irq_flags(), set_irq_handler(), setup_irq() ……… static struct irq_chip foo_irq_chip = { for(i = o; i < NR_IRQS; i++){ .ack = foo_int_ack, set_irq_handler(i, handle_level_irq); .mask = foo_int_mask, set_irq_chip(i, &foo_irq_chip); .unmask = foo_int_unmask, set_irq_flags(i, IRQF_VALID); }; } ………
  • 19. Kernel Porting - Timer struct sys_timer foo_timer = { .init = foo_timer_init, .offset = foo_gettimeoffset, };
  • 20. Kernel Porting – DMA memory (optional)  Influence to dma_alloc_coherent() usage  In arch/arm/mach-fxx/include/mach/dma.h  MAX_DMA_ADDRESS  In arch/arm/mach-fxx/include/mach/memory.h  CONSISTENT_DMA_SIZE  ISA_DMA_THRESHOLD
  • 21. Boot Options – static string  Boot options -> Default kernel command string ex: mem=8M@0x01000000 initrd=0x01180000,145762
  • 22. Boot Options – ATAG lists  ATAG provides dynamic boot option passing  There are two way to pass pointer of ATAG lists r2 value passed by bootloader, .boot_params in machine descriptor  refer to arch/arm/include/asm/setup.h struct tag_header { __u32 size; ATAG_CORE __u32 tag; }; …… struct tag { struct tag_header hdr; union { struct tag_core core; struct tag_mem32 mem; … } u; ATAG_NONE };
  • 23. Device Drivers  platform_device_register(), platform_driver_register() for some on-chip devices(ex: clock/power control)  UART subsystem in driver/serial for startup message, console ,and shell  Framebuffer subsystem in driver/video
  • 24. initramfs vs initrd initrd initramfs image ext2 image + gzip cpio + gzip implementation block device tmpfs first execution /linuxrc /init mount rootfs pivot_root switch_root initrd requires ext2 and block devices support. It adds 150KB+ to kernel size.
  • 25. initramfs  create an initramfs image by command: find . | cpio -o -H newc | gzip > ../initramfs.cpio.gz  take care of the distance between image and kernel, otherwise image will be overwritten by kernel.  /init ex: #!/bin/busybox sh #/bin/busybox --install mount -t proc proc /proc exec /bin/busybox sh
  • 26. Debug  decompression: putc() definiition in include/mach/uncompress.h  kernel debugging features in kernel hacking of kernel options (and CONFIG_DEBUG_LL option for low level debugging)  early debug: printascii/printhex(2,4,8) make use of uart macros in include/mach/debug-macro.S  printk()  CONNFIG_KGDB
  • 27. References  Embedded Linux Primer, Christopher Hallinan, Prentice Hall  Building Embedded Linux Systems 2/e, Karim Yaghmour, Oreilly  linux-2.6.2x-xx/Documentation/arm  http://heaven.branda.to/~thinker/GinGin_CGI.py/get_afile/166/porting_to_arm.pdf  http://www.glomationinc.com/PortingLinuxKernel.pdf  http://www.ens-lyon.fr/LIP/Pub/Rapports/RR/RR2006/RR2006-08.pdf  http://glt08.linuxtage.at/slides/glt08-kvas_linuxonarm.pdf  http://www.linux-arm.org/LinuxKernel/LinuxNewPlatformPort  http://gicl.cs.drexel.edu/people/sevy/linux/ARM_Linux_boot_sequence.html  http://www.simtec.co.uk/products/SWLINUX/files/booting_article.html  http://www.ibm.com/developerworks/linux/library/l-initrd.html  http://blog.linux.org.tw/~jserv/archives/001954.html
  • 28. Q&A