Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
openeuler_risc-v_qemu_install [2022/02/21 14:32] – Add software repo misaka00251 | openeuler_risc-v_qemu_install [2024/09/28 11:30] (current) – [自己装] Fix startup script misaka00251 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== 在 QEMU 内运行 openEuler RISC-V 移植版 ====== | ====== 在 QEMU 内运行 openEuler RISC-V 移植版 ====== | ||
+ | |||
+ | 目前已经是 openEuler 24.03 LTS 了,也是 RISC-V 的第一个主线合并后 LTS 版本。 | ||
+ | |||
+ | ===== QEMU ===== | ||
+ | |||
+ | QEMU 有两种方法,前提是确定一下你的 QEMU 版本一定要大于 8.1 版本。 | ||
+ | |||
+ | * 一种是直接下载安装好 openEuler 的 QEMU riscv64 架构镜像,在[[https:// | ||
+ | * 另一种是自己用 ISO 镜像安装,在[[https:// | ||
+ | |||
+ | 对于新手,我推荐直接下载 QEMU riscv64 架构镜像。因为目前模拟 QEMU riscv64 太慢了,自己安装的话至少要等 20 min。 | ||
+ | |||
+ | ==== 直接用镜像 ==== | ||
+ | |||
+ | 在下载 '' | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | 可以根据你自己想要怎么启动来下载对应的文件。 | ||
+ | |||
+ | ==== 自己装 ==== | ||
+ | |||
+ | 以下是 macOS 的启动脚本。 | ||
+ | |||
+ | <file bash run.sh> | ||
+ | cmd=" | ||
+ | -bios " | ||
+ | -machine virt, | ||
+ | -display cocoa, | ||
+ | -smp " | ||
+ | -cpu rv64 \ | ||
+ | -object memory-backend-ram, | ||
+ | -numa node, | ||
+ | -object memory-backend-ram, | ||
+ | -numa node, | ||
+ | -blockdev node-name=pflash0, | ||
+ | -blockdev node-name=pflash1, | ||
+ | -drive file=" | ||
+ | -object rng-random, | ||
+ | -device virtio-vga \ | ||
+ | -device virtio-rng-device, | ||
+ | -device virtio-blk-device, | ||
+ | -device virtio-net-device, | ||
+ | -netdev user, | ||
+ | -audiodev coreaudio, | ||
+ | -device qemu-xhci -usb -device usb-kbd -device usb-tablet -device usb-audio, | ||
+ | -drive file=" | ||
+ | -device virtio-blk-device, | ||
+ | |||
+ | |||
+ | eval $cmd | ||
+ | </ | ||
+ | |||
+ | 在启动之前,请创建一个 qcow2 磁盘,可以使用 '' | ||
+ | |||
+ | 安装成功之后,可以注释掉最后 CD 两行。 | ||
+ | |||
+ | 目前镜像已经很完善了,基本不需要做什么额外的操作。我碰到了一个坑是在开启 Loon / Quantumult X 的时候,自动 DNS 不会工作。在手动安装的时候可以在网络那里设置个 '' | ||
+ | |||
+ | ===== 硬件镜像 ===== | ||
+ | |||
+ | ==== Milk-V Pioneer ==== | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | ==== Sipeed LicheePi 4A ==== | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== 以下内容为过期内容 ===== | ||
+ | |||
+ | :!: **以下的为 openEuler 22.03 LTS 之前的内容。仅作为历史记录。** | ||
不要忘记安装最新版的 [[https:// | 不要忘记安装最新版的 [[https:// | ||
- | 去 [[https:// | + | 去 [[https:// |
- | * fw_payload_oe.elf | + | * fw_payload_oe.elf |
* openEuler-preview.riscv64.qcow2 | * openEuler-preview.riscv64.qcow2 | ||
Line 26: | Line 103: | ||
-append ' | -append ' | ||
-bios none | -bios none | ||
+ | </ | ||
+ | |||
+ | macOS 下启动: | ||
+ | |||
+ | <file powershell run.sh> | ||
+ | cmd=" | ||
+ | -machine virt -nographic \ | ||
+ | -display cocoa, | ||
+ | -smp " | ||
+ | -audiodev coreaudio, | ||
+ | -bios " | ||
+ | -drive file=" | ||
+ | -object rng-random, | ||
+ | -device virtio-vga \ | ||
+ | -device virtio-rng-device, | ||
+ | -device virtio-blk-device, | ||
+ | -device virtio-net-device, | ||
+ | -netdev user, | ||
+ | -device qemu-xhci -usb -device usb-kbd -device usb-tablet -device usb-audio, | ||
+ | |||
+ | eval $cmd | ||
</ | </ | ||
Line 33: | Line 131: | ||
qemu-system-riscv64 ` | qemu-system-riscv64 ` | ||
-nographic -machine virt ` | -nographic -machine virt ` | ||
- | -smp 2 -m 4G ` | + | -smp 8 -m 16G ` |
- | -kernel | + | -display sdl ` |
- | -drive file=openEuler-preview.riscv64.qcow2, | + | -kernel |
+ | -bios none ` | ||
+ | -drive file=openEuler-22.03-V2-xfce-qemu-preview.qcow2, | ||
+ | -device virtio-vga | ||
-device virtio-blk-device, | -device virtio-blk-device, | ||
-device virtio-net-device, | -device virtio-net-device, | ||
- | -netdev user, | + | -netdev user, |
- | -append ' | + | -device qemu-xhci -usb -device usb-kbd -device usb-tablet |
- | -bios none | + | -append ' |
</ | </ | ||
Line 51: | Line 152: | ||
默认的用户名为 '' | 默认的用户名为 '' | ||
- | ===== 软件源 | + | 注意,以下都很老了(已经不存在这些问题),仅仅作为存档用途出现在这里。 |
+ | |||
+ | ==== 软件源 ==== | ||
openEuler 使用的是 dnf 作为包管理器,配置文件在 ''/ | openEuler 使用的是 dnf 作为包管理器,配置文件在 ''/ | ||
Line 67: | Line 170: | ||
[repository] | [repository] | ||
name=openEuler-risv-v | name=openEuler-risv-v | ||
- | baseurl=https:// | + | #baseurl=https:// |
+ | baseurl=https:// | ||
gpgcheck=0 | gpgcheck=0 | ||
</ | </ | ||
然后执行 '' | 然后执行 '' | ||
+ | |||
+ | ==== 系统时间 ==== | ||
+ | |||
+ | 不过在这里你可能发现失败了,因为时间不对!通过运行 '' | ||
+ | |||
+ | 这里我们采用 ntp 自动授时的方法。配置文件位于 ''/ | ||
+ | |||
+ | <file conf timesyncd.conf> | ||
+ | # This file is part of systemd. | ||
+ | # | ||
+ | # systemd is free software; you can redistribute it and/or modify it | ||
+ | # under the terms of the GNU Lesser General Public License as published by | ||
+ | # the Free Software Foundation; either version 2.1 of the License, or | ||
+ | # (at your option) any later version. | ||
+ | # | ||
+ | # Entries in this file show the compile time defaults. | ||
+ | # You can change settings by editing this file. | ||
+ | # Defaults can be restored by simply deleting this file. | ||
+ | # | ||
+ | # See timesyncd.conf(5) for details. | ||
+ | |||
+ | [Time] | ||
+ | NTP=0.cn.pool.ntp.org 1.cn.pool.ntp.org 2.cn.pool.ntp.org 3.cn.pool.ntp.org | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | </ | ||
+ | |||
+ | 接下来就运行 ntpd 服务吧: | ||
+ | |||
+ | < | ||
+ | # systemctl enable systemd-timesyncd | ||
+ | # systemctl start systemd-timesyncd | ||
+ | # systemctl status systemd-timesyncd | ||
+ | </ | ||
+ | |||
+ | 最后一步是设置时区,大功告成! | ||
+ | |||
+ | < | ||
+ | # ln -sf / | ||
+ | </ | ||
+ | |||
+ | ==== Others ==== | ||
+ | |||
+ | '' | ||
+ | |||
+ | === 公共 CI 机器上编译用户模式的 QEMU === | ||
+ | |||
+ | 这里我们可以使用清华源来加快 git clone 的速度,然后转到最新版的分支用于构建: | ||
+ | |||
+ | < | ||
+ | $ git clone https:// | ||
+ | $ cd qemu | ||
+ | $ git checkout stable-6.1 | ||
+ | $ ./configure --target-list=riscv64-softmmu, | ||
+ | $ make | ||
+ | $ make install | ||
+ | </ | ||
+ | |||
+ | 上面的 prefix 可以自己定义位置,如果自定义了位置的话下面的 '' | ||
+ | |||
+ | 在编译成功之后,记得在 '' | ||
+ | |||
+ | <file bashrc .bashrc> | ||
+ | export QEMU_HOME=/ | ||
+ | export PATH=$QEMU_HOME/ | ||
+ | </ | ||
+ | |||
+ | 随后 '' | ||
+ | |||
+ | :!: 公共机器上无需再去 openEuler 官方下载相关文件,Wechat@nil 准备了一份放在了 / | ||
+ | |||
+ | === 我的虚拟环境没空间了 === | ||
+ | |||
+ | 这我还真在编译 openjdk 的时候遇到了。 | ||
+ | |||
+ | 首先关机,然后使用 '' | ||
+ | |||
+ | 然后使用 '' | ||
+ | |||
+ | 接下来,进入系统并安装 '' | ||
+ | |||
+ | 然后输入 '' |