編譯小米2s CyanogenMod 版本遇到的幾個問題

來源:互聯網
上載者:User

標籤:android   小米   

背景介紹
為了破除我對android的神秘感,準備親自編一個cm rom到真機上跑。反覆看了cm 支援的devices, 我能網上,國內買到最便宜的,就只有小米2s了[0],為此特意從小米官網定了一個翻新標準版。
吐槽下鎚子,竟然藐視我等,不讓root,不讓安裝第三方rom。

關於編譯機器,我用的是azure 3GB記憶體的那種虛擬機器, 一塊錢試用版的。 現在想來我應該建最高配置的VM。我的i3筆記本可以編但是把機器卡得其他活都幹不了。

關於串連googlesources, 買國外的VPS吧, 或者國內的,然後你懂得。

下面的Q&A是在[0]上遇到問題總結的,如果要折騰先執行它提到的操作,這裡不再重複。
Q: 我沒有真機,並且在VPS上也不能extract_files,如何弄到專有驅動?
A: 
最初我是小米miui論壇下載的官方版本,提取時缺少diag_klog, 搜尋找到[1]中提到的才有。
git clone https://github.com/CyanogenMod/android_device_xiaomi_aries.git device/xiaomi/aries
git clone https://github.com/cyanogenmod/android_kernel_xiaomi_aries kernel/xiaomi/aries
git clone https://github.com/linuxxxxx/proprietary_vendor_xiaomi vendor/xiaomi/aries
如果太慢就wget, 並注意解開的頂層目錄有多個檔案就行了。
 
Q: 編譯加速
A:開啟編譯緩衝,最好把下面的export放到.bashrc,不然重新登入shell,忘了設定,先前編的都白費了。
export USE_CCACHE=1
export CCACHE_DIR=~/disk_c/tmp_aries
export OUT_DIR_COMMON_BASE=~/disk_c/out_aries
./prebuilts/misc/linux-x86/ccache/ccache -M 100G
這裡設定out目的是源碼和中間結果分開,便於在不同build之間切換[3]
最好源碼和cache,out在不同分區,這樣可以分散io而加快速度。
(參考資料: 編譯成功結束後cache是928MB, out是27G)
參數"-jN", 跟據cm上的建議取物理線程數+2, 我的vps是amd 雙核,所以取4,
如果是intel 四核,一個核可以跑線程,就取10。

Q: 找不到gcc.
A:重新登入shell時下面的envsetup之後,忘了lunch, 直接就make了,這時你發現編譯的target=generic。

Q:
make: *** No rule to make target `/home/azureuser/disk_c/out_aries/xm2s/target/product/aries/obj/STATIC_LIBRARIES/libinit_msm_intermediates/export_includes‘, needed by `/home/azureuser/disk_c/out_aries/xm2s/target/product/aries/obj/EXECUTABLES/init_intermediates/import_includes‘.  Stop.
A:
我在網上找到一個臨時辦法:它說不是缺這個檔案嗎,我們就touch一個,如果寫在mk裡面,
大致這樣:
$(shell touch $(OUT)/obj/...)
我不知道加在哪個檔案,直接shell裡面搞了。
繼續編譯後缺libinit_msm.a。我也不知道如果touch一個合法的.a檔案,怎麼辦呢?
懷疑過多線程編譯,刪掉hardware目錄重新同步,都不行。
(此間徘徊過,幾乎花了一天時間後)
最後看代碼發現只需把它注釋掉也可以把init編過:
device/xiaomi/aries/BoardConfig.mk
#TARGET_INIT_VENDOR_LIB := libinit_msm
好奇的隨便看下是啥:
device/xiaomi/aries/init/init_aries.c
init_msm_properties()讀取
/sys/devices/system/soc/soc0/raw_id,
並設定ro.product.model=1812(MI2S)
<--vendor_load_properties()<--property_service_init_action()
<--system/core/init/init.c:main()
體會:不要擔心手機,大膽地添加刪除某些模組。

Q
: libwebviewchromium.so ld terminated with signal 9
A: 記憶體不夠。即使你的實體記憶體有8G也不行(因為ld.gold是for linux 2.6.8的?),需要設定交換分區,
由於在VPS上,不方便增加物理分區,我們用磁碟檔案作為分區[6]:
sudo dd if=/dev/zero of=/mnt/10GB.swap bs=1024 count=10485760
sudo chmod 600 /mnt/10GB.swap
sudo mkswap /mnt/10GB.swap
sudo swapon /mnt/10GB.swap
關於記憶體問題,我還遇到過一個奇怪的事情,就是ssh串連沒有響應了。

Q:編譯
A: 我成功編譯的指令序列,按這個試了一遍的:
vim ~/.bashrc export USE_CCACHE=1 export CCACHE_DIR=/mnt/tmp_aries export OUT_DIR_COMMON_BASE=/mnt/out_ariessource ~/.bashrccd ~/disk_c/xm2ssource build/envsetup.shlunch make -j4 --print-directory showcommands | tee ../build.log

TODO

  等手機到了,放到真機上跑。

Ref

[0] http://wiki.cyanogenmod.org/w/Aries_Info
[1] http://en.miui.com/thread-16834-1-1.html
[2] CM11.0源碼編譯 -- http://blog.csdn.net/mxgg123/article/details/26269313
[3] ccache -- http://blog.cofface.com/archives/78.html#more-78
[4] https://github.com/razrqcom-dev-team/android_local_razrqcom/issues/1
[5] http://wiki.cyanogenmod.org/w/Doc:_Using_manifests#The_local_manifest
[6] signal 9 -- http://stackoverflow.com/questions/5682854/why-is-the-linker-terminating-on-me-when-i-build-clang
 http://d.hatena.ne.jp/none53/20131128/1385601681
[7] http://wiki.cyanogenmod.org/w/Doc:_Building_Basics


編譯小米2s CyanogenMod 版本遇到的幾個問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.