*boot.img = zImage + ramdisk.img
zImage = kernel image
ramdisk.img = out/target/product/blaze/root/
%./out/host/linux-x86/bin/mkbootimg
--kernel zImage
--ramdisk ramdisk.img
--base 0x80000000
--cmdline "console=ttyO2,115200n8 mem=456M@0x80000000 mem=512M@0xA0000000 init=/init androidboot.console=ttyO2"
--board xxxx
-o boot.img.new
Output: boot.img.new
**Note: bootarg is passed to kernel via --cmdline option above
How to unpack/pack ramdisk.img
unpack:
#gunzip -c ../your-ramdisk-file | cpio -i
pack:
#find . | cpio -o -H newc | gzip > ../newramdisk.cpio.gz
+-----------------+
| boot header | 1 page
+-----------------+
| kernel | n pages
+-----------------+
| ramdisk | m pages
+-----------------+
| second stage | o pages
+-----------------+
n = (kernel_size + page_size - 1) / page_size
m = (ramdisk_size + page_size - 1) / page_size
o = (second_size + page_size - 1) / page_size
0. all entities are page_size aligned in flash
1. kernel and ramdisk are required (size != 0)
2. second is optional (second_size == 0 -> no second)
usage: mkbootimg
--kernel
--ramdisk
[ --second <2ndbootloader-filename> ]
[ --cmdline
[ --board
[ --base ]
[ --pagesize
-o|--output
bootimg:
mkdir -p $(IMAGES_PATH)
cd $(IMAGES_PATH) && $(MKIMAGE) --kernel $(KDIR)/arch/arm/boot/zImage \
--ramdisk $(OUT_TARGET_DIR)/ramdisk.img \
--base 0x80000000 --cmdline "$(KERNEL_BOOTPARAMS)" \
--board omap4 -o boot.img && cd -
ex: mkbootimg --cmdline 'no_console_suspend=1 console=null' --kernel your-kernel-file --ramdisk newramdisk.cpio.gz -o mynewimage.img
==========================================================================================================================================
* system.img
#uncompress
%./out/host/linux-x86/bin/simg2img system.img system.img.raw
#mount to directory mnt-point/
%mkdir mnt-point
%sudo mount -t ext4 -o loop system.img.raw mnt-point/
#modify any .so or apk in the mnt-point/ directory
#rezip
%sudo out/host/linux-x86/bin/make_ext4fs -s -l 512M -a system system.img.new mnt-point/
%sudo umount mnt-point/
Output: system.img.new
=====================================================================================
沒有留言:
張貼留言