CentOS CyanogenMod编译samsung (“n8000″) 全过程 cm 10.2



CentOS CyanogenMod 编译 samsung (“n8000″) 全过程 cm 10.2。编译环境

centOS/RHEL 6.2 64bit
源码已经下载完毕
一 前提条件:
1 配置好 android的编译环境
配置方法详见  http://source.android.com/source/initializing.html 网页

2 下载源码

 curl http:///git-repo-downloads/repo > ~/bin/repo
 需要用 CyanogenMod 提供的 repo工具

 repo init -u git://github.com/CyanogenMod/android.git -b cm-10.2   
 下载相应的分支

 repo sync
 下载

 下载过程很长,并且还有下载一半中断的情况,多下几次,确保下载完成,硬盘要准备足够大。大概20G.

3  Samsung 平板 GT-N8000

二 重要网页

  主要网页
  http://wiki.cyanogenmod.org/w/N8000_Info
  编译网页
  http://wiki.cyanogenmod.org/w/Build_for_n8000

三 编译源码
1 编译前的准备工作
cd ~/android/system/vendor/cm
./get-prebuilts

//(这一步是为了下载Term.apk并解压到当前propritary目录) (只需执行一次,以后编译无需执行)

 

2 $ source build/envsetup.sh

 $ breakfast n8000

 不要想着这两个命令了,由于网络原因,breakfast这个命令基本上是行不通的。

 直接下载驱动包好了

 http://www.github.com/cyanogenmod/android_device_samsung_n8000

 下载下来,驱动包很小,解压缩以后放在

cm-10/device/samsung/n8000 这个目录下,这个目录是没有的,需要自己新建一下

3 ./extract-files.sh

 首先连接好samsung note手机,然后来到 cm-10/device/samsung/n8000 这个目录下,执行上面的指令。

 这个脚本的主要作用是将手机中的驱动so库pull出来,然后新建 cm-10/vendor/samsung/n8000这个目录,然后在里面放相应的库文件。

 ok,执行,首先报错

 

[root@localhost android-cm-10.2]# breakfast n8000

including vendor/cm/vendorsetup.sh

build/core/product_config.mk:238: *** _nic.PRODUCTS.[[device/samsung/n8000/cm.mk]]: “device/samsung/n80xx-common/n80xx-common.mk” does not exist。 停止。

Device n8000 not found. Attempting to retrieve device repository from CyanogenMod Github (http://github.com/CyanogenMod).

^X^CTraceback (most recent call last):

  File “build/tools/roomservice.py”, line 76, in

    result = json.loads(urllib.request.urlopen(githubreq).read().decode())

  File “/usr/lib64/python2.6/socket.py”, line 354, in read

    data = self._sock.recv(rbufsize)

  File “/usr/lib64/python2.6/httplib.py”, line 542, in read

    s = self.fp.read(amt)

  File “/usr/lib64/python2.6/socket.py”, line 383, in read

    data = self._sock.recv(left)

  File “/usr/lib64/python2.6/ssl.py”, line 215, in recv

    return self.read(buflen)

  File “/usr/lib64/python2.6/ssl.py”, line 136, in read


    return self._sslobj.read(len)

KeyboardInterrupt

build/core/product_config.mk:238: *** _nic.PRODUCTS.[[device/samsung/n8000/cm.mk]]: “device/samsung/n80xx-common/n80xx-common.mk” does not exist。 停止。

 

** Don’t have a product spec for: ‘cm_n8000′

** Do you have the right repo manifest?

由于n8000的很多驱动是基于 n80xx-common 驱动包的,所以需要预先下载 n80xx-common 驱动包,这也是为何 n8000 驱动包那么小的缘故。

 

 从 https://github.com/CyanogenMod/android_device_samsung_n80xx-common

 这里面将 n80xx-common 驱动包下载下来,放到 cm-10/device/samsung/n80xx-common 这个目录下,这个目录本身是没有的,需要新建。

chmod +x  android-cm-10.2/device/samsung/n80xx-common/extract-files.sh
继续执行第3步 ./extract-files.sh 这个命令
报错:
[root@localhost n8000]# ./extract-files.sh 
error: device not found
lsusb命令查看设备信息
[root@localhost n8000]# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 005: ID 04e8:685c Samsung Electronics Co., Ltd 
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 002: ID 04b3:310d IBM Corp. 
[root@localhost n8000]# adb devices
List of devices attached 
执行该脚本时还可能报错
[root@localhost n8000]# ./extract-files.sh 
error: protocol fault (no status)
Pulling n80xx files…
4348 KB/s (2241584 bytes in 0.503s)
808 KB/s (42308 bytes in 0.051s)
4711 KB/s (733264 bytes in 0.151s)
remote object ‘/system/lib/hw/vendor-camera.exynos4.so’ does not exist
1330 KB/s (64664 bytes in 0.047s)
1347 KB/s (133456 bytes in 0.096s)
1 KB/s (54 bytes in 0.042s)
remote object ‘/system/usr/keylayout/max77693-muic.kl’ does not exist
remote object ‘/system/usr/keylayout/samsung-keypad.kl’ does not exist
54 KB/s (2320 bytes in 0.041s)
Pulling common files…
remote object ‘/sbin/cbd’ does not exist
405 KB/s (37042 bytes in 0.089s)
402 KB/s (37042 bytes in 0.089s)
remote object ‘/system/bin/bcm4334_semcosh.hcd’ does not exist
9 KB/s (406 bytes in 0.043s)
remote object ‘/system/etc/wifi/bcmdhd_apsta.bin_b1′ does not exist
2366 KB/s (399707 bytes in 0.164s)
remote object ‘/system/etc/wifi/bcmdhd_mfg.bin_b0′ does not exist
remote object ‘/system/etc/wifi/bcmdhd_mfg.bin_b1′ does not exist
2361 KB/s (430003 bytes in 0.177s)
remote object ‘/system/etc/wifi/bcmdhd_p2p.bin_b0′ does not exist
remote object ‘/system/etc/wifi/bcmdhd_p2p.bin_b1′ does not exist
2567 KB/s (446743 bytes in 0.169s)
remote object ‘/system/etc/wifi/bcmdhd_sta.bin_b0′ does not exist
remote object ‘/system/etc/wifi/bcmdhd_sta.bin_b1′ does not exist
536 KB/s (50264 bytes in 0.091s)
remote object ‘/system/lib/libvdis.so’ does not exist
715 KB/s (74388 bytes in 0.101s)
705 KB/s (74124 bytes in 0.102s)
remote object ‘/system/media/battery_charging_5.qmg’ does not exist
remote object ‘/system/media/battery_charging_10.qmg’ does not exist
remote object ‘/system/media/battery_charging_15.qmg’ does not exist
860 KB/s (97196 bytes in 0.110s)
remote object ‘/system/media/battery_charging_25.qmg’ does not exist
remote object ‘/system/media/battery_charging_30.qmg’ does not exist
remote object ‘/system/media/battery_charging_35.qmg’ does not exist
780 KB/s (86704 bytes in 0.108s)
remote object ‘/system/media/battery_charging_45.qmg’ does not exist
remote object ‘/system/media/battery_charging_50.qmg’ does not exist
remote object ‘/system/media/battery_charging_55.qmg’ does not exist
739 KB/s (75216 bytes in 0.099s)
remote object ‘/system/media/battery_charging_65.qmg’ does not exist
remote object ‘/system/media/battery_charging_70.qmg’ does not exist
remote object ‘/system/media/battery_charging_75.qmg’ does not exist
611 KB/s (63504 bytes in 0.101s)
remote object ‘/system/media/battery_charging_85.qmg’ does not exist
remote object ‘/system/media/battery_charging_90.qmg’ does not exist
remote object ‘/system/media/battery_charging_95.qmg’ does not exist
remote object ‘/system/usr/idc/sec_touchscreen.idc’ does not exist
3 KB/s (132 bytes in 0.042s)
15 KB/s (652 bytes in 0.041s)
remote object ‘/system/vendor/firmware/SlimISP_BH.bin’ does not exist
remote object ‘/system/vendor/firmware/SlimISP_GD.bin’ does not exist
remote object ‘/system/vendor/firmware/SlimISP_GH.bin’ does not exist
remote object ‘/system/vendor/firmware/SlimISP_GK.bin’ does not exist
remote object ‘/system/vendor/firmware/SlimISP_JH.bin’ does not exist
remote object ‘/system/vendor/firmware/SlimISP_WH.bin’ does not exist
remote object ‘/system/vendor/firmware/SlimISP_ZD.bin’ does not exist
remote object ‘/system/vendor/firmware/SlimISP_ZH.bin’ does not exist
remote object ‘/system/vendor/firmware/SlimISP_ZK.bin’ does not exist
remote object ‘/system/vendor/firmware/SlimISP_ZM.bin’ does not exist
3640 KB/s (1224006 bytes in 0.328s)
2325 KB/s (376448 bytes in 0.158s)
641 KB/s (67611 bytes in 0.102s)
1543 KB/s (124164 bytes in 0.078s)
remote object ‘/system/vendor/lib/libWVStreamControlAPI_L1.so’ does not exist
remote object ‘/system/vendor/lib/libwvdrm_L1.so’ does not exist
618 KB/s (58560 bytes in 0.092s)
解决办法:可以直接将cm-10.2-20140216-NIGHTLY-n8000/system/下的东东拷贝到android-cm-10.2/vendor/samsung/n80xx/proprietary/system/目录下

4 真正编译

 赶脚配置完成了,然后开始按照官方文档进行编译了

 $ croot

 $ brunch n8000

 

  不幸的是,立马报错

[root@localhost android-cm-10.2]# brunch n8000

including vendor/cm/vendorsetup.sh

build/core/product_config.mk:238: *** _nic.PRODUCTS.[[device/samsung/n8000/cm.mk]]: “hardware/samsung/exynos4x12.mk” does not exist。 停止。

Device n8000 not found. Attempting to retrieve device repository from CyanogenMod Github (http://github.com/CyanogenMod).

Found repository: android_device_samsung_n8000

Default revision: cm-10.2

Checking branch info

CyanogenMod/android_device_samsung_n8000 already exists

Syncing repository to retrieve project.

error: project device/samsung/n8000 not found

Repository synced!

Looking for dependencies

Done

build/core/product_config.mk:238: *** _nic.PRODUCTS.[[device/samsung/n8000/cm.mk]]: “hardware/samsung/exynos4x12.mk” does not exist。 停止。

 

** Don’t have a product spec for: ‘cm_n8000′

** Do you have the right repo manifest?

 

No such item in brunch menu. Try ‘breakfast’

缺少samsung硬件基础库。

https://github.com/CyanogenMod/android_hardware_samsung 
下载后将里面的文件替换到 hardware/samsung/下面。

继续
[root@localhost android-cm-10.2]# brunch n8000
including vendor/cm/vendorsetup.sh
Looking for dependencies
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.3.1
CM_VERSION=10.2-20140312-UNOFFICIAL-n8000
TARGET_PRODUCT=cm_n8000
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=cortex-a9
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-2.6.32-220.el6.x86_64-x86_64-with-glibc2.2.5
HOST_BUILD_TYPE=release
BUILD_ID=JLS36I
OUT_DIR=/sda5-194G-data/android-cm-10.2/out
============================================
bash: schedtool: command not found
好吧,下载个schedtool包装下呗。。。
再来。。。
[root@localhost android-cm-10.2]# brunch n8000
including vendor/cm/vendorsetup.sh
Looking for dependencies
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.3.1
CM_VERSION=10.2-20140312-UNOFFICIAL-n8000
TARGET_PRODUCT=cm_n8000
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=cortex-a9
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-2.6.32-220.el6.x86_64-x86_64-with-glibc2.2.5
HOST_BUILD_TYPE=release
BUILD_ID=JLS36I
OUT_DIR=/sda5-194G-data/android-cm-10.2/out
============================================
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=4.3.1
CM_VERSION=10.2-20140312-UNOFFICIAL-n8000
TARGET_PRODUCT=cm_n8000
TARGET_BUILD_VARIANT=userdebug
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=cortex-a9
HOST_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-2.6.32-220.el6.x86_64-x86_64-with-glibc2.2.5
HOST_BUILD_TYPE=release
BUILD_ID=JLS36I
OUT_DIR=/sda5-194G-data/android-cm-10.2/out
============================================
Checking build tools versions…
build/core/base_rules.mk:130: *** device/samsung/n80xx-common/audio: MODULE.TARGET.SHARED_LIBRARIES.audio.primary.smdk4x12 already defined by device/android_device_samsung_n80xx-common-cm-10.2/audio。 停止。
解决方法:清理下device/samsung目录,将不需要的文件夹删掉就ok
再来。。。
[root@localhost android-cm-10.2]# brunch n8000
……….
Export includes file: external/sepolicy/tools/Android.mk — /sda5-194G-data/android-cm-10.2/out/host/linux-x86/obj/EXECUTABLES/checkseapp_intermediates/export_includes
Notice file: external/sepolicy/NOTICE — /sda5-194G-data/android-cm-10.2/out/target/product/n8000/obj/NOTICE_FILES/src//root/seapp_contexts.txt
make: *** 没有规则可以创建“/sda5-194G-data/android-cm-10.2/out/target/product/n8000/root/sbin/cbd”需要的目标“vendor/samsung/smdk4412-common/proprietary/sbin/cbd”。 停止。
make: *** 正在等待未完成的任务….
Notice file: external/sepolicy/NOTICE — /sda5-194G-data/android-cm-10.2/out/target/product/n8000/obj/NOTICE_FILES/src//root/sepolicy.txt
解决办法: 从那个https://github.com/DonkeyCoyote/proprietary_vendor_samsung
下载的proprietary_vendor_samsung-android-4.3/smdk4412-commonproprietary/sbin/cbd
目录下找找cbd,copy到指定目录
 
再来。。。
[root@localhost android-cm-10.2]# brunch n8000
……….
system/core/libmincrypt/sha.c: In function ‘SHA_update’:
system/core/libmincrypt/sha.c:153:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/sda5-194G-data/android-cm-10.2/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6/bin/../lib/gcc/i686-linux/4.6.x-google/../../../../i686-linux/bin/as: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
/sda5-194G-data/android-cm-10.2/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6/bin/../lib/gcc/i686-linux/4.6.x-google/../../../../i686-linux/bin/as: error while loading shared libraries: libz.so.1: cannot open shared object file: /sda5-194G-data/android-cm-10.2/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6/bin/../lib/gcc/i686-linux/4.6.x-google/../../../../i686-linux/bin/asNo such file or directory: 
error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
make: *** [/sda5-194G-data/android-cm-10.2/out/host/linux-x86/obj/STATIC_LIBRARIES/libmincrypt_intermediates/rsa.o] 错误 1
make: *** 正在等待未完成的任务….
make: *** [/sda5-194G-data/android-cm-10.2/out/host/linux-x86/obj/STATIC_LIBRARIES/libmincrypt_intermediates/rsa_e_3.o] 错误 1
make: *** [/sda5-194G-data/android-cm-10.2/out/host/linux-x86/obj/STATIC_LIBRARIES/libmincrypt_intermediates/rsa_e_f4.o] 错误 1
/sda5-194G-data/android-cm-10.2/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6/bin/../lib/gcc/i686-linux/4.6.x-google/../../../../i686-linux/bin/as: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
make: *** [/sda5-194G-data/android-cm-10.2/out/host/linux-x86/obj/STATIC_LIBRARIES/libmincrypt_intermediates/sha.o] 错误 1
我要吐血了。。。
装一个32bit的zlib包就ok了
再来。。。
[root@localhost android-cm-10.2]# brunch n8000
……….
Generating CSSPropertyNames.h <= CSSPropertyNames.in
Generating CSSValueKeywords.h <= CSSValueKeywords.in
target Generated: libwebcore <= external/webkit/Source/WebCore/xml/XMLViewer.css
sh: gperf: command not found
calling gperf failed: 32512 at makevalues.pl line 137.
make: *** [/sda5-194G-data/android-cm-10.2/out/target/product/n8000/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/css/CSSValueKeywords.h] 错误 25
make: *** 正在删除文件“/sda5-194G-data/android-cm-10.2/out/target/product/n8000/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/css/CSSValueKeywords.h”
make: *** 正在等待未完成的任务….
sh: gperf: command not found
calling gperf failed: 32512 at ./makeprop.pl line 140.
make: *** [/sda5-194G-data/android-cm-10.2/out/target/product/n8000/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/css/CSSPropertyNames.h] 错误 25
make: *** 正在删除文件“/sda5-194G-data/android-cm-10.2/out/target/product/n8000/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/css/CSSPropertyNames.h”
再次吐血。。。
安装下gperf吧。。
再来。。。
[root@localhost android-cm-10.2]# brunch n8000
……….
target Prebuilt: Calculator (/sda5-194G-data/android-cm-10.2/out/target/common/obj/JAVA_LIBRARIES/slider_intermediates/javalib.jar)
make[1]: *** [sub-make] 错误 2
make[1]: Leaving directory `/sda5-194G-data/android-cm-10.2/kernel/samsung/smdk4412′
Copying: /sda5-194G-data/android-cm-10.2/out/target/common/obj/JAVA_LIBRARIES/calendar-common_intermediates/classes-jarjar.jar
make: *** [TARGET_KERNEL_BINARIES] 错误 2
make: *** 正在等待未完成的任务….
下载

https://github.com/cyanogenmod/android_kernel_samsung_smdk4412

这个内核,然后在项目根目录下建立 kernel/samsung/smdk4412,将内核文件拷贝过去

解压命令:unzip android_kernel_samsung_smdk4412-cm-10.2.zip (最好用此命令解压,ubuntu版解压工具可能有问题,需要下载个专门的zip解压)
索性不用 ubuntu自带的解压缩工具了,直接下载了一个7z工具,
apt-get install p7zip-full
解压缩
7z x android_kernel_samsung_smdk4412-cm-10.2.zip 
参考:
http://sunzeduo.blog.51cto.com/2758509/1357229
http://www.cnblogs.com/tomsen/archive/2013/06/04/3115460.html