FORUMS
Remove All Ads from XDA

[Tutorial] How to build a ROM?

7,702 posts
Thanks Meter: 15,780
 
By eagleeyetom, Developer Committee Lead / XDA Portal Team / Senior Moderator on 20th January 2012, 10:06 AM
Post Reply Email Thread
Hello everybody. After many attempts to build a ROM I decided to share my knowledge with you
I'm going to show you how to build CM7 for X8 using official CM sources.

As the result you will have:

CyanogenMod in version 2.3.7 for X8 aka Shakira. You need to have unlocked bootloader and flash FXP kernel to use this ROM.

WARNING: This may brick your device. You have been warned!

What are the requirements?

0. A smart head, and being willing to learn something new.
1. A PC featuring a dual-core CPU (the more, the merrier) and at least 1.5GB RAM. Having a CPU that supports 64-Bit Mode (Intel EM64T / AMD64) and Paravirtualization (Intel VT-x / AMD-V) is required if you are planning to run a 64-Bit distribution.
2. A Linux based system such as Ubuntu or Linux Mint. My guide should work on any other Ubuntu based distribution as well, though you need to adapt commands in case you're running a RPM based Red Hat/Fedora/openSUSE distribution. To make things easier if your main OS is Windows you better consider using Linux in a Virtual Machine (VirtualBox recommended).
3. Speedy internet connection so the download of the CyangogenMod sources don't take forever.
4. About 50GB of FREE disk space.
5. Ability to access to Internet in Linux / your Virtual Machine so you can access Google and XDA to search for help, because everything that can go wrong will go wrong ;P
Shall we dance?

1. Download and install Linux. Linux is perfectly legal free opensource software; you won't go to jail for downloading it. I prefer Ubuntu 10.10 or Linux Mint 10 (which I'm using). The best choice is to use the respective 64-Bit edition. You may find links in next post.
2. There is a tool called "Terminal" - it's your new best friend. Create a shortcut in desktop.

How Linux look like


Just like Windows, but better

Paste this into terminal:

For Ubuntu below 11.04 use this:

Code:
sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.8-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev openjdk-6-jdk pngcrush schedtool g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline5-dev gcc-4.3-multilib g++-4.3-multilib
NOTE: As for Ubuntu 11.04+ (also applies to Linux Mint 11+) see what Novek posted in the CMCompiler thread.

lib32readline5-dev has been replaced by lib32readline-gplv2-dev on 11.10
And "gcc-4.3-multilib g++-4.3-multilib" aren't used from 11.04 and up - not needed, so use this code:
Code:
sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.8-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev openjdk-6-jdk pngcrush schedtool g++-multilib lib32z1-dev lib32ncurses5-dev
You may want to add that piece of intel.

This will install required packages. If you'll receive errors try to delete packages from above code.

After this you'll need to create folders for CM repo.
Type:
Code:
mkdir -p ~/bin 
mkdir -p ~/android/system
PATH=~/bin:$PATH
You could name second folder as you want.

Next step: Repo installation

Code:
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo 
chmod a+x ~/bin/repo
chmod is a very important command. It's allows you to give permissions for specific files/folders.

Next step: Downloading the beast

Remember to type correct folder name!

Code:
cd ~/android/system/ 
repo init -u git://github.com/CyanogenMod/android.git -b gingerbread 
repo sync -j10
-j attribute is responsible for number of processes taken in single action. If you have powerful PC you could use -j16 or even -j32. Bigger number - quicker extraction of files.

Get the ROM Manager just in case

Code:
~/android/system/vendor/cyanogen/get-rommanager
Next step: Download Android-SDK to make ADB work

Extract this to home directory, then
Code:
cd ~/android-sdk-linux/tools
 ./android
Just do what is shown in this movies:

[YOUTUBE]dfdpYFMax8M[/YOUTUBE] [YOUTUBE]-qBpoEf1XYE[/YOUTUBE]

Download all files and get ready.

Next step: Copy proprietary files (you need to have phone connected in debugging mode) - For proprietary files use stock ROM or official CM 7.1.

Type in terminal:
Code:
cd ~/android/system/device/semc/shakira/ 
./extract-files.sh
If you have problems copy adb file to this directory and edit extract-files.sh to have something like this:

./adb pull instead of adb pull

If you have troubles do this:

After installation open terminal and type:

Code:
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools
Put correct path to your adb.

Type
Code:
./adb devices
if you'll receive such line
Code:
"List of devices attached
 ???????????? no permissions"
do specific thing.

Code:
sudo touch /etc/udev/rules.d/51-android.rules && sudo sh -c "echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", SYSFS{idProduct}=="612e", MODE="0666"' >> /etc/udev/rules.d/51-android.rules" && sudo chmod 644 /etc/udev/rules.d/51-android.rules
If something goes wrong type
Code:
lsusb
to see which devices are connected and change code.

Then

Code:
sudo restart udev
sudo ./adb kill-server
sudo ./adb start-server
And it's ready to action.

Next step: Setting build environment

Type in terminal:
Code:
cd ~/android/system/
. build/envsetup.sh && breakfast shakira
You'll see the list of CM devices
Shakira is number 136 (right now is #144)
- It won't work due to changes in CM device tree.



So use:

Code:
lunch cyanogen_shakira-eng
or
breakfast shakira
Next: Step - build!

All you need to do right now is type magic command "make"
Add -j4 to make it much quicker

To obtain update.zip file type
Code:
make -j4 bacon


Now wait patiently and fight errors

I'm glad if I helped somebody to build his/her first ROM.
If I made any mistakes feel free to correct me.

Thanks to B.Jay for help.

I spent some time to write this, so hit thanks button
You can also donate me. All donations are highly appreciated :beer:
Attached Thumbnails
Click image for larger version

Name:	Ubuntu-2012-01-20-08-44-36.png
Views:	49417
Size:	84.3 KB
ID:	864386   Click image for larger version

Name:	Ubuntu-2012-01-20-10-48-42.jpg
Views:	46794
Size:	23.2 KB
ID:	864397   Click image for larger version

Name:	Ubuntu-2012-01-20-10-55-14.jpg
Views:	44475
Size:	33.4 KB
ID:	864401  
The Following 195 Users Say Thank You to eagleeyetom For This Useful Post: [ View ] Gift eagleeyetom Ad-Free
 
 
B.Jay
20th January 2012, 02:40 PM |#2  
Guest
Thanks Meter: 0
 
More
Okay, since eagleeyetom decided to make his research about how to build CM7 public, here are a few thoughts of my own to accompany his guide...

If you're a Windows user and don't want to go through the hassle of dual-booting Linux with Windows XP/Vista/7 it's highly recommended that you install VirtualBox as your virtualization software (also download and install the Extensions Pack if you want to connect to your phone through USB right out of the VM!). Stay clear from VMware Player or VMware Workstation. Things like 3D acceleration will not work with VMware! A important aspect if you're opting to install a Gnome3/GTK3 based distribution release, or you simply want the eye-candy to make work more fun.

This means ... the specs of your system should be above "average". Since the Virtual Machine, into which you're going to install Linux, will need some RAM for its own don't even think about this approach if your system is at, or well below, 3GB RAM. Especially with Windows Vista or Windows 7 being your OS upon which VirtualBox will run you will find yourself in the situation very quickly that Windows sucks up a good Gigabyte of RAM just for itself - and keep in mind that VirtualBox will need a wee bit more than just the 1.5GB RAM (or whatever you're going to assign) + 8MB VRAM to run.

Of course you also need some spare space on your hard drive(s) as you need to create a Virtual Hard Drive for the Virtual Machine. 80GB should be considered the minimum here as you're going to need quite some space for the source, the temp files that get created during the compile, and the finalized ROM.

I'd recommend you partition your virtual hard drive this way...

~1GB ext4 as /boot
2* the amount of RAM you assigned to your VM as swap (3GB swap if your VM runs on 1.5GB RAM)
The rest ext4 as /

Stay away from btrfs as it will give terrible performance in a VM.

A better partitioning would be to keep / and /home separated in case you plan to upgrade the Linux installation in your VM...

~1GB ext4 as /boot
2* the amount of RAM you assigned to your VM as swap (3GB swap if your VM runs on 1.5GB RAM)
~10-15GB ext4 as /
The rest ext4 as /home

That way you won't lose your stuff in /home in case things go wrong at an dist-upgrade.

Once you got Linux Installed install the Guest Additions ... it'll make working with your Virtual Machine and switching back and forth between the host OS and your VM way easier. In case the build of the kernel modules bombs out with a error message open a terminal and issue "sudo apt-get install build-essentials" ... that should solve the problem.

While you should get by with 1.5GB RAM to build CM7 (aka "Gingerbread") Google specifies the use of a 64-Bit Linux Distribution and at least 8GB RAM to tinker around with Ice Cream Sandwich. If you want to play around with the CM9 sources once they become available to the masses you better keep the aforementioned system requirements in mind.

If you happen to have questions about setting up VirtualBox feel free to post.

Value added Links:

Linux Mint 10 (as used by eagleeyetom)
Download here
Linux Mint 12 (latest version at the time of writing)
Download here

Ubuntu Linux 10.04 LTS or 11.10
Download here
The Following 28 Users Say Thank You to For This Useful Post: [ View ] Gift Ad-Free
20th January 2012, 02:44 PM |#3  
andro_king's Avatar
Senior Member
Flag Coimbatore
Thanks Meter: 52
 
More
Great man
Tfs..!!
Sent from my Micromax A60 using xda premium
20th January 2012, 08:27 PM |#4  
wilbso's Avatar
Senior Member
Flag The Internet
Thanks Meter: 245
 
Donate to Me
More
Thanks fir the guide. I bow have Linux on my own laptop
The Following User Says Thank You to wilbso For This Useful Post: [ View ] Gift wilbso Ad-Free
21st January 2012, 02:06 PM |#5  
beastfren's Avatar
Member
Flag Lipa City
Thanks Meter: 9
 
More
Thumbs up
will definitely try to build my own rom,
thank you.
21st January 2012, 08:55 PM |#6  
Senior Member
Flag Macroom (Ireland)
Thanks Meter: 192
 
More
One Question , this rom will be for stock kernel am i right ?
21st January 2012, 09:08 PM |#7  
eagleeyetom's Avatar
OP Developer Committee Lead / XDA Portal Team / Senior Moderator
Flag Gdańsk
Thanks Meter: 15,780
 
Donate to Me
More
This ROM will be for FXP kernel.

Sent from my X8 using xda premium
The Following 6 Users Say Thank You to eagleeyetom For This Useful Post: [ View ] Gift eagleeyetom Ad-Free
21st January 2012, 09:29 PM |#8  
Senior Member
Flag Macroom (Ireland)
Thanks Meter: 192
 
More
and last question , what android it will be , i mean version ? 2.3.5 or 2.3.7 ?
If it will be something like that im going to made my rom ;D
22nd January 2012, 07:24 AM |#9  
eagleeyetom's Avatar
OP Developer Committee Lead / XDA Portal Team / Senior Moderator
Flag Gdańsk
Thanks Meter: 15,780
 
Donate to Me
More
It's 2.3.7. The same as the latest nightly for Shakira. Good luck:)

Sent from my X8 using xda premium
The Following 4 Users Say Thank You to eagleeyetom For This Useful Post: [ View ] Gift eagleeyetom Ad-Free
23rd January 2012, 07:55 AM |#10  
eagleeyetom's Avatar
OP Developer Committee Lead / XDA Portal Team / Senior Moderator
Flag Gdańsk
Thanks Meter: 15,780
 
Donate to Me
More
Let us know of results of building your ROMs. If you have any questions or can't solve errors, post it here - maybe we will be able to handle them
The Following 3 Users Say Thank You to eagleeyetom For This Useful Post: [ View ] Gift eagleeyetom Ad-Free
24th January 2012, 05:30 AM |#11  
Member
Flag Mohali, Punjab
Thanks Meter: 27
 
More
Thanks for the nice tutorial. Will try it.

I think I need to update my laptop as well because I will like to try it for the ICS also.

Any ways thank you very much for the tutorial.
Post Reply Subscribe to Thread

Tags
aosp, build, cyanogenmod, rom, tutorial

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes