一、编译环境搭建
(更细节的环境搭建请参考:How to Build CyanogenMod for Nexus 7 (Wi-Fi, 2012 version) (codename: grouper))
1、在执行了source build/envsetup.sh的时候,会执行vendor/cm/vendorsetup.sh:
for combo in $(curl -s https://raw.githubusercontent.com/CyanogenMod/hudson/master/cm-build-targets | sed -e 's/#.*$//' | grep cm-12.1 | awk '{printf "cm_%s-%s\n", $1, $2}') do add_lunch_combo $combo done
这里会联网下载文件:https://raw.githubusercontent.com/CyanogenMod/hudson/master/cm-build-targets,它的内容如下:
root@pengdl-HP:/home/pengdl/work/study/nexus7/Nexus7# curl -s https://raw.githubusercontent.com/CyanogenMod/hudson/master/cm-build-targets # CM build target list #[period: "D"aily, "W"eekly or "M"onthly] # Absence of a period indicates Daily (the default) # Daily cm-12.1 acclaim userdebug cm-12.1 amami userdebug cm-12.1 bacon userdebug cm-12.1 castor userdebug cm-12.1 castor_windy userdebug cm-12.1 condor userdebug cm-12.1 d2att userdebug cm-12.1 d2spr userdebug cm-12.1 d2tmo userdebug cm-12.1 d2vzw userdebug cm-12.1 d800 userdebug cm-12.1 d801 userdebug cm-12.1 d802 userdebug cm-12.1 d803 userdebug cm-12.1 d850 userdebug cm-12.1 d851 userdebug cm-12.1 d852 userdebug cm-12.1 d855 userdebug cm-12.1 deb userdebug cm-12.1 dlx userdebug cm-12.1 e975 userdebug cm-12.1 e980 userdebug cm-12.1 evita userdebug cm-12.1 falcon userdebug cm-12.1 find7 userdebug cm-12.1 find7s userdebug cm-12.1 flo userdebug cm-12.1 flounder userdebug cm-12.1 fugu userdebug cm-12.1 ghost userdebug cm-12.1 grouper userdebug cm-12.1 hammerhead userdebug cm-12.1 hammerheadcaf userdebug cm-12.1 hlte userdebug cm-12.1 hltespr userdebug cm-12.1 hltetmo userdebug cm-12.1 i605 userdebug cm-12.1 i777 userdebug cm-12.1 i9100 userdebug cm-12.1 i925 userdebug cm-12.1 honami userdebug cm-12.1 huashan userdebug cm-12.1 jactivelte userdebug cm-12.1 jem userdebug cm-12.1 jflteatt userdebug cm-12.1 jfltespr userdebug cm-12.1 jfltetmo userdebug cm-12.1 jfltevzw userdebug cm-12.1 jfltexx userdebug cm-12.1 klimtwifi userdebug cm-12.1 klte userdebug cm-12.1 kltechn userdebug cm-12.1 kltechnduo userdebug cm-12.1 klteduos userdebug cm-12.1 kltedv userdebug cm-12.1 kltekdi userdebug cm-12.1 kltespr userdebug cm-12.1 l900 userdebug cm-12.1 lettuce userdebug cm-12.1 ls980 userdebug cm-12.1 ls990 userdebug cm-12.1 m7 userdebug cm-12.1 m7vzw userdebug cm-12.1 m8 userdebug cm-12.1 mako userdebug cm-12.1 manta userdebug cm-12.1 maserati userdebug cm-12.1 mb886 userdebug cm-12.1 mondrianwifi userdebug cm-12.1 n3 userdebug cm-12.1 n5100 userdebug cm-12.1 n5110 userdebug cm-12.1 nicki userdebug cm-12.1 obake userdebug cm-12.1 peregrine userdebug cm-12.1 picassowifi userdebug cm-12.1 pollux userdebug cm-12.1 pollux_windy userdebug cm-12.1 quark userdebug cm-12.1 rendang userdebug cm-12.1 scorpion userdebug cm-12.1 scorpion_windy userdebug cm-12.1 serrano3gxx userdebug cm-12.1 serranoltexx userdebug cm-12.1 shamu userdebug cm-12.1 sirius userdebug cm-12.1 spyder userdebug cm-12.1 superior userdebug cm-12.1 t0lte userdebug cm-12.1 t6 userdebug cm-12.1 t6spr userdebug cm-12.1 t6vzw userdebug cm-12.1 targa userdebug cm-12.1 tate userdebug cm-12.1 tf300t userdebug cm-12.1 thea userdebug cm-12.1 tilapia userdebug cm-12.1 titan userdebug cm-12.1 togari userdebug cm-12.1 togari_gpe userdebug cm-12.1 tomato userdebug cm-12.1 trltespr userdebug cm-12.1 trltetmo userdebug cm-12.1 trltexx userdebug cm-12.1 umts_spyder userdebug cm-12.1 v400 userdebug cm-12.1 v410 userdebug cm-12.1 v500 userdebug cm-12.1 victara userdebug cm-12.1 ville userdebug cm-12.1 vs980 userdebug cm-12.1 vs985 userdebug cm-12.1 xt897 userdebug cm-12.1 xt907 userdebug cm-12.1 xt925 userdebug cm-12.1 xt926 userdebug cm-12.1 z3 userdebug cm-12.1 z3c userdebug cm-12.1 # Weekly cm-12.0 a5 userdebug cm-12.0 W e970 userdebug cm-12.0 W find5 userdebug cm-12.0 W jewel userdebug cm-12.0 W ks01lte userdebug cm-12.0 W ls970 userdebug cm-12.0 W m7spr userdebug cm-12.0 W mint userdebug cm-12.0 W taoshan userdebug cm-12.0 W trlteusc userdebug cm-12.0 W tsubasa userdebug cm-12.0 W # Weekly cm-11.0 a700 userdebug cm-11.0 W apexqtmo userdebug cm-11.0 W aries userdebug cm-11.0 W captivatemtd userdebug cm-11.0 W crespo userdebug cm-11.0 W d710 userdebug cm-11.0 W dogo userdebug cm-11.0 W e973 userdebug cm-11.0 W encore userdebug cm-11.0 W endeavoru userdebug cm-11.0 W enrc2b userdebug cm-11.0 W epicmtd userdebug cm-11.0 W exhilarate userdebug cm-11.0 W expressatt userdebug cm-11.0 W fireball userdebug cm-11.0 W galaxysbmtd userdebug cm-11.0 W galaxysmtd userdebug cm-11.0 W hercules userdebug cm-11.0 W hlteusc userdebug cm-11.0 W hltevzw userdebug cm-11.0 W hummingbird userdebug cm-11.0 W i9100g userdebug cm-11.0 W i9300 userdebug cm-11.0 W i9305 userdebug cm-11.0 W i9500 userdebug cm-11.0 W jflte userdebug cm-11.0 W klteusc userdebug cm-11.0 W kltevzw userdebug cm-11.0 W l01f userdebug cm-11.0 W m4 userdebug cm-11.0 W maguro userdebug cm-11.0 W n1 userdebug cm-11.0 W n5120 userdebug cm-11.0 W n7000 userdebug cm-11.0 W n7100 userdebug cm-11.0 W odin userdebug cm-11.0 W otter userdebug cm-11.0 W otter2 userdebug cm-11.0 W otterx userdebug cm-11.0 W ovation userdebug cm-11.0 W p1 userdebug cm-11.0 W p3100 userdebug cm-11.0 W p3110 userdebug cm-11.0 W p5100 userdebug cm-11.0 W p5110 userdebug cm-11.0 W p880 userdebug cm-11.0 W p930 userdebug cm-11.0 W r950 userdebug cm-11.0 W sc02c userdebug cm-11.0 W skyrocket userdebug cm-11.0 W t769 userdebug cm-11.0 W tf700t userdebug cm-11.0 W tf701t userdebug cm-11.0 W vs920 userdebug cm-11.0 W w7 userdebug cm-11.0 W ypg1 userdebug cm-11.0 W yuga userdebug cm-11.0 W
其中需要关注的是 grouper user-debug cm-12.1
然后执行lunch
root@pengdl-HP:/home/pengdl/work/study/nexus7/Nexus7# lunch You're building on Linux Lunch menu... pick a combo: 1. aosp_arm64-eng 45. cm_huashan-userdebug 89. cm_scorpion_windy-userdebug 2. aosp_arm-eng 46. cm_i605-userdebug 90. cm_serrano3gxx-userdebug 3. aosp_grouper-userdebug 47. cm_i777-userdebug 91. cm_serranoltexx-userdebug 4. aosp_mips64-eng 48. cm_i9100-userdebug 92. cm_shamu-userdebug 5. aosp_mips-eng 49. cm_i925-userdebug 93. cm_sirius-userdebug 6. aosp_x86_64-eng 50. cm_jactivelte-userdebug 94. cm_spyder-userdebug 7. aosp_x86-eng 51. cm_jem-userdebug 95. cm_superior-userdebug 8. cm_acclaim-userdebug 52. cm_jflteatt-userdebug 96. cm_t0lte-userdebug 9. cm_amami-userdebug 53. cm_jfltespr-userdebug 97. cm_t6spr-userdebug 10. cm_bacon-userdebug 54. cm_jfltetmo-userdebug 98. cm_t6-userdebug 11. cm_castor-userdebug 55. cm_jfltevzw-userdebug 99. cm_t6vzw-userdebug 12. cm_castor_windy-userdebug 56. cm_jfltexx-userdebug 100. cm_targa-userdebug 13. cm_condor-userdebug 57. cm_klimtwifi-userdebug 101. cm_tate-userdebug 14. cm_d2att-userdebug 58. cm_kltechnduo-userdebug 102. cm_tf300t-userdebug 15. cm_d2spr-userdebug 59. cm_kltechn-userdebug 103. cm_thea-userdebug 16. cm_d2tmo-userdebug 60. cm_klteduos-userdebug 104. cm_tilapia-userdebug 17. cm_d2vzw-userdebug 61. cm_kltedv-userdebug 105. cm_titan-userdebug 18. cm_d800-userdebug 62. cm_kltekdi-userdebug 106. cm_togari_gpe-userdebug 19. cm_d801-userdebug 63. cm_kltespr-userdebug 107. cm_togari-userdebug 20. cm_d802-userdebug 64. cm_klte-userdebug 108. cm_tomato-userdebug 21. cm_d803-userdebug 65. cm_l900-userdebug 109. cm_trltespr-userdebug 22. cm_d850-userdebug 66. cm_lettuce-userdebug 110. cm_trltetmo-userdebug 23. cm_d851-userdebug 67. cm_ls980-userdebug 111. cm_trltexx-userdebug 24. cm_d852-userdebug 68. cm_ls990-userdebug 112. cm_umts_spyder-userdebug 25. cm_d855-userdebug 69. cm_m7-userdebug 113. cm_v400-userdebug 26. cm_deb-userdebug 70. cm_m7vzw-userdebug 114. cm_v410-userdebug 27. cm_dlx-userdebug 71. cm_m8-userdebug 115. cm_v500-userdebug 28. cm_e975-userdebug 72. cm_mako-userdebug 116. cm_victara-userdebug 29. cm_e980-userdebug 73. cm_manta-userdebug 117. cm_ville-userdebug 30. cm_evita-userdebug 74. cm_maserati-userdebug 118. cm_vs980-userdebug 31. cm_falcon-userdebug 75. cm_mb886-userdebug 119. cm_vs985-userdebug 32. cm_find7s-userdebug 76. cm_mondrianwifi-userdebug 120. cm_xt897-userdebug 33. cm_find7-userdebug 77. cm_n3-userdebug 121. cm_xt907-userdebug 34. cm_flounder-userdebug 78. cm_n5100-userdebug 122. cm_xt925-userdebug 35. cm_flo-userdebug 79. cm_n5110-userdebug 123. cm_xt926-userdebug 36. cm_fugu-userdebug 80. cm_nicki-userdebug 124. cm_z3c-userdebug 37. cm_ghost-userdebug 81. cm_obake-userdebug 125. cm_z3-userdebug 38. cm_grouper-userdebug 82. cm_peregrine-userdebug 126. m_e_arm-userdebug 39. cm_hammerheadcaf-userdebug 83. cm_picassowifi-userdebug 127. mini_emulator_arm64-userdebug 40. cm_hammerhead-userdebug 84. cm_pollux-userdebug 128. mini_emulator_mips-userdebug 41. cm_hltespr-userdebug 85. cm_pollux_windy-userdebug 129. mini_emulator_x86_64-userdebug 42. cm_hltetmo-userdebug 86. cm_quark-userdebug 130. mini_emulator_x86-userdebug 43. cm_hlte-userdebug 87. cm_rendang-userdebug 44. cm_honami-userdebug 88. cm_scorpion-userdebug
选择38.
编译
mka bacon
2、修改内核配置
如果想编译模块,Nexus7的内核默认配置是不允许的,所以需要修改默认配置,配置文件是 cyanogenmod_grouper_defconfig
首先将这个默认配置备份一下
cd kernel/asus/grouer/arch/arm/configs/
cp cyanogenmod_grouper_defconfig cyanogenmod_grouper_defconfig_bak
修改配置
root@pengdl-HP:/home/pengdl/work/study/nexus7/Nexus7/kernel/asus/grouper# make ARCH=arm cyanogenmod_grouper_defconfig HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o SHIPPED scripts/kconfig/zconf.tab.c SHIPPED scripts/kconfig/zconf.lex.c SHIPPED scripts/kconfig/zconf.hash.c HOSTCC scripts/kconfig/zconf.tab.o HOSTLD scripts/kconfig/conf # # configuration written to .config # #### make completed successfully (10 seconds) ####
cd kernel/asus/grouper/
make ARCH=arm menuconfig
作如下修改:
[*] Enable loadable module support --->
[*] Forced module loading
[*] Module unloading
[*] Forced module unloading
需改完后,保存退出,用.config 覆盖 cyanogenmod_grouper_defconfig
然后清理环境:
make mrproper
然后再利用Android的编译系统编译出的boot.img就可以加载模块了。
二、配置USB访问权限
参考:http://source.android.com/source/initializing.html
Under GNU/Linux systems (and specifically under Ubuntu systems), regular users can't directly access USB devices by default. The system needs to be configured to allow such access.
The recommended approach is to create a file /etc/udev/rules.d/51-android.rules
(as the root user) and to copy the following lines in it.
must be replaced by the actual username of the user who is authorized to access the phones over USB.
# adb protocol on passion (Nexus One) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER="" # fastboot protocol on passion (Nexus One) SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER=" " # adb protocol on crespo/crespo4g (Nexus S) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER=" " # fastboot protocol on crespo/crespo4g (Nexus S) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER=" " # adb protocol on stingray/wingray (Xoom) SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="70a9", MODE="0600", OWNER=" " # fastboot protocol on stingray/wingray (Xoom) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="708c", MODE="0600", OWNER=" " # adb protocol on maguro/toro (Galaxy Nexus) SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER=" " # fastboot protocol on maguro/toro (Galaxy Nexus) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0600", OWNER=" " # adb protocol on panda (PandaBoard) SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d101", MODE="0600", OWNER=" " # adb protocol on panda (PandaBoard ES) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="d002", MODE="0600", OWNER=" " # fastboot protocol on panda (PandaBoard) SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d022", MODE="0600", OWNER=" " # usbboot protocol on panda (PandaBoard) SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d00f", MODE="0600", OWNER=" " # usbboot protocol on panda (PandaBoard ES) SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d010", MODE="0600", OWNER=" " # adb protocol on grouper/tilapia (Nexus 7) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e42", MODE="0600", OWNER=" " # fastboot protocol on grouper/tilapia (Nexus 7) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e40", MODE="0600", OWNER=" " # adb protocol on manta (Nexus 10) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee2", MODE="0600", OWNER=" " # fastboot protocol on manta (Nexus 10) SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4ee0", MODE="0600", OWNER=" "