dm37xx android2.3.4增加recovery升级功能
转载请注明文章出处和作者!
出处:http://blog.csdn.net/xl19862005
作者:大熊(Xandy)
今天在给TI omap3的android系统增加recovery模式升级功能时发现,这部分TI根本没有做,只能自己来处理了,参照以前freescale i.mx53平台的做法,分别修改bootloader及recovery包,现在将工作过程记录如下:
1、bootloader部分修改
1.1、增加cache及recovery分区
/* Initialize the name of fastboot flash name mappings */
fastboot_ptentry ptn[] = {
{
.name = "xloader",
.start = 0x0000000,
.length = 0x0020000,
/* Written into the first 4 0x20000 blocks
Use HW ECC */
.flags = FASTBOOT_PTENTRY_FLAGS_WRITE_I |
FASTBOOT_PTENTRY_FLAGS_WRITE_HW_ECC |
FASTBOOT_PTENTRY_FLAGS_HW_ECC_LAYOUT_2 |
FASTBOOT_PTENTRY_FLAGS_REPEAT_4,
},
{
.name = "bootloader",
.start = 0x0080000,
.length = 0x01C0000,
/* Skip bad blocks on write
Use HW ECC */
.flags = FASTBOOT_PTENTRY_FLAGS_WRITE_I |
FASTBOOT_PTENTRY_FLAGS_WRITE_HW_ECC |
FASTBOOT_PTENTRY_FLAGS_HW_ECC_LAYOUT_2,
},
{
.name = "environment",
.start = SMNAND_ENV_OFFSET, /* set in config file */
.length = 0x0040000,
.flags = FASTBOOT_PTENTRY_FLAGS_WRITE_HW_ECC |
FASTBOOT_PTENTRY_FLAGS_HW_ECC_LAYOUT_1 |
FASTBOOT_PTENTRY_FLAGS_WRITE_ENV,
},
{
.name = "kernel",
/* Test with start close to bad block
The is dependent on the individual board.
Change to what is required */
/* .start = 0x0a00000, */
/* The real start */
.start = 0x0280000,
.length = 0x0500000,
.flags = FASTBOOT_PTENTRY_FLAGS_WRITE_HW_ECC |
FASTBOOT_PTENTRY_FLAGS_HW_ECC_LAYOUT_1 |
FASTBOOT_PTENTRY_FLAGS_WRITE_I,
},
{
.name= "cache",
/* Test with start close to bad block
The is dependent on the individual board.
Change to what is required */
/* .start = 0x0a00000, */
/* The real start */
.start = 0x00780000,
.length = 0x0100000,
.flags = FASTBOOT_PTENTRY_FLAGS_WRITE_HW_ECC |
FASTBOOT_PTENTRY_FLAGS_HW_ECC_LAYOUT_1 |
FASTBOOT_PTENTRY_FLAGS_WRITE_I,
},
{
.name= "recovery",
/* Test with start close to bad block
The is dependent on the individual board.
Change to what is required */
/* .start = 0x0a00000, */
/* The real start */
.start = 0x00880000,
.length = 0x0500000,
.flags = FASTBOOT_PTENTRY_FLAGS_WRITE_HW_ECC |
FASTBOOT_PTENTRY_FLAGS_HW_ECC_LAYOUT_1 |
FASTBOOT_PTENTRY_FLAGS_WRITE_I,
},
{
.name = "system",
.start = 0x01380000,
.length = 0x1F280000,
.flags = FASTBOOT_PTENTRY_FLAGS_WRITE_HW_ECC |
FASTBOOT_PTENTRY_FLAGS_HW_ECC_LAYOUT_1 |
FASTBOOT_PTENTRY_FLAGS_WRITE_I,
},
};
注意这里的start及length之间的关系,length一定要比所将要刷入该分区的img文件大,编译后我的recovery.img大小为2.3M左右,这里我分区了recovery分区5M的大小。
1.2、修改bootcommand
/*ubi.mtd=5 指示整个系统的根文件系统在第五个mtd 上
**与board/csst/zt6810.c中的fastboot_ptentry ptn 分区一一对应
***/
/*Xandy add for recovery*/
#ifdef CONFIG_ANDROID_RECOVERY
/* SD/MMC card boot */
#define CONFIG_ANDROID_RECOVERY_BOOTARGS_MMC \
"setenv bootargs ${bootargs} init=/init root=/dev/mmcblk1p4 rootfs=ext4"
#define CONFIG_ANDROID_RECOVERY_BOOTCMD_MMC \
"run bootargs_android_recovery;mmc read 0 ${loadaddr} 0x800 0x2000;bootm"
/* Nand flash boot */
#define CONFIG_ANDROID_RECOVERY_BOOTARGS_NAND \
"setenv bootargs ${bootargs} init=/init console=ttyO2,115200n8 noinitrd ip=off " \
"rootwait mem=512M rw ubi.mtd=5,2048 rootfstype=ubifs root=ubi0:rootfs rootdelay=2 " \
"omapdss.def_disp=lcd " \
"vram=8M omapfb.vram=0:8M mpurate=1000\0"
#define CONFIG_ANDROID_RECOVERY_BOOTCMD_NAND \
"run bootargs_android_recovery;nand read ${loadaddr} 280000 500000;bootm"
#define CONFIG_ANDROID_RECOVERY_CMD_FILE "/recovery/command"
#define CONFIG_ANDROID_SYSTEM_PARTITION_MMC 2
#define CONFIG_ANDROID_RECOVERY_PARTITION_MMC 4
#define CONFIG_ANDROID_CACHE_PARTITION_MMC 6
#endif
/*"bootargs=init=/init console=ttyO2,115200n8 no_console_suspend noinitrd ip=off "
*no_console_suspend 系统suspend后串口不休眠
*/
#ifdef CONFIG_SYS_USE_UBI
#define CONFIG_EXTRA_ENV_SETTINGS \
"loadaddr=0x82000000\0" \
"nandboot=echo Booting from nand ...; " \
"nand read ${loadaddr} 280000 500000; bootm ${loadaddr}\0" \
"bootcmd=run nandboot\0" \
"bootargs=init=/init console=ttyO2,115200n8 noinitrd ip=off " \
"androidboot.console=ttyO2 rootwait mem=512M rw ubi.mtd=6,2048 " \
"rootfstype=ubifs root=ubi0:rootfs rootdelay=2 " \
"omapdss.def_disp=lcd " \
"vram=8M omapfb.vram=0:8M mpurate=1000\0"
#endif
这里要注意
ubi.mtd=6,2048,这个参数的设置,ubi.mtd=x,这里的x与1.1中的的分区一一对应,分区编号从0开始!
1.3、添加librecovery.a
这部分直接从freescale的bootloader里把recovery.c及.h文件copy过来进行修改,一开始我将这些文件放在board/(vendor)/recovery目录下(这里的vendor目录对应当前工程目录)并增加相应的Makefile,在编译的时候发现这部分源码怎么了不参考编译,后来查看bootloader根目录下的Makefile文件发现有如下内容:
LIBS += $(shell if [ -f board/$(VENDOR)/common/Makefile ]; then echo \
"board/$(VENDOR)/common/lib$(VENDOR).a"; fi)
所以才发现自己没有将所加入的文件没有加入根目录下的Makefile里面,所以无法得到期望的.a文件,果断将recovery目录重命名成common,再将编译,OK,通过。
1.4、在start_armboot中加入进入recovery系统的判断
void start_armboot (void)
{
.
.
.
.
#ifdef CONFIG_ANDROID_RECOVERY
check_recovery_mode();
#endif
#if defined(CONFIG_CMD_NET)
#if defined(CONFIG_NET_MULTI)
puts ("Net: ");
#endif
eth_initialize(gd->bd);
#if defined(CONFIG_RESET_PHY_R)
debug ("Reset Ethernet PHY\n");
reset_phy();
#endif
#endif
/* main_loop() can return to retry autoboot, if so just run it again. */
for (;;) {
main_loop ();
}
/* NOTREACHED - no way out of command loop except booting */
}
check_recovery_mode是如何判断是否要进行到recovery的模式的呢?
这部分内容在我去年写的《android recovery模式及ROM制作》这篇博客里有详细的介绍,原文地址:
http://blog.csdn.net/xl19862005/article/details/8517918
(后续更新……)