一、编译环境搭建
(更细节的环境搭建请参考:)
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 $combodone
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.1acclaim userdebug cm-12.1amami userdebug cm-12.1bacon userdebug cm-12.1castor userdebug cm-12.1castor_windy userdebug cm-12.1condor userdebug cm-12.1d2att userdebug cm-12.1d2spr userdebug cm-12.1d2tmo userdebug cm-12.1d2vzw userdebug cm-12.1d800 userdebug cm-12.1d801 userdebug cm-12.1d802 userdebug cm-12.1d803 userdebug cm-12.1d850 userdebug cm-12.1d851 userdebug cm-12.1d852 userdebug cm-12.1d855 userdebug cm-12.1deb userdebug cm-12.1dlx userdebug cm-12.1e975 userdebug cm-12.1e980 userdebug cm-12.1evita userdebug cm-12.1falcon userdebug cm-12.1find7 userdebug cm-12.1find7s userdebug cm-12.1flo userdebug cm-12.1flounder userdebug cm-12.1fugu userdebug cm-12.1ghost userdebug cm-12.1grouper userdebug cm-12.1hammerhead userdebug cm-12.1hammerheadcaf userdebug cm-12.1hlte userdebug cm-12.1hltespr userdebug cm-12.1hltetmo userdebug cm-12.1i605 userdebug cm-12.1i777 userdebug cm-12.1i9100 userdebug cm-12.1i925 userdebug cm-12.1honami userdebug cm-12.1huashan userdebug cm-12.1jactivelte userdebug cm-12.1jem userdebug cm-12.1jflteatt userdebug cm-12.1jfltespr userdebug cm-12.1jfltetmo userdebug cm-12.1jfltevzw userdebug cm-12.1jfltexx userdebug cm-12.1klimtwifi userdebug cm-12.1klte userdebug cm-12.1kltechn userdebug cm-12.1kltechnduo userdebug cm-12.1klteduos userdebug cm-12.1kltedv userdebug cm-12.1kltekdi userdebug cm-12.1kltespr userdebug cm-12.1l900 userdebug cm-12.1lettuce userdebug cm-12.1ls980 userdebug cm-12.1ls990 userdebug cm-12.1m7 userdebug cm-12.1m7vzw userdebug cm-12.1m8 userdebug cm-12.1mako userdebug cm-12.1manta userdebug cm-12.1maserati userdebug cm-12.1mb886 userdebug cm-12.1mondrianwifi userdebug cm-12.1n3 userdebug cm-12.1n5100 userdebug cm-12.1n5110 userdebug cm-12.1nicki userdebug cm-12.1obake userdebug cm-12.1peregrine userdebug cm-12.1picassowifi userdebug cm-12.1pollux userdebug cm-12.1pollux_windy userdebug cm-12.1quark userdebug cm-12.1rendang userdebug cm-12.1scorpion userdebug cm-12.1scorpion_windy userdebug cm-12.1serrano3gxx userdebug cm-12.1serranoltexx userdebug cm-12.1shamu userdebug cm-12.1sirius userdebug cm-12.1spyder userdebug cm-12.1superior userdebug cm-12.1t0lte userdebug cm-12.1t6 userdebug cm-12.1t6spr userdebug cm-12.1t6vzw userdebug cm-12.1targa userdebug cm-12.1tate userdebug cm-12.1tf300t userdebug cm-12.1thea userdebug cm-12.1tilapia userdebug cm-12.1titan userdebug cm-12.1togari userdebug cm-12.1togari_gpe userdebug cm-12.1tomato userdebug cm-12.1trltespr userdebug cm-12.1trltetmo userdebug cm-12.1trltexx userdebug cm-12.1umts_spyder userdebug cm-12.1v400 userdebug cm-12.1v410 userdebug cm-12.1v500 userdebug cm-12.1victara userdebug cm-12.1ville userdebug cm-12.1vs980 userdebug cm-12.1vs985 userdebug cm-12.1xt897 userdebug cm-12.1xt907 userdebug cm-12.1xt925 userdebug cm-12.1xt926 userdebug cm-12.1z3 userdebug cm-12.1z3c userdebug cm-12.1# Weekly cm-12.0a5 userdebug cm-12.0 We970 userdebug cm-12.0 Wfind5 userdebug cm-12.0 Wjewel userdebug cm-12.0 Wks01lte userdebug cm-12.0 Wls970 userdebug cm-12.0 Wm7spr userdebug cm-12.0 Wmint userdebug cm-12.0 Wtaoshan userdebug cm-12.0 Wtrlteusc userdebug cm-12.0 Wtsubasa userdebug cm-12.0 W# Weekly cm-11.0a700 userdebug cm-11.0 Wapexqtmo userdebug cm-11.0 Waries userdebug cm-11.0 Wcaptivatemtd userdebug cm-11.0 Wcrespo userdebug cm-11.0 Wd710 userdebug cm-11.0 Wdogo userdebug cm-11.0 We973 userdebug cm-11.0 Wencore userdebug cm-11.0 Wendeavoru userdebug cm-11.0 Wenrc2b userdebug cm-11.0 Wepicmtd userdebug cm-11.0 Wexhilarate userdebug cm-11.0 Wexpressatt userdebug cm-11.0 Wfireball userdebug cm-11.0 Wgalaxysbmtd userdebug cm-11.0 Wgalaxysmtd userdebug cm-11.0 Whercules userdebug cm-11.0 Whlteusc userdebug cm-11.0 Whltevzw userdebug cm-11.0 Whummingbird userdebug cm-11.0 Wi9100g userdebug cm-11.0 Wi9300 userdebug cm-11.0 Wi9305 userdebug cm-11.0 Wi9500 userdebug cm-11.0 Wjflte userdebug cm-11.0 Wklteusc userdebug cm-11.0 Wkltevzw userdebug cm-11.0 Wl01f userdebug cm-11.0 Wm4 userdebug cm-11.0 Wmaguro userdebug cm-11.0 Wn1 userdebug cm-11.0 Wn5120 userdebug cm-11.0 Wn7000 userdebug cm-11.0 Wn7100 userdebug cm-11.0 Wodin userdebug cm-11.0 Wotter userdebug cm-11.0 Wotter2 userdebug cm-11.0 Wotterx userdebug cm-11.0 Wovation userdebug cm-11.0 Wp1 userdebug cm-11.0 Wp3100 userdebug cm-11.0 Wp3110 userdebug cm-11.0 Wp5100 userdebug cm-11.0 Wp5110 userdebug cm-11.0 Wp880 userdebug cm-11.0 Wp930 userdebug cm-11.0 Wr950 userdebug cm-11.0 Wsc02c userdebug cm-11.0 Wskyrocket userdebug cm-11.0 Wt769 userdebug cm-11.0 Wtf700t userdebug cm-11.0 Wtf701t userdebug cm-11.0 Wvs920 userdebug cm-11.0 Ww7 userdebug cm-11.0 Wypg1 userdebug cm-11.0 Wyuga userdebug cm-11.0 W
然后执行lunch
root@pengdl-HP:/home/pengdl/work/study/nexus7/Nexus7# lunchYou're building on LinuxLunch 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访问权限
参考:
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. <username>
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=" "