imx6 MfgTool分析
解析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分析的更多相关文章
- imx6 fec分析
/***************************************************************************** * imx6 fec分析 * 本文主要分析 ...
- imx6 framebuffer 分析
分析imx6 framebuffer设备和驱动的注册过程. Tony Liu, 2016-8-31, Shenzhen 相关文件: arch/arm/mach-mx6/board-mx6q_sabre ...
- imx6 spi分析
/************************************************************************** *本文主要跟踪imx6 spi设备和驱动的注册过 ...
- imx6 i2c分析
本文主要分析: 1. i2c设备注册 2. i2c驱动注册 3. 上层调用过程参考: http://www.cnblogs.com/helloworldtoyou/p/5126618.html 1. ...
- imx6 uart分析
本文主要记录: 1.uart设备注册 2.uart驱动注册 3.上层应用调用有些地方理解的还不是很透彻,希望指正. 1.uart设备注册过程 MACHINE_START(MX6Q_SABRESD, & ...
- imx6 gpio分析
本文主要介绍如何配置IOMUX寄存器,设置IO复用寄存器,配置为GPIO功能.参考: http://www.jianshu.com/p/3c2053508342 http://www.embest-t ...
- imx6 MFG TOOL 分析
之前分析过mfgtool的内容,最近从官网下载,返现新版的mfgtool工具将imx6各种版本的linux/android都使用一个工具进行烧录.所以从新分析一下. 新版与旧版的一个区别是烧写使用的u ...
- [IMX6]Android6.0移植和分析
0. 知识点 中断(设备树) [IMX6]设备树分析--dts 1. 编译 Android6.0内核移植(1):分析编译日志 Android6.0内核移植(2):kernel编译内核 单独烧录kern ...
- imx6 uboot启动流程分析
参考http://blog.csdn.net/skyflying2012/article/details/25804209 这里以imx6平台为例,分析uboot启动流程对于任何程序,入口函数是在链接 ...
随机推荐
- Python 访问dict
访问dict 1:可以if判断元素是否存在 2:dict.get('key')我们已经能创建一个dict,用于表示名字和成绩的对应关系:d = { 'Adam': 95, 'Lisa': 85, 'B ...
- 解决Html.CheckBoxFor中”无法将类型 bool 隐式转换为 bool。存在一个显式转换..."的方法
在后面加.Value属性 @Html.CheckBoxFor(m => m.IsComment.Value, new { style = "vertical-align: middle ...
- 在mvc4里怎样引用:System.Web.Optimization和entityframework
请在nuget 里运行: Install-Package Microsoft.AspNet.Web.Optimizationinstall-package entityframework
- wait & waitpid 以及子进程传给父进程的信号分析
wait() 和 waitpid() wait() 系统调用挂起调用进程的执行直到有一个孩子终止.调用 wait(&status) 等价于: waitpid(-1, &status, ...
- ftp protocol
RFC http://www.w3.org/Protocols/rfc959/4_FileTransfer.html http://blog.chinaunix.net/uid-17238776-id ...
- 【LeetCode】105. Construct Binary Tree from Preorder and Inorder Traversal
Construct Binary Tree from Preorder and Inorder Traversal Given preorder and inorder traversal of a ...
- 如何处理JSON中的特殊字符 介绍几种解决方案
http://www.nowamagic.net/librarys/veda/detail/216JSON 是适用于 Ajax 应用程序的一种有效格式,原因是它使 JavaScript 对象和字符串值 ...
- MySQL查看和修改wait_timeout
1.全局查看wait_timeout值 mysql> show global variables like 'wait_timeout'; 2.修改全局wait_timeout值 set glo ...
- obj 格式注意事项
用Adreno Profiler分析图形效果的实现过程时,需要将特效涉及到的模型导出,以便进行多角度的详细查看,结果发现Adreno Profiler导出模型的功能有bug,总是报错并生成一个残缺的. ...
- Sql 常用的语句实例与代码
在学习SQL的时候,本来预计花三天的时候掌握MS SQL这些基础,现在争取提前一天看完.总结沉底下来,其实也没有多少东西: 1.程序初始化前,先连接数据库 MFC程序中添加记录的代码: [cpp] v ...