本文主要是介绍stm32mp135d u-boot 引导流程,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
stm32mp135d u-boot 引导流程
- 一、U-Boot启动流程
- 1. bootcmd_stm32mp 确定当前设备
- 2. distro_bootcmd 进入当前设备启动
- 3. bootcmd_mmc1 设置当前设备号
- 4. mmc_boot 设置当前设备类型
- 5. scan_dev_for_boot_part 扫描设备分区
- 6. scan_dev_for_boot 扫描指定分区
- 7. scan_dev_for_extlinux 查找指定分区的配置文件
- 8. boot_extlinux 准备启动
- 9. sysboot 启动内核
- 二、direct boot cmd 手动配置直接启动
- 三、other cmd 其他辅助命令
- 1. read config 读取
- 2. env_check 环境检查
- 3. scan_m4fw 检查是否有M4 固件
- 4. scan_overlays 检查 overlays 配置文件
此文描述了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 确定当前设备
- 打印当前启动设备
- 判断设备启动类型后(烧录usb|serial,启动emmc|nand|nor),设置环境变量boot_targets
- 执行 distro_bootcmd
env_check
echo "Boot over ${boot_device}${boot_instance}!"
if test ${boot_device} = serial || test ${boot_device} =usb; thenstm32prog ${boot_device} ${boot_instance}
elserun env_checkif test ${boot_device} = mmc; thenenv set boot_targets "mmc${boot_instance}"fiif test ${boot_device} = nand || test ${boot_device} = spi-nand; thenenv set boot_targets ubifs0fiif test ${boot_device} = nor; thenenv set boot_targets mmc0firun distro_bootcmd
fi
2. distro_bootcmd 进入当前设备启动
1.当前使用的emmc,执行bootcmd_mmc1
for target in ${boot_targets}; dorun bootcmd_${target}
done
3. bootcmd_mmc1 设置当前设备号
bootcmd_mmc1=devnum=1
run mmc_boot
4. mmc_boot 设置当前设备类型
if mmc dev ${devnum}; thendevtype=mmcrun scan_dev_for_boot_part
fi
5. scan_dev_for_boot_part 扫描设备分区
-
- 检查可引导的设备分区
-
- fstype 检查分区的文件系统类型,默认ext4
-
- 执行 scan_dev_for_boot
part list ${devtype} ${devnum} -bootable devplist;
env exists devplist || setenv devplist 1;
for distro_bootpart in ${devplist}; doif fstype ${devtype} ${devnum}:${distro_bootpart} bootfstypethenrun scan_dev_for_bootfi
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}; dorun scan_dev_for_extlinuxrun scan_dev_for_scripts
done
run scan_dev_for_efi
7. scan_dev_for_extlinux 查找指定分区的配置文件
-
- 查找配置文件
-
- prefix的值 /mmc1_
-
- ${prefix}${boot_syslinux_conf} -> /mmc1_extlinux/stm32mp135d-aaron_extlinux.conf
if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; thenecho Found ${prefix}${boot_syslinux_conf}run boot_extlinuxecho 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.confmd 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 固件
-
- 扫描设备上是否存在 M4 固件(Firmware)
if test -e ${devtype} ${devnum}:${distro_bootpart} ${m4fw_name}; thenecho Found M4 FW $m4fw_nameif load ${devtype} ${devnum}:${distro_bootpart} ${m4fw_addr} ${m4fw_name}; thenrun boot_m4fwfi
fi
4. scan_overlays 检查 overlays 配置文件
-
- 设置配置文件
iftest -e ${devtype} ${devnum}:${distro_bootpart} /overlays/overlays.txt && load ${devtype} ${devnum}:${distro_bootpart} ${loadaddr} /overlays/overlays.txt && env import -t ${loadaddr} ${filesize}
thenecho loaded overlay.txt: ${overlay}run ov_initrun ov_apply
fi
能力一般,水平有限,知识浅薄,如果能帮到您,那我感到很荣幸
这篇关于stm32mp135d u-boot 引导流程的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!