Android固件img文件的解包, 修改和打包的命令行操作


Android固件img文件的解包打包

To Unpack-Modify-Pach the system.img, I have followed the following procedure:

a) Unpacking

Run file system.img and make sure that system.img is Android Sparse Image.
Rename system.img to system.img.ext4. // Not required if you will use other name for raw image in below steps.

simg2img system.img.ext4 system.img

you will get a raw image file named system.img

mkdir system

create directory to mount system.img

sudo mount -t ext4 -o loop system.img system/

you will get all files of system.img in system folder

b) Modifying

ls -l system/init.rc

note permissions: 750

sudo chmod 777 system/init.rc

give write permissions

sudo echo "#MODIFICATION " >> system/init.rc

done some modification in init.rc

sudo chmod 750 init.rc

reset init.rc to the noted permissions

c) Calculate system sector size

tune2fs -l system.img | grep "Block size\|Block count"

you will get block size and count

echo $((1553064 * 4096))

multiply both results. I got 6361350144

d) Packing

sudo make_ext4fs -s -l 6361350144 -a system system_new.img sys/

you will get system_new.img “Android Sparse Image” that has all changes

Amlogic固件的解包修改和打包

需要兩個工具, 一個是linux下的工具

https://github.com/natinusala/linux-amlogic-toolkit

另一個是windows下的解包和打包工具 Amlogic CustomizationTool

因為前者的打包存在bug, 所以只用於對system.img進行修改, 后者用於最外層的解包和打包工作. 

 

# Mount system RW: 
mount -o rw,remount /system
# Mount system RO: 
mount -o ro,remount /system

  

/init.rc 內, 找到 service console 之后添加

service daemonsu /system/xbin/daemonsu --auto-daemon &
    class main               
    oneshot

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM