Qemu simulates the configuration network of ARM
System: Ubuntu16.04.4 32bit
Cross Compiler: arm-linux-gnueabihf-gcc
VMware: VMware Workstation 14 Pro
u-boot: u-boot-2018.03
uboot boots through the network to load linux, requires a bridge network card
1. Install the bridge tool
sudo apt-get install uml-utilities
sudo apt-get install bridge-utils
2. Add a network card
sudo vi /etc/network/interfaces
#在文件最后添加以下配置
auto ens33
auto br0
iface br0 inet dhcp
bridge_ports ens33
After restarting sudo reboot
, use ifconfig
it to see if it br0
exists and is assigned an ip address. If so, it means that the network card is successfully added. When
qemu uses the tap device, it will execute /etc/qemu-ifup
and /etc/qemu-ifdown
these two scripts, but these two scripts were created when qemu was installed, and they will already exist here. backup of these two scripts, then replace the content as follows
/etc/qemu-ifup:
#!/bin/sh
echo sudo tunctl -u $(id -un) -t $1
sudo tunctl -u $(id -un) -t $1
echo sudo ifconfig $1 0.0.0.0 promisc up
sudo ifconfig $1 0.0.0.0 promisc up
echo sudo brctl addif br0 $1
sudo brctl addif br0 $1
echo brctl show
brctl show
#设置ip
sudo ifconfig br0 192.168.1.111
#设置ens33网卡ip
sudo ifconfig ens33 192.168.1.101
/etc/qemu-ifdown:
#!/bin/sh
echo sudo brctl delif br0 $1
sudo brctl delif br0 $1
echo sudo tunctl -d $1
sudo tunctl -d $1
echo brctl show
brctl show
If your two scripts are newly created, you need to add execute permission to them
sudo chmod 755 /etc/qemu-ifup
sudo chmod 755 /etc/qemu-ifdown
It needs to be executed every time ubuntu is started /etc/qemu-ifup tap0
, so that qemu can connect to the Internet normally
3. Modify UBOOT support network
//vi include/configs/vexpress_common.h
#define CONFIG_IPADDR 192.168.1.115 //板子的ip
#define CONFIG_NETMASK 255.255.255.0
#define CONFIG_SERVERIP 192.168.1.101 //虚拟机ip
Recompile, use qemu to test whether the network is available
# -serial stdio
qemu-system-arm -M vexpress-a9 -nographic -kernel u-boot -net nic,macaddr=52:54:00:11:22:33 -net tap,ifname=tap0,script=no,downscript=no