qemu运行欧拉/鸿蒙

qemu运行openeuler-riscv64

参考[https://zhuanlan.zhihu.com/p/440896294]运行了qemu-openeuler

导出容器(可以不看这里)

docker export导出的是容器的快照,不会保存元数据,所以,如果你想让其他人也使用也就需要使用docker save,docker save是针对镜像的,所以我们需要先将我们搭建好的docker容器提交为一个镜像。
docker save与docker export的区别

docker commit 35ffde6b5958 qemu-openeuler-riscv64-on-x86_64:1.0.0

sha256:c16da49e3df482be6580b0478e37cb69518333eb5bf966852bd1e28271f17071

docker save -o ~/Downloads/qemu-openeuler-riscv64-on-x86_64.tar qemu-openeuler-riscv64-on-x86_64:1.0.0

MD5:6d166ae637f2016611127ea5c72829b9

以下是制作好的docker镜像,可以直接使用

https://cloud.189.cn/t/AVJnqyuUBfQ3(访问码:8j9c)

导入&运行docker镜像

docker load < qemu-openeuler-riscv64-on-x86_64.tar
docker run -it -p 8070:8070 -v /Users/workspace/Downloads/hello:/tmp --privileged=true qemu-openeuler-riscv64-on-x86_64:1.0.0 /bin/bash

备注

在docker镜像中

cd /home/test

运行qemu及openEuler:

qemu-system-riscv64
-nographic -machine virt
-smp 8 -m 2G
-kernel fw_payload_oe.elf
-drive file=openEuler-preview.riscv64.qcow2,format=qcow2,id=hd0
-object rng-random,filename=/dev/urandom,id=rng0
-device virtio-rng-device,rng=rng0
-device virtio-blk-device,drive=hd0
-device virtio-net-device,netdev=usernet
-netdev user,id=usernet,hostfwd=tcp::12055-:22
-append 'root=/dev/vda1 rw console=ttyS0 systemd.default_timeout_start_sec=600 selinux=0 highres=off mem=4096M earlycon'

openEuler:

用户名:root, 密码:openEuler12#$

层层套娃,终于运行上了 宿主机->docker->ubuntu->qemu->openEuler😂

qemu运行openharmony

on Windows版本,快速体验

韦东山:快速体验鸿蒙Liteos-A:IMX6ULL的QEMU系统(Windows版本)

weidongshan-qemu_image_for_imx6ull-maste.zip: https://url12.ctfile.com/f/8942412-648634167-64c2b8?p=3458 (访问密码: 3458)
百问网特制的QEMU版本:https://gitee.com/weidongshan/qemu
百问网对QEMU做了大量改动,
添加了更多的GUI显示,
添加了更多的设备模拟,
让用户可以更有真实感地使用QEMU来模拟IMX6ULL板子,
公开了所有的源码,发起一个开源项目: qemu_imx6ull
官方主页是: > http://wiki.100ask.org/100ask_imx6ul_qemu

要退出Linux中的当前程序:使用 ctrl+shift+c。
注意:ctrl+c是退出QEMU,也就是退出Linux或Liteos-A

运行

改短文件夹名称.
双击运行env.bat, 在里面执行linux.bat(拖进去,回车)即可启动Linux,输入root登录
同理可以启动liteos_a(harmony_liteos.bat)

linux中体验示例程序:LCD和触摸屏

命令:

myfb-test /dev/fb0 
ts_test


liteos_a中体验示例程序:数码相框

命令:

./bin/digitpic
退出程序
task
kill -9 PID号

on Ubuntu版本

构建docker镜像(可以不看)

版本:Ubuntu 18.04
[点开链接前先打开coding.net并登陆](https://weidongshan.coding.net/p/ubuntu-18.04_imx6ul_qemu_system/d/ubuntu-18.04_imx6ul_qemu_system/git/archive/release.tar.gz) 这个无法下载。
原来是直接下载压缩包,但是由于GIT仓库改版,只能使用下面方法下载:
[http://wiki.100ask.org/Download_ubuntu-18.04_imx6ul_qemu]
git clone https://e.coding.net/weidongshan/ubuntu-18.04_imx6ul_qemu_system.git
tar -xvf weidongshan-ubuntu-18.04_imx6ul_qemu_system-release.tgz
cd ./ubuntu-18.04_imx6ul_qemu_system
./install_sdl.sh
注意qemu系统默认登录用户名为root 无密码
运行不带GUI的imx6ul模拟器:
./qemu-imx6ul-nogui.sh // 启动后,登录名是root,无需密码
退出qemu-GUI:
Ctrl + Alt + G
退出qemu:
在终端下按住Ctrl和a键的同时按c即进入 qemu monitor模式, 再输入 q命令即可退出QEMU


docker run -it -p 8070:8070 -v /Users/workspace/Downloads/hello:/tmp --privileged=true swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0 /bin/bash
cd /tmp
git clone https://gitee.com/weidongshan/qemu.git
cd ./qemu
./configure --prefix=$PWD/ --target-list="arm-softmmu arm-linux-user" --enable-debug --enable-sdl --enable-kvm --enable-tools --disable-curl
(可能会提示安装一些缺失的包,必备包:pkg-config,libsdl2-dev,libpixman-1-dev,使用命令搜索包apt-cache search pixman)
make
make install
mkdir /ubuntu-18.04_imx6ul_qemu_system
mkdir /ubuntu-18.04_imx6ul_qemu_system/qemu-system-arm
mkdir /ubuntu-18.04_imx6ul_qemu_system/qemu-system-arm/bin
cp -R ./bin/qemu-system-arm /ubuntu-18.04_imx6ul_qemu_system/qemu-system-arm/bin
vim ~/.bashrc

~~PATH=/ubuntu-18.04_imx6ul_qemu_system/qemu-system-arm/bin:$PATH~~

source ~/.bashrc
图形界面:
qemu-imx6ul-gui.sh
命令行界面:
qemu-imx6ul-nogui.sh
然而,找不到脚本文件😂
通过某种方法,我搞到了脚本文件
qemu-imx6ull-gui_test.sh

#!/bin/bash

workdir=$(dirname $0);

if [ -z $1 ];
then
	$workdir/qemu/bin/qemu-system-arm -M mcimx6ul-evk   -show-cursor  -m 512M -kernel $workdir/imx6ull-system-image/zImage_test \
		-dtb $workdir/imx6ull-system-image/100ask_imx6ull_qemu_test.dtb  \
 -display sdl -serial mon:stdio \
 -drive  file=$workdir/imx6ull-system-image/rootfs.img,format=raw,id=mysdcard -device sd-card,drive=mysdcard \
 -append "console=ttymxc0,115200 rootfstype=ext4 root=/dev/mmcblk1  rw rootwait init=/sbin/init  loglevel=8" \
 -nic user -com 100ask
else
$workdir/qemu/bin/qemu-system-arm -M mcimx6ul-evk   -show-cursor  -m 512M -kernel $workdir/imx6ull-system-image/zImage_test \
 -dtb $workdir/imx6ull-system-image/100ask_imx6ull_qemu_test.dtb  \
 -display sdl -serial mon:stdio \
 -drive  file=$workdir/imx6ull-system-image/rootfs.img,format=raw,id=mysdcard -device sd-card,drive=mysdcard \
 -append "console=ttymxc0,115200 rootfstype=ext4 root=/dev/mmcblk1  rw rootwait init=/sbin/init  loglevel=8" \
 -nic user -com $1
fi

qemu-imx6ull-gui.sh

#!/bin/bash

workdir=$(dirname $0);

if [ -z $1 ];
then
	$workdir/qemu/bin/qemu-system-arm -M mcimx6ul-evk   -show-cursor  -m 512M -kernel $workdir/imx6ull-system-image/zImage \
		-dtb $workdir/imx6ull-system-image/100ask_imx6ull_qemu.dtb  \
 -display sdl -serial mon:stdio \
 -drive  file=$workdir/imx6ull-system-image/rootfs.img,format=raw,id=mysdcard -device sd-card,drive=mysdcard \
 -append "console=ttymxc0,115200 rootfstype=ext4 root=/dev/mmcblk1  rw rootwait init=/sbin/init  loglevel=8" \
 -nic user -com 100ask
else
$workdir/qemu/bin/qemu-system-arm -M mcimx6ul-evk   -show-cursor  -m 512M -kernel $workdir/imx6ull-system-image/zImage \
 -dtb $workdir/imx6ull-system-image/100ask_imx6ull_qemu.dtb  \
 -display sdl -serial mon:stdio \
 -drive  file=$workdir/imx6ull-system-image/rootfs.img,format=raw,id=mysdcard -device sd-card,drive=mysdcard \
 -append "console=ttymxc0,115200 rootfstype=ext4 root=/dev/mmcblk1  rw rootwait init=/sbin/init  loglevel=8" \
 -nic user -com $1
fi

qemu-imx6ull-nogui.sh

#!/bin/bash

workdir=$(dirname $0);

	$workdir/qemu/bin/qemu-system-arm -M mcimx6ul-evk    -m 512M -kernel $workdir/imx6ull-system-image/zImage \
		-dtb $workdir/imx6ull-system-image/100ask_imx6ull_qemu.dtb  \
 -nographic -serial mon:stdio \
 -drive  file=$workdir/imx6ull-system-image/rootfs.img,format=raw,id=mysdcard -device sd-card,drive=mysdcard \
 -append "console=ttymxc0,115200 rootfstype=ext4 root=/dev/mmcblk1  rw rootwait init=/sbin/init  loglevel=8" \
 -nic user 

从脚本文件看出,这里我们只实现了编译qemu,真正运行还是需要
git clone https://e.coding.net/weidongshan/ubuntu-18.04_imx6ul_qemu_system.git(按照上面方法)

编译报错:qga/main.c:35:10: fatal error: qemu-version.h: No such file or directory

#include "qemu-version.h"
^~~~~~~~~~~~~~~~
compilation terminated.

我也搜索不到这个文件,编译失败。
重新编译前:make clean
重新执行make命令[成功]
重新执行make install命令[成功]


docker ps
docker commit 9a189cb048c5 qemu-imx6ul-ohos-on-x86_64:1.0.0

sha256:d4c794173c60738744369606d2767d69f015c4029f7690dcfb256dfe867fe6bf

docker save -o ~/Downloads/qemu-imx6ul-ohos-on-x86_64.tar qemu-imx6ul-ohos-on-x86_64:1.0.0

MD5:a6b75cc6d0b8ed8e998b107e4c5d1010

构建好的,可用的docker镜像

qemu-imx6ul-ohos-on-x86_64.tar: https://url12.ctfile.com/f/8942412-648635542-1b1247?p=3458 (访问密码:3458)

备注:

docker load < qemu-imx6ul-ohos-on-x86_64.tar
docker run -it -p 8070:8070 -v /Users/workspace/Downloads/hello:/tmp --privileged=true qemu-imx6ul-ohos-on-x86_64:1.0.0 /bin/bash
cd /home/ubuntu-18.04_imx6ul_qemu_system
./qemu-imx6ull-nogui.sh
用户名:root,密码:无

退出系统:shutdown -h now
套娃方法,运行成功😂宿主机->docker->ubuntu->qemu->ohos😮‍💨

posted @ 2022-08-13 02:34  qsBye  阅读(1033)  评论(0编辑  收藏  举报