Building an Android ROM
Maybe it’s in the wrong place , it’s
not really a tutorial what you’re about to read. It’s more a simple explanation
on how an Android ROM is built. I’m going to discuss several parts that can’t
be absent if you want a fully functional Android phone, from the software point
of view that is.
Here’s a brief summary :
·
Kernel
·
Libraries (and modules)
·
Bootloader
·
Recovery
·
Radio
·
Apps, framework, core,
android-runtime, etc…
Kernel
A kernel is a critical component of
every Operating System. It can be seen as a sort of bridge between the
applications and the actual hardware of a device. Usually the data processing
part is done at hardware level, furthermore the kernel is the most low-level
abstraction layer for the resources.
There exist several types of
kernels, but I am only discussing the one that is important for the Android
ROM. The kernel for the Android ROM is a hybrid kernel, it is based on the
Linux kernel. Devices can differ in RAM memory, ROM memory, hardware parts and
so on. So it’s really important you have a kernel for your type of device, an
HTC Wildfire kernel won’t work on a Nexus One for example.
It is possible to overclock a
kernel. What the hell is overclocking you may wonder? Every CPU is designed to
work at a certain clock speed. For the HTC Wildfire the Qualcomm ARMv6
processor operates at 528 mHz; This is a limit that is coded in to the kernel
because they can’t guarantee a good cooling if you go over this limit. My
Wildfire runs at 652.8 mHz, it can go till 768 mHz but it can cause freezes.
When you overclock the kernel , the CPU will be instructed to do more
calculations per second and will so increase the performance. When you
overclock the CPU of your desktop machine it needs extra cooling, it’s not
necessary for a smartphone. However keep in mind this will degenerate your CPU
more quickly. To overclock an Android phone you must root first, and than
install SetCPU from the market , it is a paid app but it’s worth it. Further
you have to flash an overclockable kernel , I prefer the OC Kernel of
HCDR.Jacob, at XDA-forums (see links right). If you have done these 3
things you’re ready to OC!
Libraries
Imagine you want to program an
application for your phone that uses the camera. It can take a picture and turn
on the flash LED on. These are things not only your own application will use,
there can be tons of applications that have a button , that when you press it ,
it will take a photo. So think about if they always have to write the machine
code for the phone , that it instructs the phone to put on the camera. It would
be a lot of code duplication and would make an application slow. Instead for
functions like the camera, or loudspeakers, they developped libraries. These
are chunk of codes that can be executed by calling them trough a call-method (in
java : import somelibrarie.someclass;), these are already pre-written and
ready to use. It saves a lot of coding work and keeps the source code small.
Libraries in the Windows OS for example are the so called .dll files (Dynamic
Linked Libraries) , on your Android ROM or Linux OS these are the .so files
(Shared Object), when coding in Java you import .jar libraries before the class
signature. On your Android phone you have particular libraries that can’t be
absent, or else your ROM won’t even boot.
Bootloader
A bootloader in general is the first
bytes of code that a machine executes that will tell the bootsequence and will load
the operating system into the RAM. On an Android phone this is the so called
HBoot, from here you can go to the recovery partition, the system or data
partition,.. If you simple press the power button Hboot will load the OS into
your RAM. But if you want to access these partitions it is possible by
pressing, if you have a Wildfire, the volume-down button and simultaneously the
power button. This will bring up the Hboot menu. The bootloader is used as
exploit for rooting an Android phone. Once rooted you can flash custom roms ,
like ImPrOS, or just edit system files. (for a how-to , check tutorials under
Android).
Recovery
When you use a one-click-root
application, like Unrevoked3 , it will install a modded recovery. With this
modded recovery it is possible to flash a new kernel, radio image (see below),
custom rom, install applications (not the best way though),nandroid
backup,.. The modded recovery that is flashed by Unrevoked3 is called
ClockworkMod.
Radio
The lowest part of software layer is
the radio, this is the very first thing that boots even before the bootloader.
This handles the GPS-antenna,GSM antenna ,fires up the CPU, everything what
Hboot needs to load the OS. This is also upgradeable by flashing a new radio
image trough ClockworkMod. However this is not recommended : flashing a new ROM
can’t brick your phone but if anything goes wrong when you flash a ROM with a
new radio image this can brick your phone. So unless you experience bad
reception or battery drainage, don’t touch the radio!!
Applications,
framework, android-runtime,..
Now we have the fundamental software
layers, we have to decorate our ROM, it has to have some interface trough where
it can communicate with the user. We can install applications like a keyboard,
a phone application, a calculator. And last but not least the android-runtime.
This is a package of code that represents the Android Virtual Machine. The
Android programming language is based on xml and Java (mostly Java) ,
like every programming language has some sort of virtual machine, (Java has
JVM = Java Virtual Machine) Android has android-runtime.
No comments:
Post a Comment