1./common/main.c->main_loop函数中插入自己的主循环函数
void main_loop(void)
{
const char *s;
bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");
#ifdef CONFIG_VERSION_VARIABLE
setenv("ver", version_string); /* set version variable */
#endif /* CONFIG_VERSION_VARIABLE */
cli_init();
run_preboot_environment_command();
#if defined(CONFIG_UPDATE_TFTP)
update_tftp(0UL, NULL, NULL);
#endif /* CONFIG_UPDATE_TFTP */
//start custom function
RemoteUpdateLoop(); //
//end coutom function
s = bootdelay_process();
if (cli_process_fdt(&s))
cli_secure_boot_cmd(s);
autoboot_command(s);
cli_loop();
panic("No CLI available");
}
2.在自己的自定义的功能函数中, 完成通讯口的初始化工作(比如485通讯口\以太网口等),
然后接收程序文件, 再烧写到NandFlash指定的位置, 完成更新后再跳出自己的主循环即可.
void RemoteUpdateLoop(void)
{
FlashInit();
RunInit();
RemoteUpdateInit();
UsartInit();
while(1)
{
SystickMain();
UsartMain();
RunMain();
FlashMain();
RemoteUpdateMain();
if(m_ucJumpToApp) break;
}
}
3.读写NandFalsh时, 调用uboot的读写命令完成读写工作
sprintf(cmd, "nand erase 0x%08x 0x%08x", ApplicationAddress, uwLen);
run_command(cmd, 0);
sprintf(cmd, "nand write 0x%08x 0x%08x 0x%08x", DATABUF_SDRAM_ADDR|NON_CACHE, uwFlashDestination, uwLen);
run_command(cmd, 0);
|