STM32MP157-uboot启动分析

本文主要基于XLY-stm32mp157-STY分析,uboot启动内核前的准备工作分析,重点讲解启动uboot后如何启动内核过程。下图为uboot启动过程。
在这里插入图片描述

下面主要讲解的是进入main_loop循环后的启动分析。

进入main_loop后,读取到变量bootcmd。bootcmd为自动启动时执行的命令,在日常开发过程中只需要修改此部分内容就可以满足日常开发所用。

接下来主要讲解一下此命令具体内容。

启动命令:bootcmd

概念图如下:
在这里插入图片描述

我们使用的示例为STM32MP157-STY,则 bootcmd 的启动命令为 bootcmd_stm32mp。

bootcmd_stm32mp=echo "Boot over ${boot_device}${boot_instance}!";if test ${boot_device} = serial || test ${boot_device} = usb;then stm32prog ${boot_device} ${boot_instance}; else run env_check;if test ${boot_device} = mmc;then env set boot_targets "mmc${boot_instance}"; fi;if test ${boot_device} = nand || test ${boot_device} = spi-nand ;then env set boot_targets ubifs0; fi;if test ${boot_device} = nor;then env set boot_targets mmc0; fi;run distro_bootcmd;fi;

因为存储的命令行看起来不符合我们日常开发所用的格式,特意展开为以下命令,这样就符合我们日常开发所用格式。看起来就会很清晰。

bootcmd_stm32mp=
    echo "Boot over ${boot_device}${boot_instance}!";		// boot_device:设备名称,boot_instance:设备号,本例为mmc1启动
    if test ${boot_device} = serial || test ${boot_device} = usb;then 	//检测到USB或者serial连接,则执行stm32prog。使用usb下载工具。
        stm32prog ${boot_device} ${boot_instance}; 
    else 
        run env_check;

        if test ${boot_device} = mmc;then 
            env set boot_targets "mmc${boot_instance}";		//设置boot_targets参数为mmc启动,设备号为boot_instance,本例为mmc1。
        fi;
        if test ${boot_device} = nand || test ${boot_device} = spi-nand ;then 
            env set boot_targets ubifs0; 		//若boot_device为spi-nand时,设置boot_targets参数为ubifs0,此为固态存储设备启动。
        fi;
        if test ${boot_device} = nor;then 
            env set boot_targets mmc0; 		//若boot_device为nor时,设置boot_targets参数为mmc0启动,SD卡启动。
        fi;

        run distro_bootcmd;
    fi;

一、env_check

env_check=env exists env_ver || env set env_ver ${ver};if env info -p -d -q; then env save; fi;if test "$env_ver
  • 0
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值