stm32mp135d u-boot 引导流程

此文描述了u-boot是通过什么样的过程进入linux内核启动的

一、U-Boot启动流程

boot -> bootcmd_stm32mp -> distro_bootcmd -> bootcmd_mmc1 -> mmc_boot -> scan_dev_for_boot_part -> scan_dev_for_boot -> scan_dev_for_extlinux -> boot_extlinux -> sysboot -> do_sysboot(sysboot.c)

1. bootcmd_stm32mp 确定当前设备

  1. 打印当前启动设备
  2. 判断设备启动类型后(烧录usb|serial,启动emmc|nand|nor),设置环境变量boot_targets
  3. 执行 distro_bootcmd
    env_check
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

2. distro_bootcmd 进入当前设备启动

1.当前使用的emmc,执行bootcmd_mmc1

for target in ${boot_targets}; do
    run bootcmd_${target}
done

3. bootcmd_mmc1 设置当前设备号

bootcmd_mmc1=devnum=1
run mmc_boot

4. mmc_boot 设置当前设备类型

if mmc dev ${devnum}; then
    devtype=mmc
    run scan_dev_for_boot_part
fi

5. scan_dev_for_boot_part 扫描设备分区

    1. 检查可引导的设备分区
    1. fstype 检查分区的文件系统类型,默认ext4
    1. 执行 scan_dev_for_boot
part list ${devtype} ${devnum} -bootable devplist;
env exists devplist || setenv devplist 1;
for distro_bootpart in ${devplist}; do
    if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype
    then
        run scan_dev_for_boot
    fi
done
setenv devplist

6. scan_dev_for_boot 扫描指定分区

  • 1.选择 uboot 启动图像
  • 2.执行 scan_dev_for_extlinux
run select_lcd_id;
echo Scanning ${devtype} ${devnum}:${distro_bootpart}...
for prefix in ${boot_prefixes}; do
    run scan_dev_for_extlinux
    run scan_dev_for_scripts
done
run scan_dev_for_efi

7. scan_dev_for_extlinux 查找指定分区的配置文件

    1. 查找配置文件
    1. prefix的值 /mmc1_
    1. ${prefix}${boot_syslinux_conf} -> /mmc1_extlinux/stm32mp135d-aaron_extlinux.conf
if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then
    echo Found ${prefix}${boot_syslinux_conf}
    run boot_extlinux
    echo SCRIPT FAILED: continuing...
fi

8. boot_extlinux 准备启动

scan_m4fw
scan_overlays

run scan_m4fw;
run scan_overlays;
sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}

9. sysboot 启动内核

sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}

二、direct boot cmd 手动配置直接启动

prefix=/mmc1_
devtype=mmc
devnum=1
distro_bootpart=4
scriptaddr=0xc4100000
boot_syslinux_conf=extlinux/stm32mp135d-aaron_extlinux.conf

确定所有配置后,直接运行:

sysboot mmc 1:4 any 0xc4100000 /mmc1_extlinux/stm32mp135d-aaron_extlinux.conf

三、other cmd 其他辅助命令

1. read config 读取

ext4load mmc 1:4 c4100000 /mmc1_extlinux/stm32mp135d-aaron_extlinux.conf

md c4100000
md.b c4100000 288

2. env_check 环境检查

env_check 的作用是在引导过程中检查环境变量是否被修改,并在需要时将其保存到持久存储中,以确保修改的环境变量在下次引导时仍然有效
-p: 显示环境变量的名称和值。
-d: 显示默认环境变量的名称和值。
-q: 静默模式,即不显示不必要的信息。

if env info -p -d -q; then env save; fi

3. scan_m4fw 检查是否有M4 固件

    1. 扫描设备上是否存在 M4 固件(Firmware)
if test -e ${devtype} ${devnum}:${distro_bootpart} ${m4fw_name}; then
    echo Found M4 FW $m4fw_name
    if load ${devtype} ${devnum}:${distro_bootpart} ${m4fw_addr} ${m4fw_name}; then
        run boot_m4fw
    fi
fi

4. scan_overlays 检查 overlays 配置文件

    1. 设置配置文件
if
    test -e ${devtype} ${devnum}:${distro_bootpart} /overlays/overlays.txt && load ${devtype} ${devnum}:${distro_bootpart} ${loadaddr} /overlays/overlays.txt && env import -t ${loadaddr} ${filesize}
then
    echo loaded overlay.txt: ${overlay}
    run ov_init
    run ov_apply
fi

能力一般,水平有限,知识浅薄,如果能帮到您,那我感到很荣幸

相关推荐

  1. stm32mp135d u-boot 引导流程

    2024-05-01 15:24:03       11 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-05-01 15:24:03       14 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-05-01 15:24:03       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-05-01 15:24:03       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-05-01 15:24:03       18 阅读

热门阅读

  1. Python如何实现抽象工厂模式

    2024-05-01 15:24:03       7 阅读
  2. 每日算法之二叉树的层序遍历

    2024-05-01 15:24:03       10 阅读
  3. 【笔试题汇总】美团笔试题题解 第五场 2024.4.27

    2024-05-01 15:24:03       10 阅读
  4. openwrt提供的四个文件分别是干什么的

    2024-05-01 15:24:03       30 阅读
  5. 工具类,包含线程池,excel图片处理

    2024-05-01 15:24:03       10 阅读
  6. json.parse(json.stringify)的弊端

    2024-05-01 15:24:03       10 阅读
  7. Element-UI 快速入门

    2024-05-01 15:24:03       11 阅读
  8. 前端html中iframe的基本使用

    2024-05-01 15:24:03       9 阅读
  9. 【笔试题汇总】华为春招笔试题题解 2024-3-20

    2024-05-01 15:24:03       11 阅读