韦东山Linux嵌入式课程社区
直播中

孔朱磊

8年用户 1043经验值
私信 关注

移植uboot2016.09到jz2440v3之添加refresh命令实现自动更新操作分享!

在《移植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-Identifier:    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.补丁在这:

回帖(2)

陈斌

2019-9-9 10:31:50
7.实现自动更新的步骤如下:

7.1在uboot启动时,提示
Hit any key to Refresh Uboot:  3
时,按下任意键,之后,提示:


7.2在SecureCRT的菜单栏上选择Transfer——>Send Kermit


7.3选择好要下载的uboot,点击add,点击ok

文件下载完之后,会执行自动执行reset命令,从nor flash 载入新的uboot
举报

刘丰标

2019-9-9 10:41:08
下午发现程序有一个bug,在autoboot.c文件第267行,应该将bootdelay改为refreshdealy
举报

更多回帖

发帖
×
20
完善资料,
赚取积分