uboot

体验制作uboot启动boot.img 

常用命令

#查看设置
pri
#保存设置
saveenv
#帮助
help
#查看基础信息
bdinfo
#复位
reset
#设置网络相关参数
setenv ipaddr 192.168.122.149;
setenv serverip 192.168.122.1;
setenv netmask 255.255.255.0;
setenv gatewayip 192.168.122.1;
setenv bootargs 'console=ttyAMA0,115200n8'
#自动启动文件及读取地址
setenv bootcmd 'tftp 40400000 uImage;bootm 0x50500000;'
#qemu虚拟磁盘
virtio
#tftp服务下载文件到地址
tftp 40400000 uImage;
#从指定地址启动
bootm 0x50500000;
从指定地址读写内容
virtio read  0x40400000 0x1000 0x4000;
virtio write 0x40400000 0x1000 0x4000;
#地址计算文法512为单位
如:1M=800 10M=4000可依次类推

一、下载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
#解压缩
mkdir ramdisk
cpio -i -D ./ramdisk <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";
        };
    };
};
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值