同事读启动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

调试Android之system.img的来回切换。相关推荐

  1. VS2017调试Android出现System.IO.FileNotFoundException: Could not load file or assembly 'Mono.Posix, Ve

    使用visual studio 2017调试安卓程序,遇见 "System.IO.FileNotFoundException: Could not load file or assembly ...

  2. 如何调试Android Native Framework

    原文: https://zhuanlan.zhihu.com/p/24867284 如何调试Android Native Framework weishu 7 个月前 半年前写了一篇文章,介绍 如何调 ...

  3. adb链接手机调试android应用

    adb链接手机调试android应用 hulk@hulk-Lenovo:~$ adb devices List of devices attached  ???????????? no permiss ...

  4. 使用AndroidStudio查看并调试Android源码

    使用AndroidStudio查看并调试Android源码 使用AndroidStudio查看并调试Android源码 0.基础环境 1. 操作系统 2. Java 3. Android源码 1. 编 ...

  5. androidstudio调试android 源码 jni,在android studio下配置gradle用ndk-build和ndk-gbd编译调试JNI...

    因为要在旧版android在做一些工作.所以做用到了它.目标平台是:android api 10和armv6. 开发环境是:AS 版本2.3.2; SDK版配android 2.3.3(api10); ...

  6. IDA+GDB远程调试android平台 - Aarch64- elf64程序

    gdb配置 gdb和gdbserver gdbserver的是在 android-ndk-r10e\prebuilt\android-arm\gdbserver 这个目录下 gdb 是在 androi ...

  7. 动态调试android, ddmsida

    Android NDK R8提供四套运行时环境来支持c++特性: System, gabi++, stlport, gnustl Gnustl支持 C++exceptions, C++ RTTI, S ...

  8. 使用 GDB 调试 Android 应用

    GNU 工程调试器(GDB)是一个常用的 Unix 调试器.本文详述使用 gdb 调试 Android 应用和进程的方法. 调试运行中的应用或进程 gdbclient 是源码库中的一个 shell 脚 ...

  9. android eclipse services,Eclipse中调试Android Framework本地代码模块部分过程记录

    环境:Amlogic S905M2 + ubunt12.04 + win7 + adt_bundle_linux + Android SDK 过程: 1. 为避免用Eclipse基础版本(Luna)后 ...

最新文章

  1. RabbitMQ—为什么使用信道channel
  2. 支持字典_【多测师小课堂】python数据类型之列表、字典、元祖、字符串
  3. java jsp学习指南_JSP教程–最终指南
  4. 零基础入门Python:基本命令、函数、数据结构
  5. Python 3.8 新功能大揭秘
  6. 新年快乐!这是份值得收藏的2017年AI与深度学习要点大全
  7. oracle无会话锁表,深入浅出oracle锁 原理篇 停止无反应的sql会话
  8. 一个借口几万条数据但是只返回十条_爬虫实践之爬取10000条菜谱数据
  9. 进行DosBox的下载与配置
  10. Spring框架学习之路,完整版 持续更新,有代码仓库对比
  11. 计算两个日期之间,相差多少天C语言详解
  12. python爬取拉勾网_python 爬取拉勾网实战
  13. android的UI性能优化
  14. PyScripter could not load a Python engine解决方案
  15. 韩信点兵-输出韩信至少拥有的士兵人数。
  16. ML-czy的小组任务2
  17. python启动浏览器崩溃
  18. Vue3 使用 store 给请求头配上 token
  19. CentOS 7 中Tomcat7注册成服务
  20. 微信 服务器 台,2W台服务器的微信过载控制系统.docx

热门文章

  1. gcc android开发环境,[RK3399][Android7.1]开发环境搭建
  2. python root什么意思_root是什么意思
  3. python基本数据类型选择题-python基础学习——基础数据类型练习题(二)
  4. signature=7af2859164902e5f86d6728522cfd7fe,Signatures of top flavored dark matter
  5. c# 再次尝试 连接失败_和平精英ios充值失败该怎么办
  6. 探索性数据分析,这8个流行的 Python可视化工具就够了
  7. 只有想不到,「99」种扩展Jupyter功能的好方法
  8. java前端长连接框架_Java如何实现长连接
  9. 程序猿之歌 PHP,1024丨腾讯第一首程序员之歌【Code代码】
  10. mysql5.6 mysqld safe_mysql程序之mysqld_safe详解