Commit fbc1ed93 authored by Nolan's avatar Nolan

Add USB storage for qemu run targets.

Note arm64 is still not functional due to missing USB in raspi3
machine-type.
parent 1b071f51
......@@ -606,18 +606,28 @@ deploy: $(RPI3_ZIP)
########################
# Qemu emulation targets
TMP_USB_IMG=/tmp/usb.img
tmp-usb-img: $(TMP_USB_IMG)
$(TMP_USB_IMG):
$(SCRIPTDIR)/mkfatimg $(TMP_USB_IMG) 512
ifeq ($(ARCH:arm%=),)
qemu-run: $(RPI3_IMG)
#XXX 2ndary storage is broken, since raspi3 doesn't have USB host or virtio. And
# virt doesn't have sdcard. Might be able to add some rename rules to mdev or
# something to workaround sda vs mmcblk...
#XXX Try this with uboot for -kernel + no -initrd/-dtb/-append...
qemu-run: $(RPI3_IMG) $(TMP_USB_IMG)
@echo -e "\nctrl-a x to exit qemu\n"
qemu-system-$(QEMU_ARCH) -nographic -M virt \
-kernel $(IMGFSDIR)/$(KERNEL_IMG) \
-initrd $(INITRD) -m 2048 -no-reboot \
-drive if=sd,id=sd0,file=$(RPI3_IMG) -device generic-sdhci,drive=sd0
qemu-system-$(QEMU_ARCH) -M raspi3 -nographic \
-kernel $(IMGFSDIR)/$(KERNEL_IMG) -initrd $(INITRD) \
-dtb $(IMGFSDIR)/bcm2837-rpi-3-b.dtb \
-m 1024 -no-reboot -append "8250.nr_uarts=1 console=tty1 console=ttyAMA0,115200" \
-drive file=$(RPI3_IMG),if=sd,format=raw -drive file=$(TMP_USB_IMG),if=virtio,format=raw
else ifeq ($(ARCH), amd64)
qemu-run: $(PC_IMG)
qemu-run: $(PC_IMG) $(TMP_USB_IMG)
@echo -e "\nctrl-a x to exit qemu\n"
qemu-system-x86_64 -enable-kvm -nographic -m 2048 \
-hda $(PC_IMG)
-hda $(PC_IMG) -hdb $(TMP_USB_IMG)
endif
PHONY += qemu-run
......
sda1 0:0 000 ! */usr/local/sbin/storaged -d -v
sd[a-z]1 0:0 000 ! */usr/local/sbin/storaged -d -v
.* 0:0 000 !
......@@ -294,6 +294,14 @@ unmountall() {
return 0
}
get_dname() {
if egrep -qs '/dev/sda[0-9]? /boot' /proc/mounts; then
echo "sdb1"
else
echo "sda1"
fi
}
init() {
local stage="$1"
......@@ -306,7 +314,7 @@ init() {
}
init0() {
local dname="sda1"
local dname="`get_dname`"
local dev="/dev/$dname"
local mnt="/mnt/$dname"
local dir="$mnt/$spath"
......@@ -338,7 +346,7 @@ init0() {
}
init1() {
local dname="sda1"
local dname="`get_dname`"
local dev="/dev/$dname"
local mnt="/mnt/$dname"
local dir="$mnt/$spath"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment