aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/runqemu
blob: 63ea856b655b1aad4d97da97e71e594c08d6a9ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/sh

if [ "x$BUILDDIR" = "x" ]; then
    echo "You need to source poky-init-build-env before running this script"
    exit 1
fi

PATH=$BUILDDIR/tmp/staging/$BUILD_SYS/bin:$BUILDDIR/tmp/cross/bin:$PATH

KERNEL_NETWORK_CMD="ip=192.168.7.2::192.168.7.1:255.255.255.0"
QEMU_NETWORK_CMD="-net nic,vlan=0 -net tap,vlan=0,ifname=tap0,script=$OEROOT/scripts/qemu-ifup"

if [ -z "$QEMU_MEMORY" ]; then
    QEMU_MEMORY="64M"
fi

if [ "x$1" != "x" ]; then
    MACHINE=$1
else
    MACHINE="qemuarm"
fi

if [ "x$2" != "x" ]; then
    TYPE=$2
else
    TYPE="ext2"
fi

if [ "x$3" != "x" ]; then
    ZIMAGE=$3
fi

if [ "x$4" != "x" ]; then
    HDIMAGE=$4
fi

if [ "$MACHINE" = "qemuarm" -o "$MACHINE" = "spitz" -o "$MACHINE" = "borzoi" -o "$MACHINE" = "akita" ]; then
    QEMU=`which qemu-system-arm`
    if [ "x$ZIMAGE" = "x" ]; then
        ZIMAGE=$BUILDDIR/tmp/deploy/images/zImage-$MACHINE.bin
    fi
    CROSSPATH=$BUILDDIR/tmp/cross/arm-poky-linux/bin
fi

if [ "$MACHINE" = "qemux86" ]; then
    QEMU=`which qemu`
    if [ "x$ZIMAGE" = "x" ]; then
        ZIMAGE=$BUILDDIR/tmp/deploy/images/bzImage-$MACHINE.bin
    fi
    CROSSPATH=$BUILDDIR/tmp/cross/i586-poky-linux/bin
fi

export PATH=$CROSSPATH:$PATH

if [ ! -e $CROSSPATH/cc ]; then
   ln -s $CROSSPATH/gcc $CROSSPATH/cc
fi

DISTCCD=`which distccd`


if [ -x "$DISTCCD" ]; then
    $DISTCCD --allow 192.168.7.2 --daemon
else
    echo "Warning: distccd not present, no distcc support loaded"
fi

if [ "$MACHINE" = "qemuarm" ]; then
    if [ "$TYPE" = "ext2" ]; then
        if [ "x$HDIMAGE" = "x" ]; then
           HDIMAGE=$BUILDDIR/tmp/deploy/images/oh-image-sdk-qemuarm.ext2
        fi
        QEMUOPTIONS="-append \"root=/dev/sda mem=$QEMU_MEMORY\" $QEMU_NETWORK_CMD -M versatilepb -hda $HDIMAGE -usb -usbdevice wacom-tablet"
    fi
    if [ "$TYPE" = "nfs" ]; then
        dd if=/dev/zero of=/tmp/blank bs=1024 count=8192
        QEMUOPTIONS="-append \"root=/dev/nfs nfsroot=192.168.7.1:/srv/nfs/qemuarm rw $KERNEL_NETWORK_CMD\" $QEMU_NETWORK_CMD -M versatilepb -hda /tmp/blank"
    fi
fi

if [ "$MACHINE" = "qemux86" ]; then
    if [ "$TYPE" = "ext2" ]; then
        if [ "x$HDIMAGE" = "x" ]; then
           HDIMAGE=$BUILDDIR/tmp/deploy/images/oh-image-pda-qemux86.ext2
        fi
        # video=vesafb:1024x768-32@86
        QEMUOPTIONS="-std-vga -append \"root=/dev/hda mem=$QEMU_MEMORY $KERNEL_NETWORK_CMD\" $QEMU_NETWORK_CMD -hda $HDIMAGE -usb -usbdevice wacom-tablet"
    fi
    if [ "$TYPE" = "nfs" ]; then
        dd if=/dev/zero of=/tmp/blank bs=1024 count=8192
        QEMUOPTIONS="-std-vga -append \"root=/dev/nfs nfsroot=192.168.7.1:/srv/nfs/qemux86 rw $KERNEL_NETWORK_CMD\" $QEMU_NETWORK_CMD -hda /tmp/blank"
    fi
fi

if [ "x$QEMUOPTIONS" = "x" ]; then
    echo "Sorry, unable to support this configuration"
    exit 1
fi

echo "Running $QEMU using sudo..."
echo "$QEMU -kernel $ZIMAGE $QEMUOPTIONS"
sudo $QEMU -kernel $ZIMAGE $QEMUOPTIONS
# -serial file:serial.log

if [ -x "$DISTCCD" ]; then
    killall distccd
fi

if [ -e /tmp/blank ]; then
    rm /tmp/blank
fi