2013年8月30日 星期五

Porting new defconfig from versatile_defconfig

First, you need to know that the bootloader pass two information to kernel:
1: register r0  <---- 0
     register r1 <---- machine ID   (it should exist in arch/arm/tools/mach-types and kernel will check it!)
2: parameters structure name ATAG

We copy the source code from versatile board:
$> cp -rf arch/arm/mach-versatile arch/arm/mach-neo
$> cp -rf arch/arm/plat-versatile arch/arm/plat-neo

We add our machine type in arch/arm/tools/mach-types:
$> vi arch/arm/tools/mach-types
----------------------------------------------------------------------------
neo                     MACH_NEO                NEO                    387
----------------------------------------------------------------------------

We modify arch/arm/Kconfig to add ARCH_NEO & PLAT_NEO and source them:
$> vi arch/arm/Kconfig
--------------------------
.................
config ARCH_NEO
        bool "NEO development board"
        select ARM_AMBA
        select ARM_VIC
        select CLKDEV_LOOKUP
        select HAVE_MACH_CLKDEV
        select ICST
        select GENERIC_CLOCKEVENTS
        select ARCH_WANT_OPTIONAL_GPIOLIB
        select PLAT_NEO
        select PLAT_VERSATILE_CLCD
        select PLAT_VERSATILE_FPGA_IRQ
        select ARM_TIMER_SP804
        help
          This enables support for NEO development board.
...................
config PLAT_NEO
        bool
..................
source "arch/arm/mach-neo/Kconfig"
source "arch/arm/plat-neo/Kconfig"
..................
--------------------------

We modify arch/arm/Makefile to refer to mach-neo & plat-neo if we used:
$> vi arch/arm/Makefile
-------------------------
...................
machine-$(CONFIG_ARCH_NEO)      := neo
...................
plat-$(CONFIG_PLAT_NEO)         := neo
..................
-------------------------

We also need to modify arch/arm/mach-neo/Kconfig:
$> vi arch/arm/mach-neo/Kconfig
-------------------------
menu "NEO development board platform type"
        depends on ARCH_NEO

config ARCH_VERSATILE_PB
        bool "Support NEO Platform Baseboard for ARM926EJ-S"
        select CPU_ARM926T
        select MIGHT_HAVE_PCI
        default y
        help
          Include support for the ARM(R) Versatile Platform Baseboard
          for the ARM926EJ-S.

config MACH_VERSATILE_AB
        bool "Support NEO Application Baseboard for ARM926EJ-S"
        select CPU_ARM926T
        help
          Include support for the ARM(R) Versatile Application Baseboard
          for the ARM926EJ-S.

config MACH_VERSATILE_DT
        bool "Support NEO platform from device tree"
        select USE_OF
        select CPU_ARM926T
        help
          Include support for the ARM(R) Versatile/PB platform,
          using the device tree for discovery

endmenu
-------------------------

Modify arch/arm/plat-neo/Kconfig too:
$> vi arch/arm/plat-neo/Kconfig
-------------------------
if PLAT_NEO

config PLAT_VERSATILE_CLCD
        bool

config PLAT_VERSATILE_FPGA_IRQ
        bool

config PLAT_VERSATILE_LEDS
        def_bool y if LEDS_CLASS
        depends on ARCH_REALVIEW || ARCH_NEO

config PLAT_VERSATILE_SCHED_CLOCK
        def_bool y

endif
-------------------------

Now, we can create new defconfig:
$> make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- versatile_defconfig
$> make ARCH=arm menuconfig
-------------------------
System Type  --->
    ARM system type (ARM Ltd. Versatile family)  --->
          (X) NEO development board
    NEO platform type  --->
          [*] Support NEO platform from device tree
          
Kernel Features  --->
     [*] Use the ARM EABI to compile the kernel                                            
     [*]   Allow old ABI binaries to run with this kernel (EXPERIMENTAL) (NEW) 
-------------------------
$> cp .config arch/arm/configs/neo_defconfig

We can make zImage by using our new defconfig:
$> make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- neo_defconfig
$> make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- zImage
$> make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- versatile-pb.dtb

Emulator:
$> qemu-system-arm -M versatilepb -dtb ./versatile-pb.dtb -kernel zImage -initrd rootfs.img -serial stdio -append "root=/dev/ram rdinit=/sbin/init  console=ttyAMA0"


PS:
1 You can install QEMU in UBUNTU by:
$> sudo apt-get install qemu qmeu-kvm-extras
2 "CROSS_COMPILE=arm-none-linux-gnueabi-" depends on your toolchain.
3 rootfs.img.gz can be found in my old post named "Build Rootfs by Busybox for ARM on QEMU"
4 You can see versatile-pb.dts in path arch/arm/boot/dts
5 Because we use "-M versatilepb" to emulate, the machine type in  arch/arm/tools/mach-types should be 387.

沒有留言:

張貼留言