启动
U-Boot和OpenSBI开发调试指南。
uboot 功能与配置
功能介绍
uboot 的主要功能有以下几点:
- 加载启动内核
uboot 从存储介质(emmc/sd/nand/nor/ssd 等),加载内核镜像到内存指定位置,并启动内核。
- fastboot 刷机功能
通过 fastboot 工具,烧写镜像到指定的分区位置。
- 开机 logo
uboot 启动阶段显示启动 logo 以及 boot menu。
- 驱动调试
基于 uboot 调试设备驱动,如 mmc/spi/nand/nor/nvme 等驱动。uboot 提供 shell 命令行对各个驱动进行功能调试。
uboot 驱动在 drivers/目录下。
编译
本章节介绍基于 uboot 代码环境,编译生成 uboot 的镜像文件。
- 编译配置
首次编译,或者需要重新选择其他方案,则需要先选择编译配置,这里以 k1 为例:
cd ~/uboot-2022.10
make ARCH=riscv k1_defconfig -C ~/uboot-2022.10/
可视化更改编译配置:
make ARCH=riscv menuconfig
通过键盘"Y"/"N"以开启/关闭相关的功能配置。保存后会更新到 uboot 根目录的.config 文件。
- 编译 uboot
cd ~/uboot-2022.10
GCC_PREFIX=riscv64-unknown-linux-gnu-
make ARCH=riscv CROSS_COMPILE=${GCC_PREFIX} -C ~/uboot-2022.10 -j4