1 Star 3 Fork 1

wawanala / ohos

Create your Gitee Account
Explore and code with more than 8 million developers,Free private repositories !:)
Sign up
Clone or Download
ohos-virt-uboot.md 5.29 KB
Copy Edit Web IDE Raw Blame History
yx7200 authored 2021-11-29 14:29 . update ohos-virt-uboot.md.

实验目的:尝试使用qemu+uboot深度模拟ohos-master-standard版本init启动流程

实际体验:速度超级慢,启动解析脚本未优化直接使用3516.

一、编译u-boot

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

二、编译zImage

略....

三、导出virt-dtb

//初始引导时virt后面添加参数 \
-M  virt,dumpdtb=./virt-qemu.dtb\
//查看内容可用dtc -I dtb -O dts ./virt-qemu.dtb > ./virt-qemu.dts \

四、制作ramdisk-qemu

略.....

五、制作boot-qemu.img

1、编辑boot-qemu.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-qemu.dtb");
            type = "flat_dt";
            arch = "arm";
            os = "linux";
            compression = "none";
        };
	    ramdisk-1 {
            description = "Ramdisk Image";
            data = /incbin/("./ramdisk-qemu.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";
        };
    };
};

2、生成引导文件

mkimage -f boot-qemu.its boot-qemu.img

六、qemu+uboot启动

1、模拟uboot环境

sudo qemu-system-arm -M virt  -nographic  -netdev bridge,id=net0,br=virbr0 -device virtio-net-device,netdev=net0,mac=12:22:33:44:55:66  -drive if=none,file=./ohos-qemu.img,format=raw,id=ohos,index=0 -device virtio-blk-device,drive=ohos -m 512M -bios u-boot.bin

2、模拟u-boot烧录启动文件

tftp 0x50200000 boot-qemu.img;
virtio write 0x50200000 0x00002800 0x000207ff;
#virtio write: device 0 block # 10240, count 133119 ... 133119 blocks written: OK

3、从u-boot引导ohos

virtio read 0x50200000 0x00002800 0x000207ff;bootm 0x50200000;
//最终启动命令,这个参数可以在编译u-boot直接写进去。

4、启动日志:

virtio read: device 0 block # 10240, count 133119 ... 133119 blocks read: OK
## Loading kernel from FIT Image at 50200000 ...
   Using 'conf-boot' configuration
   Verifying Hash Integrity ... OK
   Trying 'kernel-1' kernel subimage
   Verifying Hash Integrity ... OK
## Loading ramdisk from FIT Image at 50200000 ...
   Using 'conf-boot' configuration
   Verifying Hash Integrity ... OK
   Trying 'ramdisk-1' ramdisk subimage
   Verifying Hash Integrity ... OK
## Loading fdt from FIT Image at 50200000 ...
   Using 'conf-boot' configuration
   Verifying Hash Integrity ... OK
   Verifying Hash Integrity ... OK
   Booting using the fdt blob at 0x50b7e36c
   Loading Kernel Image
   Using Device Tree in place at 50b7e36c, end 50c8136b

Starting kernel ...

5、virtio 命令
virtio part
//可以在u-boot环境查看磁盘信息

Partition Map for VirtIO device 0  --   Partition Type: EFI

Part	Start LBA	End LBA		Name
	Attributes
	Type GUID
	Partition GUID
  1	0x00000800	0x000027ff	"fastboot"
	attrs:	0x0000000000000000
	type:	0fc63daf-8483-4772-8e79-3d69d8477de4
	guid:	c1ce48af-255f-47d3-bc3a-e002a1bf304d
  2	0x00002800	0x000207ff	"boot"
	attrs:	0x0000000000000000
	type:	0fc63daf-8483-4772-8e79-3d69d8477de4
	guid:	ef66d3c6-0766-460c-b3b1-94e42975a6b9
  3	0x00020800	0x0002a7ff	"updater"
	attrs:	0x0000000000000000
	type:	0fc63daf-8483-4772-8e79-3d69d8477de4
	guid:	7e44fd02-436c-47bb-95f2-a19173a836f8
  4	0x0002a800	0x0002b7ff	"misc"
	attrs:	0x0000000000000000
	type:	0fc63daf-8483-4772-8e79-3d69d8477de4
	guid:	a5b73d13-7091-494d-bbca-8d7b9362d90a
  5	0x0002b800	0x006a0fff	"system"
	attrs:	0x0000000000000000
	type:	0fc63daf-8483-4772-8e79-3d69d8477de4
	guid:	b4317e52-17ae-4080-930e-623f36ad67ae
  6	0x006a1000	0x00720fff	"vendor"
	attrs:	0x0000000000000000
	type:	0fc63daf-8483-4772-8e79-3d69d8477de4
	guid:	4772a76a-9ec3-4640-b5cb-458229427154
  7	0x00721000	0x00fcffde	"userdata"
	attrs:	0x0000000000000000
	type:	0fc63daf-8483-4772-8e79-3d69d8477de4
	guid:	2ff7238a-9eb2-419f-a797-6332072e737c

ls /dev/block/platform/a003c00.virtio_mmio/by-name -la

boot -> /dev/block/vda2
fastboot -> /dev/block/vda1
misc -> /dev/block/vda4
system -> /dev/block/vda5
updater -> /dev/block/vda3
userdata -> /dev/block/vda7
vendor -> /dev/block/vda6
C
1
https://git.oschina.net/wawanala/ohos.git
git@git.oschina.net:wawanala/ohos.git
wawanala
ohos
ohos
master

Search