最小可启动工程指南
本文对应 成长路径 高优先级:用 Buildroot 产出 可重复构建 的最小镜像(kernel + rootfs + dtb),并记录验证步骤。Yocto 路径见 Yocto 与内核子系统深入。
学习目标
- 固定 defconfig + 版本号,他人可
make复现同一镜像。 - 产出 可烧录 的 boot 分区 + rootfs,串口进 shell。
- 将
.config、external tree、补丁 纳入 git 管理。
工程结构建议
my-board-bringup/
├── README.md
├── buildroot/ # 子模块或脚本指定 BR2_VERSION
├── board/myvendor/myboard/
│ ├── linux.config
│ ├── genimage.cfg
│ ├── post-build.sh
│ └── rootfs_overlay/
├── configs/myboard_defconfig
└── dl/ # 可选本地 tarball 缓存(不提交)Buildroot 快速流程
git clone https://github.com/buildroot/buildroot.git
cd buildroot
make myboard_defconfig # 或使用 BR2_EXTERNAL
make产物常见位置:
output/images/
├── Image 或 zImage
├── *.dtb
├── rootfs.ext4 / rootfs.tar
└── sdcard.img # 若配置 genimagedefconfig 要点
| 选项类 | 建议 |
|---|---|
| Toolchain | 内部 / 外部交叉工具链与 BSP 一致 |
| Kernel | 固定 版本 或 BR2_LINUX_KERNEL_CUSTOM_REPO |
| Rootfs | ext4 / tar;启用 getty on serial |
| Host tools | genimage、mtools(做 SD 镜像) |
保存配置:
make savedefconfig BR2_DEFCONFIG=../configs/myboard_defconfig与 U-Boot / 启动链衔接
- 将 Image + dtb 放入 FAT 启动分区,或按 BSP 要求 dd 到固定偏移。
- bootargs 与 eMMC 与 ext4 根文件系统 中
root=一致。 - 排障见 启动排障手册。
可复现性清单
-
README写明 Buildroot 版本 / commit -
configs/myboard_defconfig入 git - 记录
sha256sum output/images/* - CI 或脚本:
make clean && make一键构建 - 新同事按 README 30 分钟内 出相同镜像
验证步骤
- 烧录
sdcard.img或分区镜像。 - 串口见 U-Boot(若有)→ Linux banner → login prompt。
uname -a、mount、ip a基本命令正常。- 可选:启动后跑 自检脚本(写版本文件到
/etc/os-release)。