解析freescale的MfgTool中的脚本,了解imx6, android系统的分区情况。

配置文件

  1. cfg.ini

[profiles]
chip = MX6DL Linux Update
# 指定平台名称
[platform]
board = SabreSD
# 根据name名称指定ucl2.xml中运行的命令
[LIST]
name = Android-SPI_NOR-EMMC

  2. UICfg.ini

  用于配置同时烧写的主板个数,MfgTool的说明文档中指出,支持同时烧写多个主板。

[UICfg]
PortMgrDlg=1

emmc分区

  android分区脚本mksdcard-android.sh

#!/bin/bash
# 运行 sh mksdcard-android.sh /dev/mmcblk0
# partition size in MB
BOOTLOAD_RESERVE=8 # bootloader
BOOT_ROM_SIZE=8
SYSTEM_ROM_SIZE=512 # system.img
CACHE_SIZE=512 # cache
RECOVERY_ROM_SIZE=8 # recovery
VENDER_SIZE=8 # vendor
MISC_SIZE=8
#显示帮助信息
help() { bn=`basename $0`
cat << EOF
usage $bn <option> device_node options:
-h displays this help message
-s only get partition size
-np not partition.
-f flash android image.
EOF } # check the if root?
userid=`id -u`
if [ $userid -ne "0" ]; then
echo "you're not root?"
exit
fi # parse command line
moreoptions=1
node="na"
cal_only=0
flash_images=0
not_partition=0
not_format_fs=0
while [ "$moreoptions" = 1 -a $# -gt 0 ]; do
case $1 in
-h) help; exit ;;
-s) cal_only=1 ;;
-f) flash_images=1 ;;
-np) not_partition=1 ;;
-nf) not_format_fs=1 ;;
*) moreoptions=0; node=$1 ;;
esac
[ "$moreoptions" = 0 ] && [ $# -gt 1 ] && help && exit
[ "$moreoptions" = 1 ] && shift
done if [ ! -e ${node} ]; then
help
exit
fi # node /dev/mmcblk0 # call sfdisk to create partition table
# get total card size
seprate=40
# 查看分区大小,字节数
total_size=`sfdisk -s ${node}`
# 将字节转为M
total_size=`expr ${total_size} / 1024`
boot_rom_sizeb=`expr ${BOOT_ROM_SIZE} + ${BOOTLOAD_RESERVE}` # 16M
extend_size=`expr ${SYSTEM_ROM_SIZE} + ${CACHE_SIZE} + ${VENDER_SIZE} + ${MISC_SIZE} + ${seprate}`
data_size=`expr ${total_size} - ${boot_rom_sizeb} - ${RECOVERY_ROM_SIZE} - ${extend_size} + ${seprate}`
# 这一部分只是显示计算的大小
# create partitions
if [ "${cal_only}" -eq "1" ]; then
cat << EOF
BOOT : ${boot_rom_sizeb}MB
RECOVERY: ${RECOVERY_ROM_SIZE}MB
SYSTEM : ${SYSTEM_ROM_SIZE}MB
CACHE : ${CACHE_SIZE}MB
DATA : ${data_size}MB
MISC : ${MISC_SIZE}MB
EOF
exit
fi # 删除分区表
# destroy the partition table
dd if=/dev/zero of=${node} bs=1024 count=1 # 创建分区
# sfdisk 命令 man 文档中有记录。
# Id is given in hex, without the 0x prefix, or is [E|S|L|X],
# where L (LINUX_NATIVE (83)) is the default, S is LINUX_SWAP (82),
# E is EXTENDED_PARTITION (5), and X is LINUX_EXTENDED (85).
# 指定分区大小,以及分区的类型,83,LINUX_NATIVE,5:扩展分区
# 查案每种文件系统类型,可以通过命令 sfdisk -T 查看 sfdisk --force -uM ${node} << EOF
,${boot_rom_sizeb},83 # boot_rom_sizeb
,${RECOVERY_ROM_SIZE},83
,${extend_size},5
,${data_size},83
,${SYSTEM_ROM_SIZE},83
,${CACHE_SIZE},83
,${VENDER_SIZE},83
,${MISC_SIZE},83
EOF # adjust the partition reserve for bootloader.
# if you don't put the uboot on same device, you can remove the BOOTLOADER_ERSERVE
# to have 8M space.
# the minimal sylinder for some card is 4M, maybe some was 8M
# just 8M for some big eMMC 's sylinder
# 将/dev/mmcblk0分区之后的第一个分区进行调整
sfdisk --force -uM ${node} -N1 << EOF
${BOOTLOAD_RESERVE},${BOOT_ROM_SIZE},83
EOF # For MFGTool Notes:
# MFGTool use mksdcard-android.tar store this script
# if you want change it.
# do following:
# tar xf mksdcard-android.sh.tar
# vi mksdcard-android.sh
# [ edit want you want to change ]
# rm mksdcard-android.sh.tar; tar cf mksdcard-android.sh.tar mksdcard-android.sh

烧写镜像

  烧写的过程就记录在ucl2.xml中,根据cfg.ini中指定的LIST的name值选择运行的命令,将系统镜像烧写到emmc的分区中。

<!--
* Copyright (C) 2010-2013, Freescale Semiconductor, Inc. All Rights Reserved.
* The CFG element contains a list of recognized usb devices.
* DEV elements provide a name, class, vid and pid for each device.
*
* Each LIST element contains a list of update instructions.
* "Install" - Erase media and install firmware.
* "Update" - Update firmware only.
*
* Each CMD element contains one update instruction of attribute type.
* "pull" - Does UtpRead(body, file) transaction.
* "push" - Does UtpWrite(body, file) transaction.
* "drop" - Does UtpCommand(body) then waits for device to disconnect.
* "boot" - Finds configured device, forces it to "body" device and downloads "file".
* "find" - Waits for "timeout" seconds for the "body" device to connect.
* "show" - Parse and show device info in "file".
--> <UCL>
<CFG>
<STATE name="BootStrap" dev="MX6D" vid="15A2" pid="0061"/>
<STATE name="Updater" dev="MSC" vid="066F" pid="37FF"/>
</CFG>
<!--
The following Lists are for i.MX6Solo/DualLite chips
--> <LIST name="MYZR-I.MX6-SPI_NOR & eMMC" desc="Choose SPI-NOR/eMMC as media">
......
</LIST> <LIST name="MYZR-I.MX6-SPI_NOR & SD card" desc="Choose SPI-NOR/SD as media">
......
</LIST> <LIST name="MYZR-I.MX6-UBUNTU-SPI_NOR & eMMC" desc="Choose eMMC as media">
......
</LIST> <LIST name="Android-SPI_NOR-eMMC" desc="Choose SPI-NOR and SD Rootfs as media">
<!-- 按照官方文档说明更改的uboot,用于MfgTool烧写程序的时候使用 -->
<CMD state="BootStrap" type="boot" body="BootStrap" file ="myzr_u-boot.bin" >Loading U-boot</CMD>
<CMD state="BootStrap" type="load" file="uImage" address="0x10800000"
loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" >Loading Kernel.</CMD>
<CMD state="BootStrap" type="load" file="initramfs.cpio.gz.uboot" address="0x10C00000"
loadSection="OTH" setSection="OTH" HasFlashHeader="FALSE" >Loading Initramfs.</CMD>
<CMD state="BootStrap" type="jump" > Jumping to OS image. </CMD> <!--
Please use "cat /proc/mtd" to check the right partitions for NAND
,mtd0 and mtd1 are for SPI-NOR; mtd2 - mtd6 are for NAND
-->
<!-- <CMD state="Updater" type="push" body="mknod class/mtd,mtd0,/dev/mtd0"/>
<CMD state="Updater" type="push" body="mknod block,mtdblock0,/dev/mtdblock0,block"/> -->
<!----
<CMD state="Updater" type="push" body="$ flash_erase /dev/mtd0 0 0">Erasing Boot partition</CMD>
<CMD state="Updater" type="push" body="send" file="files/android/u-boot.bin">Sending U-Boot</CMD>
<!-- 将u-boot.bin写到/dev/mtd0,每次读写的大小是512-->
<CMD state="Updater" type="push" body="$ dd if=$FILE of=/dev/mtd0 bs=512">write U-Boot to SPI-NOR</CMD>
--->
<CMD state="Updater" type="push" body="send" file="mksdcard-android.sh.tar">Sending partition shell</CMD>
<CMD state="Updater" type="push" body="$ tar xf $FILE "> Partitioning...</CMD>
<CMD state="Updater" type="push" body="$ sh mksdcard-android.sh /dev/mmcblk0"> Partitioning...</CMD>
<!-- 使用脚本将/dev/mmcblk0进行分区-->
<CMD state="Updater" type="push" body="$ ls -l /dev/mmc* ">Formatting sd partition</CMD>
<!-- burn the uboot: -->
<CMD state="Updater" type="push" body="send" file="files/android/u-boot.bin">Sending U-Boot</CMD>
<!-- 将/dev/mmcblk0清0,每次操作512字节,操作次数200次,操作位置,从偏移2block的地方开始输出-->
<CMD state="Updater" type="push" body="$ dd if=/dev/zero of=/dev/mmcblk0 bs=512 seek=2 count=2000">Clean U-Bootenvironment</CMD>
<!-- 将u-boot.bin写道/dev/mmcblk0,每次写512字节,从uboot偏移地址是2 block的地方开始读取,从/dev/mmcblk0偏移2block的地方开始输出 -->
<CMD state="Updater" type="push" body="$ dd if=$FILE of=/dev/mmcblk0 bs=512 seek=2 skip=2">write U-Boot to sdcard</CMD>
<!-- burn the uImage: -->
<CMD state="Updater" type="push" body="send" file="files/android/boot.img">Sending kernel uImage</CMD>
<!-- 将boot.img写入到/dev/mmcblk0p1 -->
<CMD state="Updater" type="push" body="$ dd if=$FILE of=/dev/mmcblk0p1">write boot.img</CMD>
<CMD state="Updater" type="push" body="frf">flush the memory.</CMD>
<!-- 将/dev/mmcblk0p4格式化位ext4文件系统,并指定卷标名称为data-->
<CMD state="Updater" type="push" body="$ mkfs.ext4 -L data /dev/mmcblk0p4">Formatting sd partition</CMD>
<!-- 将/dev/mmcblk0p5格式化位ext4文件系统,并指定卷标名称为system-->
<CMD state="Updater" type="push" body="$ mkfs.ext4 -L system /dev/mmcblk0p5">Formatting system partition</CMD>
<!-- 将/dev/mmcblk0p6格式化位ext4文件系统,并指定卷标名称为cache-->
<CMD state="Updater" type="push" body="$ mkfs.ext4 -L cache -O^extent /dev/mmcblk0p6">Formatting cache partition</CMD>
<!-- 将/dev/mmcblk0p7格式化位ext4文件系统,并指定卷标名称为vender-->
<CMD state="Updater" type="push" body="$ mkfs.ext4 -L vender /dev/mmcblk0p7">Formatting data partition</CMD>
<CMD state="Updater" type="push" body="frf">flush the memory.</CMD>
<CMD state="Updater" type="push" body="$ mkfs.ext4 /dev/mmcblk0p8">Formatting misc partition</CMD>
<!-- 将system.img些到/dev/mmcblk0p5中,由于文件比较大,所以是通过读取管道再写入-->
<CMD state="Updater" type="push" body="pipe dd of=/dev/mmcblk0p5 bs=512" file="files/android/system.img">Sending and writting system.img</CMD>
<CMD state="Updater" type="push" body="frf">flush the memory.</CMD>
<!-- Write userdata.img is optional, for some customer this is needed, but it's optional. -->
<!-- Also, userdata.img will have android unit test, you can use this to do some auto test. -->
<!-- <CMD state="Updater" type="push" onError="ignore" body="pipe dd of=/dev/mmcblk0p7" file="file/android/userdate.img"> Sending userdata.img(optional) </CMD>
<CMD state="Updater" type="push" body="frf">flush the memory.</CMD> -->
<CMD state="Updater" type="push" body="pipe dd of=/dev/mmcblk0p2 bs=512" file="files/android/recovery.img">Sending and writting recovery.img</CMD>
<CMD state="Updater" type="push" body="frf">Finishing rootfs write</CMD>
<CMD state="Updater" type="push" body="$ echo Update Complete!">Done</CMD>
</LIST>
</UCL>

Author

Tony Liu

2016-8-2, Shenzhen

imx6 MfgTool分析的更多相关文章

  1. imx6 fec分析

    /***************************************************************************** * imx6 fec分析 * 本文主要分析 ...

  2. imx6 framebuffer 分析

    分析imx6 framebuffer设备和驱动的注册过程. Tony Liu, 2016-8-31, Shenzhen 相关文件: arch/arm/mach-mx6/board-mx6q_sabre ...

  3. imx6 spi分析

    /************************************************************************** *本文主要跟踪imx6 spi设备和驱动的注册过 ...

  4. imx6 i2c分析

    本文主要分析: 1. i2c设备注册 2. i2c驱动注册 3. 上层调用过程参考: http://www.cnblogs.com/helloworldtoyou/p/5126618.html 1. ...

  5. imx6 uart分析

    本文主要记录: 1.uart设备注册 2.uart驱动注册 3.上层应用调用有些地方理解的还不是很透彻,希望指正. 1.uart设备注册过程 MACHINE_START(MX6Q_SABRESD, & ...

  6. imx6 gpio分析

    本文主要介绍如何配置IOMUX寄存器,设置IO复用寄存器,配置为GPIO功能.参考: http://www.jianshu.com/p/3c2053508342 http://www.embest-t ...

  7. imx6 MFG TOOL 分析

    之前分析过mfgtool的内容,最近从官网下载,返现新版的mfgtool工具将imx6各种版本的linux/android都使用一个工具进行烧录.所以从新分析一下. 新版与旧版的一个区别是烧写使用的u ...

  8. [IMX6]Android6.0移植和分析

    0. 知识点 中断(设备树) [IMX6]设备树分析--dts 1. 编译 Android6.0内核移植(1):分析编译日志 Android6.0内核移植(2):kernel编译内核 单独烧录kern ...

  9. imx6 uboot启动流程分析

    参考http://blog.csdn.net/skyflying2012/article/details/25804209 这里以imx6平台为例,分析uboot启动流程对于任何程序,入口函数是在链接 ...

随机推荐

  1. 微信/易信公共平台开发(四):公众号调试器 (仿真微信平台,提供PHP源码)

    开发微信/易信公共平台时,调试往往很麻烦,一般只能在手机上边试边改, 或在服务器写日志.当你的服务器脚本有Bug时,手机上没有显示,追查是不容易的.我在开发过程中,编写了一个调试器, 能仿真微信/易信 ...

  2. Spring 的ioc

    Spring的两个非常重要的功能ioc和aop 依赖反转:依赖对象的获得被反转:很多非凡的应用都是由两个或多个类通过彼此的合作来上线业务逻辑.这使得每一个对象都须要与其它对象合作,也就是说 一个对象获 ...

  3. Python——极限编程

    很cool的名字,极限编程(Extreme Programming,简写XP)是编程的一种流行趋势: (1)首先是对目标进行计划: (2)然后将测试用例集合编写为一种框架: (3)之后才编写实际的代码 ...

  4. Python break

    break退出循环 用 for 循环或者 while 循环时,如果要在循环体内直接退出循环,可以使用 break 语句. 比如计算1至100的整数和,我们用while来实现: sum = 0 x = ...

  5. 【转帖】阿里金融云:分布式服务注册中心(DSR)

    https://www.cloud.alipay.com/docs/middleware/register/index.html 分布式服务注册中心(DSR) 分布式服务注册中心简介 服务注册中心 ( ...

  6. C#获取显示器屏幕数量 控制winform显示到哪一个屏幕

    获取当前系统连接的屏幕数量: Screen.AllScreens.Count();获取当前屏幕的名称:string CurrentScreenName = Screen.FromControl(thi ...

  7. 支付宝钱包手势密码破解实战(root过的手机可直接绕过手势密码)

    /* 本文章由 莫灰灰 编写,转载请注明出处. 作者:莫灰灰    邮箱: minzhenfei@163.com */ 背景 随着移动互联网的普及以及手机屏幕越做越大等特点,在移动设备上购物.消费已是 ...

  8. SQLyog之MySQL客户端的下载、安装和使用(旗舰版)(推荐)

    不多说,直接上干货! 福利 => 每天都推送 欢迎大家,关注微信扫码并加入我的4个微信公众号:   大数据躺过的坑      Java从入门到架构师      人工智能躺过的坑          ...

  9. Python 爬虫实例(2)—— 爬取今日头条

    # coding:utf-8 import base64 import random, re import sqlite3 import redis, pickle import json, time ...

  10. ubuntu下将CapsLock改为Ctrl键

    需求:Ubuntu下用Vim时,ESC因为在左上角,还算是好按,但是Ctrl就太坑了,在左右两个下角,实在是太不方便了. 经过分析决定将:CapsLock键改为Ctrl,但仍然保留下面的原Ctrl键( ...