How to compile CyanogenMod for hero (HTC Hero (GSM)).
This how-to was written for OS X 10.6.7, hero,CyanogenMod 7.x (Gingerbread), on 30 December 2010.
Install MacPorts using the instructions at MacPorts.org or if you already have MacPorts, I suggest you remove it completely to avoid conflicts, especially if you've upgraded your Mac OS X and haven't gotten to upgrade MacPorts for its current Mac OS X release. You can uninstall by doing:
sudo port -fp uninstall --follow-dependents installed
sudo rm -rf /opt/local /Applications/DarwinPorts /Applications/MacPorts /Library/LaunchDaemons/org.macports.* /Library/Receipts/DarwinPorts*.pkg /Library/Receipts/MacPorts*.pkg /Library/StartupItems/DarwinPortsStartup /Library/Tcl/darwinports1.0 /Library/Tcl/macports1.0 ~/.macports
Install the Mac OS X Developer Tools from your Mac OS X DVD.
Install the Java Developer Package from Apple's site — you'll need a free developer account from Apple. The installer you are looking for will be "Java for Mac OS X 10.6 Update 3 Developer Package" (Update 3 is the latest as of this writing).
Install the latest Android SDK. Make sure ADB is installed, and a path has been setup to the shell. If you don't know what that means, by all means, please stop now & perform further research on this topic.
While normal Macintosh volumes are case insensitive, the CyanogenMod/Android source contains files with the same name but in different cases. To solve this issue, you'll have to create and then work out of a case-sensitive disk image.
Now you need to install some stuff from macports:
For Mac OS X below 10.7, you can do the following:
sudo port selfupdate
POSIXLY_CORRECT=1 sudo port install gmake libsdl git-core gnupg e2fsprogs gsed curl libiptcdata xorg-libX* pngcrush findutils
sudo ln -s /opt/local/bin/gsed /opt/local/bin/sed
sudo ln -s /opt/local/libexec/gnubin/find /opt/local/bin/find
If you're Mac is a 32 bit box, do the following:
POSIXLY_CORRECT=1 sudo port install libsdl git-core gnupg gsed curl libiptcdata xorg-libX* pngcrush findutils
For 64 bit Macs, do the following:
POSIXLY_CORRECT=1 sudo port install libsdl git-core gnupg gsed curl libiptcdata xorg-libX* pngcrush findutils +universal
sudo ln -s /opt/local/bin/gsed /opt/local/bin/sed
sudo ln -s /opt/local/libexec/gnubin/find /opt/local/bin/find
Install the right gmake version referenced from [7] like so:
sudo vi /opt/local/etc/macports/sources.conf
mkdir /Users/Shared/dports
cd /Users/Shared/dports
svn co --revision 50980 http://svn.macports.org/repository/macports/trunk/dports/devel/gmake/ devel/gmake/
portindex /Users/Shared/dports
sudo port install gmake @3.81
sudo vi /usr/include/string.h
Go to line 143 by pressing :143
and Enter. Start appending the line by pressingi
followed by//
. PressEsc
and :wq
to save and quit vi.
While that's going, let's get your workspace ready.
Open Terminal (/Applications/Utilities/Terminal.app), and type the following commands:
cd /Volumes/CyanogenModWorkspace/
mkdir -p bin
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > bin/repo
chmod a+x bin/repo
mkdir -p android/system/
Let's put that bin folder in your path:
PATH=${PATH}:/Volumes/CyanogenModWorkspace/bin:
You can also add that line to the end of your ~/.profile if you want future terminal windows to have it.
echo "PATH=\${PATH}:/Volumes/CyanogenModWorkspace/bin:" >> ~/.profile
Here's a little one-time link you should set up to avoid errors when you are compiling up until Froyo:
cd /Developer/SDKs
sudo ln -s MacOSX10.6.sdk/ MacOSX10.4u.sdk
For Gingerbread and above, do the following:
cd /Developer/SDKs
sudo mv MacOSX10.5.sdk MacOSX10.5.sdk.old
sudo ln -s MacOSX10.6.sdk MacOSX10.5.sdk
Enter the following to initialize the repository:
cd /Volumes/CyanogenModWorkspace/android/system/
repo init -u git://github.com/CyanogenMod/android.git -b gingerbread
repo sync
You will need to have a hero with a working copy of CyanogenMod install and ADB working on the computer. This script will copy the proprietary files from the device.
Connect the device to the computer and ensure that ADB is working properly.
cd /Volumes/CyanogenModWorkspace/android/system/device/htc/hero/
./extract-files.sh
For Commtiva Z71, the above steps are not suffice, do the followings to get more needed proprietary binaries:
cd /Volumes/CyanogenModWorkspace/android/system/device/htc/hero/bin
adb pull /system/bin/hostapd .
P.S.
(1)执行.extract-files.sh如果获取手机的属性文件缺少的话,如下图。可以到
https://github.com/koush/proprietary_vendor_htc/tree/gingerbread/hero/proprietary
上寻找你缺少的文件,下载后放到
/home/loulijun/cyanogenmod/vendor/htc/hero/proprietary下即可
Download RomManager which is needed by the build:
$cd /Volumes/CyanogenModWorkspace/android/system/vendor/cyanogen/
/Volumes/CyanogenModWorkspace/android/system/vendor/cyanogen/get-rommanager
Mac OS X Lion will fail to compile QEMU (Emulator) codes. You do the following to disable building QEMU components.
cd /Volumes/CyanogenModWorkspace/android/system/
vi external/qemu/Android.mk
You will need to append #
at the start of the line to every lines on that file. Pressi
to insert andEsc
+:wq
to save and quit vi.
First, check for updates in the source:
cd /Volumes/CyanogenModWorkspace/android/system/
repo sync
Now, the environment must be configured to build for the hero.
cd /Volumes/CyanogenModWorkspace/android/system/
cp ./vendor/cyanogen/products/cyanogen_hero.mk ./buildspec.mk
. build/envsetup.sh
lunch cyanogen_hero-eng
Now, the ROM must be compiled, from code, for thehero.
cd /Volumes/CyanogenModWorkspace/android/system/
make -j`sysctl -an hw.logicalcpu` bacon
To further optimize the build, you can tweak the build.prop
file located at/system
to enable better performance and more battery saving options. Follow the steps below to edit yourbuild.prop
file:
adb shell mount -o remount rw /system
adb shell
vi system/build.prop
Go to the end of the file and press o
. Add the following tweaks:
Increase Dalvik VM heap size
dalvik.vm.heapsize=64m
TCP Buffer Tweaks
net.tcp.buffersize.default=4096,87380,256960,4096,16384,256960
net.tcp.buffersize.wifi=4096,87380,256960,4096,16384,256960
net.tcp.buffersize.umts=4096,87380,256960,4096,16384,256960
net.tcp.buffersize.gprs=4096,87380,256960,4096,16384,256960
net.tcp.buffersize.edge=4096,87380,256960,4096,16384,256960
Render parts of the UI using the GPU
debug.sf.hw=1
Media related Tweaks to increase quality
ro.media.enc.jpeg.quality=100
ro.media.dec.jpeg.memcap=8000000
ro.media.enc.hprof.vid.bps=8000000
media.stagefright.enable-player=true
media.stagefright.enable-meta=true
media.stagefright.enable-scan=true
media.stagefright.enable-http=true
Boot Tweaks
persist.sys.shutdown.mode=hibernate
ro.ext4fs=1
When you're done adding the tweaks, press Esc
and :wq
to save and quit vi. Typeexit
to exit fromAndroid'd shell. Reboot the device by typing the following:
adb reboot