前言
为基于LA32处理器部署国产操作系统,尝试针对虚拟单片机模拟RT-Thread NANO系统部署过程,为创建虚拟单片机,该文章记录了如何在Win10系统上,利用wsl2,在Ubuntu20,04虚拟机上部署虚拟单片机环境la32r-QEMU
Step1:安装wsl2+Ubuntu20.04
步骤见Windows下Linux子系统(WSL)完美安装流程 - 简书 (jianshu.com)
Ubuntu20.04安装包备用
链接:https://pan.baidu.com/s/1Ef3XMGKfMBBvuXLtzapoNA?pwd=v5pr
提取码:v5pr
--来自百度网盘超级会员V6的分享
下载后将.appx后缀改成.zip,解压到非系统盘即可
Step2:部署la32r-QEMU
2.1准备源代码
win+x
打开Windows power-shell管理员版本
为查看<Ubuntu版本号>:输入
wsl -l -v
回车,如下图所示
输入(以Ubuntu-20.04为例)
wsl -d Ubuntu-20.04
启动Ubuntu20,04
首先我们需要进入根目录下,而非Win系统文件系统
cd ~/
可以先新建一个文件夹并进入此文件夹
sudo mkdir QEMU_la32r
cd QEMU_la32r
输入
git clone https://gitee.com/loongson-edu/la32r-QEMU.git
等待克隆完毕,直到出现
2.2编译代码
输入
ls
发现新增文件夹 la32r-QEMU,并进入该文件夹
cd la32r-QEMU
进入release分支
git checkout la32_release
建立build.sh脚本文件,按键盘上的I进入编辑模式,输入下一段代码
vim build.sh
#!/bin/bash
if [ ! -d "build" ]; then
mkdir build
fi
cd build
../configure --target-list=loongarch32-softmmu --disable-werror --enable-debug
make -j
#maybe support ‘loongarch32-linux-user’ in the future.
按ESC退出编辑模式,输入
:wq
退出文件
给予其可执行权限
chmod +x build.sh
执行该脚本
./build.sh
即自动开始多线程构建、编译
成功则显示如下画面
再进入build文件夹,输入
cd build
sudo make install
执行完运行qemu-system-loongarch32
qemu-system-loongarch32 -machine ls3a5k32
出现如下画面则表明安装成功
可通过ctrl+A+C退出QEMU
下次进入可通过VNC登录如上端口127.0.0.1:5900(以自己端口为准)
或再运行
qemu-system-loongarch32 -machine ls3a5k32
即可
补充./build.sh命令运行时报错及解决办法
1.报错
ERROR: GNU make (make) not found
./build.sh: line 7: make: command not found
解决方法:
sudo apt update
sudo apt install make
2.报错
ERROR: Cannot find Ninja
make: *** No targets specified and no makefile found. Stop.
解决办法:
sudo apt update
sudo apt install ninja-build
3.报错
ERROR: "cc" either does not exist or does not work
make: *** No targets specified and no makefile found. Stop.
解决办法:
sudo apt update
sudo apt install build-essential
4.报错
ERROR: pkg-config binary 'pkg-config' not found
make: *** No targets specified and no makefile found. Stop.
解决办法:
sudo apt update
sudo apt install pkg-config
5.报错
ERROR: glib-2.56 gthread-2.0 is required to compile QEMU
make: *** No targets specified and no makefile found. Stop.
解决办法:
sudo apt update
sudo apt install libglib2.0-dev
6.报错
Run-time dependency appleframeworks found: NO (tried framework) Found pkg-config: /usr/bin/pkg-config (0.29.1) Run-time dependency pixman-1 found: NO (tried pkgconfig)
../meson.build:460:2: ERROR: Dependency "pixman-1" not found, tried pkgconfig
A full log can be found at /root/QEMU_la32r/la32r-QEMU/build/meson-logs/meson-log.txt
ERROR: meson setup failed
config-host.mak is out-of-date, running configure GIT ui/keycodemapdb meson tests/fp/berkeley-testfloat-3 tests/fp/berkeley-softfloat-3 dtc capstone slirp bash: line 3: ./config.status: No such file or directory make: *** No rule to make target 'config-host.mak', needed by 'meson.stamp'. Stop. make: *** Waiting for unfinished jobs....
解决办法:
sudo apt update
sudo apt install libpixman-1-dev