Cyanogenmod ROM Sony Xperia U (Kumquat)
ROM
|
Download
|
Stable
|
–
|
Nightly
|
–
|
ROM
|
Download
|
Stable
|
–
|
Nightly
|
–
|
Download (nightly build)
CyanogenMod 14.1 (Android 7.1 (Nougat))
Device | http://www.github.com/cyanogenmod/android_device_sony_huashan |
Kernel | http://www.github.com/cyanogenmod/android_kernel_sony_msm8960t |
Codename: | huashan |
---|---|
Vendor: | Sony |
Release date: | 2013 April |
Type: | phone |
GSM freq: | HSDPA 850 / 900 / 1700 / 1900 / 2100 |
LTE freq: | LTE 800 / 850 / 900 / 1800 / 2100 / 2600 |
Platform: | Qualcomm Snapdragon S4 Pro MSM8960T |
CPU: | 1.7 GHz dual-core Krait |
GPU: | Adreno 320 |
RAM: | 1GB |
Weight: | 144 g (5.47 oz) |
Dimensions: | 133 mm (h) 68 mm (w) 10.6 mm (d) |
Screen size: | 116.0 mm (4.6 in) |
Resolution: | 720×1280 |
Screen density: | 323 ppi |
Screen type: | TFT |
Internal storage: | 8GB |
SD Card: | officially up to 32GB |
Bluetooth: | Bluetooth 4.0 + A2DP |
Wi-Fi: | 802.11 2.4GHz b/g/n 5GHz |
Main camera: | 8MP f/2.4, flash: LED |
Secondary camera: | VGA |
Power: | Non-removable 2370 mAh |
Peripherals: | Wi-Fi Direct, Wi-Fi Display, Wi-Fi Hotspot, MHL HDMI, GPS, NFC, Accelerometer, Compass, Gyroscope, Light sensor, Proximity Sensor |
CM supported: | 11, 12.1, 13, 14.1 |
Note: DISCLAIMER
Modifying or replacing your device’s software may void your device’s warranty, lead to data loss, hair loss, financial loss, privacy loss, security breaches, or other damage, and therefore must be done entirely at your own risk. No one affiliated with the CyanogenMod project is responsible for your actions. Good luck.
The first step in putting any custom operating system on your Xperia SP is to unlock the bootloader. A bootloader is the very first program that runs when you turn on your device. The bootloader initializes some hardware and then loads the kernel and ramdisk, and gets the boot process going. If the bootloader is in locked mode, it will ensure that only the stock operating system can run. Since you will be installing your own operating system (CyanogenMod), you need to turn this off.
To unlock your bootloader, you’ll first need a program on your computer called adb. One way to get adb is to download and install the Android SDK (Software Developer Kit) from Google. The SDK is used by app developers when they’re writing programs for Android, and who knows, you may want to write apps someday.
Download the SDK, per the steps on Google’s web page. Then install it by following the specific instructions for your computer.
Note:
Unlocking the bootloader on a Sony device may automatically wipe internal storage; a backup of the sdcard is suggested. It will also irreversibly erase the DRM keys stored in the TA partition of some devices, which will result in the loss of certain proprietary features that may have been included. Check your specific device forum on XDA to learn more.
In order to unlock the bootloader on your Xperia SP you will need to obtain a code from Sony. The following process will help you acquire this code so that you can flash a custom recovery.
*#06#
to obtain the device’s IMEI, IDID or MEID. Save this for later use.
fastboot getvar version
fastboot oem unlock 0xKEY
The Xperia SP’s bootloader should now be unlocked.
boot.img
from the zip to your computer, you will need this file for fastboot.fastboot flash boot boot.img
fastboot reboot
adb backup -apk -all -f backup20161224.ab
adb sideload update.zip
, where update.zip
should be replaced with the package filename. If you are installing multiple packages, install CyanogenMod first and then install any subsequent packages on top of it. The installer does not necessarily display an “Install complete.” message. You can tell the install is complete if there were no fatal error messages and you have regained control over the menu.Note:
On all 2011 model Sony devices, the kernel will not update when flashed in recovery, so the kernel must be updated via fastboot every time you flash a new build of CyanogenMod.
/storage/sdcard0
as a mountable volume, go ahead and mount it. If you do not see this directory, then instead mount the /data
directory. Take note of which volume you mounted. Now, push the package(s) to your device:adb push update.zip /storage/sdcard0/
adb push update.zip /sdcard/0/
update.zip
should be replaced with the package filename. Go back to the main menu and select install zip. Choose to install from the same directory where you pushed the package(s). If you are installing multiple packages, install CyanogenMod first and then install any subsequent packages on top of it.Note:
On all 2011 model Sony devices, the kernel will not update when flashed in recovery, so the kernel must be updated via fastboot every time you flash a new build of CyanogenMod.
Helpful Tip
These instructions will hopefully assist you to start with a stock Xperia SP, unlock the bootloader (if necessary), and then download the required tools as well as the very latest source code for CyanogenMod (based on Google’s Android operating system). Using these, you can build both CyanogenMod and CyanogenMod Recovery image from source code, and then install them both to your device.
It is difficult to say how much experience is necessary to follow these instructions. While this guide is certainly not for the very very very uninitiated, these steps shouldn’t require a PhD in software development either. Some readers will have no difficulty and breeze through the steps easily. Others may struggle over the most basic operation. Because people’s experiences, backgrounds, and intuitions differ, it may be a good idea to read through just to ascertain whether you feel comfortable or are getting over your head.
Remember, you assume all risk of trying this, but you will reap the rewards! It’s pretty satisfying to boot into a fresh operating system you baked at home :) And once you’re an Android-building ninja, there will be no more need to wait for “nightly” builds from anyone. You will have at your fingertips the skills to build a full operating system from code to a running device, whenever you want. Where you go from there– maybe you’ll add a feature, fix a bug, add a translation, or use what you’ve learned to build a new app or port to a new device– or maybe you’ll never build again– it’s all really up to you.
cd
for “change directory”, the concept of directory hierarchies, that in Linux they are separated by /
, etc.If you are not accustomed to using Linux– this is an excellent chance to learn. It’s free– just download and run a virtual machine (VM) such as Virtualbox, then install a Linux distribution such as Ubuntu (AOSP vets Ubuntu as well). Any recent 64-bit version should work great, but the latest is recommended.
Note:
You want to use a 64-bit version of Linux. A 32-bit Linux environment will only work if you are building CyanogenMod 6 and older. For CyanogenMod 10.1, if you encounter issues with 64bit host binaries, you can set BUILD_HOST_32bit=1
in your environment. This is generally not needed, though, especially with CyanogenMod 10.2 and newer.
Using a VM allows Linux to run as a guest inside your host computer– a computer in a computer, if you will. If you hate Linux for whatever reason, you can always just uninstall and delete the whole thing. (There are plenty of places to find instructions for setting up Virtualbox with Ubuntu, so I’ll leave it to you to do that.)
So let’s begin!
Note:
You only need to do these steps the first time you build. If you previously prepared your build environment and have downloaded the CyanogenMod source code for another device, skip to Prepare the device-specific code.
Helpful Tip
While the SDK contains lots of different things– the two tools you are most interested in for building Android are adb and fastboot, located in the /platform-tools
directory.
Several “build packages” are needed to build CyanogenMod. You can install these using the package manager of your choice.
Helpful Tip
A package manager in Linux is a system used to install or remove software (usually originating from the Internet) on your computer. With Ubuntu, you can use the Ubuntu Software Center. Even better, you may also use the apt-get install
command directly in the Terminal. (Learn more about the apt packaging tool system from Wikipedia.)
For both 32-bit & 64-bit systems, you’ll need:
bc bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop maven openjdk-7-jdk pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev
In addition to the above, for 64-bit systems, get these:
g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev
For Ubuntu 15.10 (wily) and newer, substitute:
lib32readline-gplv2-dev
→ lib32readline6-dev
For Ubuntu 16.04 (xenial) and newer, substitute (additionally see java notes below):
libwxgtk2.8-dev
→ libwxgtk3.0-dev
openjdk-7-jdk
→ openjdk-8-jdk
Java versions: Different versions of CyanogenMod require different versions of the JDK (Java Development Kit):
Ubuntu 16.04 (Xenial Xerus) or newer and OpenJDK: Since OpenJDK 1.7 was removed from the official Ubuntu repositories, you have a couple options:
$HOME/.bashrc
file: export EXPERIMENTAL_USE_JAVA8=true
.Also see http://source.android.com/source/initializing.html which lists needed packages.
You will need to set up some directories in your build environment.
To create them:
$ mkdir -p ~/bin
$ mkdir -p ~/android/system
repo
commandEnter the following to download the “repo” binary and make it executable (runnable):
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
~/bin
directory in your path of executionIn recent versions of Ubuntu, ~/bin
should already be in your PATH. You can check this by opening ~/.profile
with a text editor and verifying the following code exists (add it if it is missing):
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
Enter the following to initialize the repository:
$ cd ~/android/system/
$ repo init -u https://github.com/CyanogenMod/android.git -b cm-13.0
To start the download of all the source code to your computer:
$ repo sync
The CM manifests include a sensible default configuration for repo
, which we strongly suggest you use (i.e. don’t add any options to sync
). For reference, our default values are -j 4
and -c
. The -j 4
part means that there will be four simultaneous threads/connections. If you experience problems syncing, you can lower this to -j 3
or -j 2
. -c
will ask repo to pull in only the current branch, instead of the entire CM history.
Prepare to wait a long time while the source code downloads.
Helpful Tip
The repo sync
command is used to update the latest source code from CyanogenMod and Google. Remember it, as you can do it every few days to keep your code base fresh and up-to-date.
Next,
$ cd ~/android/system/vendor/cm
then enter:
$ ./get-prebuilts
You won’t see any confirmation- just another prompt. But this should cause some prebuilt apps to be loaded and installed into the source code. Once completed, this does not need to be done again.
Helpful Tip – Errors during breakfast
Different maintainers setup their device inheritance rules differently. Some require a vendor directory to be populated before breakfast will even succeed. If you receive an error here about vendor makefiles, then jump down to the next section Extract proprietary blobs. The first portion of breakfast should have succeeded at pulling in the device tree and the extract blobs script should be available. After completing that section, you can rerun breakfast huashan
After the source downloads, ensure you are in the root of the source code (cd ~/android/system
), then type:
$ source build/envsetup.sh
$ breakfast huashan
This will download the device specific configuration and kernel source for your device. An alternative to using the breakfast
command is to build your own local manifest. To do this, you will need to locate your device on CyanogenMod’s GitHub and list all of the repositories defined in cm.dependencies in your local manifest.
Helpful Tip
If you want to know more about what source build/envsetup.sh
does or simply want to know more about the breakfast
, brunch
and lunch
commands, you can head over to the Envsetup help page.
Helpful Tip
Instead of typing cd ~/android/system
every time you want to return back to the root of the source code, here’s a short command that will do it for you: croot
. To use this command, you must first run source build/envsetup.sh
from ~/android/system
.
Now ensure that your Xperia SP is connected to your computer via the USB cable and that you are in the ~/android/system/device/sony/huashan
directory (you can cd ~/android/system/device/sony/huashan
if necessary). Then run the extract-files.sh
script:
$ ./extract-files.sh
You should see the proprietary files (aka “blobs”) get pulled from the device and moved to the ~/android/system/vendor/sony
directory. If you see errors about adb being unable to pull the files, adb may not be in the path of execution. If this is the case, see the adb page for suggestions for dealing with “command not found” errors.
Note:
Your device should already be running a build of CyanogenMod for the branch you wish to build for the extract-files.sh
script to function properly.
Note:
It’s important that these proprietary files are extracted to the ~/android/system/vendor/sony
directory by using the extract-files.sh
script. Makefiles are generated at the same time to make sure the blobs are eventually copied to the device. Without these blobs, CyanogenMod may build without error, but you’ll be missing important functionality, such as graphics libraries that enable you to see anything!
You can speed up subsequent builds by adding
export USE_CCACHE=1
to your ~/.bashrc
file (what’s a .bashrc file?). Then, specify the amount of disk space to dedicate to ccache by typing this from the top of your Android tree:
prebuilts/misc/linux-x86/ccache/ccache -M 50G
where 50G
corresponds to 50GB of cache. This only needs to be run once and the setting will be remembered. Anywhere in the range of 25GB to 100GB will result in very noticeably increased build speeds (for instance, a typical 1hr build time can be reduced to 20min). If you’re only building for one device, 25GB-50GB is fine. If you plan to build for several devices that do not share the same kernel source, aim for 75GB-100GB. This space will be permanently occupied on your drive, so take this into consideration. See more information about ccache on Google’s android build environment initialization page.
Helpful Tip
If you are a very active developer, working on many other projects than just Android, you might prefer to keep your Android ccache independent (because it’s huge and can slow down the efficiency of ccache in your other projects). Beginning with CyanogenMod 12.1, you can specify environment variables for the location and size of CyanogenMod’s ccache. Some syntax examples: export ANDROID_CCACHE_DIR="$HOME/android/.ccache"
and export ANDROID_CCACHE_SIZE="50G"
.
Time to start building! So now type:
$ croot
$ brunch huashan
The build should begin.
Helpful Tip
If the build doesn’t start, try lunch
and choose your device from the menu. If that doesn’t work, try breakfast
and choose from the menu. The command make huashan
should then work.
Helpful Tip
A second, bonus tip! If you get a command not found error for croot
, brunch
, or lunch
, be sure you’ve done the source build/envsetup.sh
command in this Terminal session from the ~/android/system
directory.
Helpful Tip
A third tip! If the build to fails while downloading Gello, you’ll need to import a missing certificate into Maven’s truststore. Detailed instructions on how to do that can be found here
ERROR: signapk.jar failed: return code 1make: *** [out/target/product/huashan/cm_huashan-ota-eng.root.zip] Error 1
…you may want to make the following change to ~/android/system/build/tools/releasetools/common.py
:
Search for instances of -Xmx2048m
(it should appear either under OPTIONS.java_args
or near usage of signapk.jar
), and replace it with -Xmx1024m
or -Xmx512m
.
Then start the build again (with brunch).
Assuming the build completed without error (it will be obvious when it finishes), type:
$ cd $OUT
in the same terminal window that you did the build. Here you’ll find all the files that were created. The stuff that will go in /system
is in a folder called system
. The stuff that will become your ramdisk is in a folder called root
. And your kernel is called… kernel
.
But that’s all just background info. The two files we are interested in are (1) recovery.img
, which contains CyanogenMod Recovery, and (2) cm-13.0-20161224-UNOFFICIAL-huashan.zip
, which is the CyanogenMod installation package.
Back to the $OUT
directory on your computer– you should see a file that looks something like:
cm-13.0-20161224-UNOFFICIAL-huashan.zip
Note:
The above file name may vary depending on the version of CM you are building. Your build may not include a version number or may identify itself as a “KANG
” rather than UNOFFICIAL
version. Regardless, the file name will end in .zip
and should be titled similarly to official builds.
Now you can flash the cm...zip
file above as usual via recovery mode. Before doing so, now is a good time to make a backup of whatever installation is currently running on the device in case something goes wrong with the flash attempt. While CyanogenMod Recovery doesn’t have a backup feature, there are other custom recoveries available that do. You can also use something like Titanium Backup (root required) as an alternative.
You’ve done it! Welcome to the elite club of self-builders. You’ve built your operating system from scratch, from the ground up. You are the master/mistress of your domain… and hopefully you’ve learned a bit on the way and had some fun too.
Now that you’ve succeeded in building CyanogenMod for your device, here are some suggestions on what to do next.
Also, be sure to take a glance at the Dev Center on this wiki for all kinds of more detailed information about developer topics ranging from collecting logs, understanding what’s in the source code directories, submitting your own contributions, porting CyanogenMod to new devices, and a lot more.
Congrats again!
Content of this page is based on informations from wiki.cyanogenmod.org, under CC BY-SA 3.0 licence.
Download (nightly build)
CyanogenMod 12.1 (Android 5.1 (Lollipop))
Device | http://www.github.com/cyanogenmod/android_device_sony_amami |
Kernel | http://www.github.com/cyanogenmod/android_kernel_sony_msm8974 |
Codename: | amami |
---|---|
Also known as: | D5503 |
Vendor: | Sony |
Manufacturer: | Sony |
Release date: | 2014 January 24 |
Type: | phone |
GSM freq: | 850, 900, 1800, 1900 MHz. UMTS/HSPA+: 850, 900, 1700, 1900, 2100 MHz |
LTE freq: | 800, 850, 900, 1700, 1800, 1900, 2100, 2600 MHz |
Platform: | Qualcomm MSM8974 |
CPU: | 2.2 GHz quad-core Qualcomm Snapdragon 800 |
GPU: | Adreno 330 |
RAM: | 2GB |
Weight: | 137 g |
Dimensions: | 127.0 x 64.9 x 9.5 mm |
Screen size: | 109 mm (4.3 in) |
Resolution: | 1280×720 |
Screen density: | 342 ppi |
Screen type: | IPS LCD |
Internal storage: | 16GB |
SD Card: | microSDXC (currently up to 128GB) |
Bluetooth: | Bluetooth 4.0 |
Wi-Fi: | 802.11a/b/g/n/ac |
Main camera: | 20.7 MP w/ LED flash |
Secondary camera: | 2 MP |
Power: | 2300 mAh |
Peripherals: | light sensor, proximity sensor, accelerometer, compass, gyroscope, NFC |
CM supported: | 11, 12, 12.1 |
Note: DISCLAIMER
Modifying or replacing your device’s software may void your device’s warranty, lead to data loss, hair loss, financial loss, privacy loss, security breaches, or other damage, and therefore must be done entirely at your own risk. No one affiliated with the CyanogenMod project is responsible for your actions. Good luck.
The first step in putting any custom operating system on your Xperia Z1 Compact is to unlock the bootloader. A bootloader is the very first program that runs when you turn on your device. The bootloader initializes some hardware and then loads the kernel and ramdisk, and gets the boot process going. If the bootloader is in locked mode, it will ensure that only the stock operating system can run. Since you will be installing your own operating system (CyanogenMod), you need to turn this off.
To unlock your bootloader, you’ll first need a program on your computer called adb. One way to get adb is to download and install the Android SDK (Software Developer Kit) from Google. The SDK is used by app developers when they’re writing programs for Android, and who knows, you may want to write apps someday.
Download the SDK, per the steps on Google’s web page. Then install it by following the specific instructions for your computer.
Note:
Unlocking the bootloader on a Sony device may automatically wipe internal storage; a backup of the sdcard is suggested. It will also irreversibly erase the DRM keys stored in the TA partition of some devices, which will result in the loss of certain proprietary features that may have been included. Check your specific device forum on XDA to learn more.
In order to unlock the bootloader on your Xperia Z1 Compact you will need to obtain a code from Sony. The following process will help you acquire this code so that you can flash a custom recovery.
*#06#
to obtain the device’s IMEI, IDID or MEID. Save this for later use.
fastboot getvar version
fastboot oem unlock 0xKEY
The Xperia Z1 Compact’s bootloader should now be unlocked.
boot.img
from the zip to your computer, you will need this file for fastboot.fastboot flash boot boot.img
fastboot reboot
adb backup -apk -all -f backup20161224.ab
adb sideload update.zip
, where update.zip
should be replaced with the package filename. If you are installing multiple packages, install CyanogenMod first and then install any subsequent packages on top of it. The installer does not necessarily display an “Install complete.” message. You can tell the install is complete if there were no fatal error messages and you have regained control over the menu.Note:
On all 2011 model Sony devices, the kernel will not update when flashed in recovery, so the kernel must be updated via fastboot every time you flash a new build of CyanogenMod.
/storage/sdcard0
as a mountable volume, go ahead and mount it. If you do not see this directory, then instead mount the /data
directory. Take note of which volume you mounted. Now, push the package(s) to your device:adb push update.zip /storage/sdcard0/
adb push update.zip /sdcard/0/
update.zip
should be replaced with the package filename. Go back to the main menu and select install zip. Choose to install from the same directory where you pushed the package(s). If you are installing multiple packages, install CyanogenMod first and then install any subsequent packages on top of it.Note:
On all 2011 model Sony devices, the kernel will not update when flashed in recovery, so the kernel must be updated via fastboot every time you flash a new build of CyanogenMod.
Helpful Tip
These instructions will hopefully assist you to start with a stock Xperia Z1 Compact, unlock the bootloader (if necessary), and then download the required tools as well as the very latest source code for CyanogenMod (based on Google’s Android operating system). Using these, you can build both CyanogenMod and CyanogenMod Recovery image from source code, and then install them both to your device.
It is difficult to say how much experience is necessary to follow these instructions. While this guide is certainly not for the very very very uninitiated, these steps shouldn’t require a PhD in software development either. Some readers will have no difficulty and breeze through the steps easily. Others may struggle over the most basic operation. Because people’s experiences, backgrounds, and intuitions differ, it may be a good idea to read through just to ascertain whether you feel comfortable or are getting over your head.
Remember, you assume all risk of trying this, but you will reap the rewards! It’s pretty satisfying to boot into a fresh operating system you baked at home :) And once you’re an Android-building ninja, there will be no more need to wait for “nightly” builds from anyone. You will have at your fingertips the skills to build a full operating system from code to a running device, whenever you want. Where you go from there– maybe you’ll add a feature, fix a bug, add a translation, or use what you’ve learned to build a new app or port to a new device– or maybe you’ll never build again– it’s all really up to you.
cd
for “change directory”, the concept of directory hierarchies, that in Linux they are separated by /
, etc.If you are not accustomed to using Linux– this is an excellent chance to learn. It’s free– just download and run a virtual machine (VM) such as Virtualbox, then install a Linux distribution such as Ubuntu (AOSP vets Ubuntu as well). Any recent 64-bit version should work great, but the latest is recommended.
Note:
You want to use a 64-bit version of Linux. A 32-bit Linux environment will only work if you are building CyanogenMod 6 and older. For CyanogenMod 10.1, if you encounter issues with 64bit host binaries, you can set BUILD_HOST_32bit=1
in your environment. This is generally not needed, though, especially with CyanogenMod 10.2 and newer.
Using a VM allows Linux to run as a guest inside your host computer– a computer in a computer, if you will. If you hate Linux for whatever reason, you can always just uninstall and delete the whole thing. (There are plenty of places to find instructions for setting up Virtualbox with Ubuntu, so I’ll leave it to you to do that.)
So let’s begin!
Note:
You only need to do these steps the first time you build. If you previously prepared your build environment and have downloaded the CyanogenMod source code for another device, skip to Prepare the device-specific code.
Helpful Tip
While the SDK contains lots of different things– the two tools you are most interested in for building Android are adb and fastboot, located in the /platform-tools
directory.
Several “build packages” are needed to build CyanogenMod. You can install these using the package manager of your choice.
Helpful Tip
A package manager in Linux is a system used to install or remove software (usually originating from the Internet) on your computer. With Ubuntu, you can use the Ubuntu Software Center. Even better, you may also use the apt-get install
command directly in the Terminal. (Learn more about the apt packaging tool system from Wikipedia.)
For both 32-bit & 64-bit systems, you’ll need:
bc bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop maven openjdk-7-jdk pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev
In addition to the above, for 64-bit systems, get these:
g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev
For Ubuntu 15.10 (wily) and newer, substitute:
lib32readline-gplv2-dev
→ lib32readline6-dev
For Ubuntu 16.04 (xenial) and newer, substitute (additionally see java notes below):
libwxgtk2.8-dev
→ libwxgtk3.0-dev
openjdk-7-jdk
→ openjdk-8-jdk
Java versions: Different versions of CyanogenMod require different versions of the JDK (Java Development Kit):
Ubuntu 16.04 (Xenial Xerus) or newer and OpenJDK: Since OpenJDK 1.7 was removed from the official Ubuntu repositories, you have a couple options:
$HOME/.bashrc
file: export EXPERIMENTAL_USE_JAVA8=true
.Also see http://source.android.com/source/initializing.html which lists needed packages.
You will need to set up some directories in your build environment.
To create them:
$ mkdir -p ~/bin
$ mkdir -p ~/android/system
repo
commandEnter the following to download the “repo” binary and make it executable (runnable):
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
~/bin
directory in your path of executionIn recent versions of Ubuntu, ~/bin
should already be in your PATH. You can check this by opening ~/.profile
with a text editor and verifying the following code exists (add it if it is missing):
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
Enter the following to initialize the repository:
$ cd ~/android/system/
$ repo init -u https://github.com/CyanogenMod/android.git -b cm-13.0
To start the download of all the source code to your computer:
$ repo sync
The CM manifests include a sensible default configuration for repo
, which we strongly suggest you use (i.e. don’t add any options to sync
). For reference, our default values are -j 4
and -c
. The -j 4
part means that there will be four simultaneous threads/connections. If you experience problems syncing, you can lower this to -j 3
or -j 2
. -c
will ask repo to pull in only the current branch, instead of the entire CM history.
Prepare to wait a long time while the source code downloads.
Helpful Tip
The repo sync
command is used to update the latest source code from CyanogenMod and Google. Remember it, as you can do it every few days to keep your code base fresh and up-to-date.
Next,
$ cd ~/android/system/vendor/cm
then enter:
$ ./get-prebuilts
You won’t see any confirmation- just another prompt. But this should cause some prebuilt apps to be loaded and installed into the source code. Once completed, this does not need to be done again.
Helpful Tip – Errors during breakfast
Different maintainers setup their device inheritance rules differently. Some require a vendor directory to be populated before breakfast will even succeed. If you receive an error here about vendor makefiles, then jump down to the next section Extract proprietary blobs. The first portion of breakfast should have succeeded at pulling in the device tree and the extract blobs script should be available. After completing that section, you can rerun breakfast amami
After the source downloads, ensure you are in the root of the source code (cd ~/android/system
), then type:
$ source build/envsetup.sh
$ breakfast amami
This will download the device specific configuration and kernel source for your device. An alternative to using the breakfast
command is to build your own local manifest. To do this, you will need to locate your device on CyanogenMod’s GitHub and list all of the repositories defined in cm.dependencies in your local manifest.
Helpful Tip
If you want to know more about what source build/envsetup.sh
does or simply want to know more about the breakfast
, brunch
and lunch
commands, you can head over to the Envsetup help page.
Helpful Tip
Instead of typing cd ~/android/system
every time you want to return back to the root of the source code, here’s a short command that will do it for you: croot
. To use this command, you must first run source build/envsetup.sh
from ~/android/system
.
Now ensure that your Xperia Z1 Compact is connected to your computer via the USB cable and that you are in the ~/android/system/device/sony/amami
directory (you can cd ~/android/system/device/sony/amami
if necessary). Then run the extract-files.sh
script:
$ ./extract-files.sh
You should see the proprietary files (aka “blobs”) get pulled from the device and moved to the ~/android/system/vendor/sony
directory. If you see errors about adb being unable to pull the files, adb may not be in the path of execution. If this is the case, see the adb page for suggestions for dealing with “command not found” errors.
Note:
Your device should already be running a build of CyanogenMod for the branch you wish to build for the extract-files.sh
script to function properly.
Note:
It’s important that these proprietary files are extracted to the ~/android/system/vendor/sony
directory by using the extract-files.sh
script. Makefiles are generated at the same time to make sure the blobs are eventually copied to the device. Without these blobs, CyanogenMod may build without error, but you’ll be missing important functionality, such as graphics libraries that enable you to see anything!
You can speed up subsequent builds by adding
export USE_CCACHE=1
to your ~/.bashrc
file (what’s a .bashrc file?). Then, specify the amount of disk space to dedicate to ccache by typing this from the top of your Android tree:
prebuilts/misc/linux-x86/ccache/ccache -M 50G
where 50G
corresponds to 50GB of cache. This only needs to be run once and the setting will be remembered. Anywhere in the range of 25GB to 100GB will result in very noticeably increased build speeds (for instance, a typical 1hr build time can be reduced to 20min). If you’re only building for one device, 25GB-50GB is fine. If you plan to build for several devices that do not share the same kernel source, aim for 75GB-100GB. This space will be permanently occupied on your drive, so take this into consideration. See more information about ccache on Google’s android build environment initialization page.
Helpful Tip
If you are a very active developer, working on many other projects than just Android, you might prefer to keep your Android ccache independent (because it’s huge and can slow down the efficiency of ccache in your other projects). Beginning with CyanogenMod 12.1, you can specify environment variables for the location and size of CyanogenMod’s ccache. Some syntax examples: export ANDROID_CCACHE_DIR="$HOME/android/.ccache"
and export ANDROID_CCACHE_SIZE="50G"
.
Time to start building! So now type:
$ croot
$ brunch amami
The build should begin.
Helpful Tip
If the build doesn’t start, try lunch
and choose your device from the menu. If that doesn’t work, try breakfast
and choose from the menu. The command make amami
should then work.
Helpful Tip
A second, bonus tip! If you get a command not found error for croot
, brunch
, or lunch
, be sure you’ve done the source build/envsetup.sh
command in this Terminal session from the ~/android/system
directory.
Helpful Tip
A third tip! If the build to fails while downloading Gello, you’ll need to import a missing certificate into Maven’s truststore. Detailed instructions on how to do that can be found here
ERROR: signapk.jar failed: return code 1make: *** [out/target/product/amami/cm_amami-ota-eng.root.zip] Error 1
…you may want to make the following change to ~/android/system/build/tools/releasetools/common.py
:
Search for instances of -Xmx2048m
(it should appear either under OPTIONS.java_args
or near usage of signapk.jar
), and replace it with -Xmx1024m
or -Xmx512m
.
Then start the build again (with brunch).
Assuming the build completed without error (it will be obvious when it finishes), type:
$ cd $OUT
in the same terminal window that you did the build. Here you’ll find all the files that were created. The stuff that will go in /system
is in a folder called system
. The stuff that will become your ramdisk is in a folder called root
. And your kernel is called… kernel
.
But that’s all just background info. The two files we are interested in are (1) recovery.img
, which contains CyanogenMod Recovery, and (2) cm-13.0-20161224-UNOFFICIAL-amami.zip
, which is the CyanogenMod installation package.
Back to the $OUT
directory on your computer– you should see a file that looks something like:
cm-13.0-20161224-UNOFFICIAL-amami.zip
Note:
The above file name may vary depending on the version of CM you are building. Your build may not include a version number or may identify itself as a “KANG
” rather than UNOFFICIAL
version. Regardless, the file name will end in .zip
and should be titled similarly to official builds.
Now you can flash the cm...zip
file above as usual via recovery mode. Before doing so, now is a good time to make a backup of whatever installation is currently running on the device in case something goes wrong with the flash attempt. While CyanogenMod Recovery doesn’t have a backup feature, there are other custom recoveries available that do. You can also use something like Titanium Backup (root required) as an alternative.
You’ve done it! Welcome to the elite club of self-builders. You’ve built your operating system from scratch, from the ground up. You are the master/mistress of your domain… and hopefully you’ve learned a bit on the way and had some fun too.
Now that you’ve succeeded in building CyanogenMod for your device, here are some suggestions on what to do next.
Also, be sure to take a glance at the Dev Center on this wiki for all kinds of more detailed information about developer topics ranging from collecting logs, understanding what’s in the source code directories, submitting your own contributions, porting CyanogenMod to new devices, and a lot more.
Congrats again!
Content of this page is based on informations from wiki.cyanogenmod.org, under CC BY-SA 3.0 licence.
Download (nightly build)
CyanogenMod 7 (Android 2.3 (Gingerbread))
Note: Support Status
This device does not support the latest official release of CyanogenMod. This may be due to hardware limitations or simply because development is ongoing. The most recent version supported is based on the gingerbread branch of CyanogenMod.
gen 2 only!
Device | http://www.github.com/cyanogenmod/android_device_zte_v9 |
Codename: | v9 |
---|---|
Vendor: | ZTE |
Type: | tablet |
GSM freq: | Quad band GSM 850 900 1800 1900 MHz GPRS/EDGE HSDPA/HSUPA |
Platform: | Qualcomm MSM7227 |
CPU: | 600 MHz single-core Qualcomm MSM7227-1 |
GPU: | Qualcomm Adreno 200 |
RAM: | 512MB |
Weight: | 403 g (14.2 oz) |
Dimensions: | 192 mm (7.56 in) (h)
110 mm (4.33 in) (w) |
Screen size: | 178 mm (7.0 in) |
Resolution: | 480×800 |
Screen type: | TFT LCD |
Internal storage: | 512 MB |
SD Card: | up to 32GB |
Bluetooth: | Bluetooth 2.1+EDR |
Wi-Fi: | 802.11b/g |
Main camera: | 3.5 megapixel |
Power: | 3400 mAh internal rechargeable removable lithium-ion battery |
Peripherals: | microUSB, A-GPS, FM Radio resistive touchscreen, headset controls, ambient light sensors, 3-axis accelerometer, digital compass |
CM supported: | 7 |
Latest CM version: | gingerbread |
Note: DISCLAIMER
Modifying or replacing your device’s software may void your device’s warranty, lead to data loss, hair loss, financial loss, privacy loss, security breaches, or other damage, and therefore must be done entirely at your own risk. No one affiliated with the CyanogenMod project is responsible for your actions. Good luck.
adb push rageagainstthecage-arm5.bin /data/local/tmp/
adb shell
chmod 755 /data/local/tmp/rageagainstthecage-arm5.bin
/data/local/tmp/rageagainstthecage-arm5.bin
exit
adb kill-server
adb start-server
adb shell
mount -o rw,remount /system
exit
adb push su /system/xbin/
adb shell chmod 4755 /system/xbin/su
adb push Superuser.apk /system/app/
/storage/sdcard0
or /sdcard
as a mountable volume, go ahead and mount it. If you do not see one of these partitions, then instead mount the /data
partition. Take note of which volume you mounted. Now, push the package(s) to your device (also, see tip below):adb push update.zip /storage/sdcard0/
adb push update.zip /sdcard/
update.zip
should be replaced with the package filename. Go back to the main menu and select install zip. Choose to install from the same directory where you pushed the package(s). If you are installing multiple packages, install CyanogenMod first and then install any subsequent packages on top of it.Helpful Tip – SD card folders
CyanogenMod 10.1 and newer have multi-user support (introduced in Android 4.2). If your device has storage on the /data partition, then Android actually looks in /data/media/0/ for the first user’s /sdcard/ storage. ClockworkMod recovery symlinks /sdcard/ to /data/media/ though. So, if you are pushing files to internal storage in recovery and want them to be visible in Android, you should push them to /sdcard/0/ or /data/media/0/. Here’s the most frequent scenarios:
adb push update.zip /sdcard/
adb shell "mkdir /sdcard/0/"
followed by adb push update.zip /sdcard/0/
adb push update.zip /sdcard/0/
These instructions will hopefully assist you to start with a stock v9, unlock the bootloader (if necessary), and then download the required tools as well as the very latest source code for CyanogenMod (based on Google’s Android operating system). Using these, you can build both CyanogenMod and CyanogenMod Recovery image from source code, and then install them both to your device.
It is difficult to say how much experience is necessary to follow these instructions. While this guide is certainly not for the very very very uninitiated, these steps shouldn’t require a PhD in software development either. Some readers will have no difficulty and breeze through the steps easily. Others may struggle over the most basic operation. Because people’s experiences, backgrounds, and intuitions differ, it may be a good idea to read through just to ascertain whether you feel comfortable or are getting over your head.
Remember, you assume all risk of trying this, but you will reap the rewards! It’s pretty satisfying to boot into a fresh operating system you baked at home :) And once you’re an Android-building ninja, there will be no more need to wait for “nightly” builds from anyone. You will have at your fingertips the skills to build a full operating system from code to a running device, whenever you want. Where you go from there– maybe you’ll add a feature, fix a bug, add a translation, or use what you’ve learned to build a new app or port to a new device– or maybe you’ll never build again– it’s all really up to you.
cd
for “change directory”, the concept of directory hierarchies, that in Linux they are separated by /
, etc.If you are not accustomed to using Linux– this is an excellent chance to learn. It’s free– just download and run a virtual machine (VM) such as Virtualbox, then install a Linux distribution such as Ubuntu (AOSP vets Ubuntu as well). Any recent 64-bit version should work great, but the latest is recommended.
Note:
You want to use a 64-bit version of Linux. A 32-bit Linux environment will only work if you are building CyanogenMod 6 and older. For CyanogenMod 10.1, if you encounter issues with 64bit host binaries, you can set BUILD_HOST_32bit=1
in your environment. This is generally not needed, though, especially with CyanogenMod 10.2 and newer.
Using a VM allows Linux to run as a guest inside your host computer– a computer in a computer, if you will. If you hate Linux for whatever reason, you can always just uninstall and delete the whole thing. (There are plenty of places to find instructions for setting up Virtualbox with Ubuntu, so I’ll leave it to you to do that.)
So let’s begin!
Note:
You only need to do these steps the first time you build. If you previously prepared your build environment and have downloaded the CyanogenMod source code for another device, skip to Prepare the device-specific code.
Helpful Tip
While the SDK contains lots of different things– the two tools you are most interested in for building Android are adb and fastboot, located in the /platform-tools
directory.
Several “build packages” are needed to build CyanogenMod. You can install these using the package manager of your choice.
Helpful Tip
A package manager in Linux is a system used to install or remove software (usually originating from the Internet) on your computer. With Ubuntu, you can use the Ubuntu Software Center. Even better, you may also use the apt-get install
command directly in the Terminal. (Learn more about the apt packaging tool system from Wikipedia.)
For both 32-bit & 64-bit systems, you’ll need:
bc bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop maven openjdk-7-jdk pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev
In addition to the above, for 64-bit systems, get these:
g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev
For Ubuntu 15.10 (wily) and newer, substitute:
lib32readline-gplv2-dev
→ lib32readline6-dev
For Ubuntu 16.04 (xenial) and newer, substitute (additionally see java notes below):
libwxgtk2.8-dev
→ libwxgtk3.0-dev
openjdk-7-jdk
→ openjdk-8-jdk
Java versions: Different versions of CyanogenMod require different versions of the JDK (Java Development Kit):
Ubuntu 16.04 (Xenial Xerus) or newer and OpenJDK: Since OpenJDK 1.7 was removed from the official Ubuntu repositories, you have a couple options:
$HOME/.bashrc
file: export EXPERIMENTAL_USE_JAVA8=true
.Also see http://source.android.com/source/initializing.html which lists needed packages.
You will need to set up some directories in your build environment.
To create them:
$ mkdir -p ~/bin
$ mkdir -p ~/android/system
repo
commandEnter the following to download the “repo” binary and make it executable (runnable):
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
~/bin
directory in your path of executionIn recent versions of Ubuntu, ~/bin
should already be in your PATH. You can check this by opening ~/.profile
with a text editor and verifying the following code exists (add it if it is missing):
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
Enter the following to initialize the repository:
$ cd ~/android/system/
$ repo init -u https://github.com/CyanogenMod/android.git -b gingerbread
To start the download of all the source code to your computer:
$ repo sync
The CM manifests include a sensible default configuration for repo
, which we strongly suggest you use (i.e. don’t add any options to sync
). For reference, our default values are -j 4
and -c
. The -j 4
part means that there will be four simultaneous threads/connections. If you experience problems syncing, you can lower this to -j 3
or -j 2
. -c
will ask repo to pull in only the current branch, instead of the entire CM history.
Prepare to wait a long time while the source code downloads.
Helpful Tip
The repo sync
command is used to update the latest source code from CyanogenMod and Google. Remember it, as you can do it every few days to keep your code base fresh and up-to-date.
$ cd ~/android/system/vendor/cyanogen
then enter:
$ ./get-rommanager
You won’t see any confirmation- just another prompt. But this should cause the Rom Manager apps to be loaded and installed into the source code. Once completed, this does not need to be done again.
After the source downloads, ensure you are in the root of the source code (cd ~/android/system
), then type:
$ source build/envsetup.sh
$ lunch
You should see a list of devices, including something like cm_v9-userdebug
. Select it by typing its number. It is possible that lunch
does not display your device. In that case try
$ lunch cm_v9-userdebug
or
$ lunch full_v9-userdebug
If all goes well, you should see that v9-specific directories are downloaded automatically.
Helpful Tip
If you want to know more about what source build/envsetup.sh
does or simply want to know more about the breakfast
, brunch
and lunch
commands, you can head over to the Envsetup help page.
Helpful Tip
Instead of typing cd ~/android/system
every time you want to return back to the root of the source code, here’s a short command that will do it for you: croot
. To use this command, you must first run source build/envsetup.sh
from ~/android/system
.
Now ensure that your v9 is connected to your computer via the USB cable and that you are in the ~/android/system/device/zte/v9
directory (you can cd ~/android/system/device/zte/v9
if necessary). Then run the extract-files.sh
script:
$ ./extract-files.sh
You should see the proprietary files (aka “blobs”) get pulled from the device and moved to the ~/android/system/vendor/zte
directory. If you see errors about adb being unable to pull the files, adb may not be in the path of execution. If this is the case, see the adb page for suggestions for dealing with “command not found” errors.
Note:
Your device should already be running a build of CyanogenMod for the branch you wish to build for the extract-files.sh
script to function properly.
Note:
It’s important that these proprietary files are extracted to the ~/android/system/vendor/zte
directory by using the extract-files.sh
script. Makefiles are generated at the same time to make sure the blobs are eventually copied to the device. Without these blobs, CyanogenMod may build without error, but you’ll be missing important functionality, such as graphics libraries that enable you to see anything!
You can speed up subsequent builds by adding
export USE_CCACHE=1
to your ~/.bashrc
file (what’s a .bashrc file?). Then, specify the amount of disk space to dedicate to ccache by typing this from the top of your Android tree:
prebuilt/linux-x86/ccache/ccache -M 50G
where 50G
corresponds to 50GB of cache. This only needs to be run once and the setting will be remembered. Anywhere in the range of 25GB to 100GB will result in very noticeably increased build speeds (for instance, a typical 1hr build time can be reduced to 20min). If you’re only building for one device, 25GB-50GB is fine. If you plan to build for several devices that do not share the same kernel source, aim for 75GB-100GB. This space will be permanently occupied on your drive, so take this into consideration. See more information about ccache on Google’s android build environment initialization page.
Helpful Tip
If you are a very active developer, working on many other projects than just Android, you might prefer to keep your Android ccache independent (because it’s huge and can slow down the efficiency of ccache in your other projects). Beginning with CyanogenMod 12.1, you can specify environment variables for the location and size of CyanogenMod’s ccache. Some syntax examples: export ANDROID_CCACHE_DIR="$HOME/android/.ccache"
and export ANDROID_CCACHE_SIZE="50G"
.
Time to start building! So now type:
$ croot
$ brunch v9
The build should begin.
Helpful Tip
If the build doesn’t start, try lunch
and choose your device from the menu. If that doesn’t work, try breakfast
and choose from the menu. The command make v9
should then work.
Helpful Tip
A second, bonus tip! If you get a command not found error for croot
, brunch
, or lunch
, be sure you’ve done the source build/envsetup.sh
command in this Terminal session from the ~/android/system
directory.
Helpful Tip
A third tip! If the build to fails while downloading Gello, you’ll need to import a missing certificate into Maven’s truststore. Detailed instructions on how to do that can be found here
ERROR: signapk.jar failed: return code 1make: *** [out/target/product/v9/cm_v9-ota-eng.root.zip] Error 1
…you may want to make the following change to ~/android/system/build/tools/releasetools/common.py
:
Search for instances of -Xmx2048m
(it should appear either under OPTIONS.java_args
or near usage of signapk.jar
), and replace it with -Xmx1024m
or -Xmx512m
.
Then start the build again (with brunch).
Assuming the build completed without error (it will be obvious when it finishes), type:
$ cd $OUT
in the same terminal window that you did the build. Here you’ll find all the files that were created. The stuff that will go in /system
is in a folder called system
. The stuff that will become your ramdisk is in a folder called root
. And your kernel is called… kernel
.
But that’s all just background info. The two files we are interested in are (1) recovery.img
, which contains CyanogenMod Recovery, and (2) cm-7-20161224-UNOFFICIAL-v9.zip
, which is the CyanogenMod installation package.
Back to the $OUT
directory on your computer– you should see a file that looks something like:
cm-7-20161224-UNOFFICIAL-v9.zip
Note:
The above file name may vary depending on the version of CM you are building. Your build may not include a version number or may identify itself as a “KANG
” rather than UNOFFICIAL
version. Regardless, the file name will end in .zip
and should be titled similarly to official builds.
Now you can flash the cm...zip
file above as usual via recovery mode. Before doing so, now is a good time to make a backup of whatever installation is currently running on the device in case something goes wrong with the flash attempt. While CyanogenMod Recovery doesn’t have a backup feature, there are other custom recoveries available that do. You can also use something like Titanium Backup (root required) as an alternative.
You’ve done it! Welcome to the elite club of self-builders. You’ve built your operating system from scratch, from the ground up. You are the master/mistress of your domain… and hopefully you’ve learned a bit on the way and had some fun too.
Now that you’ve succeeded in building CyanogenMod for your device, here are some suggestions on what to do next.
Also, be sure to take a glance at the Dev Center on this wiki for all kinds of more detailed information about developer topics ranging from collecting logs, understanding what’s in the source code directories, submitting your own contributions, porting CyanogenMod to new devices, and a lot more.
Congrats again!
Content of this page is based on informations from wiki.cyanogenmod.org, under CC BY-SA 3.0 licence.
Download (nightly build)
CyanogenMod 13.0 (Android 6.0/6.0.1 (Marshmallow))
Device | http://www.github.com/cyanogenmod/android_device_samsung_serranoltexx |
Kernel | http://www.github.com/cyanogenmod/android_kernel_samsung_msm8930-common |
Codename: | serranoltexx |
---|---|
Also known as: | GT-I9195 |
Vendor: | Samsung |
Release date: | 2013 July |
Type: | phone |
GSM freq: | EDGE / GPRS Class 33 / GSM Quad Band (850 / 900 / 1,800 / 1,900MHz) 3G (850 / 900 / 1,900 / 2,100MHz) |
LTE freq: | LTE Band 3 (1,800MHz), Band 7 (2,600MHz), Band 8 (900MHz), Band 20 (800MHz) |
Platform: | Qualcomm Snapdragon 400 |
CPU: | 1.7 GHz dual-core Krait |
GPU: | Adreno 305 |
RAM: | 1.5GB |
Weight: | 107g |
Dimensions: | 124.6 x 61.3 x 8.9 mm |
Screen size: | 109 mm (4.3 in) |
Resolution: | 960×540 |
Screen density: | 256 ppi |
Screen type: | Super AMOLED |
Internal storage: | 8GB |
SD Card: | up to 64GB |
Bluetooth: | v4.0 with A2DP, LE, EDR |
Wi-Fi: | 802.11 a/b/g/n, dual-band, DLNA, Wi-Fi Direct, Wi-Fi hotspot |
Main camera: | 8 MP, 1080p Full HD Video Recording @ 30fps, flash: LED |
Secondary camera: | 1.9 MP 720p HD Video Recording @ 30fps |
Power: | 1900 mAh Li-ion, removable |
Peripherals: | Accelerometer, gyroscope, proximity sensor, compass, SNS integration, stereo FM radio with RDS, infrared port, GPS/GLONASS, NFC, microUSB v2.0, Corning Gorilla Glass |
CM supported: | 10.1, 10.2, 11, 12, 12.1, 13 |
Note: DISCLAIMER
Modifying or replacing your device’s software may void your device’s warranty, lead to data loss, hair loss, financial loss, privacy loss, security breaches, or other damage, and therefore must be done entirely at your own risk. No one affiliated with the CyanogenMod project is responsible for your actions. Good luck.
Samsung devices come with a unique boot mode called Download Mode which is very similar to Fastboot Mode on some devices with unlocked bootloaders. Heimdall is a cross-platform, open source tool for interfacing with Download Mode on Samsung devices. The preferred method of installing a custom recovery is through this boot mode. Rooting the stock firmware is neither recommended nor necessary.
heimdall.exe
. You can verify Heimdall is working by opening a command prompt in this directory and typing heimdall version
. If you receive an error, be sure that you have the Microsoft Visual C++ 2012 Redistributable Package (x86/32bit) installed on your computer.-frontend
packages are not required for this guide. After installation, heimdall should be available from the terminal; type heimdall version
to verify installation succeeded.heimdall version
to verify installation succeeded.README
file on Github under the relevant operating system directory. You can also refer to the Install and compile Heimdall instructions on this wiki.
zadig.exe
from the Drivers folder of the Heimdall Suite. heimdall flash --RECOVERY recovery.img --no-reboot
Note: Flashing with heimdall
sudo heimdall flash [...]
. Typical symptoms of this are:
--KERNEL
instead of --kernel
and/or --recovery
instead of --RECOVERY
.sudo kextunload -b com.apple.driver.AppleUSBCDC;
sudo kextunload -b com.apple.driver.AppleUSBCDCACMControl;
sudo kextunload -b com.apple.driver.AppleUSBCDCACMData;
sudo kextunload -b com.devguru.driver.SamsungComposite;
sudo kextunload -b com.devguru.driver.SamsungACMData
sudo kextunload -b com.devguru.driver.SamsungACMControl
Error: Failed to confirm end of PIT file transfer!
Helpful Tip
.zip
package, as well as any optional .zip
packages, on the root of /sdcard
:
adb push filename.zip /sdcard/
.zip
packages to your device using any method you are familiar with. The adb
method is used here because it is universal across all devices and works in both Android and recovery mode. If you are in recovery mode, you may need to ensure /sdcard
(sometimes called Internal Storage) is mounted by checking its status in the Mounts menu. If you have booted regularly, USB debugging must be enabled./sdcard
and select the CyanogenMod .zip
package.Helpful Tip
These instructions will hopefully assist you to start with a stock Galaxy S4 Mini (International LTE), unlock the bootloader (if necessary), and then download the required tools as well as the very latest source code for CyanogenMod (based on Google’s Android operating system). Using these, you can build both CyanogenMod and CyanogenMod Recovery image from source code, and then install them both to your device.
It is difficult to say how much experience is necessary to follow these instructions. While this guide is certainly not for the very very very uninitiated, these steps shouldn’t require a PhD in software development either. Some readers will have no difficulty and breeze through the steps easily. Others may struggle over the most basic operation. Because people’s experiences, backgrounds, and intuitions differ, it may be a good idea to read through just to ascertain whether you feel comfortable or are getting over your head.
Remember, you assume all risk of trying this, but you will reap the rewards! It’s pretty satisfying to boot into a fresh operating system you baked at home :) And once you’re an Android-building ninja, there will be no more need to wait for “nightly” builds from anyone. You will have at your fingertips the skills to build a full operating system from code to a running device, whenever you want. Where you go from there– maybe you’ll add a feature, fix a bug, add a translation, or use what you’ve learned to build a new app or port to a new device– or maybe you’ll never build again– it’s all really up to you.
cd
for “change directory”, the concept of directory hierarchies, that in Linux they are separated by /
, etc.If you are not accustomed to using Linux– this is an excellent chance to learn. It’s free– just download and run a virtual machine (VM) such as Virtualbox, then install a Linux distribution such as Ubuntu (AOSP vets Ubuntu as well). Any recent 64-bit version should work great, but the latest is recommended.
Note:
You want to use a 64-bit version of Linux. A 32-bit Linux environment will only work if you are building CyanogenMod 6 and older. For CyanogenMod 10.1, if you encounter issues with 64bit host binaries, you can set BUILD_HOST_32bit=1
in your environment. This is generally not needed, though, especially with CyanogenMod 10.2 and newer.
Using a VM allows Linux to run as a guest inside your host computer– a computer in a computer, if you will. If you hate Linux for whatever reason, you can always just uninstall and delete the whole thing. (There are plenty of places to find instructions for setting up Virtualbox with Ubuntu, so I’ll leave it to you to do that.)
So let’s begin!
Note:
You only need to do these steps the first time you build. If you previously prepared your build environment and have downloaded the CyanogenMod source code for another device, skip to Prepare the device-specific code.
Helpful Tip
While the SDK contains lots of different things– the two tools you are most interested in for building Android are adb and fastboot, located in the /platform-tools
directory.
Several “build packages” are needed to build CyanogenMod. You can install these using the package manager of your choice.
Helpful Tip
A package manager in Linux is a system used to install or remove software (usually originating from the Internet) on your computer. With Ubuntu, you can use the Ubuntu Software Center. Even better, you may also use the apt-get install
command directly in the Terminal. (Learn more about the apt packaging tool system from Wikipedia.)
For both 32-bit & 64-bit systems, you’ll need:
bc bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop maven openjdk-7-jdk pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev
In addition to the above, for 64-bit systems, get these:
g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev
For Ubuntu 15.10 (wily) and newer, substitute:
lib32readline-gplv2-dev
→ lib32readline6-dev
For Ubuntu 16.04 (xenial) and newer, substitute (additionally see java notes below):
libwxgtk2.8-dev
→ libwxgtk3.0-dev
openjdk-7-jdk
→ openjdk-8-jdk
Java versions: Different versions of CyanogenMod require different versions of the JDK (Java Development Kit):
Ubuntu 16.04 (Xenial Xerus) or newer and OpenJDK: Since OpenJDK 1.7 was removed from the official Ubuntu repositories, you have a couple options:
$HOME/.bashrc
file: export EXPERIMENTAL_USE_JAVA8=true
.Also see http://source.android.com/source/initializing.html which lists needed packages.
You will need to set up some directories in your build environment.
To create them:
$ mkdir -p ~/bin
$ mkdir -p ~/android/system
repo
commandEnter the following to download the “repo” binary and make it executable (runnable):
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
~/bin
directory in your path of executionIn recent versions of Ubuntu, ~/bin
should already be in your PATH. You can check this by opening ~/.profile
with a text editor and verifying the following code exists (add it if it is missing):
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
Enter the following to initialize the repository:
$ cd ~/android/system/
$ repo init -u https://github.com/CyanogenMod/android.git -b cm-13.0
To start the download of all the source code to your computer:
$ repo sync
The CM manifests include a sensible default configuration for repo
, which we strongly suggest you use (i.e. don’t add any options to sync
). For reference, our default values are -j 4
and -c
. The -j 4
part means that there will be four simultaneous threads/connections. If you experience problems syncing, you can lower this to -j 3
or -j 2
. -c
will ask repo to pull in only the current branch, instead of the entire CM history.
Prepare to wait a long time while the source code downloads.
Helpful Tip
The repo sync
command is used to update the latest source code from CyanogenMod and Google. Remember it, as you can do it every few days to keep your code base fresh and up-to-date.
Next,
$ cd ~/android/system/vendor/cm
then enter:
$ ./get-prebuilts
You won’t see any confirmation- just another prompt. But this should cause some prebuilt apps to be loaded and installed into the source code. Once completed, this does not need to be done again.
Helpful Tip – Errors during breakfast
Different maintainers setup their device inheritance rules differently. Some require a vendor directory to be populated before breakfast will even succeed. If you receive an error here about vendor makefiles, then jump down to the next section Extract proprietary blobs. The first portion of breakfast should have succeeded at pulling in the device tree and the extract blobs script should be available. After completing that section, you can rerun breakfast serranoltexx
After the source downloads, ensure you are in the root of the source code (cd ~/android/system
), then type:
$ source build/envsetup.sh
$ breakfast serranoltexx
This will download the device specific configuration and kernel source for your device. An alternative to using the breakfast
command is to build your own local manifest. To do this, you will need to locate your device on CyanogenMod’s GitHub and list all of the repositories defined in cm.dependencies in your local manifest.
Helpful Tip
If you want to know more about what source build/envsetup.sh
does or simply want to know more about the breakfast
, brunch
and lunch
commands, you can head over to the Envsetup help page.
Helpful Tip
Instead of typing cd ~/android/system
every time you want to return back to the root of the source code, here’s a short command that will do it for you: croot
. To use this command, you must first run source build/envsetup.sh
from ~/android/system
.
Now ensure that your Galaxy S4 Mini (International LTE) is connected to your computer via the USB cable and that you are in the ~/android/system/device/samsung/serranoltexx
directory (you can cd ~/android/system/device/samsung/serranoltexx
if necessary). Then run the extract-files.sh
script:
$ ./extract-files.sh
You should see the proprietary files (aka “blobs”) get pulled from the device and moved to the ~/android/system/vendor/samsung
directory. If you see errors about adb being unable to pull the files, adb may not be in the path of execution. If this is the case, see the adb page for suggestions for dealing with “command not found” errors.
Note:
Your device should already be running a build of CyanogenMod for the branch you wish to build for the extract-files.sh
script to function properly.
Note:
It’s important that these proprietary files are extracted to the ~/android/system/vendor/samsung
directory by using the extract-files.sh
script. Makefiles are generated at the same time to make sure the blobs are eventually copied to the device. Without these blobs, CyanogenMod may build without error, but you’ll be missing important functionality, such as graphics libraries that enable you to see anything!
You can speed up subsequent builds by adding
export USE_CCACHE=1
to your ~/.bashrc
file (what’s a .bashrc file?). Then, specify the amount of disk space to dedicate to ccache by typing this from the top of your Android tree:
prebuilts/misc/linux-x86/ccache/ccache -M 50G
where 50G
corresponds to 50GB of cache. This only needs to be run once and the setting will be remembered. Anywhere in the range of 25GB to 100GB will result in very noticeably increased build speeds (for instance, a typical 1hr build time can be reduced to 20min). If you’re only building for one device, 25GB-50GB is fine. If you plan to build for several devices that do not share the same kernel source, aim for 75GB-100GB. This space will be permanently occupied on your drive, so take this into consideration. See more information about ccache on Google’s android build environment initialization page.
Helpful Tip
If you are a very active developer, working on many other projects than just Android, you might prefer to keep your Android ccache independent (because it’s huge and can slow down the efficiency of ccache in your other projects). Beginning with CyanogenMod 12.1, you can specify environment variables for the location and size of CyanogenMod’s ccache. Some syntax examples: export ANDROID_CCACHE_DIR="$HOME/android/.ccache"
and export ANDROID_CCACHE_SIZE="50G"
.
Time to start building! So now type:
$ croot
$ brunch serranoltexx
The build should begin.
Helpful Tip
If the build doesn’t start, try lunch
and choose your device from the menu. If that doesn’t work, try breakfast
and choose from the menu. The command make serranoltexx
should then work.
Helpful Tip
A second, bonus tip! If you get a command not found error for croot
, brunch
, or lunch
, be sure you’ve done the source build/envsetup.sh
command in this Terminal session from the ~/android/system
directory.
Helpful Tip
A third tip! If the build to fails while downloading Gello, you’ll need to import a missing certificate into Maven’s truststore. Detailed instructions on how to do that can be found here
ERROR: signapk.jar failed: return code 1make: *** [out/target/product/serranoltexx/cm_serranoltexx-ota-eng.root.zip] Error 1
…you may want to make the following change to ~/android/system/build/tools/releasetools/common.py
:
Search for instances of -Xmx2048m
(it should appear either under OPTIONS.java_args
or near usage of signapk.jar
), and replace it with -Xmx1024m
or -Xmx512m
.
Then start the build again (with brunch).
Assuming the build completed without error (it will be obvious when it finishes), type:
$ cd $OUT
in the same terminal window that you did the build. Here you’ll find all the files that were created. The stuff that will go in /system
is in a folder called system
. The stuff that will become your ramdisk is in a folder called root
. And your kernel is called… kernel
.
But that’s all just background info. The two files we are interested in are (1) recovery.img
, which contains CyanogenMod Recovery, and (2) cm-13.0-20161224-UNOFFICIAL-serranoltexx.zip
, which is the CyanogenMod installation package.
Back to the $OUT
directory on your computer– you should see a file that looks something like:
cm-13.0-20161224-UNOFFICIAL-serranoltexx.zip
Note:
The above file name may vary depending on the version of CM you are building. Your build may not include a version number or may identify itself as a “KANG
” rather than UNOFFICIAL
version. Regardless, the file name will end in .zip
and should be titled similarly to official builds.
Now you can flash the cm...zip
file above as usual via recovery mode. Before doing so, now is a good time to make a backup of whatever installation is currently running on the device in case something goes wrong with the flash attempt. While CyanogenMod Recovery doesn’t have a backup feature, there are other custom recoveries available that do. You can also use something like Titanium Backup (root required) as an alternative.
You’ve done it! Welcome to the elite club of self-builders. You’ve built your operating system from scratch, from the ground up. You are the master/mistress of your domain… and hopefully you’ve learned a bit on the way and had some fun too.
Now that you’ve succeeded in building CyanogenMod for your device, here are some suggestions on what to do next.
Also, be sure to take a glance at the Dev Center on this wiki for all kinds of more detailed information about developer topics ranging from collecting logs, understanding what’s in the source code directories, submitting your own contributions, porting CyanogenMod to new devices, and a lot more.
Congrats again!
Content of this page is based on informations from wiki.cyanogenmod.org, under CC BY-SA 3.0 licence.
Download (nightly build)
CyanogenMod 11 (Android 4.4-4.4.4 (KitKat))
The install guide assumes the Samsung Galaxy S B already has stock Android 2.2 (VJJPD)
Device | http://www.github.com/cyanogenmod/android_device_samsung_galaxysbmtd |
Kernel | http://www.github.com/cyanogenmod/android_kernel_samsung_aries |
Codename: | galaxysbmtd |
---|---|
Vendor: | Samsung |
Manufacturer: | samsung |
Type: | phone |
GSM freq: | 850 900 1800 1900 MHz GPRS/EDGE 850 2100 MHz UMTS/HSPA |
Platform: | Samsung Exynos 3 |
CPU: | 1 GHz single-core Cortex A8 |
GPU: | PowerVR SGX540 |
RAM: | 512MB |
Weight: | 119 g (4.2 oz) |
Dimensions: | 122 mm (4.8 in) (h) 64 mm (2.52 in) (w) 10 mm (0.394 in) (d) |
Screen size: | 102 mm (4.0 in) |
Resolution: | 800×480 |
Screen density: | 223 PPI |
Internal storage: | 8/16GB |
SD Card: | up to 32GB |
Bluetooth: | 3.0 |
Wi-Fi: | 802.11 a/b/g/n |
Main camera: | 5MP w/ LED flash |
Secondary camera: | 0.3MP |
Power: | 1500 mAh |
Peripherals: | ISDB-T TV Tuner |
CM supported: | 7, 9, 10, 10.1, 10.2, 11 |
Note: DISCLAIMER
Modifying or replacing your device’s software may void your device’s warranty, lead to data loss, hair loss, financial loss, privacy loss, security breaches, or other damage, and therefore must be done entirely at your own risk. No one affiliated with the CyanogenMod project is responsible for your actions. Good luck.
The install guide assumes the Samsung Galaxy S B already has stock Android 2.2 (VJJPD)
Samsung devices come with a unique boot mode called Download Mode which is very similar to Fastboot Mode on some devices with unlocked bootloaders. Heimdall is a cross-platform, open source tool for interfacing with Download Mode on Samsung devices. The preferred method of installing a custom recovery is through this boot mode. Rooting the stock firmware is neither recommended nor necessary.
heimdall.exe
. You can verify Heimdall is working by opening a command prompt in this directory and typing heimdall version
. If you receive an error, be sure that you have the Microsoft Visual C++ 2012 Redistributable Package (x86/32bit) installed on your computer.-frontend
packages are not required for this guide. After installation, heimdall should be available from the terminal; type heimdall version
to verify installation succeeded.heimdall version
to verify installation succeeded.README
file on Github under the relevant operating system directory. You can also refer to the Install and compile Heimdall instructions on this wiki.cf7a4e62b9956d295f4f3b633e0bb8fe
zadig.exe
from the Drivers folder of the Heimdall Suite. heimdall flash --kernel zImage --no-reboot
zImage
above.
Note: Flashing with heimdall
sudo heimdall flash [...]
. Typical symptoms of this are:
--KERNEL
instead of --kernel
and/or --recovery
instead of --RECOVERY
.sudo kextunload -b com.apple.driver.AppleUSBCDC;
sudo kextunload -b com.apple.driver.AppleUSBCDCACMControl;
sudo kextunload -b com.apple.driver.AppleUSBCDCACMData;
sudo kextunload -b com.devguru.driver.SamsungComposite;
sudo kextunload -b com.devguru.driver.SamsungACMData
sudo kextunload -b com.devguru.driver.SamsungACMControl
Error: Failed to confirm end of PIT file transfer!
Helpful Tip
/storage/sdcard0
or /sdcard
as a mountable volume, go ahead and mount it. If you do not see one of these partitions, then instead mount the /data
partition. Take note of which volume you mounted. Now, push the package(s) to your device (also, see tip below):adb push update.zip /storage/sdcard0/
adb push update.zip /sdcard/
update.zip
should be replaced with the package filename. Go back to the main menu and select install zip. Choose to install from the same directory where you pushed the package(s). If you are installing multiple packages, install CyanogenMod first and then install any subsequent packages on top of it.Helpful Tip – SD card folders
CyanogenMod 10.1 and newer have multi-user support (introduced in Android 4.2). If your device has storage on the /data partition, then Android actually looks in /data/media/0/ for the first user’s /sdcard/ storage. ClockworkMod recovery symlinks /sdcard/ to /data/media/ though. So, if you are pushing files to internal storage in recovery and want them to be visible in Android, you should push them to /sdcard/0/ or /data/media/0/. Here’s the most frequent scenarios:
adb push update.zip /sdcard/
adb shell "mkdir /sdcard/0/"
followed by adb push update.zip /sdcard/0/
adb push update.zip /sdcard/0/
Helpful Tip
These instructions will hopefully assist you to start with a stock Galaxy S B, unlock the bootloader (if necessary), and then download the required tools as well as the very latest source code for CyanogenMod (based on Google’s Android operating system). Using these, you can build both CyanogenMod and CyanogenMod Recovery image from source code, and then install them both to your device.
It is difficult to say how much experience is necessary to follow these instructions. While this guide is certainly not for the very very very uninitiated, these steps shouldn’t require a PhD in software development either. Some readers will have no difficulty and breeze through the steps easily. Others may struggle over the most basic operation. Because people’s experiences, backgrounds, and intuitions differ, it may be a good idea to read through just to ascertain whether you feel comfortable or are getting over your head.
Remember, you assume all risk of trying this, but you will reap the rewards! It’s pretty satisfying to boot into a fresh operating system you baked at home :) And once you’re an Android-building ninja, there will be no more need to wait for “nightly” builds from anyone. You will have at your fingertips the skills to build a full operating system from code to a running device, whenever you want. Where you go from there– maybe you’ll add a feature, fix a bug, add a translation, or use what you’ve learned to build a new app or port to a new device– or maybe you’ll never build again– it’s all really up to you.
cd
for “change directory”, the concept of directory hierarchies, that in Linux they are separated by /
, etc.If you are not accustomed to using Linux– this is an excellent chance to learn. It’s free– just download and run a virtual machine (VM) such as Virtualbox, then install a Linux distribution such as Ubuntu (AOSP vets Ubuntu as well). Any recent 64-bit version should work great, but the latest is recommended.
Note:
You want to use a 64-bit version of Linux. A 32-bit Linux environment will only work if you are building CyanogenMod 6 and older. For CyanogenMod 10.1, if you encounter issues with 64bit host binaries, you can set BUILD_HOST_32bit=1
in your environment. This is generally not needed, though, especially with CyanogenMod 10.2 and newer.
Using a VM allows Linux to run as a guest inside your host computer– a computer in a computer, if you will. If you hate Linux for whatever reason, you can always just uninstall and delete the whole thing. (There are plenty of places to find instructions for setting up Virtualbox with Ubuntu, so I’ll leave it to you to do that.)
So let’s begin!
Note:
You only need to do these steps the first time you build. If you previously prepared your build environment and have downloaded the CyanogenMod source code for another device, skip to Prepare the device-specific code.
Helpful Tip
While the SDK contains lots of different things– the two tools you are most interested in for building Android are adb and fastboot, located in the /platform-tools
directory.
Several “build packages” are needed to build CyanogenMod. You can install these using the package manager of your choice.
Helpful Tip
A package manager in Linux is a system used to install or remove software (usually originating from the Internet) on your computer. With Ubuntu, you can use the Ubuntu Software Center. Even better, you may also use the apt-get install
command directly in the Terminal. (Learn more about the apt packaging tool system from Wikipedia.)
For both 32-bit & 64-bit systems, you’ll need:
bc bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop maven openjdk-7-jdk pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev
In addition to the above, for 64-bit systems, get these:
g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev
For Ubuntu 15.10 (wily) and newer, substitute:
lib32readline-gplv2-dev
→ lib32readline6-dev
For Ubuntu 16.04 (xenial) and newer, substitute (additionally see java notes below):
libwxgtk2.8-dev
→ libwxgtk3.0-dev
openjdk-7-jdk
→ openjdk-8-jdk
Java versions: Different versions of CyanogenMod require different versions of the JDK (Java Development Kit):
Ubuntu 16.04 (Xenial Xerus) or newer and OpenJDK: Since OpenJDK 1.7 was removed from the official Ubuntu repositories, you have a couple options:
$HOME/.bashrc
file: export EXPERIMENTAL_USE_JAVA8=true
.Also see http://source.android.com/source/initializing.html which lists needed packages.
You will need to set up some directories in your build environment.
To create them:
$ mkdir -p ~/bin
$ mkdir -p ~/android/system
repo
commandEnter the following to download the “repo” binary and make it executable (runnable):
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
~/bin
directory in your path of executionIn recent versions of Ubuntu, ~/bin
should already be in your PATH. You can check this by opening ~/.profile
with a text editor and verifying the following code exists (add it if it is missing):
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
Enter the following to initialize the repository:
$ cd ~/android/system/
$ repo init -u https://github.com/CyanogenMod/android.git -b cm-13.0
To start the download of all the source code to your computer:
$ repo sync
The CM manifests include a sensible default configuration for repo
, which we strongly suggest you use (i.e. don’t add any options to sync
). For reference, our default values are -j 4
and -c
. The -j 4
part means that there will be four simultaneous threads/connections. If you experience problems syncing, you can lower this to -j 3
or -j 2
. -c
will ask repo to pull in only the current branch, instead of the entire CM history.
Prepare to wait a long time while the source code downloads.
Helpful Tip
The repo sync
command is used to update the latest source code from CyanogenMod and Google. Remember it, as you can do it every few days to keep your code base fresh and up-to-date.
Next,
$ cd ~/android/system/vendor/cm
then enter:
$ ./get-prebuilts
You won’t see any confirmation- just another prompt. But this should cause some prebuilt apps to be loaded and installed into the source code. Once completed, this does not need to be done again.
Helpful Tip – Errors during breakfast
Different maintainers setup their device inheritance rules differently. Some require a vendor directory to be populated before breakfast will even succeed. If you receive an error here about vendor makefiles, then jump down to the next section Extract proprietary blobs. The first portion of breakfast should have succeeded at pulling in the device tree and the extract blobs script should be available. After completing that section, you can rerun breakfast galaxysbmtd
After the source downloads, ensure you are in the root of the source code (cd ~/android/system
), then type:
$ source build/envsetup.sh
$ breakfast galaxysbmtd
This will download the device specific configuration and kernel source for your device. An alternative to using the breakfast
command is to build your own local manifest. To do this, you will need to locate your device on CyanogenMod’s GitHub and list all of the repositories defined in cm.dependencies in your local manifest.
Helpful Tip
If you want to know more about what source build/envsetup.sh
does or simply want to know more about the breakfast
, brunch
and lunch
commands, you can head over to the Envsetup help page.
Helpful Tip
Instead of typing cd ~/android/system
every time you want to return back to the root of the source code, here’s a short command that will do it for you: croot
. To use this command, you must first run source build/envsetup.sh
from ~/android/system
.
Now ensure that your Galaxy S B is connected to your computer via the USB cable and that you are in the ~/android/system/device/samsung/galaxysbmtd
directory (you can cd ~/android/system/device/samsung/galaxysbmtd
if necessary). Then run the extract-files.sh
script:
$ ./extract-files.sh
You should see the proprietary files (aka “blobs”) get pulled from the device and moved to the ~/android/system/vendor/samsung
directory. If you see errors about adb being unable to pull the files, adb may not be in the path of execution. If this is the case, see the adb page for suggestions for dealing with “command not found” errors.
Note:
Your device should already be running a build of CyanogenMod for the branch you wish to build for the extract-files.sh
script to function properly.
Note:
It’s important that these proprietary files are extracted to the ~/android/system/vendor/samsung
directory by using the extract-files.sh
script. Makefiles are generated at the same time to make sure the blobs are eventually copied to the device. Without these blobs, CyanogenMod may build without error, but you’ll be missing important functionality, such as graphics libraries that enable you to see anything!
You can speed up subsequent builds by adding
export USE_CCACHE=1
to your ~/.bashrc
file (what’s a .bashrc file?). Then, specify the amount of disk space to dedicate to ccache by typing this from the top of your Android tree:
prebuilts/misc/linux-x86/ccache/ccache -M 50G
where 50G
corresponds to 50GB of cache. This only needs to be run once and the setting will be remembered. Anywhere in the range of 25GB to 100GB will result in very noticeably increased build speeds (for instance, a typical 1hr build time can be reduced to 20min). If you’re only building for one device, 25GB-50GB is fine. If you plan to build for several devices that do not share the same kernel source, aim for 75GB-100GB. This space will be permanently occupied on your drive, so take this into consideration. See more information about ccache on Google’s android build environment initialization page.
Helpful Tip
If you are a very active developer, working on many other projects than just Android, you might prefer to keep your Android ccache independent (because it’s huge and can slow down the efficiency of ccache in your other projects). Beginning with CyanogenMod 12.1, you can specify environment variables for the location and size of CyanogenMod’s ccache. Some syntax examples: export ANDROID_CCACHE_DIR="$HOME/android/.ccache"
and export ANDROID_CCACHE_SIZE="50G"
.
Time to start building! So now type:
$ croot
$ brunch galaxysbmtd
The build should begin.
Helpful Tip
If the build doesn’t start, try lunch
and choose your device from the menu. If that doesn’t work, try breakfast
and choose from the menu. The command make galaxysbmtd
should then work.
Helpful Tip
A second, bonus tip! If you get a command not found error for croot
, brunch
, or lunch
, be sure you’ve done the source build/envsetup.sh
command in this Terminal session from the ~/android/system
directory.
Helpful Tip
A third tip! If the build to fails while downloading Gello, you’ll need to import a missing certificate into Maven’s truststore. Detailed instructions on how to do that can be found here
ERROR: signapk.jar failed: return code 1make: *** [out/target/product/galaxysbmtd/cm_galaxysbmtd-ota-eng.root.zip] Error 1
…you may want to make the following change to ~/android/system/build/tools/releasetools/common.py
:
Search for instances of -Xmx2048m
(it should appear either under OPTIONS.java_args
or near usage of signapk.jar
), and replace it with -Xmx1024m
or -Xmx512m
.
Then start the build again (with brunch).
Assuming the build completed without error (it will be obvious when it finishes), type:
$ cd $OUT
in the same terminal window that you did the build. Here you’ll find all the files that were created. The stuff that will go in /system
is in a folder called system
. The stuff that will become your ramdisk is in a folder called root
. And your kernel is called… kernel
.
But that’s all just background info. The two files we are interested in are (1) recovery.img
, which contains CyanogenMod Recovery, and (2) cm-13.0-20161224-UNOFFICIAL-galaxysbmtd.zip
, which is the CyanogenMod installation package.
Back to the $OUT
directory on your computer– you should see a file that looks something like:
cm-13.0-20161224-UNOFFICIAL-galaxysbmtd.zip
Note:
The above file name may vary depending on the version of CM you are building. Your build may not include a version number or may identify itself as a “KANG
” rather than UNOFFICIAL
version. Regardless, the file name will end in .zip
and should be titled similarly to official builds.
Now you can flash the cm...zip
file above as usual via recovery mode. Before doing so, now is a good time to make a backup of whatever installation is currently running on the device in case something goes wrong with the flash attempt. While CyanogenMod Recovery doesn’t have a backup feature, there are other custom recoveries available that do. You can also use something like Titanium Backup (root required) as an alternative.
You’ve done it! Welcome to the elite club of self-builders. You’ve built your operating system from scratch, from the ground up. You are the master/mistress of your domain… and hopefully you’ve learned a bit on the way and had some fun too.
Now that you’ve succeeded in building CyanogenMod for your device, here are some suggestions on what to do next.
Also, be sure to take a glance at the Dev Center on this wiki for all kinds of more detailed information about developer topics ranging from collecting logs, understanding what’s in the source code directories, submitting your own contributions, porting CyanogenMod to new devices, and a lot more.
Congrats again!
Content of this page is based on informations from wiki.cyanogenmod.org, under CC BY-SA 3.0 licence.
Download (nightly build)
CyanogenMod 13.0 (Android 6.0/6.0.1 (Marshmallow))
This is a KEXEC build and must be installed in SafeStrap (builds older than 9/1/2013 must be installed on rom-slot1). CM-12.0 requires at least Safestrap v3.75.
Device | http://www.github.com/cyanogenmod/android_device_motorola_maserati |
Kernel | http://www.github.com/cyanogenmod/android_kernel_motorola_omap4-common |
Codename: | maserati |
---|---|
Vendor: | Motorola |
Release date: | 2012 February 10 |
Carrier: | Verizon |
Type: | phone (slider) |
GSM freq: | 850/900/1800/1900 HSDPA 850/900/1900/2100 |
CDMA freq: | 800/1900 CDMA2000 1xEV-DO |
LTE freq: | 700 MHz Class 13 |
Platform: | TI OMAP4430 |
CPU: | 1.2 GHz dual-core Cortex-A9 |
GPU: | PowerVR SGX540 |
RAM: | 1GB |
Weight: | 178.9 g (6.28 oz) |
Dimensions: | 127 x 67.3 x 12.7 mm (5.0 x 2.65 x 0.5 in) |
Screen size: | 102 mm (4.0 in) |
Resolution: | 540 x 960 |
Screen density: | 275 ppi |
Screen type: | TFT capacitive touchscreen |
Internal storage: | 16GB |
SD Card: | microSD, up to 32 GB |
Bluetooth: | v4.0 with LE+EDR |
Wi-Fi: | Wi-Fi 802.11 b/g/n |
Main camera: | 8MP, flash: LED |
Secondary camera: | 1.3MP |
Power: | 1785 mAh |
Peripherals: | Accelerometer, proximity, compass, GPS, HDMI, FM Radio (Not officialy supported) |
CM supported: | 10.1, 10.2, 11, 12, 12.1, 13 |
Note: DISCLAIMER
Modifying or replacing your device’s software may void your device’s warranty, lead to data loss, hair loss, financial loss, privacy loss, security breaches, or other damage, and therefore must be done entirely at your own risk. No one affiliated with the CyanogenMod project is responsible for your actions. Good luck.
This is a KEXEC build and must be installed in SafeStrap (builds older than 9/1/2013 must be installed on rom-slot1). CM-12.0 requires at least Safestrap v3.75.
af6112a1d1a42ddc79dbad3624fe11c3
adb install YOURAPK.apk
.zip
package, as well as any optional .zip
packages, on the root of /sdcard
:
adb push filename.zip /sdcard/
.zip
packages to your device using any method you are familiar with. The adb
method is used here because it is universal across all devices and works in both Android and recovery mode. If you are in recovery mode, you may need to ensure /sdcard
(sometimes called Internal Storage) is mounted by checking its status in the Mounts menu. If you have booted regularly, USB debugging must be enabled./sdcard
and select the CyanogenMod .zip
package.Helpful Tip
These instructions will hopefully assist you to start with a stock Droid 4, unlock the bootloader (if necessary), and then download the required tools as well as the very latest source code for CyanogenMod (based on Google’s Android operating system). Using these, you can build both CyanogenMod and CyanogenMod Recovery image from source code, and then install them both to your device.
It is difficult to say how much experience is necessary to follow these instructions. While this guide is certainly not for the very very very uninitiated, these steps shouldn’t require a PhD in software development either. Some readers will have no difficulty and breeze through the steps easily. Others may struggle over the most basic operation. Because people’s experiences, backgrounds, and intuitions differ, it may be a good idea to read through just to ascertain whether you feel comfortable or are getting over your head.
Remember, you assume all risk of trying this, but you will reap the rewards! It’s pretty satisfying to boot into a fresh operating system you baked at home :) And once you’re an Android-building ninja, there will be no more need to wait for “nightly” builds from anyone. You will have at your fingertips the skills to build a full operating system from code to a running device, whenever you want. Where you go from there– maybe you’ll add a feature, fix a bug, add a translation, or use what you’ve learned to build a new app or port to a new device– or maybe you’ll never build again– it’s all really up to you.
cd
for “change directory”, the concept of directory hierarchies, that in Linux they are separated by /
, etc.If you are not accustomed to using Linux– this is an excellent chance to learn. It’s free– just download and run a virtual machine (VM) such as Virtualbox, then install a Linux distribution such as Ubuntu (AOSP vets Ubuntu as well). Any recent 64-bit version should work great, but the latest is recommended.
Note:
You want to use a 64-bit version of Linux. A 32-bit Linux environment will only work if you are building CyanogenMod 6 and older. For CyanogenMod 10.1, if you encounter issues with 64bit host binaries, you can set BUILD_HOST_32bit=1
in your environment. This is generally not needed, though, especially with CyanogenMod 10.2 and newer.
Using a VM allows Linux to run as a guest inside your host computer– a computer in a computer, if you will. If you hate Linux for whatever reason, you can always just uninstall and delete the whole thing. (There are plenty of places to find instructions for setting up Virtualbox with Ubuntu, so I’ll leave it to you to do that.)
So let’s begin!
Note:
You only need to do these steps the first time you build. If you previously prepared your build environment and have downloaded the CyanogenMod source code for another device, skip to Prepare the device-specific code.
Helpful Tip
While the SDK contains lots of different things– the two tools you are most interested in for building Android are adb and fastboot, located in the /platform-tools
directory.
Several “build packages” are needed to build CyanogenMod. You can install these using the package manager of your choice.
Helpful Tip
A package manager in Linux is a system used to install or remove software (usually originating from the Internet) on your computer. With Ubuntu, you can use the Ubuntu Software Center. Even better, you may also use the apt-get install
command directly in the Terminal. (Learn more about the apt packaging tool system from Wikipedia.)
For both 32-bit & 64-bit systems, you’ll need:
bc bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop maven openjdk-7-jdk pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev
In addition to the above, for 64-bit systems, get these:
g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev
For Ubuntu 15.10 (wily) and newer, substitute:
lib32readline-gplv2-dev
→ lib32readline6-dev
For Ubuntu 16.04 (xenial) and newer, substitute (additionally see java notes below):
libwxgtk2.8-dev
→ libwxgtk3.0-dev
openjdk-7-jdk
→ openjdk-8-jdk
Java versions: Different versions of CyanogenMod require different versions of the JDK (Java Development Kit):
Ubuntu 16.04 (Xenial Xerus) or newer and OpenJDK: Since OpenJDK 1.7 was removed from the official Ubuntu repositories, you have a couple options:
$HOME/.bashrc
file: export EXPERIMENTAL_USE_JAVA8=true
.Also see http://source.android.com/source/initializing.html which lists needed packages.
You will need to set up some directories in your build environment.
To create them:
$ mkdir -p ~/bin
$ mkdir -p ~/android/system
repo
commandEnter the following to download the “repo” binary and make it executable (runnable):
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
~/bin
directory in your path of executionIn recent versions of Ubuntu, ~/bin
should already be in your PATH. You can check this by opening ~/.profile
with a text editor and verifying the following code exists (add it if it is missing):
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
Enter the following to initialize the repository:
$ cd ~/android/system/
$ repo init -u https://github.com/CyanogenMod/android.git -b cm-13.0
To start the download of all the source code to your computer:
$ repo sync
The CM manifests include a sensible default configuration for repo
, which we strongly suggest you use (i.e. don’t add any options to sync
). For reference, our default values are -j 4
and -c
. The -j 4
part means that there will be four simultaneous threads/connections. If you experience problems syncing, you can lower this to -j 3
or -j 2
. -c
will ask repo to pull in only the current branch, instead of the entire CM history.
Prepare to wait a long time while the source code downloads.
Helpful Tip
The repo sync
command is used to update the latest source code from CyanogenMod and Google. Remember it, as you can do it every few days to keep your code base fresh and up-to-date.
Next,
$ cd ~/android/system/vendor/cm
then enter:
$ ./get-prebuilts
You won’t see any confirmation- just another prompt. But this should cause some prebuilt apps to be loaded and installed into the source code. Once completed, this does not need to be done again.
Helpful Tip – Errors during breakfast
Different maintainers setup their device inheritance rules differently. Some require a vendor directory to be populated before breakfast will even succeed. If you receive an error here about vendor makefiles, then jump down to the next section Extract proprietary blobs. The first portion of breakfast should have succeeded at pulling in the device tree and the extract blobs script should be available. After completing that section, you can rerun breakfast maserati
After the source downloads, ensure you are in the root of the source code (cd ~/android/system
), then type:
$ source build/envsetup.sh
$ breakfast maserati
This will download the device specific configuration and kernel source for your device. An alternative to using the breakfast
command is to build your own local manifest. To do this, you will need to locate your device on CyanogenMod’s GitHub and list all of the repositories defined in cm.dependencies in your local manifest.
Helpful Tip
If you want to know more about what source build/envsetup.sh
does or simply want to know more about the breakfast
, brunch
and lunch
commands, you can head over to the Envsetup help page.
Helpful Tip
Instead of typing cd ~/android/system
every time you want to return back to the root of the source code, here’s a short command that will do it for you: croot
. To use this command, you must first run source build/envsetup.sh
from ~/android/system
.
Now ensure that your Droid 4 is connected to your computer via the USB cable and that you are in the ~/android/system/device/motorola/maserati
directory (you can cd ~/android/system/device/motorola/maserati
if necessary). Then run the extract-files.sh
script:
$ ./extract-files.sh
You should see the proprietary files (aka “blobs”) get pulled from the device and moved to the ~/android/system/vendor/motorola
directory. If you see errors about adb being unable to pull the files, adb may not be in the path of execution. If this is the case, see the adb page for suggestions for dealing with “command not found” errors.
Note:
Your device should already be running a build of CyanogenMod for the branch you wish to build for the extract-files.sh
script to function properly.
Note:
It’s important that these proprietary files are extracted to the ~/android/system/vendor/motorola
directory by using the extract-files.sh
script. Makefiles are generated at the same time to make sure the blobs are eventually copied to the device. Without these blobs, CyanogenMod may build without error, but you’ll be missing important functionality, such as graphics libraries that enable you to see anything!
You can speed up subsequent builds by adding
export USE_CCACHE=1
to your ~/.bashrc
file (what’s a .bashrc file?). Then, specify the amount of disk space to dedicate to ccache by typing this from the top of your Android tree:
prebuilts/misc/linux-x86/ccache/ccache -M 50G
where 50G
corresponds to 50GB of cache. This only needs to be run once and the setting will be remembered. Anywhere in the range of 25GB to 100GB will result in very noticeably increased build speeds (for instance, a typical 1hr build time can be reduced to 20min). If you’re only building for one device, 25GB-50GB is fine. If you plan to build for several devices that do not share the same kernel source, aim for 75GB-100GB. This space will be permanently occupied on your drive, so take this into consideration. See more information about ccache on Google’s android build environment initialization page.
Helpful Tip
If you are a very active developer, working on many other projects than just Android, you might prefer to keep your Android ccache independent (because it’s huge and can slow down the efficiency of ccache in your other projects). Beginning with CyanogenMod 12.1, you can specify environment variables for the location and size of CyanogenMod’s ccache. Some syntax examples: export ANDROID_CCACHE_DIR="$HOME/android/.ccache"
and export ANDROID_CCACHE_SIZE="50G"
.
Time to start building! So now type:
$ croot
$ brunch maserati
The build should begin.
Helpful Tip
If the build doesn’t start, try lunch
and choose your device from the menu. If that doesn’t work, try breakfast
and choose from the menu. The command make maserati
should then work.
Helpful Tip
A second, bonus tip! If you get a command not found error for croot
, brunch
, or lunch
, be sure you’ve done the source build/envsetup.sh
command in this Terminal session from the ~/android/system
directory.
Helpful Tip
A third tip! If the build to fails while downloading Gello, you’ll need to import a missing certificate into Maven’s truststore. Detailed instructions on how to do that can be found here
ERROR: signapk.jar failed: return code 1make: *** [out/target/product/maserati/cm_maserati-ota-eng.root.zip] Error 1
…you may want to make the following change to ~/android/system/build/tools/releasetools/common.py
:
Search for instances of -Xmx2048m
(it should appear either under OPTIONS.java_args
or near usage of signapk.jar
), and replace it with -Xmx1024m
or -Xmx512m
.
Then start the build again (with brunch).
Assuming the build completed without error (it will be obvious when it finishes), type:
$ cd $OUT
in the same terminal window that you did the build. Here you’ll find all the files that were created. The stuff that will go in /system
is in a folder called system
. The stuff that will become your ramdisk is in a folder called root
. And your kernel is called… kernel
.
But that’s all just background info. The two files we are interested in are (1) recovery.img
, which contains CyanogenMod Recovery, and (2) cm-13.0-20161224-UNOFFICIAL-maserati.zip
, which is the CyanogenMod installation package.
{{{install_md5sum}}}
adb install YOURAPK.apk
Back to the $OUT
directory on your computer– you should see a file that looks something like:
cm-13.0-20161224-UNOFFICIAL-maserati.zip
Note:
The above file name may vary depending on the version of CM you are building. Your build may not include a version number or may identify itself as a “KANG
” rather than UNOFFICIAL
version. Regardless, the file name will end in .zip
and should be titled similarly to official builds.
Now you can flash the cm...zip
file above as usual via recovery mode. Before doing so, now is a good time to make a backup of whatever installation is currently running on the device in case something goes wrong with the flash attempt. While CyanogenMod Recovery doesn’t have a backup feature, there are other custom recoveries available that do. You can also use something like Titanium Backup (root required) as an alternative.
You’ve done it! Welcome to the elite club of self-builders. You’ve built your operating system from scratch, from the ground up. You are the master/mistress of your domain… and hopefully you’ve learned a bit on the way and had some fun too.
Now that you’ve succeeded in building CyanogenMod for your device, here are some suggestions on what to do next.
Also, be sure to take a glance at the Dev Center on this wiki for all kinds of more detailed information about developer topics ranging from collecting logs, understanding what’s in the source code directories, submitting your own contributions, porting CyanogenMod to new devices, and a lot more.
Congrats again!
Content of this page is based on informations from wiki.cyanogenmod.org, under CC BY-SA 3.0 licence.
Download (nightly build)
CyanogenMod 12.1 (Android 5.1 (Lollipop))
Note:
Your device must be bootloader unlocked.
For CM 11.0, the device builds have been unified. Get the latest CM 11.0 build for KitKat bootloader updated devices here and for devices still on JellyBean bootloader here.
For CM 12.0 and newer, KitKat bootloader is required and builds were de-unified again. Get them under the usual xt907 builds.
Device | http://www.github.com/cyanogenmod/android_device_motorola_xt907 |
Kernel | http://www.github.com/cyanogenmod/android_kernel_motorola_msm8960-common |
Codename: | xt907 |
---|---|
Also known as: | scorpion_mini |
Vendor: | Motorola |
Release date: | 2012 September |
Carrier: | Verizon |
Type: | phone |
GSM freq: | GSM 850/900/1800/1900 HSDPA 850/900/1900/2100 |
CDMA freq: | CDMA 800/1900 CDMA2000 1xEV-DO |
LTE freq: | LTE 700 MHz Class 13 |
Platform: | Qualcomm MSM8960 |
CPU: | 1.5 GHz dual-core Krait |
GPU: | Adreno 225 |
RAM: | 1GB |
Weight: | 126 g (4.44 oz) |
Dimensions: | 122.5 mm (4.82 in) (h) 60.9 mm (2.40 in) (w) 8.3 mm (0.33 in) (d) |
Screen size: | 109 mm (4.3 in) |
Resolution: | 540 x 960 |
Screen density: | ~256 ppi |
Screen type: | Super AMOLED |
Internal storage: | 8 GB (4 GB user available) |
SD Card: | microSD, up to 32 GB |
Bluetooth: | v4.0 with LE+EDR |
Wi-Fi: | 802.11 a/b/g/n, dual-band, Wi-Fi hotspot, DLNA |
Main camera: | 8MP, flash: LED |
Secondary camera: | VGA |
Power: | Non-removable Li-Ion 2000 mAh battery |
Peripherals: | Accelerometer, proximity, compass |
CM supported: | 10.1, 10.2, 11, 12, 12.1 |
Note: DISCLAIMER
Modifying or replacing your device’s software may void your device’s warranty, lead to data loss, hair loss, financial loss, privacy loss, security breaches, or other damage, and therefore must be done entirely at your own risk. No one affiliated with the CyanogenMod project is responsible for your actions. Good luck.
Note:
Your device must be bootloader unlocked.
For CM 11.0, the device builds have been unified. Get the latest CM 11.0 build for KitKat bootloader updated devices here and for devices still on JellyBean bootloader here.
For CM 12.0 and newer, KitKat bootloader is required and builds were de-unified again. Get them under the usual xt907 builds.
./run.sh
See All About Recovery Images for more information about custom recoveries and their capabilities.
ec2177f9d1c3a3d4671e99522d9b6315
adb reboot bootloader
fastboot devices
fastboot flash recovery your_recovery_image.img
.zip
package, as well as any optional .zip
packages, on the root of /sdcard
:
adb push filename.zip /sdcard/
.zip
packages to your device using any method you are familiar with. The adb
method is used here because it is universal across all devices and works in both Android and recovery mode. If you are in recovery mode, you may need to ensure /sdcard
(sometimes called Internal Storage) is mounted by checking its status in the Mounts menu. If you have booted regularly, USB debugging must be enabled./sdcard
and select the CyanogenMod .zip
package.Helpful Tip
Devices with System Version “182.46.15.XT907.Verizon.en.US” or “183.46.15.XT907.Verizon.en.US” (Check under Settings -> About Phone) as installed by an Over-The-Air update can not have their boot loader unlocked unless it was unlocked prior to the update. As of mid 2015, there are no known ways of unlocking the boot loader with those system versions, regardless of if you have root access or not.
These instructions will hopefully assist you to start with a stock Droid RAZR M, unlock the bootloader (if necessary), and then download the required tools as well as the very latest source code for CyanogenMod (based on Google’s Android operating system). Using these, you can build both CyanogenMod and CyanogenMod Recovery image from source code, and then install them both to your device.
It is difficult to say how much experience is necessary to follow these instructions. While this guide is certainly not for the very very very uninitiated, these steps shouldn’t require a PhD in software development either. Some readers will have no difficulty and breeze through the steps easily. Others may struggle over the most basic operation. Because people’s experiences, backgrounds, and intuitions differ, it may be a good idea to read through just to ascertain whether you feel comfortable or are getting over your head.
Remember, you assume all risk of trying this, but you will reap the rewards! It’s pretty satisfying to boot into a fresh operating system you baked at home :) And once you’re an Android-building ninja, there will be no more need to wait for “nightly” builds from anyone. You will have at your fingertips the skills to build a full operating system from code to a running device, whenever you want. Where you go from there– maybe you’ll add a feature, fix a bug, add a translation, or use what you’ve learned to build a new app or port to a new device– or maybe you’ll never build again– it’s all really up to you.
cd
for “change directory”, the concept of directory hierarchies, that in Linux they are separated by /
, etc.If you are not accustomed to using Linux– this is an excellent chance to learn. It’s free– just download and run a virtual machine (VM) such as Virtualbox, then install a Linux distribution such as Ubuntu (AOSP vets Ubuntu as well). Any recent 64-bit version should work great, but the latest is recommended.
Note:
You want to use a 64-bit version of Linux. A 32-bit Linux environment will only work if you are building CyanogenMod 6 and older. For CyanogenMod 10.1, if you encounter issues with 64bit host binaries, you can set BUILD_HOST_32bit=1
in your environment. This is generally not needed, though, especially with CyanogenMod 10.2 and newer.
Using a VM allows Linux to run as a guest inside your host computer– a computer in a computer, if you will. If you hate Linux for whatever reason, you can always just uninstall and delete the whole thing. (There are plenty of places to find instructions for setting up Virtualbox with Ubuntu, so I’ll leave it to you to do that.)
So let’s begin!
Note:
You only need to do these steps the first time you build. If you previously prepared your build environment and have downloaded the CyanogenMod source code for another device, skip to Prepare the device-specific code.
Helpful Tip
While the SDK contains lots of different things– the two tools you are most interested in for building Android are adb and fastboot, located in the /platform-tools
directory.
Several “build packages” are needed to build CyanogenMod. You can install these using the package manager of your choice.
Helpful Tip
A package manager in Linux is a system used to install or remove software (usually originating from the Internet) on your computer. With Ubuntu, you can use the Ubuntu Software Center. Even better, you may also use the apt-get install
command directly in the Terminal. (Learn more about the apt packaging tool system from Wikipedia.)
For both 32-bit & 64-bit systems, you’ll need:
bc bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop maven openjdk-7-jdk pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev
In addition to the above, for 64-bit systems, get these:
g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev
For Ubuntu 15.10 (wily) and newer, substitute:
lib32readline-gplv2-dev
→ lib32readline6-dev
For Ubuntu 16.04 (xenial) and newer, substitute (additionally see java notes below):
libwxgtk2.8-dev
→ libwxgtk3.0-dev
openjdk-7-jdk
→ openjdk-8-jdk
Java versions: Different versions of CyanogenMod require different versions of the JDK (Java Development Kit):
Ubuntu 16.04 (Xenial Xerus) or newer and OpenJDK: Since OpenJDK 1.7 was removed from the official Ubuntu repositories, you have a couple options:
$HOME/.bashrc
file: export EXPERIMENTAL_USE_JAVA8=true
.Also see http://source.android.com/source/initializing.html which lists needed packages.
You will need to set up some directories in your build environment.
To create them:
$ mkdir -p ~/bin
$ mkdir -p ~/android/system
repo
commandEnter the following to download the “repo” binary and make it executable (runnable):
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
~/bin
directory in your path of executionIn recent versions of Ubuntu, ~/bin
should already be in your PATH. You can check this by opening ~/.profile
with a text editor and verifying the following code exists (add it if it is missing):
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
Enter the following to initialize the repository:
$ cd ~/android/system/
$ repo init -u https://github.com/CyanogenMod/android.git -b cm-13.0
To start the download of all the source code to your computer:
$ repo sync
The CM manifests include a sensible default configuration for repo
, which we strongly suggest you use (i.e. don’t add any options to sync
). For reference, our default values are -j 4
and -c
. The -j 4
part means that there will be four simultaneous threads/connections. If you experience problems syncing, you can lower this to -j 3
or -j 2
. -c
will ask repo to pull in only the current branch, instead of the entire CM history.
Prepare to wait a long time while the source code downloads.
Helpful Tip
The repo sync
command is used to update the latest source code from CyanogenMod and Google. Remember it, as you can do it every few days to keep your code base fresh and up-to-date.
Next,
$ cd ~/android/system/vendor/cm
then enter:
$ ./get-prebuilts
You won’t see any confirmation- just another prompt. But this should cause some prebuilt apps to be loaded and installed into the source code. Once completed, this does not need to be done again.
Helpful Tip – Errors during breakfast
Different maintainers setup their device inheritance rules differently. Some require a vendor directory to be populated before breakfast will even succeed. If you receive an error here about vendor makefiles, then jump down to the next section Extract proprietary blobs. The first portion of breakfast should have succeeded at pulling in the device tree and the extract blobs script should be available. After completing that section, you can rerun breakfast xt907
After the source downloads, ensure you are in the root of the source code (cd ~/android/system
), then type:
$ source build/envsetup.sh
$ breakfast xt907
This will download the device specific configuration and kernel source for your device. An alternative to using the breakfast
command is to build your own local manifest. To do this, you will need to locate your device on CyanogenMod’s GitHub and list all of the repositories defined in cm.dependencies in your local manifest.
Helpful Tip
If you want to know more about what source build/envsetup.sh
does or simply want to know more about the breakfast
, brunch
and lunch
commands, you can head over to the Envsetup help page.
Helpful Tip
Instead of typing cd ~/android/system
every time you want to return back to the root of the source code, here’s a short command that will do it for you: croot
. To use this command, you must first run source build/envsetup.sh
from ~/android/system
.
Now ensure that your Droid RAZR M is connected to your computer via the USB cable and that you are in the ~/android/system/device/motorola/xt907
directory (you can cd ~/android/system/device/motorola/xt907
if necessary). Then run the extract-files.sh
script:
$ ./extract-files.sh
You should see the proprietary files (aka “blobs”) get pulled from the device and moved to the ~/android/system/vendor/motorola
directory. If you see errors about adb being unable to pull the files, adb may not be in the path of execution. If this is the case, see the adb page for suggestions for dealing with “command not found” errors.
Note:
Your device should already be running a build of CyanogenMod for the branch you wish to build for the extract-files.sh
script to function properly.
Note:
It’s important that these proprietary files are extracted to the ~/android/system/vendor/motorola
directory by using the extract-files.sh
script. Makefiles are generated at the same time to make sure the blobs are eventually copied to the device. Without these blobs, CyanogenMod may build without error, but you’ll be missing important functionality, such as graphics libraries that enable you to see anything!
You can speed up subsequent builds by adding
export USE_CCACHE=1
to your ~/.bashrc
file (what’s a .bashrc file?). Then, specify the amount of disk space to dedicate to ccache by typing this from the top of your Android tree:
prebuilts/misc/linux-x86/ccache/ccache -M 50G
where 50G
corresponds to 50GB of cache. This only needs to be run once and the setting will be remembered. Anywhere in the range of 25GB to 100GB will result in very noticeably increased build speeds (for instance, a typical 1hr build time can be reduced to 20min). If you’re only building for one device, 25GB-50GB is fine. If you plan to build for several devices that do not share the same kernel source, aim for 75GB-100GB. This space will be permanently occupied on your drive, so take this into consideration. See more information about ccache on Google’s android build environment initialization page.
Helpful Tip
If you are a very active developer, working on many other projects than just Android, you might prefer to keep your Android ccache independent (because it’s huge and can slow down the efficiency of ccache in your other projects). Beginning with CyanogenMod 12.1, you can specify environment variables for the location and size of CyanogenMod’s ccache. Some syntax examples: export ANDROID_CCACHE_DIR="$HOME/android/.ccache"
and export ANDROID_CCACHE_SIZE="50G"
.
Time to start building! So now type:
$ croot
$ brunch xt907
The build should begin.
Helpful Tip
If the build doesn’t start, try lunch
and choose your device from the menu. If that doesn’t work, try breakfast
and choose from the menu. The command make xt907
should then work.
Helpful Tip
A second, bonus tip! If you get a command not found error for croot
, brunch
, or lunch
, be sure you’ve done the source build/envsetup.sh
command in this Terminal session from the ~/android/system
directory.
Helpful Tip
A third tip! If the build to fails while downloading Gello, you’ll need to import a missing certificate into Maven’s truststore. Detailed instructions on how to do that can be found here
ERROR: signapk.jar failed: return code 1make: *** [out/target/product/xt907/cm_xt907-ota-eng.root.zip] Error 1
…you may want to make the following change to ~/android/system/build/tools/releasetools/common.py
:
Search for instances of -Xmx2048m
(it should appear either under OPTIONS.java_args
or near usage of signapk.jar
), and replace it with -Xmx1024m
or -Xmx512m
.
Then start the build again (with brunch).
Assuming the build completed without error (it will be obvious when it finishes), type:
$ cd $OUT
in the same terminal window that you did the build. Here you’ll find all the files that were created. The stuff that will go in /system
is in a folder called system
. The stuff that will become your ramdisk is in a folder called root
. And your kernel is called… kernel
.
But that’s all just background info. The two files we are interested in are (1) recovery.img
, which contains CyanogenMod Recovery, and (2) cm-13.0-20161224-UNOFFICIAL-xt907.zip
, which is the CyanogenMod installation package.
See All About Recovery Images for more information about custom recoveries and their capabilities.
adb reboot bootloader
fastboot devices
fastboot flash recovery your_recovery_image.img
Back to the $OUT
directory on your computer– you should see a file that looks something like:
cm-13.0-20161224-UNOFFICIAL-xt907.zip
Note:
The above file name may vary depending on the version of CM you are building. Your build may not include a version number or may identify itself as a “KANG
” rather than UNOFFICIAL
version. Regardless, the file name will end in .zip
and should be titled similarly to official builds.
Now you can flash the cm...zip
file above as usual via recovery mode. Before doing so, now is a good time to make a backup of whatever installation is currently running on the device in case something goes wrong with the flash attempt. While CyanogenMod Recovery doesn’t have a backup feature, there are other custom recoveries available that do. You can also use something like Titanium Backup (root required) as an alternative.
You’ve done it! Welcome to the elite club of self-builders. You’ve built your operating system from scratch, from the ground up. You are the master/mistress of your domain… and hopefully you’ve learned a bit on the way and had some fun too.
Now that you’ve succeeded in building CyanogenMod for your device, here are some suggestions on what to do next.
Also, be sure to take a glance at the Dev Center on this wiki for all kinds of more detailed information about developer topics ranging from collecting logs, understanding what’s in the source code directories, submitting your own contributions, porting CyanogenMod to new devices, and a lot more.
Congrats again!
Content of this page is based on informations from wiki.cyanogenmod.org, under CC BY-SA 3.0 licence.
Download (nightly build)
CyanogenMod 12.1 (Android 5.1 (Lollipop))
Note:
For CM 11.0, the builds have been unified. Get the latest CM 11.0 builds for mb886 here.
For CM 12.0 and newer, builds were de-unified again and can be found under the usual mb886 device builds.
Note:
Your device must be bootloader unlocked to run CyanogenMod. This can only be accomplished on stock firmware versions prior to 9.20.1
Device | http://www.github.com/cyanogenmod/android_device_motorola_mb886 |
Kernel | http://www.github.com/cyanogenmod/android_kernel_motorola_msm8960-common |
Codename: | mb886 |
---|---|
Also known as: | qinara |
Vendor: | Motorola |
Release date: | 2012 July |
Carrier: | AT&T |
Type: | phone |
GSM freq: | GSM 850/900/1800/1900 HSDPA 850/1700/1900/2100 |
LTE freq: | LTE 700 MHz Class 17/2100 |
Platform: | Qualcomm MSM8960 |
CPU: | 1.5 GHz dual-core Krait |
GPU: | Adreno 225 |
RAM: | 1GB |
Weight: | 140 g (4.94 oz) |
Dimensions: | 133.5 mm (5.26 in) (h) 69.9 mm (2.75in) (w) 8.4 mm (0.33 in) (d) |
Screen size: | 114 mm (4.5 in) |
Resolution: | 720 x 1280 |
Screen density: | ~326 ppi |
Screen type: | TFT |
Internal storage: | 8 GB (4 GB user available) |
SD Card: | microSD, up to 32 GB |
Bluetooth: | v4.0 with A2DP, LE, EDR |
Wi-Fi: | 802.11 a/b/g/n, dual-band, Wi-Fi Direct |
Main camera: | 8MP, flash: LED |
Secondary camera: | 1.3MP |
Power: | Non-removable Li-Ion 1780 mAh battery |
Peripherals: | Accelerometer, proximity, compass |
CM supported: | 10.1, 10.2, 11, 12, 12.1 |
Note: DISCLAIMER
Modifying or replacing your device’s software may void your device’s warranty, lead to data loss, hair loss, financial loss, privacy loss, security breaches, or other damage, and therefore must be done entirely at your own risk. No one affiliated with the CyanogenMod project is responsible for your actions. Good luck.
Note:
For CM 11.0, the builds have been unified. Get the latest CM 11.0 builds for mb886 here.
For CM 12.0 and newer, builds were de-unified again and can be found under the usual mb886 device builds.
Note:
Your device must be bootloader unlocked to run CyanogenMod. This can only be accomplished on stock firmware versions prior to 9.20.1
./run.sh
See All About Recovery Images for more information about custom recoveries and their capabilities.
adb reboot bootloader
fastboot devices
fastboot flash recovery your_recovery_image.img
/storage/sdcard0
or /sdcard
as a mountable volume, go ahead and mount it. If you do not see one of these partitions, then instead mount the /data
partition. Take note of which volume you mounted. Now, push the package(s) to your device (also, see tip below):adb push update.zip /storage/sdcard0/
adb push update.zip /sdcard/
update.zip
should be replaced with the package filename. Go back to the main menu and select install zip. Choose to install from the same directory where you pushed the package(s). If you are installing multiple packages, install CyanogenMod first and then install any subsequent packages on top of it.Helpful Tip – SD card folders
CyanogenMod 10.1 and newer have multi-user support (introduced in Android 4.2). If your device has storage on the /data partition, then Android actually looks in /data/media/0/ for the first user’s /sdcard/ storage. ClockworkMod recovery symlinks /sdcard/ to /data/media/ though. So, if you are pushing files to internal storage in recovery and want them to be visible in Android, you should push them to /sdcard/0/ or /data/media/0/. Here’s the most frequent scenarios:
adb push update.zip /sdcard/
adb shell "mkdir /sdcard/0/"
followed by adb push update.zip /sdcard/0/
adb push update.zip /sdcard/0/
Helpful Tip
These instructions will hopefully assist you to start with a stock Atrix HD, unlock the bootloader (if necessary), and then download the required tools as well as the very latest source code for CyanogenMod (based on Google’s Android operating system). Using these, you can build both CyanogenMod and CyanogenMod Recovery image from source code, and then install them both to your device.
It is difficult to say how much experience is necessary to follow these instructions. While this guide is certainly not for the very very very uninitiated, these steps shouldn’t require a PhD in software development either. Some readers will have no difficulty and breeze through the steps easily. Others may struggle over the most basic operation. Because people’s experiences, backgrounds, and intuitions differ, it may be a good idea to read through just to ascertain whether you feel comfortable or are getting over your head.
Remember, you assume all risk of trying this, but you will reap the rewards! It’s pretty satisfying to boot into a fresh operating system you baked at home :) And once you’re an Android-building ninja, there will be no more need to wait for “nightly” builds from anyone. You will have at your fingertips the skills to build a full operating system from code to a running device, whenever you want. Where you go from there– maybe you’ll add a feature, fix a bug, add a translation, or use what you’ve learned to build a new app or port to a new device– or maybe you’ll never build again– it’s all really up to you.
cd
for “change directory”, the concept of directory hierarchies, that in Linux they are separated by /
, etc.If you are not accustomed to using Linux– this is an excellent chance to learn. It’s free– just download and run a virtual machine (VM) such as Virtualbox, then install a Linux distribution such as Ubuntu (AOSP vets Ubuntu as well). Any recent 64-bit version should work great, but the latest is recommended.
Note:
You want to use a 64-bit version of Linux. A 32-bit Linux environment will only work if you are building CyanogenMod 6 and older. For CyanogenMod 10.1, if you encounter issues with 64bit host binaries, you can set BUILD_HOST_32bit=1
in your environment. This is generally not needed, though, especially with CyanogenMod 10.2 and newer.
Using a VM allows Linux to run as a guest inside your host computer– a computer in a computer, if you will. If you hate Linux for whatever reason, you can always just uninstall and delete the whole thing. (There are plenty of places to find instructions for setting up Virtualbox with Ubuntu, so I’ll leave it to you to do that.)
So let’s begin!
Note:
You only need to do these steps the first time you build. If you previously prepared your build environment and have downloaded the CyanogenMod source code for another device, skip to Prepare the device-specific code.
Helpful Tip
While the SDK contains lots of different things– the two tools you are most interested in for building Android are adb and fastboot, located in the /platform-tools
directory.
Several “build packages” are needed to build CyanogenMod. You can install these using the package manager of your choice.
Helpful Tip
A package manager in Linux is a system used to install or remove software (usually originating from the Internet) on your computer. With Ubuntu, you can use the Ubuntu Software Center. Even better, you may also use the apt-get install
command directly in the Terminal. (Learn more about the apt packaging tool system from Wikipedia.)
For both 32-bit & 64-bit systems, you’ll need:
bc bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop maven openjdk-7-jdk pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev
In addition to the above, for 64-bit systems, get these:
g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev
For Ubuntu 15.10 (wily) and newer, substitute:
lib32readline-gplv2-dev
→ lib32readline6-dev
For Ubuntu 16.04 (xenial) and newer, substitute (additionally see java notes below):
libwxgtk2.8-dev
→ libwxgtk3.0-dev
openjdk-7-jdk
→ openjdk-8-jdk
Java versions: Different versions of CyanogenMod require different versions of the JDK (Java Development Kit):
Ubuntu 16.04 (Xenial Xerus) or newer and OpenJDK: Since OpenJDK 1.7 was removed from the official Ubuntu repositories, you have a couple options:
$HOME/.bashrc
file: export EXPERIMENTAL_USE_JAVA8=true
.Also see http://source.android.com/source/initializing.html which lists needed packages.
You will need to set up some directories in your build environment.
To create them:
$ mkdir -p ~/bin
$ mkdir -p ~/android/system
repo
commandEnter the following to download the “repo” binary and make it executable (runnable):
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
~/bin
directory in your path of executionIn recent versions of Ubuntu, ~/bin
should already be in your PATH. You can check this by opening ~/.profile
with a text editor and verifying the following code exists (add it if it is missing):
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
Enter the following to initialize the repository:
$ cd ~/android/system/
$ repo init -u https://github.com/CyanogenMod/android.git -b cm-13.0
To start the download of all the source code to your computer:
$ repo sync
The CM manifests include a sensible default configuration for repo
, which we strongly suggest you use (i.e. don’t add any options to sync
). For reference, our default values are -j 4
and -c
. The -j 4
part means that there will be four simultaneous threads/connections. If you experience problems syncing, you can lower this to -j 3
or -j 2
. -c
will ask repo to pull in only the current branch, instead of the entire CM history.
Prepare to wait a long time while the source code downloads.
Helpful Tip
The repo sync
command is used to update the latest source code from CyanogenMod and Google. Remember it, as you can do it every few days to keep your code base fresh and up-to-date.
Next,
$ cd ~/android/system/vendor/cm
then enter:
$ ./get-prebuilts
You won’t see any confirmation- just another prompt. But this should cause some prebuilt apps to be loaded and installed into the source code. Once completed, this does not need to be done again.
Helpful Tip – Errors during breakfast
Different maintainers setup their device inheritance rules differently. Some require a vendor directory to be populated before breakfast will even succeed. If you receive an error here about vendor makefiles, then jump down to the next section Extract proprietary blobs. The first portion of breakfast should have succeeded at pulling in the device tree and the extract blobs script should be available. After completing that section, you can rerun breakfast mb886
After the source downloads, ensure you are in the root of the source code (cd ~/android/system
), then type:
$ source build/envsetup.sh
$ breakfast mb886
This will download the device specific configuration and kernel source for your device. An alternative to using the breakfast
command is to build your own local manifest. To do this, you will need to locate your device on CyanogenMod’s GitHub and list all of the repositories defined in cm.dependencies in your local manifest.
Helpful Tip
If you want to know more about what source build/envsetup.sh
does or simply want to know more about the breakfast
, brunch
and lunch
commands, you can head over to the Envsetup help page.
Helpful Tip
Instead of typing cd ~/android/system
every time you want to return back to the root of the source code, here’s a short command that will do it for you: croot
. To use this command, you must first run source build/envsetup.sh
from ~/android/system
.
Now ensure that your Atrix HD is connected to your computer via the USB cable and that you are in the ~/android/system/device/motorola/mb886
directory (you can cd ~/android/system/device/motorola/mb886
if necessary). Then run the extract-files.sh
script:
$ ./extract-files.sh
You should see the proprietary files (aka “blobs”) get pulled from the device and moved to the ~/android/system/vendor/motorola
directory. If you see errors about adb being unable to pull the files, adb may not be in the path of execution. If this is the case, see the adb page for suggestions for dealing with “command not found” errors.
Note:
Your device should already be running a build of CyanogenMod for the branch you wish to build for the extract-files.sh
script to function properly.
Note:
It’s important that these proprietary files are extracted to the ~/android/system/vendor/motorola
directory by using the extract-files.sh
script. Makefiles are generated at the same time to make sure the blobs are eventually copied to the device. Without these blobs, CyanogenMod may build without error, but you’ll be missing important functionality, such as graphics libraries that enable you to see anything!
You can speed up subsequent builds by adding
export USE_CCACHE=1
to your ~/.bashrc
file (what’s a .bashrc file?). Then, specify the amount of disk space to dedicate to ccache by typing this from the top of your Android tree:
prebuilts/misc/linux-x86/ccache/ccache -M 50G
where 50G
corresponds to 50GB of cache. This only needs to be run once and the setting will be remembered. Anywhere in the range of 25GB to 100GB will result in very noticeably increased build speeds (for instance, a typical 1hr build time can be reduced to 20min). If you’re only building for one device, 25GB-50GB is fine. If you plan to build for several devices that do not share the same kernel source, aim for 75GB-100GB. This space will be permanently occupied on your drive, so take this into consideration. See more information about ccache on Google’s android build environment initialization page.
Helpful Tip
If you are a very active developer, working on many other projects than just Android, you might prefer to keep your Android ccache independent (because it’s huge and can slow down the efficiency of ccache in your other projects). Beginning with CyanogenMod 12.1, you can specify environment variables for the location and size of CyanogenMod’s ccache. Some syntax examples: export ANDROID_CCACHE_DIR="$HOME/android/.ccache"
and export ANDROID_CCACHE_SIZE="50G"
.
Time to start building! So now type:
$ croot
$ brunch mb886
The build should begin.
Helpful Tip
If the build doesn’t start, try lunch
and choose your device from the menu. If that doesn’t work, try breakfast
and choose from the menu. The command make mb886
should then work.
Helpful Tip
A second, bonus tip! If you get a command not found error for croot
, brunch
, or lunch
, be sure you’ve done the source build/envsetup.sh
command in this Terminal session from the ~/android/system
directory.
Helpful Tip
A third tip! If the build to fails while downloading Gello, you’ll need to import a missing certificate into Maven’s truststore. Detailed instructions on how to do that can be found here
ERROR: signapk.jar failed: return code 1make: *** [out/target/product/mb886/cm_mb886-ota-eng.root.zip] Error 1
…you may want to make the following change to ~/android/system/build/tools/releasetools/common.py
:
Search for instances of -Xmx2048m
(it should appear either under OPTIONS.java_args
or near usage of signapk.jar
), and replace it with -Xmx1024m
or -Xmx512m
.
Then start the build again (with brunch).
Assuming the build completed without error (it will be obvious when it finishes), type:
$ cd $OUT
in the same terminal window that you did the build. Here you’ll find all the files that were created. The stuff that will go in /system
is in a folder called system
. The stuff that will become your ramdisk is in a folder called root
. And your kernel is called… kernel
.
But that’s all just background info. The two files we are interested in are (1) recovery.img
, which contains CyanogenMod Recovery, and (2) cm-13.0-20161224-UNOFFICIAL-mb886.zip
, which is the CyanogenMod installation package.
See All About Recovery Images for more information about custom recoveries and their capabilities.
adb reboot bootloader
fastboot devices
fastboot flash recovery your_recovery_image.img
Back to the $OUT
directory on your computer– you should see a file that looks something like:
cm-13.0-20161224-UNOFFICIAL-mb886.zip
Note:
The above file name may vary depending on the version of CM you are building. Your build may not include a version number or may identify itself as a “KANG
” rather than UNOFFICIAL
version. Regardless, the file name will end in .zip
and should be titled similarly to official builds.
Now you can flash the cm...zip
file above as usual via recovery mode. Before doing so, now is a good time to make a backup of whatever installation is currently running on the device in case something goes wrong with the flash attempt. While CyanogenMod Recovery doesn’t have a backup feature, there are other custom recoveries available that do. You can also use something like Titanium Backup (root required) as an alternative.
You’ve done it! Welcome to the elite club of self-builders. You’ve built your operating system from scratch, from the ground up. You are the master/mistress of your domain… and hopefully you’ve learned a bit on the way and had some fun too.
Now that you’ve succeeded in building CyanogenMod for your device, here are some suggestions on what to do next.
Also, be sure to take a glance at the Dev Center on this wiki for all kinds of more detailed information about developer topics ranging from collecting logs, understanding what’s in the source code directories, submitting your own contributions, porting CyanogenMod to new devices, and a lot more.
Congrats again!
Content of this page is based on informations from wiki.cyanogenmod.org, under CC BY-SA 3.0 licence.
Download (nightly build)
CyanogenMod 7 (Android 2.3 (Gingerbread))
Note: Support Status
This device does not support the latest official release of CyanogenMod. This may be due to hardware limitations or simply because development is ongoing. The most recent version supported is based on the gingerbread branch of CyanogenMod.
Device | http://www.github.com/cyanogenmod/android_device_motorola_olympus |
Codename: | olympus |
---|---|
Vendor: | Motorola |
Manufacturer: | motorola |
Release date: | 2011 August 5 |
Carrier: | Verizon |
Type: | phone |
GSM freq: | 850 900 1800 1900 MHz |
CDMA freq: | 850 1900 2100 MHz |
LTE freq: | 700MHz |
Platform: | NVIDIA Tegra 2 |
CPU: | 1 GHz dual-core Nvidia Tegra 2 |
GPU: | GeForce ULP |
RAM: | 1GB |
Weight: | 158 g (5.6 oz) |
Dimensions: | 127 mm (5 in) (h) 67 mm (2.6 in) (w) 12 mm (0.472 in) (d) |
Screen size: | 109 mm (4.3 in) |
Resolution: | 960 x 540 px |
Internal storage: | 16GB |
SD Card: | up to 32 GB |
Bluetooth: | 2.1 |
Wi-Fi: | 802.11 b/g/n |
Main camera: | 8MP w/ Dual LED flash |
Secondary camera: | 1.3MP |
Power: | 1700 mAh internal rechargeable removable lithium-ion polymer battery |
CM supported: | 7 |
Latest CM version: | gingerbread |
Note: DISCLAIMER
Modifying or replacing your device’s software may void your device’s warranty, lead to data loss, hair loss, financial loss, privacy loss, security breaches, or other damage, and therefore must be done entirely at your own risk. No one affiliated with the CyanogenMod project is responsible for your actions. Good luck.
If the bootloader of the Motorola Atrix 4G has already been unlocked, you may skip this section.
feb9a71470ee539e074bf420a2e4d8bd
703af2c5d0258fa09e6e2ace6e1ef648
a5da47565160e0f95b84a1e769b9028b
f609dbc4c5842f9654e44a1980375100
fastboot oem unlock
chmod +x sbf_flash
./sbf_flash <SBF File name here>.sbf
fastboot oem unlock
fastboot oem unlock **ID**
fastboot reboot
See All About Recovery Images for more information about custom recoveries and their capabilities.
c03a7a40c633cd66886d51793dbb29c2
adb reboot bootloader
fastboot devices
fastboot flash recovery your_recovery_image.img
/storage/sdcard0
or /sdcard
as a mountable volume, go ahead and mount it. If you do not see one of these partitions, then instead mount the /data
partition. Take note of which volume you mounted. Now, push the package(s) to your device (also, see tip below):adb push update.zip /storage/sdcard0/
adb push update.zip /sdcard/
update.zip
should be replaced with the package filename. Go back to the main menu and select install zip. Choose to install from the same directory where you pushed the package(s). If you are installing multiple packages, install CyanogenMod first and then install any subsequent packages on top of it.Helpful Tip – SD card folders
CyanogenMod 10.1 and newer have multi-user support (introduced in Android 4.2). If your device has storage on the /data partition, then Android actually looks in /data/media/0/ for the first user’s /sdcard/ storage. ClockworkMod recovery symlinks /sdcard/ to /data/media/ though. So, if you are pushing files to internal storage in recovery and want them to be visible in Android, you should push them to /sdcard/0/ or /data/media/0/. Here’s the most frequent scenarios:
adb push update.zip /sdcard/
adb shell "mkdir /sdcard/0/"
followed by adb push update.zip /sdcard/0/
adb push update.zip /sdcard/0/
These instructions will hopefully assist you to start with a stock Atrix 4G, unlock the bootloader (if necessary), and then download the required tools as well as the very latest source code for CyanogenMod (based on Google’s Android operating system). Using these, you can build both CyanogenMod and CyanogenMod Recovery image from source code, and then install them both to your device.
It is difficult to say how much experience is necessary to follow these instructions. While this guide is certainly not for the very very very uninitiated, these steps shouldn’t require a PhD in software development either. Some readers will have no difficulty and breeze through the steps easily. Others may struggle over the most basic operation. Because people’s experiences, backgrounds, and intuitions differ, it may be a good idea to read through just to ascertain whether you feel comfortable or are getting over your head.
Remember, you assume all risk of trying this, but you will reap the rewards! It’s pretty satisfying to boot into a fresh operating system you baked at home :) And once you’re an Android-building ninja, there will be no more need to wait for “nightly” builds from anyone. You will have at your fingertips the skills to build a full operating system from code to a running device, whenever you want. Where you go from there– maybe you’ll add a feature, fix a bug, add a translation, or use what you’ve learned to build a new app or port to a new device– or maybe you’ll never build again– it’s all really up to you.
cd
for “change directory”, the concept of directory hierarchies, that in Linux they are separated by /
, etc.If you are not accustomed to using Linux– this is an excellent chance to learn. It’s free– just download and run a virtual machine (VM) such as Virtualbox, then install a Linux distribution such as Ubuntu (AOSP vets Ubuntu as well). Any recent 64-bit version should work great, but the latest is recommended.
Note:
You want to use a 64-bit version of Linux. A 32-bit Linux environment will only work if you are building CyanogenMod 6 and older. For CyanogenMod 10.1, if you encounter issues with 64bit host binaries, you can set BUILD_HOST_32bit=1
in your environment. This is generally not needed, though, especially with CyanogenMod 10.2 and newer.
Using a VM allows Linux to run as a guest inside your host computer– a computer in a computer, if you will. If you hate Linux for whatever reason, you can always just uninstall and delete the whole thing. (There are plenty of places to find instructions for setting up Virtualbox with Ubuntu, so I’ll leave it to you to do that.)
So let’s begin!
Note:
You only need to do these steps the first time you build. If you previously prepared your build environment and have downloaded the CyanogenMod source code for another device, skip to Prepare the device-specific code.
Helpful Tip
While the SDK contains lots of different things– the two tools you are most interested in for building Android are adb and fastboot, located in the /platform-tools
directory.
Several “build packages” are needed to build CyanogenMod. You can install these using the package manager of your choice.
Helpful Tip
A package manager in Linux is a system used to install or remove software (usually originating from the Internet) on your computer. With Ubuntu, you can use the Ubuntu Software Center. Even better, you may also use the apt-get install
command directly in the Terminal. (Learn more about the apt packaging tool system from Wikipedia.)
For both 32-bit & 64-bit systems, you’ll need:
bc bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop maven openjdk-7-jdk pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev
In addition to the above, for 64-bit systems, get these:
g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev
For Ubuntu 15.10 (wily) and newer, substitute:
lib32readline-gplv2-dev
→ lib32readline6-dev
For Ubuntu 16.04 (xenial) and newer, substitute (additionally see java notes below):
libwxgtk2.8-dev
→ libwxgtk3.0-dev
openjdk-7-jdk
→ openjdk-8-jdk
Java versions: Different versions of CyanogenMod require different versions of the JDK (Java Development Kit):
Ubuntu 16.04 (Xenial Xerus) or newer and OpenJDK: Since OpenJDK 1.7 was removed from the official Ubuntu repositories, you have a couple options:
$HOME/.bashrc
file: export EXPERIMENTAL_USE_JAVA8=true
.Also see http://source.android.com/source/initializing.html which lists needed packages.
You will need to set up some directories in your build environment.
To create them:
$ mkdir -p ~/bin
$ mkdir -p ~/android/system
repo
commandEnter the following to download the “repo” binary and make it executable (runnable):
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
~/bin
directory in your path of executionIn recent versions of Ubuntu, ~/bin
should already be in your PATH. You can check this by opening ~/.profile
with a text editor and verifying the following code exists (add it if it is missing):
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
Enter the following to initialize the repository:
$ cd ~/android/system/
$ repo init -u https://github.com/CyanogenMod/android.git -b gingerbread
To start the download of all the source code to your computer:
$ repo sync
The CM manifests include a sensible default configuration for repo
, which we strongly suggest you use (i.e. don’t add any options to sync
). For reference, our default values are -j 4
and -c
. The -j 4
part means that there will be four simultaneous threads/connections. If you experience problems syncing, you can lower this to -j 3
or -j 2
. -c
will ask repo to pull in only the current branch, instead of the entire CM history.
Prepare to wait a long time while the source code downloads.
Helpful Tip
The repo sync
command is used to update the latest source code from CyanogenMod and Google. Remember it, as you can do it every few days to keep your code base fresh and up-to-date.
$ cd ~/android/system/vendor/cyanogen
then enter:
$ ./get-rommanager
You won’t see any confirmation- just another prompt. But this should cause the Rom Manager apps to be loaded and installed into the source code. Once completed, this does not need to be done again.
After the source downloads, ensure you are in the root of the source code (cd ~/android/system
), then type:
$ source build/envsetup.sh
$ lunch
You should see a list of devices, including something like cm_olympus-userdebug
. Select it by typing its number. It is possible that lunch
does not display your device. In that case try
$ lunch cm_olympus-userdebug
or
$ lunch full_olympus-userdebug
If all goes well, you should see that olympus-specific directories are downloaded automatically.
Helpful Tip
If you want to know more about what source build/envsetup.sh
does or simply want to know more about the breakfast
, brunch
and lunch
commands, you can head over to the Envsetup help page.
Helpful Tip
Instead of typing cd ~/android/system
every time you want to return back to the root of the source code, here’s a short command that will do it for you: croot
. To use this command, you must first run source build/envsetup.sh
from ~/android/system
.
Now ensure that your Atrix 4G is connected to your computer via the USB cable and that you are in the ~/android/system/device/motorola/olympus
directory (you can cd ~/android/system/device/motorola/olympus
if necessary). Then run the extract-files.sh
script:
$ ./extract-files.sh
You should see the proprietary files (aka “blobs”) get pulled from the device and moved to the ~/android/system/vendor/motorola
directory. If you see errors about adb being unable to pull the files, adb may not be in the path of execution. If this is the case, see the adb page for suggestions for dealing with “command not found” errors.
Note:
Your device should already be running a build of CyanogenMod for the branch you wish to build for the extract-files.sh
script to function properly.
Note:
It’s important that these proprietary files are extracted to the ~/android/system/vendor/motorola
directory by using the extract-files.sh
script. Makefiles are generated at the same time to make sure the blobs are eventually copied to the device. Without these blobs, CyanogenMod may build without error, but you’ll be missing important functionality, such as graphics libraries that enable you to see anything!
You can speed up subsequent builds by adding
export USE_CCACHE=1
to your ~/.bashrc
file (what’s a .bashrc file?). Then, specify the amount of disk space to dedicate to ccache by typing this from the top of your Android tree:
prebuilt/linux-x86/ccache/ccache -M 50G
where 50G
corresponds to 50GB of cache. This only needs to be run once and the setting will be remembered. Anywhere in the range of 25GB to 100GB will result in very noticeably increased build speeds (for instance, a typical 1hr build time can be reduced to 20min). If you’re only building for one device, 25GB-50GB is fine. If you plan to build for several devices that do not share the same kernel source, aim for 75GB-100GB. This space will be permanently occupied on your drive, so take this into consideration. See more information about ccache on Google’s android build environment initialization page.
Helpful Tip
If you are a very active developer, working on many other projects than just Android, you might prefer to keep your Android ccache independent (because it’s huge and can slow down the efficiency of ccache in your other projects). Beginning with CyanogenMod 12.1, you can specify environment variables for the location and size of CyanogenMod’s ccache. Some syntax examples: export ANDROID_CCACHE_DIR="$HOME/android/.ccache"
and export ANDROID_CCACHE_SIZE="50G"
.
Time to start building! So now type:
$ croot
$ brunch olympus
The build should begin.
Helpful Tip
If the build doesn’t start, try lunch
and choose your device from the menu. If that doesn’t work, try breakfast
and choose from the menu. The command make olympus
should then work.
Helpful Tip
A second, bonus tip! If you get a command not found error for croot
, brunch
, or lunch
, be sure you’ve done the source build/envsetup.sh
command in this Terminal session from the ~/android/system
directory.
Helpful Tip
A third tip! If the build to fails while downloading Gello, you’ll need to import a missing certificate into Maven’s truststore. Detailed instructions on how to do that can be found here
ERROR: signapk.jar failed: return code 1make: *** [out/target/product/olympus/cm_olympus-ota-eng.root.zip] Error 1
…you may want to make the following change to ~/android/system/build/tools/releasetools/common.py
:
Search for instances of -Xmx2048m
(it should appear either under OPTIONS.java_args
or near usage of signapk.jar
), and replace it with -Xmx1024m
or -Xmx512m
.
Then start the build again (with brunch).
Assuming the build completed without error (it will be obvious when it finishes), type:
$ cd $OUT
in the same terminal window that you did the build. Here you’ll find all the files that were created. The stuff that will go in /system
is in a folder called system
. The stuff that will become your ramdisk is in a folder called root
. And your kernel is called… kernel
.
But that’s all just background info. The two files we are interested in are (1) recovery.img
, which contains CyanogenMod Recovery, and (2) cm-7-20161224-UNOFFICIAL-olympus.zip
, which is the CyanogenMod installation package.
Back to the $OUT
directory on your computer– you should see a file that looks something like:
cm-7-20161224-UNOFFICIAL-olympus.zip
Note:
The above file name may vary depending on the version of CM you are building. Your build may not include a version number or may identify itself as a “KANG
” rather than UNOFFICIAL
version. Regardless, the file name will end in .zip
and should be titled similarly to official builds.
Now you can flash the cm...zip
file above as usual via recovery mode. Before doing so, now is a good time to make a backup of whatever installation is currently running on the device in case something goes wrong with the flash attempt. While CyanogenMod Recovery doesn’t have a backup feature, there are other custom recoveries available that do. You can also use something like Titanium Backup (root required) as an alternative.
You’ve done it! Welcome to the elite club of self-builders. You’ve built your operating system from scratch, from the ground up. You are the master/mistress of your domain… and hopefully you’ve learned a bit on the way and had some fun too.
Now that you’ve succeeded in building CyanogenMod for your device, here are some suggestions on what to do next.
Also, be sure to take a glance at the Dev Center on this wiki for all kinds of more detailed information about developer topics ranging from collecting logs, understanding what’s in the source code directories, submitting your own contributions, porting CyanogenMod to new devices, and a lot more.
Congrats again!
Content of this page is based on informations from wiki.cyanogenmod.org, under CC BY-SA 3.0 licence.