体验制作uboot启动boot.img
一、下载uboot
wget https://ftp.denx.de/pub/u-boot/u-boot-2021.04.tar.bz2 tar -xvf u-boot-2021.04.tar.bz2
二、下载qemu
https://blog.csdn.net/lenovo8088/article/details/116895806
三、编译uboot-virt
cd u-boot-2021.04 make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- qemu_arm_defconfig make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j 8
四、编译qemu-virt
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- multi_v7_defconfig make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- kvm_guest.config make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- -j 32 zImage
五、qemu导出virt.dtb
qemu-system-arm -M virt,dumpdtb=virt.dtb
六、制作ramdisk
#提前制作好启动文件,然后压缩为ramdisk.img find . | cpio -c -o -v >../ramdisk.img
七、生成 boot.img
#its文件附后 mkimage -f ohos.its boot.img
八、启动qemu
sudo qemu-system-arm -M virt -bios u-boot.bin -m 2048 -nographic -netdev bridge,id=net0,br=virbr0 -device virtio-net-device,netdev=net0,mac=12:22:33:44:55:66
九、uboot引导boot.img启动
setenv bootargs ' console=ttyAMA0 root=/dev/ram0 init=init ' setenv tftpboot 'tftp 50500000 ohos.img;bootm 0x50500000;'; setenv bootcmd 'run tftpboot' ; run bootcmd;
十、解压缩boot.img
#查看boot.img dumpimage -l ./boot.img #解压缩 dumpimage ./boot.img -T flat_dt -p 2 -o ./ramdisk.img dumpimage ./boot.img -T flat_dt -p 1 -o ./virt.dtb dumpimage ./boot.img -T flat_dt -p 0 -o ./zImage
十一、解压缩与压缩保持版本一致
#尝试解压缩ohos-master中boot.img,总是失败,后来查看是dnf install 安装与hi3516dv300中third集成的版本不同,后将代码中uboot 重新编译一下,重新生成tools(mkimage dumpimage)生问题解决。 make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- hi3516dv300_emmc_smp_defconfig
附ohos.its文件
/dts-v1/;
/ {
description = "U-Boot zImage-dtb-ramdisk";
#address-cells = <1>;
images {
kernel-1 {
description = "Linux kernel ";
data = /incbin/("./zImage");
type = "kernel";
arch = "arm";
os = "linux";
compression = "none";
load = <0x40800000>;
entry = <0x40800000>;
};
dtb-1 {
description = "ohos dtb ";
data = /incbin/("./virt.dtb");
type = "flat_dt";
arch = "arm";
os = "linux";
compression = "none";
};
ramdisk-1 {
description = "Ramdisk Image";
data = /incbin/("./ramdisk.img");
type = "ramdisk";
arch = "arm";
os = "linux";
compression = "none";
};
};
configurations {
default = "conf-boot";
conf-boot {
description = "booting ARM Linux Kernel Image Ramdisk";
kernel = "kernel-1";
fdt = "dtb-1";
ramdisk = "ramdisk-1";
};
};
};


