forked from Byzantium/ByzPi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathraspbian_in_qemu.sh
executable file
·77 lines (66 loc) · 2.55 KB
/
raspbian_in_qemu.sh
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
#!/bin/bash
# raspbian_in_qemu.sh - Does what it says on the tin. Requires that you have
# qemu-system-arm installed and that it supports the arm1176 processor.
# Takes two arguments, the kernel to boot and the disk image to mount.
# By: The Doctor [412/724/301/703][ZS] <drwho at virtadpt dot net>
# Written for Project Byzantium (http://project-byzantium.org/)
# License: GPLv3
# Notes:
# v1 RasPi's only have 256 MB of RAM. v2 RasPi's have 512 MB. Some in the
# community seem to have decided that defaulting to 256 MB is safest, but if
# you want to try larger amounts of memory feel free to do so.
# The evocation of QEMU came from this page, which I learned from:
# http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/
# The serial port is redirected to the terminal you executed this script from,
# so you have direct access to the virtual unit if the X window goes wonky for
# whatever reason.
# Count the number of command line arguments passed to the script. ABEND if
# we're missing a few.
#
# Download raspian images at the following addresses.
#
# http://downloads.raspberrypi.org/images/raspbian/2013-02-09-wheezy-raspbian/2013-02-09-wheezy-raspbian.zip.torrent
#
# http://downloads.raspberrypi.org/images/raspbian/2013-02-09-wheezy-raspbian/2013-02-09-wheezy-raspbian.zip
#
# SHA-1 b4375dc9d140e6e48e0406f96dead3601fac6c81
# Default login Username: pi Password: raspberry
#
# For instructions on raspberry pi
# http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/
#
# Raspberry pi kernel
# http://xecdesign.com/downloads/linux-qemu/kernel-qemu
#
if [ "$#" -lt 2 ]; then
echo "Error - insufficient command line arguments."
echo "Usage: $0 -k <kernel> -i <disk image>"
exit 1
fi
# See if the files passed on the command line exist, and if they don't ABEND.
if [ ! -f $1 ]; then
echo "Error - Kernel image not found."
exit 1
fi
if [ ! -f $2 ]; then
echo "Error - Disk image not found."
exit 1
fi
# Test to see if QEMU is installed.
which qemu-system-arm 1>/dev/null 2>/dev/null
if [ $? -gt 0 ]; then
echo "Error - qemu-system-arm executable not found."
exit 1
fi
# Test to see if qemu-system-arm can emulate the 1176 processor core, and
# ABEND if not.
CPU_FOUND=`qemu-system-arm -cpu ? | grep 1176`
if [ ! "$CPU_FOUND" ]; then
echo "Error - qemu-system-arm does not emulate the arm1176 CPU."
exit 1
fi
# Start QEMU in RaspberryPi mode.
qemu-system-arm -kernel $1 -cpu arm1176 -m 256 -M versatilepb -no-reboot \
-serial stdio -append "root=/dev/sda2 panic=1" -hda $2
# Fin.
exit 0