Qemu simulates the configuration network of ARM

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

write picture description here
After restarting sudo reboot, use ifconfigit to see if it br0exists and is assigned an ip address. If so, it means that the network card is successfully added. When
write picture description here
qemu uses the tap device, it will execute /etc/qemu-ifupand /etc/qemu-ifdownthese 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
write picture description here

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

write picture description here
write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325170544&siteId=291194637