Uboot 2015 代码解析6 main_loop

本文深入探讨了U-Boot的启动过程,详细讲解了从board_init_r到main_loop的跳转,包括命令行解析初始化、进入命令行解析函数cli_loop()及启动kernel的过程。通过代码注释,读者可以了解到U-Boot初始化后的关键步骤,如modem初始化、环境变量设置、命令执行等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

从board_init_r跳转到main_loop完成uboot最后工作:命令行解析,启动kernel。

简介

main_loop主要做了

1.命令行解析初始化。

2.进入命令行解析函数cli_loop();

3.启动kernel。

 

代码注释

/* We come here after U-Boot is initialised and ready to process commands */
void main_loop(void)
{
    const char *s;

    bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");                       //mark main_loop

#ifndef CONFIG_SYS_GENERIC_BOARD
    puts("Warning: Your board does not use generic board. Please read\n");
    puts("doc/README.generic-board and take action. Boards not\n");
    puts("upgraded by the late 2014 may break or be removed.\n");
#endif

    modem_init();                                                                   //modem初始化
#ifdef CONFIG_VERSION_VARIABLE
    setenv("ver", version_string);  /* set version variable */                      //
#endif /* CONFIG_VERSION_VARIABLE */

    cli_init();                                                                     //cmd line初始化

    run_preboot_environment_command();                                              //执行preboot 命令

#if defined(CONFIG_UPDATE_TFTP)
    update_tftp(0UL);                                                               //?
#endif /* CONFIG_UPDATE_TFTP */

    s = bootdelay_process();                                                        //s=获取bootcmd
    if (cli_process_fdt(&s))
        cli_secure_boot_cmd(s);

    autoboot_command(s);                                                            //执行命令s

    cli_loop();                                                                     //进入命令行解析
}   

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值