修改/etc/apt/sources.list的软件源为163的源
deb http://mirrors.163.com/ubuntu/ precise main restricted deb-src http://mirrors.163.com/ubuntu/ precise main restricted deb http://mirrors.163.com/ubuntu/ precise-updates main restricted deb-src http://mirrors.163.com/ubuntu/ precise-updates main restricted deb http://mirrors.163.com/ubuntu/ precise universe deb-src http://mirrors.163.com/ubuntu/ precise universe deb http://mirrors.163.com/ubuntu/ precise-updates universe deb-src http://mirrors.163.com/ubuntu/ precise-updates universe deb http://mirrors.163.com/ubuntu/ precise multiverse deb-src http://mirrors.163.com/ubuntu/ precise multiverse deb http://mirrors.163.com/ubuntu/ precise-updates multiverse deb-src http://mirrors.163.com/ubuntu/ precise-updates multiverse deb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse deb-src http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse deb http://mirrors.163.com/ubuntu/ precise-security main restricted deb-src http://mirrors.163.com/ubuntu/ precise-security main restricted deb http://mirrors.163.com/ubuntu/ precise-security universe deb-src http://mirrors.163.com/ubuntu/ precise-security universe deb http://mirrors.163.com/ubuntu/ precise-security multiverse deb-src http://mirrors.163.com/ubuntu/ precise-security multiverse deb http://extras.ubuntu.com/ubuntu precise main deb-src http://extras.ubuntu.com/ubuntu precise main
或者直接用http://mirrors.163.com/.help/sources.list.precise替换
添加JDK6的源
sudo add-apt-repository "deb http://us.archive.ubuntu.com/ubuntu/ hardy multiverse"
如果是ubuntu11,需要使用下面这个
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
加完之后,记得使用命令更新一下软件源
sudo apt-get update
如果以上方法还不行,可以尝试以下的方法
add-apt-repository ppa:sun-java-community-team/sun-java6 apt-get update apt-get install sun-java6-jdk update-java-alternatives -s java-6-sun
安装相关工具
git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.6-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev sun-java6-jdk pngcrush schedtool
64位机器需要安装的工具
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \ zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \ libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \ libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \ python-markdown libxml2-utils xsltproc zlib1g-dev:i386 $ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
修改/etc/fstab挂载android目录
/dev/sdb /home/yondy/android ext4 errors=remount-ro 0 0
自动挂载windows分区
UUID=A2EAD759EAD72875 /media/c ntfs-3g defaults,locale=zh_CN.UTF-8 0 0 #Entry for /dev/sda5 : UUID=7701C217FD2A17D3 /media/d ntfs-3g defaults,locale=zh_CN.UTF-8 0 0 #Entry for /dev/sda6 : UUID=F1FD0A29C7E1502E /media/e ntfs-3g defaults,locale=zh_CN.UTF-8 0 0 #Entry for /dev/sda7 : UUID=7EF2D71898143C23 /media/f ntfs-3g defaults,locale=zh_CN.UTF-8 0 0
下载repo
mkdir -p ~/android/bin mkdir -p ~/android/cm7 curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/android/bin/repo
chmod a+x ~/android/bin/repo
将repo路径加入~/.bashrc
export PATH=~/android/bin:$PATH
source ~/.bashrc
更新代码
cd ~/android/cm7/ repo init -u git://github.com/CyanogenMod/android.git -b gingerbread repo sync -j4
上面的git:可更换为http:,貌似可以更稳定的下载
如果要使用代理,可以使用设置http_proxy环境变量
export http_proxy=IP:端口
下载过程中挂死后,如果手工中断,会残留一些临时文件,可以通过命令删除掉.repo/内的tmp文件
find .repo/ -name tmp* -exec rm {} \;
-------------------------------
编译kernel
kernel/arch/arm/configs里包含一些可以用于编译的配置文件,可以使用make命令来生成.config文件
在生成配置文件的时候,需要用到变量ARCH,编译时用到CROSS_COMPILER,有两种方式添加:
一是将下面的内容添加到~/.bashrc中
export CCOMPILER=${HOME}/android/cm7/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-
export ARCH=arm
然后执行
make hw7x30_defconfig
二是直接在make命令后带上述两个变量
make ARCH=arm hw7x30_defconfig
然后执行编译
make CROSS_COMPILE=$CCOMPILE
#或者
make CROSS_COMPILE="path to arm-eabi-"
-------------------------------------
编译CM7
source ./build/envsetup.sh lunch
~/android/cm7$ lunch You're building on Linux Lunch menu... pick a combo: 1. full-eng 2. full_x86-eng 3. simulator 4. huawei_u8800-eng 5. huawei_u8800-userdebug 6. cyanogen_generic-eng Which would you like? [full-eng] 4 build/core/product_config.mk:196: *** _nic.PRODUCTS.[[vendor/cyanogen/products/cyanogen_ace.mk]]: "device/htc/ace/ace.mk" does not exist。 停止。 Device u8800 not found. Attempting to retrieve device repository from CyanogenMod Github (http://github.com/CyanogenMod).
搜索vendor目录内包含cyanogen_ace的文件,发现vendor/cyanogen/products/AndroidProducts.mk 包含很多不相关的设备编译配置文件
将里面的内容替换为
PRODUCT_MAKEFILES := \ $(LOCAL_DIR)/cyanogen_u8800.mk
重新lunch,顺利通过
然后正式编译
make -j4
完成后,执行make otapackage生成升级包
如果是终端重新打开的,原先设置的环境变量会失效,导致失败。需要执行下面的命令来解决
source ./build/envsetup.sh && lunch 4 make otapackage
生成升级包的过程信息可以参考http://blog.csdn.net/zjujoe/article/details/6206010
后续关注内容
APP、FONTS、FRAMEWORK、MEDIA、XBIN、MISC,这6个文件夹
BIN文件:
Debuggerd
mkyaffs2image
Recovery
su0
Sysd
bootanimation
LIB的文件:
libandroid_runtime
Libdss
Liblame
libmicrobes_jni
libphoneloc_jni
Libams
Libapkchecker
Libapollo
Libcryptor
Liblocation
Libminimapv315
Libsmschecker
Libskia
Libutils
Build.prop配置文件:
ro.build.display.id=版本号
ro.product.locale.language=zh
ro.product.locale.region=CN 默认中文
ro.lewa.device=机型
wifi.supplicant_scan_interval=WIFI扫描时间(建议最小50,最大200)
以下8排可以全部移植到CM7.2里
ro.lewa.swapper.part_path=/dev/block/mmcblk1p3
ro.lewa.swapper.flash_swappiness=99
ro.lewa.swapper.sd_swappiness=60
ro.error.receiver.system.apps=com.lewa.fc
ro.error.receiver.default=com.lewa.fc
persist.sys.notif-speaker=1
persist.sys.ring-speaker=1
persist.sys.alarm-speaker=1
http://forum.xda-developers.com/showthread.php?t=1598713
http://wiki.cyanogenmod.com/wiki/Samsung_Galaxy_S_II:_Compile_CyanogenMod_(Linux)
===============================================================
使用https://github.com/Victor-android/android_device_huawei_u8800pro 进行编译CM7
解压里面的内容到device/huawei/u8800pro目录
添加device/huawei/u8800pro/vendorsetup.sh
add_lunch_combo huawei_u8800pro-eng add_lunch_combo huawei_u8800pro-userdebug
执行命令进行编译
source ./build/envsetup.sh lunch huawei_u8800pro-eng make
之后提示device/huawei/u8800pro/recovery/graphics.c找不到font.h
target thumb C: libminui <= bootable/recovery/minui/http://www.cnblogs.com/../device/huawei/u8800pro/recovery/graphics.c bootable/recovery/minui/http://www.cnblogs.com/../device/huawei/u8800pro/recovery/graphics.c:34:18: error: font.h: No such file or directory bootable/recovery/minui/http://www.cnblogs.com/../device/huawei/u8800pro/recovery/graphics.c:35:21: error: chinese.h: No such file or directory bootable/recovery/minui/http://www.cnblogs.com/../device/huawei/u8800pro/recovery/graphics.c: In function 'gr_measure': bootable/recovery/minui/http://www.cnblogs.com/../device/huawei/u8800pro/recovery/graphics.c:206: warning: implicit declaration of function 'str_utf8_length' bootable/recovery/minui/http://www.cnblogs.com/../device/huawei/u8800pro/recovery/graphics.c: In function 'gr_text': bootable/recovery/minui/http://www.cnblogs.com/../device/huawei/u8800pro/recovery/graphics.c:234: warning: implicit declaration of function 'ch_utf8_to_custom' bootable/recovery/minui/http://www.cnblogs.com/../device/huawei/u8800pro/recovery/graphics.c:238: error: 'font' undeclared (first use in this function) bootable/recovery/minui/http://www.cnblogs.com/../device/huawei/u8800pro/recovery/graphics.c:238: error: (Each undeclared identifier is reported only once bootable/recovery/minui/http://www.cnblogs.com/../device/huawei/u8800pro/recovery/graphics.c:238: error: for each function it appears in.) bootable/recovery/minui/http://www.cnblogs.com/../device/huawei/u8800pro/recovery/graphics.c:251: warning: implicit declaration of function 'ch_utf8_length' bootable/recovery/minui/http://www.cnblogs.com/../device/huawei/u8800pro/recovery/graphics.c: In function 'gr_init_font': bootable/recovery/minui/http://www.cnblogs.com/../device/huawei/u8800pro/recovery/graphics.c:306: error: 'font' undeclared (first use in this function) make: *** [out/target/product/u8800pro/obj/STATIC_LIBRARIES/libminui_intermediates/http://www.cnblogs.com/../device/huawei/u8800pro/recovery/graphics.o] 错误 1
搜索了一下,没找到font.h ...
对比一下device里其他的graphics.c,发现引用的的头文件为
#ifndef BOARD_LDPI_RECOVERY #include "font_10x18.h" #else #include "font_7x16.h" #endif
然后抄一把,再编译,接着提示error: chinese.h: No such file or directory
将device/u8800pro/BoardConfig.mk中的BOARD_USES_RECOVERY_CHINESE := true改为false
再用device/semc/msm7x30-common/recovery/graphics.h进行覆盖
将android_vendor_huawei_u8800pro-gingerbread改名u8800pro,复制到device/huawei/下
再次make -j4
make: *** 没有规则可以创建“out/target/product/u8800pro/obj/SHARED_LIBRARIES/lights.u8800pro_intermediates/LINKED/lights.u8800pro.so”需要的目标“out/target/product/u8800pro/obj/lib/libhwrpc.so”。 停止。
从android_vendor_cm7_u8800-master搜出了这东西
将文件复制到vendor/huawei/u8800pro/proprietary/system/lib
修改vendor/huawei/u8800pro/vendor-u8800pro-blobs.mk,修改下面的内容
vendor/huawei/u8800pro/proprietary/system/lib/libhwrpc.so:system/lib/libhwrpc.so \
vendor/huawei/u8800pro/proprietary/system/lib/libhwrpc.so:obj/lib/libhwrpc.so \
#编译里用的共享库,要拷贝到out/target/product/u8800pro/obj/lib/中的
可以通过在PRODUCT_COPY_FILES += xxx/xxx.so:obj/lib/xxx.so实现库的复制
u8800pro-vendor.mk和u8800pro-vendor-blobs.mk,主要是将需要复制的输出目录的内容添加到PRODUCT_COPY_FILES
vendor中的二进制文件和xxx-vendor-blobs.mk,一般是由device中的extract-files.sh通过adb pull 从手机中读取文件和生成的
-----------------------------
编译成功之后,再make otapackage 可以生成zip格式的刷机包,但刷不进去,提示
assert failed: write_raw("tmp/boot.img", "boot")
E:Error in /sdcard/XXX.zip
(Status 7)
对比一下与其他的刷新包,刷新脚本的类型不一样,cm中生成的是update-script,其他的是般是updater-script
通过Kichen可以将其转为另一种格式。
但转换了之后,在文件目录的挂载上还是有区别:CM中挂载MTD为/system,但实践上应该是/dev/block/mmcblk0p12。所以作下面的修改:
format("MTD", "system"); mount("MTD", "system", "/system"); package_extract_dir("system", "/system"); #-------------- #-------------- format("ext3", "EMMC", "/dev/block/mmcblk0p12"); mount("ext3", "EMMC", "/dev/block/mmcblk0p12", "/system"); package_extract_dir("system", "/system"); ################################# ################################# assert(package_extract_file("boot.img", "/tmp/boot.img"), write_raw_image("/tmp/boot.img", "boot"), delete("/tmp/boot.img")); #-------------- #-------------- mount("vfat", "EMMC", "/dev/block/mmcblk0p1", "/cust"); package_extract_file("boot.img","/cust/image/boot.img");
还是提示format() expects 2 args got 3
原因是update-binary版本与当前脚本不一致,不支持四个参数的format和mount
删除脚本中的, "EMMC"
--------
实际device中已经带了一个修改刷机脚本的脚本了的,只要将下面文件内容中的u8800改为u8800pro
/home/yondy/android/cm7/device/huawei/u8800pro/tools/u8800update
再执行
source ./build/envsetup.sh && lunch huawei_u8800pro-eng ./device/huawei/u8800pro/tools/u8800update
编译后刷机,卡在第一屏,adb devices能看到设备信息,但敲入adb shell提示exec '/system/bin/sh' failed: No such file or directory (2)
是bootloader没有跳到androi kernel? 还是android kernel没挂载成功/system? 不知道。。。
将别的正常的rom的boot.img用厨房解开,对比了一下,貌似是init.rc中,缺少/system的操作
在device_u8800pro.mk中增加
# Init PRODUCT_COPY_FILES += \ device/huawei/u8800pro/init.huawei.rc:root/init.huawei.rc \ device/huawei/u8800pro/init.rc:root/init.rc \ device/huawei/u8800pro/init:root/init \ device/huawei/u8800pro/initlogo.rle:root/initlogo.rle
同时从android_device_huawei_u8800pro-gingerbread中将上面的几个文件复制过来
然后再次make