同事读启动log信息,认为是系统挂载出问题了,在网上搜了一写,对system.img的处理。
从一篇网文开始
step1
sdat2img.py <transfer_list> <system_new_file> <system_ext4>
- <transfer_list> = input, system.transfer.list from rom zip
- <system_new_file> = input, system.new.dat from rom zip
- <system_ext4> = output ext4 raw image file
and a quick example:
sdat2img.py system.transfer.list system.new.dat system.img
by running this command you will get as output the file my_new_system.img which is the raw ext4 image.
但第一步当时并不会做,因为两个inout文件没见到过,直到第四步昨晚发现竟然是一个循环步骤,此时搜了其他命令生成了raw的文件
/home/sun/rk3288work/RK3288_7.1_181121/out/host/linux-x86/bin/simg2img system.img system_raw.img
生成了system_raw.img
Step 2 - Decompress EXT4 (raw image) -> OUTPUT folder -> Compress EXT4 (raw image)
Now we need to mount or ext4 raw image into an output folder so we can see apks/jars etc.
To do this we need to type this command:
sudo mount -t ext4 -o loop system.img output/
As you can see there is a new folder called output which we can edit/modify/delete your files (not able to? see here)
Now we need to compress it back to a raw ext4 image, to do this we need the make_ext4fs binary. Make sure you have the file_contexts file (taken from the Rom zip) inside the make_ext4fs path. Then type this (got issues? see here)
./make_ext4fs -T 0 -S file_contexts -l 1073741824 -a system system_new.img output/
You will get the new raw ext4 image called 'system_new.img' ready for the next step.
这一步吧第一步生成的文件挂载后,又用make_ext4fs打包了output文件夹下挂载的系统
做的步骤
root@sun:/home/sun/rk3288work/RK3288_7.1_181121/rockdev/Image-rk3288# mkdir output
root@sun:/home/sun/rk3288work/RK3288_7.1_181121/rockdev/Image-rk3288# cd output/
root@sun:/home/sun/rk3288work/RK3288_7.1_181121/rockdev/Image-rk3288# mount -t ext4 -o loop ../system_raw.img ./
root@sun:/home/sun/rk3288work/RK3288_7.1_181121/rockdev/Image-rk3288# ../../out/host/linux-x86/bin/make_ext4fs -T 0 -S ../../out/target/product/rk3288/root/file_contexts.bin -l 2048M -a system system_2th.img output/
Step 3 - Converting = EXT4 (raw image) -> IMG (sparse image)
Now we need to convert the ext4 raw image into a sparse image. For this you need img2simg binary you can find here (thx to @A.S._id).
The usage is simple:
img2simg <raw_image_file> <sparse_image_file>
Pretty self-explanatory, the output will be a new sparse image (.img).
做了这种操作
这个操作的img2simg命令不能用,搜了一下发现SDK中有源码,需要编译执行变异的过程是
在SDK的根目录下执行
source build/envsetup.sh
lunch
选要变异的版本,我是14
make img2simg_host
之后这个命令就可用了
root@sun:/home/sun/rk3288work/RK3288_7.1_181121/rockdev/Image-rk3288# ../../out/host/linux-x86/bin/img2simg system_2th.img system_3th.img
接下来做第四步
Step 4 - Converting = IMG (sparse image) -> DAT (sparse data)
Now we need the img2sdat binary, the usage is very simple (make sure you have python 2.7+ installed):
./img2sdat.py <system_img>
- <system_img> = name of input sparse image file (from step 3)
As you can see the output is composed by system.transfer.list, (system.patch.dat) & system.new.dat, ready to be replaced inside your Rom zip.
第四步找不到命令,就看到文章下边有那个命令的Python代码
DOWNLOADs
sdat2img.py
- github.com
make_ext4fs
- mega.co.nz
img2sdat.py
- github.com
接下来就进去把命令克隆下来
点击进入img2sdat.py
- github.com 这个链接下,最好和之前编译源文件的文件夹目录一致,比如~/rk3288work/RK3288_7.1_181121/system/core/libdata$ 我在core/下新建了乐意libdata文件夹然后克隆了两个命令文本
sun@sun:~/rk3288work/RK3288_7.1_181121/system/core/libdata$ git clone https://github.com/xpirt/img2sdat.git
sun@sun:~/rk3288work/RK3288_7.1_181121/system/core/libdata$ git clone https://github.com/xpirt/sdat2img.git
然后就直接运行了该目录下的第四步的命令
root@sun:/home/sun/rk3288work/RK3288_7.1_181121/rockdev/Image-rk3288# ../../system/core/libdata/img2sdat/img2sdat.py system_3th.img
生成了3个文件
-rw-r--r-- 1 root root 61K 12月 29 15:57 system.transfer.list
-rw-r--r-- 1 root root 0 12月 29 15:57 system.patch.dat
-rw-r--r-- 1 root root 518M 12月 29 15:57 system.new.dat
至此四步做完了,然后忽然发现还有返回的命令,就做了一下操作,做完后,发现就是第一步的操作,发现这是格式的转换过程。
root@sun:/home/sun/rk3288work/RK3288_7.1_181121/rockdev/Image-rk3288# ../../system/core/libdata/sdat2img/sdat2img.py system.transfer.list system.new.dat system_5th.img