全部博文(685)
分类: 嵌入式
2014-09-29 09:35:50
Android模拟器默认内核不支持netfilter,所以试图使用iptalbes时,会出现错误。
# iptables -L iptables -L iptables v1.3.7: can't initialize iptables table `filter': iptables who? (do you need to insmod?) Perhaps iptables or your kernel needs to be upgraded. #
实验环境:ubuntu10.04 64bit
下载适用模拟器的android内核代码
root@ubuntu:~/android/kernel# git clone Initialized empty Git repository in /home/shanks/android/kernel/goldfish/.git/ remote: Counting objects: 28280, done remote: Finding sources: 100% (6/6) remote: Getting sizes: 100% (5/5) remote: Compressing objects: 100% (5/5) Receiving objects: 100% (2442118/2442118), 499.20 MiB | 772 KiB/s, done. remote: Total 2442118 (delta 2048586), reused 2442116 (delta 2048586) Resolving deltas: 100% (2048602/2048602), done.
root@ubuntu:~/android/kernel/goldfish# git branch -a * master remotes/origin/HEAD -> origin/master remotes/origin/android-goldfish-2.6.29 remotes/origin/android-goldfish-3.4 remotes/origin/linux-goldfish-3.0-wip remotes/origin/master
root@ubuntu:~/android/kernel/goldfish# git checkout remotes/origin/android-goldfish-2.6.29 Checking out files: 100% (26821/26821), done. Note: checking out 'remotes/origin/android-goldfish-2.6.29'.
root@ubuntu:~/android/kernel/goldfish# export ARCH=arm root@ubuntu:~/android/kernel/goldfish# export SUBARCH=arm root@ubuntu:~/android/kernel/goldfish# export CROSS_COMPILE=arm-eabi- root@ubuntu:~/android/kernel/goldfish# export PATH=/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin:$PATH
运行make
make goldfish_defconfig
接下来配置编译的模块,这个过程可能会报缺少一些必要的包,可以提前安装相关的包,也可以根据错误逐步添加。
root@ubuntu:~/android/kernel/goldfish# apt-get install ia32-libs
root@ubuntu:~/android/kernel/goldfish# make menuconfig *** Unable to find the ncurses libraries or the *** required header files. *** 'make menuconfig' requires the ncurses libraries. *** *** Install ncurses (ncurses-devel) and try again. *** make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1 make: *** [menuconfig] Error 2 root@ubuntu:~/android/kernel/goldfish# apt-get install libncurses-dev Reading package lists... Done Building dependency tree Reading state information... Done
配置完成后,进行编译
root@ubuntu:~/android/kernel/goldfish# make -j4 make: arm-eabi-gcc: Command not found CHK include/linux/version.h make[1]: `include/asm-arm/mach-types.h' is up to date. CHK include/linux/utsrelease.h SYMLINK include/asm -> include/asm-arm CC scripts/mod/empty.o /bin/sh: arm-eabi-gcc: not found make[2]: *** [scripts/mod/empty.o] Error 127 make[1]: *** [scripts/mod] Error 2 make: *** [scripts] Error 2 root@ubuntu:~/android/kernel/goldfish# apt-get install lib32ncurses5-dev root@ubuntu:~/android/kernel/goldfish# make -j4 CHK include/linux/version.h SYMLINK include/asm -> include/asm-arm make[1]: `include/asm-arm/mach-types.h' is up to date. CHK include/linux/utsrelease.h CC scripts/mod/empty.o .../prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/../../../../arm-eabi/bin/as: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory make[2]: *** [scripts/mod/empty.o] Error 1 make[1]: *** [scripts/mod] Error 2 make: *** [scripts] Error 2 root@ubuntu:~/android/kernel/goldfish# apt-get install ia32-libs OBJCOPY arch/arm/boot/zImage Kernel: arch/arm/boot/zImage is ready
...\tools>emulator.exe -avd CM2.3 -kernel ....\zImage -show-kernel -no-snapshot serial0 console Uncompressing Linux......................................................... done, booting the kernel. Initializing cgroup subsys cpu Linux version 2.6.29-gcb06bef (root@ubuntu) (gcc version 4.4.3 (GCC) ) #1 Thu Nov 8 01:35:29 PST 2012 CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00093177 CPU: VIVT data cache, VIVT instruction cache问题得以解决
参考:
http://blog.csdn.net/fdl19881/article/details/7467129