农业网站设计,虚拟展馆官方网站建设,广州注册公司流程及费用,青岛谁优化网站做的好处在使用实体ESP32C3 安装鸿蒙失败后#xff0c;就是这个#xff1a;完全按照手册win10里装Ubuntu 虚拟机然后编译ESP32#xff08;主要是想针对ESP32C3和S3#xff09;开发板的鸿蒙系统(失败)-CSDN博客转向用qemu模拟环境装鸿蒙 学习手册riscv32_virt/README_zh.md OpenHar…在使用实体ESP32C3 安装鸿蒙失败后就是这个完全按照手册win10里装Ubuntu 虚拟机然后编译ESP32主要是想针对ESP32C3和S3开发板的鸿蒙系统(失败)-CSDN博客转向用qemu模拟环境装鸿蒙 学习手册riscv32_virt/README_zh.md · OpenHarmony/device_qemu - Gitee.com
Qemu RISC-V virt 教程
1. 简介
riscv32_virt/ 子目录包含部分Qemu RISC-V虚拟化平台验证的OpenHarmony kernel_liteos_m的代码目录名为riscv32_virt。 RISC-V 虚拟化平台是一个 qemu-system-riscv32 的目标设备通过它来模拟一个通用的、基于RISC-V架构的单板。
这次模拟的配置是RISC-V架构1个CPU128M内存。
提示: 系统内存硬编码为128MB。
2. 环境搭建
环境搭建
编译器安装:gcc_riscv32, 提示: 可直接下载
3. 获取源码
代码获取
提示: 可以使用 repo 命令来获取源码。
4. 源码构建
在已经获取的源码根目录请输入
hb set选择ohemu下的qemu_riscv_mini_system_demo选项。
然后执行构建命令如下
hb build这个命令构建会产生 OHOS_Image 的镜像文件。
在构建完成之后对应的镜像文件在如下目录
out/riscv32_virt/qemu_riscv_mini_system_demo/5. 在Qemu中运行镜像
a) 如果没有安装 qemu-system-riscv32 安装请参考链接:Qemu安装指导
b) 运行
(1). qemu 版本 5.0.0
cd device/qemu/riscv32_virt
qemu-system-riscv32 -machine virt -m 128M -kernel ../../../out/riscv32_virt/qemu_riscv_mini_system_demo/OHOS_Image -nographic -append rootdev/vda or consolettyS0(2). qemu 版本 5.0.0
执行./qemu-run --help提示如下
Usage: qemu-run [OPTION]...
Run a OHOS image in qemu according to the options.Options:-e, --exec file_name kernel exec file name-n, --net-enable enable net-l, --local-desktop no VNC-g, --gdb enable gdb for kernel-t, --test test mode, exclusive with -g-h, --help print help infoBy default, the kernel exec file is: out/riscv32_virt/qemu_riscv_mini_system_demo/OHOS_Image,and net will not be enabled, gpu enabled and waiting for VNC connection at port 5920.默认不加参数的情况下网络不会自动配置并使用默认镜像文件若需更改默认镜像文件可以利用 ./qemu-run -e [file_name] 指定
6. gdb调试
cd device/qemu/riscv32_virt
vim liteos_m/config.gni将 board_opt_flags 中的
board_opt_flags []编译选项修改为:
board_opt_flags [ -g ]保存并退出在OHOS根目录重新编译:
hb build -f在一个窗口中输入命令
./qemu-run -g在另一个窗口中输入命令
riscv32-unknown-elf-gdb out/riscv32_virt/qemu_riscv_mini_system_demo/OHOS_Image
(gdb) target remote localhost:1234
(gdb) b main更多gdb相关的调试可以查阅gdb指导手册。
7. 用法示例
用FAT映像传递文件
实践 安装python库
pip3 install setuptools scons kconfiglib pycryptodome ecdsa six
pip install
安装gcc-riscv32
安装apt库 下载源码
wget https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/device-dev/get-code/sourcecode-acquire.md
获取源码这块就晕了竟然好几G我就想装个riscv32的鸿蒙啊
下载这个试试
git clone https://gitee.com/openharmony/kernel_liteos_a
kernel_liteos_a: LiteOS kernel for embedded devices with rich resources | 适用于资源较丰富嵌入式设备的LiteOS内核
直接下载编译器
wget https://gitee.com/link?targethttps%3A%2F%2Frepo.huaweicloud.com%2Fharmonyos%2Fcompiler%2Fgcc_riscv32%2F7.3.0%2Flinux%2Fgcc_riscv32-linux-7.3.0.tar.gz 安装qemu-system-misc试试
apt install qemu-system-misc
中间一度碰到清华源报错的问题改为山大源
# 默认注释了源码镜像以提高 apt update 速度如有需要可自行取消注释
deb https://mirrors.sdu.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.sdu.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.sdu.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.sdu.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.sdu.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.sdu.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse# 以下安全更新软件源包含了官方源与镜像站配置如有需要可自行修改注释切换
# deb https://mirrors.sdu.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# # deb-src https://mirrors.sdu.edu.cn/ubuntu/ jammy-security main restricted universe multiversedeb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse# 预发布软件源不建议启用
# deb https://mirrors.sdu.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# # deb-src https://mirrors.sdu.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
设置环境变量
将gcc_riscv32目录放置到/opt目录设置环境变量
export PATH/opt/gcc_riscv32/bin:$PATH 这是至少命令是可以执行了 hb工具是啥
hb是HarmonyOS2.0里新增加的编译构建命令行工具。需要Python 3.7.4及以上版本的支持建议安装3.8.x。源码在OpenHarmony\build\lite\hb这个目录下。 安装方法可以直接使用pip安装打包好的工具。但是我们为了方便调试我们直接使用源码进行单步调试。
python3 -m pip install --user ohos-build 源码构建
在已经获取的源码根目录请输入
hb set选择ohemu下的qemu_riscv_mini_system_demo选项。
然后执行构建命令如下
hb build
git clone https://gitee.com/openharmony/kernel_liteos_a
进入目录后hb报错
hb
Traceback (most recent call last):File /usr/local/bin/hb, line 8, in modulesys.exit(main())File /usr/local/lib/python3.10/dist-packages/hb/__main__.py, line 49, in maintopdir find_top()File /usr/local/lib/python3.10/dist-packages/hb/__main__.py, line 37, in find_topraise Exception(Please call hb utilities inside source root directory)
Exception: Please call hb utilities inside source root directory下载这个包试试
git clone https://gitee.com/openharmony/device_qemu hb还是报错