1 Star 4 Fork 2

yunxiang / risc-v openEuler

Create your Gitee Account
Explore and code with more than 8 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
README_1.md 11.18 KB
Copy Edit Web IDE Raw Blame History
yunxiang authored 2022-05-10 02:07 . update chapter3/class1/README_1.md.

第三章 第一讲 在openEuler RISC-V QEMU搭建XFCE+Firefox环境

本文分7个部分,第1-3部分用于指导安装支持图形化的openEuler RISC-V QEMU环境,第4-6部分用于指导安装XFCE桌面管理器,第7部分用于指导Firefox的安装。

1. 编译支持视频输出的 QEMU

1.1 支持视频输出的 QEMU

QEMU代码见https://gitlab.com/wangjunqiang/qemu/-/tree/display

git clone -b display https://gitlab.com/wangjunqiang/qemu.git

1.2 安装 qemu-riscv64

参考文档:https://wiki.qemu.org/Documentation/Platforms/RISCV

1.2.1 Ubuntu 20.04上安装qemu-rv64

在Mint 20.02,内核1 5.4.0-74-generic上验证成功。

1.2.1.1 qemu命令简介
oem-qemu-meta       # Meta package for QEMU
qemu                # fast processor emulator, dummy package
qemu-system         # QEMU full system emulation binaries
aqemu               # QEMU 和 KVM 的 Qt5 前端
grub-firmware-qemu  # GRUB firmware image for QEMU
nova-compute-qemu   # OpenStack Compute - compute node (QEmu)
qemu-guest-agent    # Guest-side qemu-system agent
qemu-system-x86-xen # QEMU full system emulation binaries (x86)
qemu-user           # QEMU user mode emulation binaries
qemu-user-binfmt    # QEMU user mode binfmt registration for qemu-user
qemu-user-static    # QEMU user mode emulation binaries (static version)
qemubuilder 	    # pbuilder using QEMU as backend
1.2.1.2 通过QEMU源代码构建
  • 安装必要的构建工具
sudo apt install build-essential autoconf automake autotools-dev pkg-config bc curl gawk git bison flex texinfo gperf libtool patchutils mingw-w64 libmpc-dev libmpfr-dev libgmp-dev libexpat-dev libfdt-dev zlib1g-dev libglib2.0-dev libpixman-1-dev libncurses5-dev libncursesw5-dev meson libvirglrenderer-dev libsdl2-dev -y
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.9 python3-pip  -y
sudo apt install -f
pip3 install meson
  • 下载支持视频输出QEMU 源码包

命令格式如下(需要申请gitee账号)

git clone -b display https://gitlab.com/wangjunqiang/qemu.git
cd qemu
git submodule init
git submodule update --recursive
mkdir build
cd build
  • 配置riscv64-qemu

以下命令中xbot为用户目录名

../configure  --enable-kvm --enable-sdl --enable-gtk --enable-virglrenderer --enable-opengl --target-list=riscv64-softmmu,riscv64-linux-user --prefix=/home/xbot/program/riscv64-qemu

riscv-64-linux-user为用户模式,可以运行基于 RISC-V 指令集编译的程序文件, softmmu为镜像模拟器,可以运行基于 RISC-V 指令集编译的Linux镜像,为了测试方便,可以两个都安装

  • 编译
make -j $(nproc)
make install

如果 --prefix 指定的目录位于根目录下,则需要在 ./configure 前加入 sudo

1.2.1.3 Ubuntu上配置环境变量

在环境变量PATH中添加riscv64-qemu所在目录,使相关命令可以直接使用

vim ~/.bashrc

~/.bashrc文末添加

export QEMU_HOME=/home/xbot/program/riscv64-qemu
export PATH=$QEMU_HOME/bin:$PATH

注意一定要将 QEMU_HOME 路径替换为 --prefix 定义的路径

检查是否添加成功

source ~/.bashrc
echo $PATH

屏幕回显包含/home/xbot/program/riscv64-qemu

/home/xbot/program/riscv64-qemu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
1.2.1.4 验证安装是否正确
qemu-system-riscv64 --version

如出现类似如下输出表示 QEMU 工作正常

QEMU emulator version 6.2.90 (v7.0.0-rc0-40-g2058fdbe81)
Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers

1.2.2 CentOS7上安装qemu-rv64

1.2.2.1 安装依赖
  1. 安装Python3.7
  • 下载Python

将python3.7安装包,下载到/usr/local/src文件夹下

cd /usr/local/src/
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
  1. 解压python3.7文件夹
# 解压
tar xvf Python-3.7.0.tar.xz
# 重命名文件夹
mv Python-3.7.0 python3
# 进入到解压出的文件夹
cd python3
  1. 编译python3.7

安装python的yum依赖

yum -y install zlib-devel bzip2-devel openssl-devel openssl-static ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel lzma gcc

设置./configure

./configure --prefix=/usr/local/python3
  1. 安装

将python3.7 安装到/usr/local/python3 下

make -j $(nproc) && make install
ln -fs /usr/local/python3/bin/python3.7 ./python3
  1. 安装其它依赖
sudo yum install autoconf automake libmpc-devel mpfr-devel gmp-devel gawk bison flex texinfo patchutils gcc gcc-c++ zlib-devel expat-devel git python3 glib2 glib2-devel pixman pixman-devel qemu dnf gtk3-devel SDL2-devel mesa* freeglut* autoconf-archive xorg-x11-util-macros -y

添加virglrenderer支持

wget https://kojipkgs.fedoraproject.org//packages/virglrenderer/0.8.0/1.20191002git4ac3a04c.el8/x86_64/virglrenderer-0.8.0-1.20191002git4ac3a04c.el8.x86_64.rpm
rpm -i virglrenderer-0.8.0-1.20191002git4ac3a04c.el8.x86_64.rpm
wget https://kojipkgs.fedoraproject.org//packages/virglrenderer/0.8.0/1.20191002git4ac3a04c.el8/x86_64/virglrenderer-devel-0.8.0-1.20191002git4ac3a04c.el8.x86_64.rpm
rpm -i virglrenderer-devel-0.8.0-1.20191002git4ac3a04c.el8.x86_64.rpm
1.2.2.2 安装支持视频输出的 QEMU
git clone -b display https://gitlab.com/wangjunqiang/qemu.git
su 
yum install ninja-build libepoxy-devel centos-release-scl devtoolset-8-gcc-c++
pip3 install meson
scl enable devtoolset-8 bash
cd qemu
git submodule init
git submodule update --recursive
mkdir build
cd build
../configure  --enable-kvm --enable-sdl --enable-gtk --enable-virglrenderer --enable-opengl --target-list=riscv64-softmmu,riscv64-linux-user --prefix=/home/xbot/program/riscv64-qemu
make -j $(nproc)
make install  # 安装
1.2.2.4 CentOS上配置环境变量

在环境变量PATH中添加riscv64-qemu所在目录,使相关命令可以直接使用

vim ~/.bashrc

~/.bashrc文末添加

export QEMU_HOME=/home/xbot/program/riscv64-qemu
export PATH=$QEMU_HOME/bin:$PATH

注意一定要将 QEMU_HOME 路径替换为 --prefix 定义的路径

检查是否添加成功

source ~/.bashrc
echo $PATH

屏幕回显包含/home/xbot/program/riscv64-qemu

1.2.2.4 验证安装是否正确
$ qemu-system-riscv64 --version

如出现类似如下输出表示 QEMU 工作正常

QEMU emulator version 6.2.90 (v7.0.0-rc0-40-g2058fdbe81)
Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers

2. 下载 openEuler RISC-V 系统镜像

恭喜你已经成功编译安装了最新版的 QEMU,接下来我们需要下载 openEuler RISC-V 的系统镜像。

2.1 下载 编译支持视频输出的 kernel

https://gitee.com/yunxiangluo/riscv-openeuler/raw/master/chapter3/class1/Image

建议git clone或zip下载后放入目录

git clone https://gitee.com/yunxiangluo/riscv-openeuler.git
cp ./riscv-openeuler/chapter3/class1/Image .

2.2 下载 openeuler risc-v 文件系统

https://mirror.iscas.ac.cn/openeuler-sig-riscv/openEuler-RISC-V/development/2203/Image/openEuler-22.03.riscv64.qcow2

wget --no-check-certificate https://mirror.iscas.ac.cn/openeuler-sig-riscv/openEuler-RISC-V/development/2203/Image/openEuler-22.03.riscv64.qcow2 

3. QEMU启动RISC-V openEuler

将以下脚本start_oe.bash,openEuler-preview.riscv64.qcow2,Image放入同一个文件夹里,给bash脚本赋可执行权限chmod +x ./start_oe.bash,脚本内容如下。qemu-system-riscv64 是我们编译的 qemu,-kernel 后面跟的是我们自己编译的内核。其中-smp 8 -m 4G分别配置CPU 8 线程和内存4G,可根据实际硬件情况进行配置。运行脚本./start_oe.bash后,会出现一个标题为 QEMU 的视频输出窗口。详细配置可参考

  1. https://wiki.gentoo.org/wiki/QEMU/Options#Display_options

  2. https://czak.pl/2020/04/09/three-levels-of-qemu-graphics.html

#!/usr/bin/bash

qemu-system-riscv64 \
  -nographic   -machine virt \
  -smp 8 -m 4G \
  -display sdl   -vga std \
  -kernel Image \
  -append "loglevel=3 swiotlb=1 console=ttyS0 rw root=/dev/vda1" \
  -drive file=openEuler-22.03.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 \
  -device qemu-xhci -device usb-tablet -device usb-kbd
wget https://gitee.com/yunxiangluo/riscv-openeuler/raw/master/chapter3/class1/start_oe.bash
chmod +x ./start_oe.bash
./start_oe.bash

或添加gl=on,如下,实测启动xfce速度变化不大。

#!/usr/bin/bash

qemu-system-riscv64 \
  -nographic   -machine virt \
  -smp 8 -m 4G \
  -display sdl,gl=on\
  -vga virtio \
  -kernel Image \
  -append "loglevel=3 swiotlb=1 console=ttyS0 rw root=/dev/vda1" \
  -drive file=openEuler-22.03.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 \
  -device qemu-xhci -device usb-tablet -device usb-kbd

4. 安装Xfce

root 默认密码为 openEuler12#$

4.1 添加xfce软件源

注:以下步骤使用了三个源,后续会改为mainline和epol两个源

openeuler risc-v 启动以后,修改以下 repo:

vim /etc/yum.repos.d/openEuler.repo

文件修改为如下内容

[22.03]
name=22.03
baseurl=http://obs-backend.tarsier-infra.com:82/openEuler:/22.03/openEuler_2203/
enabled=1
gpgcheck=0

[22.03Epol]
name=22.03Epol
baseurl=http://obs-backend.tarsier-infra.com:82/openEuler:/22.03:/Epol/openEuler_22.03_Epol/
enabled=1
gpgcheck=0

4.2 安装 xfce4

yum install libxfce4util xfconf libxfce4ui exo garcon thunar thunar-volman tumbler xfce4-appfinder xfce4-panel xfce4-power-manager xfce4-settings xfdesktop xfwm4 xfce4-session xfce4-terminal -y

再安装 xorg 的软件包 xorg-x11-xinit 和 xorg-x11-server。

yum install xorg-x11-xinit xorg-x11-server -y

5. 启动 Xfce

在视频输出窗口中输入 startxfce4 启动 xfce4。

startxfce4

显示效果如下图。

figure_1

figure_2

7. 安装Firefox

7.1 安装依赖

yum install alsa-lib-devel dbus-glib desktop-file-utils -y

7.2 安装firefox

vim /etc/yum.repos.d/openEuler.repo

文件修改为如下内容

[standard]
name=standard
baseurl=http://obs-backend.tarsier-infra.com:82/home:/Jingwiw:/Build-Firefox/22.03/
enabled=1
gpgcheck=0

[standard1]
name=standard1
baseurl=https://mirror.iscas.ac.cn/openeuler-sig-riscv/openEuler-RISC-V/development/2203/Everything/
enabled=1
gpgcheck=0

安装Firefox

yum clean all
yum install pciutils mesa* --skip-broken
yum install firefox -y

7.3 启动Firefox

cd /usr/lib64/firefox
./firefox

figure_6

Comment ( 0 )

Sign in to post a comment

C
1
https://gitee.com/yunxiangluo/riscv-openeuler.git
git@gitee.com:yunxiangluo/riscv-openeuler.git
yunxiangluo
riscv-openeuler
risc-v openEuler
master

Search