HTC Hero (GSM): Compile CyanogenMod (OS X)

祝高超
2023-12-01

HTC Hero (GSM): Compile CyanogenMod (OS X)

From CyanogenMod Wiki
Jump to: navigation, search
*** This Howto has not been tested yet ***

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.

Prepare the Build Environment

Reading List

  • Google Android Official Documentation[1]
  • Marko Gargenta's [2] basic screencasts about Android's internals and compiling it, part 1[3] and part 2[4]
  • Modaco’s tips & trick compiling CyanogenMod in OS X Lion [5]
  • A blog post by Batista Harahap on compiling Gingerbread in Mac OS X Lion for Nexian Journey A890[6]
  • Coffee and about 3+ hours to spend when building the first time depending on CPU power and bandwidth available.

(Re)Install MacPorts

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 Developer Tools

Install the Mac OS X Developer Tools from your Mac OS X DVD.

Install the Java Developer Package

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 Android SDK

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.

Create a Case-Sensitive Workspace

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.

  1. Open the Disk Utility (/Applications/Utilities/Disk Utility.app).
  2. Click on New Image.
  3. Save as "CyanogenModWorkspace.sparseimage" and set the following parameters as followed:
    • Name: "CyanogenModWorkspace"
    • Size: 15 GB is minimum recommended (A sparseimage will save unused space)
    • Format: Mac OS Extended (CASE-SENSITIVE, Journaled)
    • Encryption: none, Partition- Single Apple Partition Map
    • Image Format: Sparse Disk Image (this will save you disk space)
  4. Save this wherever you like, and then double-click the sparseimage file to mount.
  5. Your workspace will be:
    /Volumes/CyanogenModWorkspace/

Install Required Ports

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

Mac OS X 10.7 String Library Hack

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.

Set up the Workspace

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

Quick Symlink

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

cd /Developer/SDKs
sudo ln -s /Developer/SDKs/MacOSX10.6.sdk /Developer/SDKs/MacOSX10.5.sdk

Install the Repository

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

Copy proprietary files

NOTE: This only needs done the first time you build. If you have already done these steps, you may skip to Download RomManager.

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

NOTE: This only needs to be done when an update to RomManager is released. If you are-up-to date, you may skip to Building CyanogenMod.

Download RomManager which is needed by the build:


$cd /Volumes/CyanogenModWorkspace/android/system/vendor/cyanogen/
$./get-rommanager

/Volumes/CyanogenModWorkspace/android/system/vendor/cyanogen/get-rommanager

Building CyanogenMod

Mac OS X 10.7 Shortcomings

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.

Check for updates

First, check for updates in the source:

cd /Volumes/CyanogenModWorkspace/android/system/
repo sync

Configure Build

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

Compile

Now, the ROM must be compiled, from code, for thehero.

cd /Volumes/CyanogenModWorkspace/android/system/
make -j`sysctl -an hw.logicalcpu` bacon

Install

  1. Copy your .zip file from Volumes/CyanogenModWorkspace/android/system/out/target/product/hero/update.cm-XXXXX-signed.zip to the root of the SD card.
    Optional: Download Google Apps for CyanogenMod 7 and place it on the root of the SD card.
  2. Flash both of these .zip files from recovery.

Post Install

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
 类似资料: