system.img boot.img 等解包 压缩

eMMC binaries

This is the efi partition table as exists on the emmc

Sector#    Size Name
    256     128K xloader
    512     256K bootloader
   2048       8M recovery                                                      
  18432       8M boot                                                          
  34816     512M system                                                        
1083392     256M cache                                                         
1607680     512M userdata                                                      
2656256    2183M media

[edit]Creating the GPT table

On Target
  1. Connect a USB cable to the OTG port on your platform
  2. Boot your platform up with a stock u-boot and MLO
  3. Once you platform is booted you will see the following:
Fastboot entered...
On Host Machine

locate fastboot in you android filesystem

cd $mydroid/out/host/linux-x86/bin/fastboot

Search for fastboot devices

fastboot devices

Create GPT table on eMMC/SD card

fastboot oem format

From the android build these are the binaries that go into each partition:

 Sector#    Size Name            Binary
    256     128K xloader         MLO
    512     256K bootloader      u-boot.bin
   2048       8M recovery        recovery.img                                                    
  18432       8M boot            boot.img                                  
  34816     512M system          system.img                                      
1083392     256M cache           cache.img                                    
1607680     512M userdata        userdata.img                                     
2656256    2183M media           none


File locations
  • MLO --> x-loader/MLO
  • u-boot --> u-boot/u-boot.bin
  • boot.img --> need to create using zImage + ramdisk.img
  • recovery.img ---> need to create using zImage + ramdisk-recovery.img
  • system.img --> $mydroid/out/target/product/<platform>/system.img
  • cache.img -->
  • userdata.img --> $mydroid/out/target/product/<platform>/userdata.img


All these partitions can be flashed with the given binary using fastboot.

 fastboot flash <name> <binary>

Example flashing of all partitions

 fastboot flash xloader     MLO
 fastboot flash bootloader  u-boot.bin
 fastboot flash recovery    recovery.img
 fastboot flash boot        boot.img
 fastboot flash system      system.img
 fastboot flash cache       cache.img
 fastboot flash userdata    userdata.img

[edit]Modifying .IMG Files

Typically when you want to modify any of the partitions, you would need to unzip-modify-rezip and then fastboot flash.

Following section talks about how to do that for each partition

BOOT.IMG

 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 vram=10M omapfb.vram=0:4M androidboot.console=ttyO2" 
 --board omap4 
 -o boot.img.new
 Output: boot.img.new
 **Note: bootarg is passed to kernel via --cmdline option above
 **Note:For Pandaboard ES,--cmdline should be mmodified as "console=ttyO2,115200n8 mem=456M@0x80000000 mem=512M@0xA0000000 init=/init vram=32M omapfb.vram=0:16M androidboot.console=ttyO2"

To "just" boot boot.img (before flashing) you can use:

%fastboot boot boot.img

RAMDISK.IMG

 %mkdir root
 %cd root
 %gunzip -c ../ramdisk.img | cpio -i
 <make changes to root/ contents...>
 %./out/host/linux-x86/bin/mkbootfs root/ | ./out/host/linux-x86/bin/minigzip >ramdisk.img.new
 #output: ramdisk.img.new
 ** Note: any init.rc changes will need to use this method

RECOVERY.IMG

Is just like boot.img. 
recovery.img = zImage + ramdisk-recovery.img
*Follow the same steps as boot.img for packing/unpacking

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

Instead of having to reflash the whole big system.img, one can selective update any binary in /system folder on running target

%adb remount
%adb push <local> <remote>
Eg: 
%adb remount
%adb push out/target/product/blaze/obj/lib/overlay.omap4.so /system/lib/hw/overlay.omap4.so
%adb sync

USERDATA.IMG

 #uncompress
 %./out/host/linux-x86/bin/simg2img userdata.img userdata.img.raw
 #mount to directory mnt-point/
 %mkdir mnt-point
 %sudo mount -t ext4 -o loop userdata.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 userdata userdata.img.new mnt-point/
 # Above command won't work on GB/HC. For GB/HC, please use the following updated command
 %sudo ./out/host/linux-x86/bin/make_ext4fs -s -l 512M -a data userdata.img.new mnt-point/
 %sudo umount mnt-point/
 Output: userdata.img.new

CACHE.IMG

 #This is empty ext4 fs image
 %mkdir mnt-point/
 %sudo ./make_ext4fs -s -l 256M -a cache cache.img mnt-point/
 Output: cache.img

[edit]TI Android build setup

Copy kernel zImage, u-boot.bin and MLO for your board in folder device/ti/blaze/boot/.

Rename as:

 %mv MLO MLO_es2.2_emu 
 or 
 %mv MLO MLO_es2.2_gp 
 (based on your board being GP or EMU)

Next start standard android build and all img files are generated in:

out/target/product/blaze/*.img

A script is introduced in TI Android release to make this flashing process easier: device/ti/blaze/boot/fastboot.sh

Usage:
cd device/ti/blaze/boot/
%fastboot.sh --emu
or
%fastboot.sh --gp

Running this script will flash whole android system on your board.


来源 http://omappedia.org/wiki/Android_eMMC_Booting#Modifying_.IMG_Files

### 回答1: Android系统的boot.img文件是Android固件中的一个重要部分,它包含了Android系统的内核和一些初始化脚本等文件。解包和打包boot.img文件是进行Android固件定制或修改的重要步骤之一。 在解包和打包boot.img文件时,可以使用一些工具集来辅助完成。以下是一些常用的工具集: 1. Android Kitchen:这是一个基于Linux系统的命令行工具集,可以用来解包和打包boot.img文件。它提供了一系列的命令,如unpackbootimg用于解包boot.img,mkbootimg用于打包boot.img。使用Android Kitchen工具集需要一些基本的Linux命令行操作知识。 2. Magisk Manager:这是一个通用的Android系统修改工具,其中包含了解包和打包boot.img文件的功能。Magisk Manager可以通过安装Magisk框架来实现对Android系统的修改,并且提供了可视化的操作界面,方便用户进行boot.img解包和打包操作。 3. Android Image Kitchen:这是另一个基于Linux系统的命令行工具集,用于解包和打包Android系统的映像文件,包括boot.img文件。Android Image Kitchen提供了一系列的命令,如unpackimg用于解包boot.img,repackimg用于打包boot.img。 除了上述工具集外,还有一些第三方的GUI工具可供使用,如Magisk Manager中提供的可视化操作界面,以及一些名为"bootimage-tools"的工具集。 总之,解包和打包boot.img文件是进行Android固件定制或修改的重要环节之一,可以通过一些命令行工具集,如Android Kitchen、Android Image Kitchen等,或者一些GUI工具,如Magisk Manager等,来实现这一操作。这些工具集提供了相应的命令或操作界面,方便用户进行boot.img解包和打包操作。 ### 回答2: Android boot.img解包和打包工具集是用于对Android系统中的boot.img文件进行解包和打包操作的一组工具集。 解包工具集包括: 1. binwalk:可以用于识别和提取boot.img文件中的各种结构和组件。 2. Unpackbootimg:可以将boot.img文件解包为ramdisk.img、kernel和cmdline等组成部分。 3. mkbootimg:可以重新打包解包后的ramdisk.img、kernel和cmdline等组成部分为新的boot.img文件。 4. Android Image Kitchen:可以提取和重新打包boot.img文件中的各种文件、分区和可执行程序。 5. Bootimg-tools:提供了一系列工具来处理boot.img文件,包括解包、打印信息、拆分和合并等操作。 使用这些工具集,可以将boot.img文件解包为其包含的ramdisk、kernel和cmdline等文件,可以对这些文件进行修改和定制。然后可以使用mkbootimg或Android Image Kitchen将修改后的文件重新打包为新的boot.img文件。这样,就可以实现对Android系统启动过程中的各种配置和组件进行修改和定制。 这些工具集对于Android系统开发和定制非常有用,可以帮助开发者理解和修改Android系统的启动过程,同时也可以帮助厂商和用户改变和优化系统的启动行为。然而,由于涉及到系统底层,使用这些工具集需要谨慎操作,避免对系统造成损害。 ### 回答3: Android的boot.img是一个包含了Linux内核和设备树的镜像文件,用于引导Android设备的启动过程。解包和打包boot.img需要使用一些专门的工具集。 解包boot.img的工具集主要包括以下几个工具: 1. mkbootimg工具:用于解析和生成Android boot.img文件,可以从boot.img中提取出内核、ramdisk、cmdline等信息。 2. unmkbootimg工具:用于解包boot.img文件,将其中的内核、ramdisk、cmdline等内容提取出来。可以使用该工具将boot.img解包boot.img-zImage(内核文件)、boot.img-ramdisk.gz(ramdisk文件)等。 3. simg2img工具:用于将boot.img中的system.img(系统分区镜像)解包为ext4格式的文件系统,以便进行修改和查看。 4. mkdtimg工具:用于打包设备树文件,依赖于设备树编译工具,可以将设备树编译成设备树二进制文件(.dtb)后再使用mkdtimg打包成dt.img 文件,然后将dt.img文件与之前解包得到的zImage、ramdisk等文件一起打包为新的boot.img。 打包boot.img的工具集主要包括以下几个工具: 1. mkbootimg工具:用于生成新的boot.img文件,需要提供新的zImage(内核文件)、ramdisk(ramdisk文件)、cmdline等参数。 2. mkdtimg工具:用于打包设备树文件,将设备树二进制文件(.dtb)打包为dt.img文件,然后将dt.img文件与zImage、ramdisk等文件一起打包为新的boot.img。 以上是Android boot.img解包和打包工具集的一些介绍。需要注意的是,操作boot.img需要一定的技术知识和经验,不当的操作可能导致设备变砖或无法正常启动,因此使用前请谨慎,并在了解清楚操作步骤后进行操作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值