Hi all, I am trying to cross compile TUN kernel module. My config file is like this
1)First we download the kernel source code from http://android.git.kernel.org Within that page there are kernels for other platforms too. We choose to download kernel/common project from there. 2)$git clone git://android.git.kernel.org/kernel/common We check which branch we have downloaded: 3)$git branch it shows * android-2.6.27, not the one we are searching for: To list all remote available branches: 3)$git branch -r origin/HEAD -> origin/android-2.6.27 origin/android-2.6.25 origin/android-2.6.27 origin/android-2.6.29 origin/android-2.6.32 origin/android-goldfish-2.6.27 origin/android-goldfish-2.6.29 What does goldfish mean? (from android-kernel mail list) Goldfish is the kernel hacked branch that supports the qemu based arm emulator for android, so it is the one we need. Download GOLDFISH kernel version 4)$git checkout --track -b android-goldfish-2.6.29 origin/android-goldfish-2.6.29 5)$git branch android-2.6.27 * android-goldfish-2.6.29 ----------------------------------------------------------------------------------------- Second step ----------------------------------------------------------------------------------------- RUNNING THE EMULATOR Within this link we will find how to get the android emulator, and launch it. Building Android in Debian Sid Showing the kernel version running in the emulator 6)$adb shell 7)#cat /proc/version Linux version 2.6.29-00261-g0097074 (di...@digit.mtv.corp.google.com) (gcc version 4.4.0 (GCC) ) #14 Tue Feb 2 15:49:02 PST 2010 ----------------------------------------------------------------------------------------------------- Third Step ------------------------------------------------------------------------------------------------------ OBTAINING KERNEL CONFIGURATION We are going to obtain the kernel configuration .config file from within our running emulator. 8)$cd common # we enter in the kernel source directory. 9)$adb pull /proc/config.gz . # get compressed .config file from the emulator. 10)$gunzip config.gz # uncompress it. 11)$cp config .config # rename it into .config Now you can edit .config file the way it suits you the most. --------------------------------------------------------------------------------------------------------- Fourth Step --------------------------------------------------------------------------------------------------------- BUILDING AND COMPILING THE KERNEL 12)CROSS_COMPILE environment variable stores the path to the arm cross compiling toolchain. I use the one which comes with android source code. 13)$ARCH=arm CROSS_COMPILE=/path/to/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- make ARCH=arm CROSS_COMPILE=/android-ndk-r4/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/arm-eabi- make Executing make will build the kernel. Last lines will show: Kernel: arch/arm/boot/Image is ready Kernel: arch/arm/boot/zImage is ready So we have obtained Image and zImage kernel binary files. ----------------------------------------------------------------------------------------------------------------------- FIFTH STEP ---------------------------------------------------------------------------------------------------------------------- RUN THE EMULATOR USING THE NEW COMPILED KERNEL IMAGE We need -kernel option: $emulator -kernel /path/to/common/arch/arm/boot/zImage -show-kernel -verbose $./emulator -avd neo -kernel /home/subhas/Desktop/android/common/arch/arm/boot/zImage -show-kernel -verbose $./emulator -avd tuntap -kernel /home/subhas/Desktop/android/common/arch/arm/boot/zImage -show-kernel -verbose $./emulator -avd tunmodule -kernel /home/subhas/Desktop/android/common/arch/arm/boot/zImage -show-kernel -verbose $./emulator -avd armv7y -kernel /home/subhas/Desktop/android/common/arch/arm/boot/zImage -show-kernel -verbose? We can check now the kernel version: $adb shell # cat /proc/version Linux version 2.6.29-00262-gb0d93fb (u...@mypc) (gcc version 4.4.0 (GCC) ) #1 Sun May 2 14:27:31 CEST 2010 If we do not specify kernel option it usually uses the prebuilt one: $emulator -show-kernel -verbose emulator: argv[01] = "-kernel" emulator: argv[02] = "/path/to/mydroid/prebuilt/android-arm/kernel/kernel-qemu" ACTIVATING MODULE LOADING SUPPORT IN THE KERNEL Module loading support is previously disabled in the kernel, if we want to load modules in the kernel we have to enable it: edit .config file and set: CONFIG_MODULES=y $ ARCH=arm CROSS_COMPILE=/path/to/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- make I am asked about some options when executing make. I ask yes for module related options. After compiling I see several modules have been built. MODPOST 6 modules CC drivers/video/fb_sys_fops.mod.o LD [M] drivers/video/fb_sys_fops.ko CC drivers/video/syscopyarea.mod.o LD [M] drivers/video/syscopyarea.ko CC drivers/video/sysfillrect.mod.o LD [M] drivers/video/sysfillrect.ko CC drivers/video/sysimgblt.mod.o LD [M] drivers/video/sysimgblt.ko CC drivers/video/tun.ko LD [M] drivers/video/vfb.ko We can upload the modules in the emulator and install them: $adb push drivers/video/tun.ko /data $adb shell #insmod /data/tun.ko please help me out emulator: Adding boot property: 'dalvik.vm.heapsize' = '16m' emulator: argv[00] = "./emulator" emulator: argv[01] = "-kernel" emulator: argv[02] = "/home/subhas/Desktop/android/common/arch/arm/boot/zImage" emulator: argv[03] = "-initrd" emulator: argv[04] = "/home/subhas/Desktop/android-sdk-linux_86/platforms/android-8/images//ramdisk.img" emulator: argv[05] = "-nand" emulator: argv[06] = "system,size=0x4e00000,initfile=/home/subhas/Desktop/android-sdk-linux_86/platforms/android-8/images//system.img" emulator: argv[07] = "-nand" emulator: argv[08] = "userdata,size=0x4200000,file=/home/subhas/.android/avd/neo.avd/userdata-qemu.img" emulator: argv[09] = "-nand" emulator: argv[10] = "cache,size=0x4200000,file=/home/subhas/.android/avd/neo.avd/cache.img" emulator: argv[11] = "-hda" emulator: argv[12] = "/home/subhas/.android/avd/neo.avd/sdcard.img" emulator: argv[13] = "-serial" emulator: argv[14] = "android-kmsg" emulator: argv[15] = "-serial" emulator: argv[16] = "android-qemud" emulator: argv[17] = "-append" emulator: argv[18] = "qemu=1 console=ttyS0 android.checkjni=1 android.qemud=ttyS1 android.ndns=2" emulator: argv[19] = "-m" emulator: argv[20] = "96" emulator: argv[21] = "-clock" emulator: argv[22] = "unix" emulator: mapping 'system' NAND image to /tmp/android/emulator-dx8E62 emulator: rounding devsize up to a full eraseunit, now 4e1e000 emulator: using 'alsa' audio input backend emulator: using 'alsa' audio output backend emulator: Trace file name is not set emulator: control console listening on port 5554, ADB on port 5555 emulator: can't connect to ADB server: Connection refused emulator: ping program: /home/subhas/Desktop/android-sdk-linux_86/tools/ddms emulator: ping command: /home/subhas/Desktop/android-sdk-linux_86/tools/ddms ping emulator 6.0 ................... done, booting the kernel. Initializing cgroup subsys cpu Linux version 2.6.29-droid-debian-00262-gb0d93fb-dirty (r...@subhas-desktop) (gcc version 4.4.0 (GCC) ) #2 Mon Aug 2 16:05:26 IST 2010 CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00093177 CPU: VIVT data cache, VIVT instruction cache Machine: Goldfish Memory policy: ECC disabled, Data cache writeback Built 1 zonelists in Zone order, mobility grouping on. Total pages: 24384 Kernel command line: qemu=1 console=ttyS0 android.checkjni=1 android.qemud=ttyS1 android.ndns=2 Unknown boot option `android.checkjni=1': ignoring Unknown boot option `android.qemud=ttyS1': ignoring Unknown boot option `android.ndns=2': ignoring PID hash table entries: 512 (order: 9, 2048 bytes) Console: colour dummy device 80x30 Dentry cache hash table entries: 16384 (order: 4, 65536 bytes) Inode-cache hash table entries: 8192 (order: 3, 32768 bytes) Memory: 96MB = 96MB total Memory: 92980KB available (3724K code, 355K data, 108K init) Calibrating delay loop... 210.53 BogoMIPS (lpj=1052672) Mount-cache hash table entries: 512 Initializing cgroup subsys debug Initializing cgroup subsys cpuacct Initializing cgroup subsys freezer CPU: Testing write buffer coherency: ok net_namespace: 544 bytes NET: Registered protocol family 16 bio: create slab <bio-0> at 0 NET: Registered protocol family 2 IP route cache hash table entries: 1024 (order: 0, 4096 bytes) TCP established hash table entries: 4096 (order: 3, 32768 bytes) TCP bind hash table entries: 4096 (order: 2, 16384 bytes) TCP: Hash tables configured (established 4096 bind 4096) TCP reno registered NET: Registered protocol family 1 checking if image is initramfs... it is Freeing initrd memory: 160K goldfish_new_pdev goldfish_interrupt_controller at ff000000 irq -1 goldfish_new_pdev goldfish_device_bus at ff001000 irq 1 goldfish_new_pdev goldfish_timer at ff003000 irq 3 goldfish_new_pdev goldfish_rtc at ff010000 irq 10 goldfish_new_pdev goldfish_tty at ff002000 irq 4 goldfish_new_pdev goldfish_tty at ff011000 irq 11 goldfish_new_pdev smc91x at ff012000 irq 12 goldfish_new_pdev goldfish_fb at ff013000 irq 13 goldfish_new_pdev goldfish_audio at ff004000 irq 14 goldfish_new_pdev goldfish_mmc at ff005000 irq 15 goldfish_new_pdev goldfish_memlog at ff006000 irq -1 goldfish_new_pdev goldfish-battery at ff014000 irq 16 goldfish_new_pdev goldfish_events at ff015000 irq 17 goldfish_new_pdev goldfish_nand at ff016000 irq -1 goldfish_new_pdev goldfish-switch at ff017000 irq 18 goldfish_new_pdev goldfish-switch at ff018000 irq 19 Kprobe smoke test started Kprobe smoke test passed successfully goldfish_pdev_worker registered goldfish_interrupt_controller goldfish_pdev_worker registered goldfish_device_bus goldfish_pdev_worker registered goldfish_timer goldfish_pdev_worker registered goldfish_rtc goldfish_pdev_worker registered goldfish_tty goldfish_pdev_worker registered goldfish_tty goldfish_pdev_worker registered smc91x goldfish_pdev_worker registered goldfish_fb goldfish_audio_probe goldfish_pdev_worker registered goldfish_audio goldfish_pdev_worker registered goldfish_mmc goldfish_pdev_worker registered goldfish_memlog goldfish_pdev_worker registered goldfish-battery goldfish_pdev_worker registered goldfish_events goldfish_pdev_worker registered goldfish_nand goldfish_pdev_worker registered goldfish-switch goldfish_pdev_worker registered goldfish-switch ashmem: initialized Installing knfsd (copyright (C) 1996 o...@monad.swb.de). JFS: nTxBlock = 728, nTxLock = 5825 yaffs Jul 26 2010 18:23:39 Installing. msgmni has been set to 182 alg: No test for stdrng (krng) io scheduler noop registered io scheduler anticipatory registered (default) io scheduler deadline registered io scheduler cfq registered allocating frame buffer 320 * 480, got ffa10000 Console: switching to colour frame buffer device 40x30 console [ttyS0] enabled brd: module loaded loop: module loaded nbd: registered device at major 43 lkdtm : Invalid command smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <n...@cam.org> eth0 (smc91x): not using net_device_ops yet eth0: SMC91C11xFD (rev 1) at c68ba000 IRQ 12 [nowait] eth0: Ethernet addr: 52:54:00:12:34:56 goldfish nand dev0: size 4bc0000, page 2048, extra 64, erase 131072 goldfish nand dev1: size 4000000, page 2048, extra 64, erase 131072 goldfish nand dev2: size 4000000, page 2048, extra 64, erase 131072 mice: PS/2 mouse device common for all mice *** events probe *** events_probe() addr=0xc68c2000 irq=17 events_probe() keymap=qwerty2 input: qwerty2 as /devices/virtual/input/input0 goldfish_rtc goldfish_rtc: rtc core: registered goldfish_rtc as rtc0 device-mapper: uevent: version 1.0.3 device-mapper: ioctl: 4.14.0-ioctl (2008-04-23) initialised: dm-de...@redhat.com IPv4 over IPv4 tunneling driver GRE over IPv4 tunneling driver TCP probe registered (port=0) TCP cubic registered NET: Registered protocol family 17 RPC: Registered udp transport module. RPC: Registered tcp transport module. 802.1Q VLAN Support v1.8 Ben Greear <gree...@candelatech.com> All bugs added by David S. Miller <da...@redhat.com> VFP support v0.3: implementor 41 architecture 1 part 10 variant 9 rev 0 goldfish_rtc goldfish_rtc: setting system clock to 2010-08-02 11:57:27 UTC (1280750247) Freeing init memory: 108K mmc0: new SD card at address e118 mmcblk0: mmc0:e118 SU02G 512 MiB mmcblk0: init: cannot open '/initlogo.rle' yaffs: dev is 32505856 name is "mtdblock0" yaffs: passed flags "" yaffs: Attempting MTD mount on 31.0, "mtdblock0" yaffs_read_super: isCheckpointed 0 save exit: isCheckpointed 0 yaffs: dev is 32505857 name is "mtdblock1" yaffs: passed flags "" yaffs: Attempting MTD mount on 31.1, "mtdblock1" yaffs_read_super: isCheckpointed 0 yaffs: dev is 32505858 name is "mtdblock2" yaffs: passed flags "" yaffs: Attempting MTD mount on 31.2, "mtdblock2" yaffs_read_super: isCheckpointed 0 init: cannot find '/system/bin/dbus-daemon', disabling 'dbus' init: cannot find '/system/etc/install-recovery.sh', disabling 'flash_recovery' sh: can't access tty; job control turned off # eth0: link up init: untracked pid 40 exited init: untracked pid 41 exited warning: `rild' uses 32-bit capabilities (legacy support in use) init: untracked pid 52 exited init: untracked pid 51 exited init: untracked pid 65 exited init: untracked pid 68 exited init: untracked pid 69 exited init: untracked pid 72 exited init: critical process 'servicemanager' exited 4 times in 4 minutes; rebooting into recovery mode save exit: isCheckpointed 1 save exit: isCheckpointed 1 Restarting system with command 'recovery'. Reboot failed -- System halted -- unsubscribe: android-kernel+unsubscr...@googlegroups.com website: http://groups.google.com/group/android-kernel