U-Boot
Ttips
- Das U-Boot -- the Universal Boot Loader
- Manual
- wikipedia Das U-Boot
- 主要用于嵌入式系统的开机加载程序,可以支持多种不同的计算机系统结构.
- 支持架构
- 68k, ARM, Blackfin, MicroBlaze, MIPS, Nios, SuperH, PPC, RISC-V, x86
- 参考
- u-boot qemu-x86
- 包内容 uboot-tools
- u-boot-all
- 所有开发板的 uboot
- RPi U-Boot
- uboot qemu
- Run u-boot in qemu
- https://sourceforge.net/projects/powerast/files/Firmware/
- https://variwiki.com/index.php?title=U-Boot_features
- https://linux-sunxi.org/U-Boot
- https://wiki.alpinelinux.org/wiki/DIY_Fully_working_Alpine_Linux_for_Allwinner_and_Other_ARM_SOCs
- mkimg.arm.sh
- raspberrypi-bootloader
# 编译
# 支持配置 https://github.com/u-boot/u-boot/tree/master/configs
# 依赖 https://git.alpinelinux.org/aports/tree/main/uboot-tools/APKBUILD
apk add swig python3-dev bison flex openssl-dev linux-headers
make qemu-x86_64_defconfig
# make cscope
make all -j $(nproc)
# test
qemu-system-x86_64 -nographic -no-reboot -bios u-boot.rom
# vexpress_ca9x4_defconfig
# menuconfig
make qemu_arm64_defconfig
make all -j $(nproc)
# export CROSS_COMPILE=arm-linux-gnueabi-
# export CROSS_COMPILE=aarch64-linux-gnu-
# make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- vexpress_ca9x4_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j8
# example - /usr/share/doc/uboot-tools/examples/fw_env.config
apk add uboot-tools uboot-tools-examples
cat <<CONF > boot.scr
usb start
setenv bootargs earlyprintk console=tty0 console=ttyAMA0
CONF
mkimage -A arm -O linux -T script -C none -n boot.scr -d boot.scr boot.scr.uimg
#
# mkenvimage -s 1024 /usr/share/doc/uboot-tools/examples/fw_env.config
fw_printenv -c /usr/share/doc/uboot-tools/examples/fw_env.config
- 开发板启动需要有串口来进行调试
- 默认串口配置 115200/8N1 (115200 bps, 8 Bit per character, no parity, 1 stop bit, no handshake)
- Linux 下推荐使用 kermit 或 cu,不要使用 minicom,也可以使用 screen 和 picocom,切记关闭硬件和软件 flow control
image
- “raw” ELF image (vmlinux)
- uImage format, which contains the compressed vmlinux plus a few extra bytes of metadata that describe the kernel load address.
- How can I create an uImage from a ELF file
arch | name |
---|---|
alpha | Alpha |
arc | ARC |
arm | ARM |
arm64 | AArch64 |
avr32 | AVR32 |
blackfin | Blackfin |
ia64 | IA64 |
invalid | Invalid ARCH |
m68k | M68K |
microblaze | MicroBlaze |
mips | MIPS |
mips64 | MIPS 64 Bit |
nds32 | NDS32 |
nios2 | NIOS II |
or1k | OpenRISC 1000 |
powerpc | PowerPC |
riscv | RISC-V |
s390 | IBM S390 |
sandbox | Sandbox |
sh | SuperH |
sparc | SPARC |
sparc64 | SPARC 64 Bit |
x86 | Intel x86 |
x86_64 | AMD x86_64 |
xtensa | Xtensa |
mkimage -A arm -O linux -T kernel -C gzip -d vmlinux uImage
mkimage -A arm64 -O linux -T ramdisk -C gzip -d init.cpio.gz initramfs.uImage
# https://www.denx.de/wiki/view/DULG/HowCanILoadAndUncompressACompressedImage
# bootm
# -T standalone
boot
- boot.scr.uimg
- https://mediawiki.compulab.com/w/index.php?title=U-Boot:_Quick_reference
- https://www.digi.com/resources/documentation/digidocs/PDFs/90000852.pdf
# 版本
version
# 主板信息
bdinfo
# 串口信息
coninfo
# cpu 信息
cpu info
cpu detail
# QEMU 固件列表
qfw list
virtio scan
virtio info
# 子系统
ide
usb
virtio
nvme
mmc
#
dm tree
ext4ls ide 0 /
ext4ls ide 0:2 /
ext4load ide 0 ${kernel_addr_r} vmlinuz-lts
ext4load ide 0 ${ramdisk_addr_r} initramfs-lts
zboot ${kernel_addr_r}
# sda
setenv bootargs root=/dev/sda1 ro
load ide 0 ${kernel_addr_r} /vmlinuz-lts
load ide 0 ${ramdisk_addr_r} /initramfs-lts
zboot ${kernel_addr_r} - ${ramdisk_addr_r} ${filesize}
# 持久
setenv bootargs root=UUID=b2aaf743-0418-4d90-94cc-3e6108d7d968 ro
setenv boot zboot 03000000 0 04000000 \${filesize}
setenv bootcmd "ext2load scsi 0:2 03000000 /boot/vmlinuz-3.13.0-58-generic; ext2load scsi 0:2 04000000 /boot/initrd.img-3.13.0-58-generic; run boot"
saveenv
# vda
setenv bootargs root=/dev/vda1 ro
load virtio 0 03000000 /vmlinuz-lts
load virtio 0 04000000 /initramfs-lts
zboot 03000000 0 04000000 ${filesize}
qemu-system-x86_64 -m 1024 -smp 2 -nographic -bios artifacts/uboot/qemu-x86_64/u-boot.rom \
-kernel virt/vmlinuz-virt -append 'root=/dev/ram console=ttyS0' \
-initrd virt/initramfs-virt
qfw load
zboot 01000000 - 04000000 5fe85e
part list mmc 0
ls mmc 0:1
load mmc 0:1 0x60008000 zImage
ext4load mmc 0:1 0x60008000 zImage
load mmc 0:1 0x61000000 vexpress-v2p-ca9.dtb
ext4load mmc 0:1 0x61000000 vexpress-v2p-ca9.dtb
setenv bootargs 'root=/dev/mmcblk0p2 rw rootfstype=ext4 rootwait earlycon console=tty0 console=ttyAMA0 init=/linuxrc ignore_loglevel'
bootz 0x60008000 - 0x61000000
setenv ipaddr 10.8.8.100; setenv netmask 255.255.255.0; setenv serverip 10.8.8.3;
setenv bootargs 'root=/dev/nfs rw nfsroot=10.8.8.3:/home/macrofun/NFS_HOME init=/linuxrc ip=10.8.8.100 console=ttyAMA0';
saveenv
tftp 0x60003000 uImage;
setenv bootargs root=/dev/nfs rw nfsroot=10.8.8.3:/home/macrofun/NFS_HOME,proto=tcp,nfsvers=4,nolock init=/linuxrc ip=10.8.8.100 console=ttyAMA0 console=tty0
# qemu-system-arm -M vexpress-a9 -m 512 -serial stdio -net nic -net tap,ifname=tap0,script=no -kernel u-boot
# qemu-system-aarch64 -nographic -curses -machine virt -cpu cortex-a57 -bios u-boot.bin
if load ${devtype} ${devnum}:${bootpart} ${kernel_addr_r} /boot/Image; then
echo fdt: ${fdtfile}
if load ${devtype} ${devnum}:${bootpart} ${fdt_addr_r} /boot/dtbs/${fdtfile}; then
if load ${devtype} ${devnum}:${bootpart} ${ramdisk_addr_r} /boot/initramfs-linux.img; then
booti ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r};
else
booti ${kernel_addr_r} - ${fdt_addr_r};
fi;
fi;
fi