關於android中的ramdisk.img及uImage無法包含驅動模組(*.ko)的問題

來源:互聯網
上載者:User

這幾天一起在整理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 filesConfiguration 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 noOther 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 headersKernel 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 tarballDocumentation 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 filesArchitecture 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/shMAKE_KERNEL=$1#root dirKERNEL_DIR=$(pwd)#out dirOUT_DIR=${KERNEL_DIR}/../../out#modules install pathRAMDISK_DIR=ramdiskINSTALL_MOD_PATH=${OUT_DIR}/tmp/${RAMDISK_DIR}#echo "make kernel?(y,n)";read MAKE_KERNELecho    "******************************"echo    "*        Make Kernel         *"echo    "******************************"if [ "$MAKE_KERNEL"x = "n"x ]; thenecho "*** skip ***"elsemake -j4make uImage -j4cp arch/arm/boot/uImage ${OUT_DIR}fiecho    "******************************"echo    "*    Install modules         *"echo    "******************************"cd ${OUT_DIR}[ -e "tmp" ] || { echo "mkdir tmp"; mkdir tmp; }cp ./ramdisk.img ./tmp#上一次退出狀態: 判斷ramdisk.img是否存在case "$?" in"0")cd tmpmv ramdisk.img ramdisk.img.gzcd ./${RAMDISK_DIR}gunzip ramdisk.img.gz[ -e "${RAMDISK_DIR}" ] || { echo "mkdir ${RAMDISK_DIR}"; mkdir ${RAMDISK_DIR}; }cd ${RAMDISK_DIR}cpio -i -F ../ramdisk.imgcd ${KERNEL_DIR}make modules_install             #重點在這裡,在kernel目錄下運行此命令時,會把相關的*.ko檔案install到由INSTALL_MOD_PATH指定的目錄下!!cd ${INSTALL_MOD_PATH}find . | cpio -o -H newc | gzip > ../ramdisk.imgcd ..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.imgmv uramdisk.img ./..cd ..rm -rf ./tmpcd ${KERNEL_DIR}echo "***OKAY***";;"1")echo "ramdisk.img檔案不存在!!!!!!"rm -rf ./tmpcd ${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.binlrwxrwxrwx 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.symbolsdrwxr-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目錄下!

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.