Details on individual partitions

本文深入解析了OMAP4平台下Boot、System和UserData分区的详细信息,包括如何生成boot.img、system.img和userdata.img文件,以及如何编辑ramdisk.img进行调试。此外,还提供了系统分区、用户数据分区、缓存分区的创建方法及常用命令,为开发者提供了一站式解决方案。

 Details on individual partitions

Boot.img details

The boot.img is generated using umulti.sh script (also shown below)

   ./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

As you see in the line above, the kernel image used is zImage instead of uImage that we usually use.

TIP: If you have a uImage, you can create a zImage from it using the following command

    dd if=uImage bs=64 skip=1 of=zImage

The zImage is combined with ramdisk.img, which contains all the initial boot up programs (init, init.rc etc).

If you have to edit ramdisk.img, it can be done by following this

Opening and changing files in ramdisk.img for debugging

A ramdisk is basically a small filesystem containing the core files needed to initialize the system. It includes the critical init process, as well as init.rc, which is where you can set many system-wide properties. If you really want to know more about it, here is the documentation. Here's a list of files on a typical ramdisk:

data
default.prop
dev
env.txt
init
init.goldfish.rc
init.omapzoom2.rc
init.rc
proc
sbin\
sbin\adbd
sbin\hotplug

Here are the steps to open, edit and create a new ramdisk.img

  • Copy the ramdisk.img to your UBuntu (Linux) machine
  • Back up ramdisk.img and Create a temporary folder, say tmp
       # cp ramdisk.img ramdisk.img.bkup
       # mkdir tmp && cd tmp
  • Extract the ramdisk using the command below
       # gunzip -c ../ramdisk.img | cpio -i
  • Modify the contents of tmp folder. The contents of tmp folder will get into the ramdisk.img
       Modify the contents of file in tmp folder eg. init.rc
  • Recreate the ramdisk.cpio with command:
        # find . | cpio -o -H newc | gzip > ../ramdisk.img


Once the ramdisk.img is re-generated, you need to regenerate the boot.img using mkbootimg command shown above, and flash it for your init.rc changes to get reflected. Similarly, for updating the kernel you should regenerate boot.img with new zImage and flash it using fastboot command in earlier section.

TIP: If you want to just test your boot.img, without flashing you can use the command below

     ./fastboot boot ./boot.img
System.img details

System image is a sparsed ext4 loop mounted file system. To open (mount) system image use the commands below

      ./simg2img system.img system.img.raw
      mkdir tmp 
      sudo mount -t ext4 -o loop system.img.raw tmp/

After this, all your system image files are part of tmp folder.

Make any changes you need in the tmp folder. To re-create the parsed system image (system.img.new) use the command below. This can be individually flashed using fastboot command

      sudo ./make_ext4fs -s -l 512M -a system system.img.new tmp/
      sudo umount tmp
      rm -rf tmp

Userdata.img details

This partition contains user-installed applications and data, including customization data

Again this is a sparsed ext4 loop mounted filesystem. To extract the sparesed image, use the command below

   ./simg2img userdata.img userdata.img.raw
   ./mkdir tmp
   sudo mount -t ext4 -o loop userdata.img.raw tmp/

Now you can make any changed in the tmp folder. To re-create a new userdata.img, use the command below to generate userdata.img.new, which can be flashed using fastboot.

   sudo ./make_ext4fs -s -l 512M -a userdata userdata.img.new tmp/
   sudo umount tmp
   rm -rf tmp

Cache.img details

This partition can be used to store temporary data. It is currently an empty ext4 image.

Commands to create this image

  mkdir tmp/
  sudo ./make_ext4fs -s -l 256M -a cache cache.img tmp/

Frequently used Commands for eMMC

To remount system partition in R/W mode for OMAP4

    adb remount                  - remounts the /system partition on the device read-write

To remount rootfs as R/W mode

   mount -o rw,remount -t auto /dev/block/mmcblk0p1 /

To add busybox run the commands below

   adb shell 'chmod 0755 /data/busybox/bin/* /data/busybox/sbin/*'
   adb shell '/data/busybox/bin/mount -oremount,rw /'
   adb shell '/data/busybox/bin/mount -oremount,rw /system'
   adb shell 'ln -s /data/busybox/bin /system/vendor/bin'
   adb shell 'ln -s /data/busybox/sbin /system/vendor/sbin'


 

 

 

<think>我们分析用户提供的日志信息:"打印了15 RedBoot partitions found on MTD device nor0" 这意味着在MTD设备nor0上,使用RedBoot解析器成功找到了15个分区。 结合之前的代码分析,这个日志是由mtd_part_do_parse函数中的pr_notice打印的: pr_notice("%d %s partitions found on MTD device %s\n", ret, parser->name, master->name); 在这里: - ret = 15(分区数量) - parser->name = "RedBoot"(解析器名称) - master->name = "nor0"(MTD设备名称) 因此,我们可以推断: 1. 系统在初始化MTD设备nor0时,尝试了分区解析器。 2. 在尝试到RedBoot解析器时,该解析器的parse_fn回调函数返回了15,表示成功解析出15个分区。 3. 根据之前讨论的解析器调用顺序(default_mtd_part_types数组),RedBoot可能是默认解析器之一,或者是通过其他方式注册的解析器。 需要注意的是,RedBoot并不是之前示例中提到的默认解析器(cmdlinepart, ofpart),所以它可能是通过其他方式被调用的。解析器的注册是通过mtd_part_parser_register函数完成的,可以静态编译进内核,也可以作为模块加载。 此外,根据mtd_part_do_parse的调用逻辑,一旦某个解析器成功解析(返回>0),就会停止尝试其他解析器。因此,这里RedBoot解析器成功解析,所以不会再去尝试cmdlinepart或ofpart。 下面我们将按照要求组织回答,并在最后提出相关问题。 </think>### MTD分区解析日志分析 根据日志内容"15 RedBoot partitions found on MTD device nor0",可以得出以下关键信息: ```c pr_notice("%d %s partitions found on MTD device %s\n", 15, "RedBoot", "nor0"); ``` #### 日志生成机制解析: 1. **触发位置**: - 日志产生于`mtd_part_do_parse()`函数中的成功路径 - 当`parse_fn`返回值 > 0 时触发此通知 2. **参数对应关系**: | 日志参数 | 实际值 | 含义 | |----------|--------|------| | %d | 15 | 成功解析的分区数量 | | %s | "RedBoot" | 使用的分区解析器名称 | | %s | "nor0" | 目标MTD设备名称 | 3. **解析器工作流程**: ```mermaid flowchart TB 开始 --> A[调用RedBoot解析器] 解析器工作 --> B[扫描分区表] B --> C[验证CRC校验] C --> D[解析FIS目录] D --> E[返回分区数15] ``` #### 系统行为推断: 1. **解析器选择顺序**: - 表明系统在`default_mtd_part_types`遍历中: - cmdlinepart未提供有效分区表(返回≤0) - ofpart未提供有效分区表(返回≤0) - RedBoot作为后续解析器成功识别分区 2. **NOR闪存特性**: - 设备名"nor0"表明使用NOR闪存 - RedBoot常用于NOR设备的FIS分区管理 - 15个分区暗示复杂存储布局(可能包含:引导区/内核区/根文件系统区/配置区等) 3. **启动阶段影响**: | 阶段 | 影响 | |------|------| | 内核初始化 | MTD子系统完成设备注册 | | 解析器执行 | 约1-5ms(取决于FIS表大小) | | 后续流程 | 创建15个/dev/mtdblockX设备节点 | > ⚠️ **潜在问题诊断** > - 若出现`mtd: partition exceeds flash size`警告:表示FIS表损坏 > - 若分区数异常多:可能误解析用户数据区为分区表 > - 若出现`RedBoot: invalid FIS entry`:需检查闪存擦写状态 ---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值