Qemu - 运行OpenWRT
- 平台:ubuntu 22.04
- 对象:Qemu仿真OpenWRT.
- 文件:openwrt
1.安装依赖
$ sudo apt install build-essential bc flex bison gawk git unzip curl wget texinfo libssl-dev libncurses5-dev binutils patch zlib1g-dev
$ sudo apt install qemu-system-arm qemu-system-aarch64 qemu-system-x86
2.下载openwrt
$ git clone https://github.com/openwrt/openwrt.git
$ cd openwrt/
$ git branch -vv
* master 3c3d797c4d [origin/master] busybox: enable taskset by default
3.安装更新
$ cd openwrt/
$ ./scripts/feeds update -a
$ ./scripts/feeds install -a
4.配置config
$ make defconfig
$ make menuconfig
做如下修改:
Target System (x86) --->
(X) x86
ubtarget (x86_64) --->
(X) x86_64
Target Profile (Generic x86/64) --->
(X) Generic x86/64
Target Images --->
# 此处取消勾选
[ ] GZip images
我选了x86_64平台,你可以根据实际选择其它平台,另外如果想要网络控制面板,还可以配置LuCI。
可以通过以下命令,得知相应Qemu支持的开发板情况,例如:
$ qemu-system-x86_64 -M help
5.编译openwrt
$ make -j4 V=s
编译期间保持联网,因为编译过程会从网络下载相应功能的源码包。
6.仿真运行
$ cd openwrt/bin/targets/x86/64/
$ qemu --enable-kvm -nographic -kernel openwrt-x86-64-generic-squashfs-combined.img
正常情况下,就可以进入openwrt命令行界面,完成。
另外,想要qemu和host通信,可以配置netplan的配置文件,添加虚拟桥接网络:
$ sudo vim etc/netplan/xxx.yaml
$ sudo netplan apply