在《移植uboot2016.09到jz2440v3——(三)支持dm9000,配置部分环境变量》的基础上,添加烧写uboot至nor flash的功能,并在启动的时候实现延时提示是否更新uboot。
1.参考u-boot-1.1.6_jz2440_burn_nor_with_nand_uboot.patch中实现的copy uboot from nor flash to nand flash 的命令
nand read.jffs2 30000000 bootloader; protect off all; erase 0 3ffff; cp.b 30000000 0 40000
先实现将uboot从nand flash读取到nor flash的功能
实现这个命令:
nand read.jffs2 30000000 0 40000; protect off all; erase 0 3ffff; cp.b 30000000 0 40000
2.再尝试利用loadb 命令下载uboot 到ram,实现了这个命令(就是下面的refresh命令)
loadb 30000000 115200; protect off all; erase 0 3ffff; cp.b 30000000 0 40000
3.添加refresh命令到uboot中
在cmd文件夹下新建refresh_uboot.c,
/*
* Copyright 2000-2009
* Wolfgang Denk, DENX Software Engineering,
wd@denx.de.
*
* SPDX-License-Iden
tifier: GPL-2.0+
*/
#include
#include
#ifdef CONFIG_CMD_REFRESH_UBOOT
static int do_refresh_uboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
char cmd_buf[200];
printf("Refresh uboot . . .n");
strcpy(cmd_buf, "loadb 30000000 115200; protect off all; erase 0 3ffff; cp.b 30000000 0 40000");
run_command(cmd_buf, 0);
return 0;
}
U_BOOT_CMD(
refresh, CONFIG_SYS_MAXARGS, 1, do_refresh_uboot,
"refresh uboot over serial line ",
"load binary file over serial line , then write it to nor flash.n"
);
#endif /*CONFIG_CMD_REFRESH_UBOOT*/
4.在启动延时之前添加refresh延时,实现的效果如下:

5.说明:为方便裁剪,在头文件中添加了几个宏定义
#define CONFIG_CMD_REFRESH_UBOOT
#define CONFIG_CMD_REFRESH_UBOOT_DELAY 3
6.补丁在这: