When doing some tweaks on your android device, you may need to change some parameters on the root filesystem. For example you may have to modify /init.rc, /init.sun5i.rc, /initlogo.rle or your root logo /initlogo.rle (the second one displayed in the boot process).
You will then quickly realise that whatever change you will do on these files will be lost after every reboot, even if you do it as root.
This comes from the fact that on android devices the root filesystem is mounted as a initramfs. So it is unpacked and mounted into RAM at every boot. Whatever change you do is done in RAM only.
So to make permanent changes to your root filesystem, you need to modify the files whithin the initrd.img file used during the boot process.
This guide will explain how to extract Root image from Slidepad 704ce
- unpack it & extract initrd files
- change the boot logo
- repack the modified initrd files
- flash back the root image on the device
It has been specifically designed for Slidepad 704ce, but it should be applicable to any device powered by A10 or A13 Allwinner SoC.
Your tablet should run ICS or JB and should be fully rooted. If it's not the case ... follow the guides :
- Slidepad 704ce - ICS 4.0.4 : Root, Tweaks & Google Play
- Slidepad 704ce - Jelly Bean 4.1.1 : Root your tablet
Whole procedure is designed to be done from a Ubuntu computer. Any other Linux flavour should be fine.
All following commands have to be run from your computer with your tablet connected with USB Debug on.
This article is only for advanced users. You really need to know what you are doing if you want to follow this procedure.
If you only need a rooted tablet with Google apps, you don't need to follow all these steps and to go further.
1. Install needed Tools
To do the job, we will use the abootimg package available in Ubuntu repositories.
# sudo apt-get install abootimg
2. Extract Root image & InitRamFS files
On Slidepad 704ce, root image is available under /dev/block/nandc.
If you are having another device, just make sure to target the right nand partition.
First step is to extract & unpack root image from the tablet :
# adb shell su -c "cat /dev/block/nandc > /mnt/sdcard/nandc-root.img"
# adb pull /mnt/sdcard/nandc-root.img
5038 KB/s (33554432 bytes in 6.502s)
# abootimg -x nandc-root.img
writing boot image config in bootimg.cfg
extracting kernel in zImage
extracting ramdisk in initrd.img
All 3 files are available in your current directory.
We can now unpack initrd.img which is holding the InitRamFS files :
# mkdir initrd
# cd initrd
# gunzip -c ../initrd.img | cpio -i
The complete InitRamFS file structure is now available in your current initrd directory.
3. Modify the root filesystem files
You can now modify whatever file you want within the initrd directory structure.
You have to be careful as when you will repack the image, it will take whatever files are available in this directory.
So, at the end of the modification job, make sure to clean any unneeded temporary file (like ~xxx files).
3.1. Change the Boot logo
On Slidepad 704ce (and I suppose also on other A10 and A13 tablet), boot logo is inside bootlogo.rle and even if it is having a .rle extension, it's a plain inversed RGBA raw file.
We will use ffmpeg, the multimedia swiss army knife, to do the different format conversions.
If you want to convert the original bootlogo.rle to a standard bootlogo.png, just do :
# ffmpeg -vcodec rawvideo -f rawvideo -pix_fmt bgra -s 800x480 -i initlogo.rle -f image2 -vcodec png initlogo.png
initlogo.png is now ready for modification.
If you want to create a logo from scratch, just create a 800×480 PNG picture, without transparency.
Once your new logo initlogo.png is ready, lets convert it back to initlogo.rle :
# ffmpeg -vcodec png -i initlogo.png -vcodec rawvideo -f rawvideo -pix_fmt bgra initlogo.rle
initlogo.rle is ready to replace the original one in the extracted initrd directory.
4. Repack the Root filesystem
Before going further, check that you haven't left any temporary files in the initrd directory structure.
We can now :
- regenerate the initrd.img from the current directory content
- update root image with the updated initramfs
This is done from whithin initrd directory with the following commands :
# find . | cpio -o -H newc | gzip > ../initrd-new.img
# cd ..
# abootimg -u nandc-root.img -r initrd-new.img
reading ramdisk from initrd-new.img
Writing Boot Image nandc-root.img
Your root image is now up-to-date.
5. Flash back the new root image
It is ready to be flashed back to your tablet.
Don't make any mistake, be sure to target the proper nand partition /dev/block/nandc or your tablet may get into trouble !
# adb push nandc-root.img /mnt/sdcard
4734 KB/s (33554432 bytes in 6.921s)
# adb shell su -c "cat /mnt/sdcard/nandc-root.img > /dev/block/nandc"
# adb shell su -c "sync"
# adb shell su -c "reboot"
Your tablet will now reboot with your updated Root filesystem.
Cross fingers ... and enjoy :-)
Hope it helps !