본문 바로가기

Programming

Xilinx QEMU bridge mode

source : https://wiki.ubuntu.com/ARM/RootfsFromScratch



The first thing to do is to active a bridge on your host machine. For that you have to modify the /etc/network/interfaces file as follow:

Before:

auto eth0
iface eth0 inet dhcp

After:

auto br0
iface br0 inet dhcp
  bridge_ports eth0
  bridge_maxwait 0

Then you need to install the bridge-utils package and restart your network interface:

# apt-get install bridge-utils
# ifdown eth0
# ifup br0

Create a script call /etc/qemu-ifup that will be executed upon the start of QEMU:

echo "Executing /etc/qemu-ifup"
echo "Bringing up $1 for bridged mode..."
sudo /sbin/ifconfig $1 0.0.0.0 promisc up
echo "Adding $1 to br0..."
sudo /usr/sbin/brctl addif br0 $1
sleep 2

As you probably don't want to execute QEMU as root, you need to create a qemu user group and authorize the brctl and ifconfig commands for users of the qemu via sudo. You need to add the following lines to /etc/sudoers (edit the file using visudo):

...
Cmnd_Alias QEMU = /usr/sbin/brctl, /sbin/ifconfig
%qemu ALL=NOPASSWD: QEMU

Tap networking requires that the tun module is loaded:

$ sudo modprobe tun

To load it automatically on boot, edit /etc/modules and add a line that says "tun" so that the file looks like this:

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

lp
tun

Finally you can start your emulated machine using the following command

$ qemu-system-arm -M versatilepb -kernel ./vmlinuz-2.6.28-versatile -hda arm-rootfs.img -m 256 
-append "root=/dev/sda mem=256M ro" -net nic,macaddr=00:16:3e:00:00:01 -net tap



내 linux 에서는 eth0 대신 eth2 로 되어있어서 그부분을 수정해야했음.

xilinx QEMU 실행시키고 


root@declspec-desktop:/var/www/snu# cat run.sh

/var/www/snu/qemu/arm-softmmu/qemu-system-arm -M arm-generic-fdt -nographic -serial mon:stdio -dtb /var/www/snu/devicetree.dtb -kernel /var/www/snu/uImage.bin -initrd /var/www/snu/uramdisk.image.gz -machine linux=on -smp 2 -net nic,macaddr=00:16:3e:00:00:01 -net tap



SoC 리눅스에서 /etc/network/interfaces 만들어준다음


cat /etc/network/interfaces

auto eth0
iface eth0 inet dhcp
ifup eth0 하면 됨!






-net nic,macaddr=00:16:3e:00:00:01 -net tap make ARCH=arm xilinx_zynq_defconfig make ARCH=arm UIMAGE_LOADADDR=0x8000 uImage make ARCH=arm dtbs mkimage -A arm -T ramdisk -C gzip -d ramdisk.image.gz uramdisk.image.gz /opt/Xilinx/14.4/ISE_DS/EDK/gnu/arm/lin/bin/arm-xilinx-eabi-gcc KERNEL_DIR=/home/viulian/android_platform/kernel-2.1.A.0.435/kernel obj-m := cpufreq_smartass.o PWD := $(shell pwd) default: $(MAKE) ARCH=arm CROSS_COMPILE=/home/viulian/android_platform/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- -C $(KERNEL_DIR) SUBDIRS=$(PWD) modules clean: $(MAKE) -C $(KERNEL_DIR) SUBDIRS=$(PWD) clean


으어어


'Programming' 카테고리의 다른 글

x64 parameter passing  (0) 2013.06.24
kernel module cross compile makefile  (1) 2013.06.14
md5 sqlinjection hash  (0) 2013.06.12
python post script  (0) 2013.06.12
Hook Disclosure with Timing Attack  (0) 2013.06.05