这几天一起在整理freescale的imx53的android源码,今天在编译android kernel的时候发现make menuconfig中配置成<M>模式的驱动模块没有加入编译
之前一直是按照原厂的资料运行下面命令编译内核的:
make uImage
通过查看kernel的makefile发些了一些蛛丝马迹,现在将工作笔记记录如下:
在imx_kernel下运行终端,输入如下命令查看kernel编译相关的一些信息
make help
将会看到如下和编译相关的命令和信息
Cleaning targets:
clean - Remove most generated files but keep the config and
enough build support to build external modules
mrproper - Remove all generated files + config + various backup files
distclean - mrproper + remove editor backup and patch files
Configuration targets:
config - Update current config utilising a line-oriented program
nconfig - Update current config utilising a ncurses menu based program
menuconfig - Update current config utilising a menu based program
xconfig - Update current config utilising a QT based front-end
gconfig - Update current config utilising a GTK based front-end
oldconfig - Update current config utilising a provided .config as base
localmodconfig - Update current config disabling modules not loaded
localyesconfig - Update current config converting local mods to core
silentoldconfig - Same as oldconfig, but quietly, additionally update deps
randconfig - New config with random answer to all options
defconfig - New config with default answer to all options
allmodconfig - New config selecting modules when possible
allyesconfig - New config where all options are accepted with yes
allnoconfig - New config where all options are answered with no
Other generic targets:
all - Build all targets marked with [*]
* vmlinux - Build the bare kernel
* modules - Build all modules
modules_install - Install all modules to INSTALL_MOD_PATH (default: /)
firmware_install- Install all firmware to INSTALL_FW_PATH
(default: $(INSTALL_MOD_PATH)/lib/firmware)
dir/ - Build all files in dir and below
dir/file.[oisS] - Build specified target only
dir/file.lst - Build specified mixed source/assembly target only
(requires a recent binutils and recent build (System.map))
dir/file.ko - Build module including final link
modules_prepare - Set up for building external modules
tags/TAGS - Generate tags file for editors
cscope - Generate cscope index
kernelrelease - Output the release version string
kernelversion - Output the version stored in Makefile
headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH
(default: /data/EN3/freescale/i.MX536/i.MX53-QSB-Android-Release3.3/src/kernel_imx/usr)
Static analysers
checkstack - Generate a list of stack hogs
namespacecheck - Name space analysis on compiled kernel
versioncheck - Sanity check on version.h usage
includecheck - Check for duplicate included header files
export_report - List the usages of all exported symbols
headers_check - Sanity check on exported headers
headerdep - Detect inclusion cycles in headers
Kernel packaging:
rpm-pkg - Build both source and binary RPM kernel packages
binrpm-pkg - Build only the binary kernel package
deb-pkg - Build the kernel as an deb package
tar-pkg - Build the kernel as an uncompressed tarball
targz-pkg - Build the kernel as a gzip compressed tarball
tarbz2-pkg - Build the kernel as a bzip2 compressed tarball
Documentation targets:
Linux kernel internal documentation in different formats:
htmldocs - HTML
pdfdocs - PDF
psdocs - Postscript
xmldocs - XML DocBook
mandocs - man pages
installmandocs - install man pages generated by mandocs
cleandocs - clean all generated DocBook files
Architecture specific targets (arm):
* zImage - Compressed kernel image (arch/arm/boot/zImage)
Image - Uncompressed kernel image (arch/arm/boot/Image)
* xipImage - XIP kernel image, if configured (arch/arm/boot/xipImage)
uImage - U-Boot wrapped zImage
bootpImage - Combined zImage and initial RAM disk
(supply initrd image via make variable INITRD=<path>)
install - Install uncompressed kernel
zinstall - Install compressed kernel
Install using (your) ~/bin/installkernel or
(distribution) /sbin/installkernel or
install to $(INSTALL_PATH) and run lilo
………………
………………
………………
可以看到很多编译相关的命令,如:make, make all, make clean, make uImage等等
经过测试发现运行make命令之后,在make menuconfig中配置成<M>的驱动模块都可以加入编译,但是再make uImage生成uImage文件烧到板子上的时候,在目标板上的文件系统里怎么也找不到那些*.ko文件,看了一上午android filesystem相关的资料,总算是找到了解决办法,就是通过修改android生成的ramdisk.img,用脚本把这些*.ko文件导入到android的filesystem中,下面代码就是实现整个过程的脚本:
#!/bin/sh
MAKE_KERNEL=$1
#root dir
KERNEL_DIR=$(pwd)
#out dir
OUT_DIR=${KERNEL_DIR}/../../out
#modules install path
RAMDISK_DIR=ramdisk
INSTALL_MOD_PATH=${OUT_DIR}/tmp/${RAMDISK_DIR}
#echo "make kernel?(y,n)";read MAKE_KERNEL
echo "******************************"
echo "* Make Kernel *"
echo "******************************"
if [ "$MAKE_KERNEL"x = "n"x ]; then
echo "*** skip ***"
else
make -j4
make uImage -j4
cp arch/arm/boot/uImage ${OUT_DIR}
fi
echo "******************************"
echo "* Install modules *"
echo "******************************"
cd ${OUT_DIR}
[ -e "tmp" ] || { echo "mkdir tmp"; mkdir tmp; }
cp ./ramdisk.img ./tmp
#上一次退出状态: 判断ramdisk.img是否存在
case "$?" in
"0")
cd tmp
mv ramdisk.img ramdisk.img.gz
cd ./${RAMDISK_DIR}
gunzip ramdisk.img.gz
[ -e "${RAMDISK_DIR}" ] || { echo "mkdir ${RAMDISK_DIR}"; mkdir ${RAMDISK_DIR}; }
cd ${RAMDISK_DIR}
cpio -i -F ../ramdisk.img
cd ${KERNEL_DIR}
make modules_install #重点在这里,在kernel目录下运行此命令时,会把相关的*.ko文件install到由INSTALL_MOD_PATH指定的目录下!!
cd ${INSTALL_MOD_PATH}
find . | cpio -o -H newc | gzip > ../ramdisk.img
cd ..
echo "******************************"
echo "* Make uramdisk.img *"
echo "******************************"
mkimage -A arm -O linux -T ramdisk -C none -a 0x70308000 -n "Android Root Filesystem" -d ./ramdisk.img ./uramdisk.img
mv uramdisk.img ./..
cd ..
rm -rf ./tmp
cd ${KERNEL_DIR}
echo "***OKAY***"
;;
"1")
echo "ramdisk.img文件不存在!!!!!!"
rm -rf ./tmp
cd ${KERNEL_DIR}
;;
esac
经过这样的处理就可以向android源码生成的ramdisk.img中install任何我们自己的东西了,把uImage和uramdisk.img一起烧到板子上,通过串口查看,得到了我想要的东西,如下:
lrwxrwxrwx radio radio 2011-07-06 08:58 build -> /data/EN3/freescale/i.MX536/i.MX53-QSB-Android-Release3.3/src/kernel_imx
-rw-r--r-- radio radio 81 2011-07-06 08:58 modules.isapnpmap
-rw-r--r-- radio radio 74 2011-07-06 08:58 modules.ofmap
-rw-r--r-- radio radio 43 2011-07-06 08:58 modules.seriomap
-rw-r--r-- radio radio 2908 2011-07-06 08:58 modules.dep.bin
-rw-r--r-- radio radio 1671 2011-07-06 08:58 modules.symbols.bin
lrwxrwxrwx radio radio 2011-07-06 08:58 source -> /data/EN3/freescale/i.MX536/i.MX53-QSB-Android-Release3.3/src/kernel_imx
-rw-r--r-- radio radio 141 2011-07-06 08:58 modules.inputmap
-rw-r--r-- radio radio 11595 2011-07-06 08:58 modules.builtin
-rw-r--r-- radio radio 99 2011-07-06 08:58 modules.pcimap
-rw-r--r-- radio radio 1072 2011-07-06 08:58 modules.symbols
drwxr-xr-x radio radio 2011-07-06 08:58 kernel
-rw-r--r-- radio radio 13189 2011-07-06 08:58 modules.builtin.bin
-rw-r--r-- radio radio 3795 2011-07-06 08:58 modules.alias.bin
-rw-r--r-- radio radio 189 2011-07-06 08:58 modules.usbmap
-rw-r--r-- radio radio 1189 2011-07-06 08:58 modules.dep
-rw-r--r-- radio radio 4404 2011-07-06 08:58 modules.alias
-rw-r--r-- radio radio 1042 2011-07-06 08:58 modules.order
-rw-r--r-- radio radio 69 2011-07-06 08:58 modules.ccwmap
-rw-r--r-- radio radio 73 2011-07-06 08:58 modules.ieee1394map
相关的*.ko驱动模块就在kernel目录下!