Android添加分区并打包数据

1 篇文章 0 订阅
1 篇文章 0 订阅

Android编译文件

The device tree, for example, /device/lg/gt540would consist of the following make files:

Android.mk
this will tell the build system to include and to build sources specifically for your device. See below, for an example.
This is dependant on the device and hardware, you could have libsensors, liblights, libcamera subdirectories under the example device tree, i.e. /device/lg/gt540/libsensors,/device/lg/gt540/liblights, /device/lg/gt540/libcamera etc.
AndroidBoard.mk
this is for the kernel, the build system uses that to drop the kernel image in place (more about this in a few
minutes)
AndroidProducts.mk
specifies the appropriate device’s make file, to use for building. i.e. /device/lg/gt540/device_gt540.mk, this is specific also.
device_xxxxx.mk
specifies the properties and extras to copy over into the final output, in this case, it could be for example, device_gt540.mk
BoardConfig.mk
This is the meat of it all, this is where compiler conditional flags are set, partition layouts, boot addresses,> ramdisk size, and so on.

make_ext4fs参数的含义

Expected filename after options make_ext4fs [ -l ] [ -j
] [ -b <block_size> ]
[ -g ] [ -i ] [ -I ]
[ -L

img的两种格式

  • raw ext4 image,即raw image,使用file观察它:
    其特点是完整的ext4分区镜像(包含很多全零的无效填充区),可以直接使用mount进行挂载,因此比较大(一般1G左右)。
file system.img
    system.img: Linux rev 1.0 ext4 filesystem data, UUID=57f8f4bc-abf4-655f-bf67-946fc0f9f25b (extents) (large files)
  • sparse ext4 image
    即simg,使用file观察它:
file system.img
system.img: data

simg是一个非常普通的dat文件。由于它将raw ext4进行稀疏描述,因此尺寸比较小(没有全零的无效填充区,一般在300到500M之间)

android本身提供了源代码工具在两者之间转换,源代码位于:

system/core/libsparse/simg2img.c // 将sparse image转换为raw image;
system/core/libsparse/img2simg.c // 将raw image转换为sparse image;

如果完整的进行过一次Android的编译,默认会将simg2img当作主机工具编译出来,放在out/host/linux-x86/bin/simg2img处
但默认是不会编译img2simg的,我们可以手工进行编译:

$ . build/envsetup.sh
$ lunch aosp_hammerhead-userdebug
$ make img2simg_host

这样就会编译出out/host/linux-x86/bin/img2simg。
如果要将system.raw.img转换为system.simg:

$ img2simg system.raw.img system.simg

使用方法:

$ simg2img <sparse_image_files> <raw_image_file>
$ img2simg <raw_image_file> <sparse_image_file> [<block_size>]

android分区挂载fstab

/vendor/etc/fstab.n00010

Android 5.1分区挂载配置文件:fstab.xxxx.xxxx,不同于android4.4(vold.fstab),在5.1后分区配置文件发生了变化。fstab定义如下:

<src> <mount point> <filesystem type> <mount flags parameters> <fs_mgr_flags>
/dev/ /mnt/internal vfat defaults voldmanaged=internal_sd:14,nomulated

mount flags parameters文件系统的参数:
async/sync : 设置是否为同步方式运行
auto/noauto : 当下载mount -a 的命令时,此文件系统是否被主动挂载。默认为auto
rw/ro : 是否以以只读或者读写模式挂载
exec/noexec : 限制此文件系统内是否能够进行”执行”的操作
user/nouser : 是否允许用户使用mount命令挂载
suid/nosuid : 是否允许SUID的存在
usrquota : 启动文件系统支持磁盘配额模式
grpquota : 启动文件系统对群组磁盘配额模式的支持
defaults : 同时具有rw,suid,dev,exec,auto,nouser,async等默认参数的设置

fstab作用

通过配置fstab,vold服务通过函数process_config调用fs_mgr_read_fstab来完成对分区文件的解析。
fs_mgr_read_fstab—>fs_mgr进程,该服务源码位于system/core/fs_mgr/fs_mgr_main.c,主要是解析分区文件,并完成挂载任务的最终工作者

kernel加载完后第一个执行的就是init进程,init进程会根据init.rc的规则启动进程或者服务,init.rc通过

import /init.${ro.hardware}.rc导入平台的规则。device/rockchip/common/init.rk30board.rc中:
import init.${ro.hardware}.bootmode.{ro.bootmode}.rc -----> init.rk30board.bootmode.emmc.rc

device/rockchip/common/init.rk30board.bootmode.emmc.rc中:

on fs
mount_all fstab.rk30board

mount_all是一条命令,fstab.rk30board是传入的参数,在system/core/init/keywords.h中,定义了mount_all命令:

KEYWORD(mount_all, COMMAND, 1, do_mount_all)

注意问题

(1)setenv quiet=y查看日志
(2)make_ext4fs是否需要添加-s制作simg
某些板子上添加-s会导致/dsdata分区无法挂载

参考
https://blog.csdn.net/ctrl_qun/article/details/78086499
https://blog.csdn.net/howellzhu/article/details/43165507
https://blog.csdn.net/u014770862/article/details/54583157

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

seiyaaa

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值