Open wutiejun opened 7 years ago
#!/bin/bash
Image=./source/kernel/linux-3.10.53/arch/arm/boot/zImage
Rootfs=./rootfs.img
LinuxArgs="root=/dev/ram rdinit=/sbin/init console=ttyAMA0"
NetConfig="-net nic -net tap,vlan=0,ifname=tap0,script=./qemu-ifup,downscript=./qemu-ifdown"
MtdConfig="-mtdblock ./flash.bin"
qemu-system-arm -nographic -M vexpress-a9 -m 256M \
-kernel $Image \
-initrd $Rootfs \
$MtdConfig \
-append "$LinuxArgs" \
$NetConfig \
#!/bin/bash
#/sbin/ifconfig $1 192.168.0.1 netmask 255.255.255.252
#/sbin/ifconfig $1 192.168.1.5 netmask 255.255.255.252
eth=tap0
IP=`ifconfig $eth |grep "inet addr"|awk '{print $2}'|sed 's/addr://'`
GATEWAY=`ip route |grep default |awk '{print $3}'`
ip addr del $IP dev $eth
ifconfig $1 up
ifconfig br0 down &>/dev/null
brctl delbr br0 &>/dev/null
brctl addbr br0
brctl addif br0 $eth
brctl addif br0 $1
ifconfig br0 $IP up
ifconfig $eth mtu 1600
#ip route add default via $GATEWAY dev br0 &>/dev/null
#!/bin/bash
#/sbin/ifconfig $1 down
eth=tap0
IP=`ifconfig br0|grep "inet addr"|awk '{print $2}'|sed 's/addr://'`
GATEWAY=`ip route |grep default|awk '{print $3}'`
ip addr del $IP dev br0
ifconfig br0 down
brctl delbr br0
ifconfig $eth $IP up
ip route add default via $GATEWAY dev $eth
ifconfig $eth mtu 1500
make vexpress_ca9x4_config
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-
make vexpress_ca9x4_config
make
注意,就是u-boot文件,不是u-boot.bin文件
qemu-system-arm -M vexpress-a9 \
-kernel ./source/uboot/u-boot-2015.10/u-boot -nographic
#/home/wutiejun/workspace/VBox/rootfs 0.0.0.0(rw,sync,no_subtree_check)
/srv/rootfs 192.168.100.0/24(rw,async,no_subtree_check,insecure,no_root_squash)
LinuxArgs="root=/dev/nfs nfsroot=192.168.100.101:/srv/rootfs,nfsvers=3 rw \
ip=192.168.100.1::192.168.100.2:255.255.255.0 console=ttyAMA0 \
user_debug=0x1f panic=1"
Tip: according to the error message, try to remove the net device config.
#!/bin/bash
Image=./source/kernel/linux-3.16.48/arch/arm/boot/zImage
#Image=./source/kernel/linux-3.10.53/arch/arm/boot/zImage
#Image=./flash.bin
Rootfs=./rootfs.img
#LinuxArgs="root=/dev/ram rdinit=/sbin/init console=ttyAMA0 ubi.mtd=0 mtdparts=physmap-flash:0x100000(u-boot),0x3f00000(ubifs),-(data) user_debug=0x1f panic=1"
#LinuxArgs="root=/dev/ram rdinit=/sbin/init console=ttyAMA0 ubi.mtd=0 mtdparts=SmartMedia:0x100000(u-boot),0x3f00000(ubifs),-(data) user_debug=0x1f panic=1"
LinuxArgs="root=/dev/nfs nfsroot=192.168.100.101:/home/wutiejun/workspace/VBox/rootfs,nfsvers=3 rw ip=192.168.100.1::192.168.100.2:255.255.255.0 \
console=ttyAMA0 user_debug=0x1f panic=1 mtdparts=physmap-flash:0x100000(u-boot),0x3f00000(ubifs),-(data)"
# "mtdparts=physmap-flash:0x100000(u-boot),0x3f00000(ubifs),-(data)"
#LinuxArgs="root=/dev/nfs rootwait rw init=/bin/init nfsroot=192.168.100.1:/srv/rootfs,nfsvers=3 ip=dhcp console=ttyAMA0 user_debug=0x1f panic=1"
#LinuxArgs="noalign console=ttyAMA0 root=/dev/mtdblock1 rootfstype=squashfs ubi.mtd=0 mtdparts=armflash:0x100000@0x0(u-boot),0x3f00000@0x100000(ubifs) user_debug=0x1f panic=1"
NetConfig="-net nic -net tap,vlan=0,ifname=tap0,script=./qemu-ifup,downscript=./qemu-ifdown"
#NetConfig="-net nic -net tap,vlan=0,ifname=tap0,script=no"
MtdConfig="-pflash ./flash.bin"
#MtdConfig="-mtdblock ./flash.bin"
#MtdConfig="-drive id=mtd0,file=./flash2.bin,if=mtd,bus=1,unit=0,format=raw"
InitrdArgs="-initrd ./rootfs.img"
#qemu-system-arm -M vexpress-a9 -kernel ./source/uboot/u-boot-2015.10/u-boot -nographic
#/home/wutiejun/MyTools/bin/
# -initrd $Rootfs \
#-append "$LinuxArgs" \
#-initrd $Rootfs \
#-append "$LinuxArgs" \
if [ "$1" == "debug" ]; then
Debug="-s -S"
else
Debug=""
fi
#QEMU=/home/wutiejun/MyTools/bin/qemu-system-arm
QEMU=qemu-system-arm
sudo $QEMU -nographic -M vexpress-a9 -smp 4 -m 512M \
-kernel $Image \
-append "$LinuxArgs" \
$InitrdArgs \
$MtdConfig \
$NetConfig \
$Debug
# Restore TTY from Qemu target
stty sane
#!/bin/bash
cd ./rootfs/
chmod +x etc/init.d/rcS
find . | cpio -o --format=newc > ../rootfs.img
cd ..
rm -f ./rootfs.squashfs
rm -f ./rootfs.squashfs.ubi
rm -f ./flash.bin
#mksquashfs ./rootfs ./rootfs.squashfs
mksquashfs rootfs rootfs.squashfs -xattrs -comp xz
zImagefile=./source/kernel/zImage
mkimage -A arm -C none -O linux -T kernel -d $zImagefile -a 0x00010000 -e 0x00010000 uImage
ubinize -o flash.ubi -p 128KiB -m 2048 ubi.conf
#mkimage -A arm -C none -O linux -T ramdisk -d rootfs.img.gz -a 0x00800000 -e 0x00800000 rootfs.uimg
ubootfile=./source/uboot/u-boot
arm-linux-gnueabi-strip $ubootfile
flashimg -s 64M -t nand -f flash.bin -p flash.conf \
-w uboot,$ubootfile \
-w ubi,flash.ubi -z 2048
#mkimage -A arm -C none -O linux -T kernel -d zImage -a 0x00010000 -e 0x00010000 zImage.uimg
#mkimage -A arm -C none -O linux -T ramdisk -d rootfs.img.gz -a 0x00800000 -e 0x00800000 rootfs.uimg
#dd if=/dev/zero of=flash2.bin bs=1K count=32K
#dd if=$ubootfile of=flash.bin conv=notrunc bs=1K
#dd if=uImage of=flash.bin conv=notrunc bs=1 seek=1M
#dd if=rootfs.squashfs of=flash.bin conv=notrunc bs=1 seek=4M
Qemu Add Nand Flash
Booting Linux with U-Boot on QEMU ARM
https://balau82.wordpress.com/2010/04/12/booting-linux-with-u-boot-on-qemu-arm/
http://blog.csdn.net/zeroboundary/article/details/12657215
Compile Linux, BusyBox for ARM and load it using QEMU
https://github.com/surajx/qemu-arm-linux/wiki/Compile-Linux,-BusyBox-for-ARM-and-load-it-using-QEMU
https://git.linaro.org/
http://blog.csdn.net/caspiansea/article/details/12986565
http://www.cnblogs.com/pengdonglin137/p/5023342.html#_label5