5. Customized Android firmware¶
Note: The following is only compatible with Android 8.1 and below.
There are two ways to customize Android firmware:
Change the source code and compile the firmware.
Tailoring the existing firmware.
In the former method, Android can be customized from all levels, with great freedom, but high requirements for the compilation environment and technology, which can be referred to [Compile Android firmware].(compile_android8.1_firmware.html). Now introduce the latter method, which is divided into three phases: unpacking, customization and packaging. The host operating system is Linux, and the tools used are open source software.
5.2. Firmware format¶
release_update.img contains the boot loader
loader.img and the actual firmware data -
update.img is a composite file containing multiple files described by package-file. A typical package-file is:
# NAME Relative path package-file package-file bootloader Image/MiniLoaderAll.bin parameter
Image/system.img backup RESERVED
#update-script update-script #recover-script recover-script
update.imgpackage description file,
update.imgalso contains a
Start the loader - bootloader.
Parameter file, can set the kernel boot parameters, there are important partition information.
trust.imgis the U-Boot as the secondary loader package.
Image of misc partition, used to control whether Android starts normally or enters Recovery Mode.
Resource image with kernel boot image and kernel Device Tree Blob.
The memory boot disk (initrd) of the Android kernel, the first root file system to be loaded after the kernel is started, contains important initialization actions that generally do not need to be changed.
Android image,including Recovery Mode with kernel and root file system of Recovery Mode.
Corresponds to the Android
/systempartition and is the following custom object.
Unpacking, is to extract the
release_update.img, then the extracted with
package-file statement by multiple files.
Packaging is an inverse process to synthesize the multiple files listed in the package-file to
update.img, add to the
loader.img, and finally generate the
5.3. Tools preparation¶
git clone https://github.com/TeeFirefly/rk2918_tools.git
sudo cp afptool img_unpack img_maker mkkrnlimg /usr/local/bin
Now that the firmware has been unpacked successfully, let’s start customizing it.
First, check the size of
system.img and make necessary size adjustments against the partition of the
parameter file.(Refer to the documentation The file format parameter)
For example, the system partition size in
parameter.txt file, you can find the
CMDLINE line and then find the
Before @ is the size of the partition, the unit is 512 bytes, so the size of the system partition is:
$ echo $(( 0x00200000 * 512 / 1024 / 1024))M
As long as the size of
system.img does not exceed 1024M, the parameter file does not need to be changed.
If the partition does not change, you can use the upgrade tool to upgrade the new
system.img directly to the
system partition on the development board for testing. Otherwise, you need to make new firmware and burn it before testing.
Here are the steps required to package it into a unified firmware
Compose release_update.img ：
$ img_maker -rk33 loader.img update_new.img release_update_new.img
release_update_new.img is a unified firmware file that can be upgraded for the final generation
Q1 : Where’s the firmware version Settings?
A1 : In the parameter file, you can find the downward direction and modify it. Note that the version number is a number, and the middle two dots cannot be omitted.