summaryrefslogtreecommitdiffstats
path: root/configs
diff options
context:
space:
mode:
authorRobert Schwebel <r.schwebel@pengutronix.de>2017-01-06 16:39:09 +0100
committerRobert Schwebel <r.schwebel@pengutronix.de>2017-01-06 16:39:09 +0100
commite977f927e62e7ce3d25adad0d3a3185c272d593a (patch)
treec13ff47f25dee52c41df578e6d289a10df406c7f /configs
parentfb594924cfbe21ef6bb09b7db79676b9ee03cdc0 (diff)
downloadDistroKit-e977f927e62e7ce3d25adad0d3a3185c272d593a.tar.gz
DistroKit-e977f927e62e7ce3d25adad0d3a3185c272d593a.tar.xz
run: move to new script with plan 9 filesystem support
Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de>
Diffstat (limited to 'configs')
-rwxr-xr-xconfigs/platform-v7a/run187
1 files changed, 169 insertions, 18 deletions
diff --git a/configs/platform-v7a/run b/configs/platform-v7a/run
index eba8197..613b340 100755
--- a/configs/platform-v7a/run
+++ b/configs/platform-v7a/run
@@ -1,21 +1,172 @@
#!/bin/bash
+
+platformconfig=selected_platformconfig
+# fallback to platformconfig in the same dir as this script
+if [ ! -e "$platformconfig" ]; then
+ platformconfig=$(dirname $0)/platformconfig
+fi
+
+#
+# we need information about the platform
#
-# For some information about how to work with qemu for ARM, please
-# refer: http://fedoraproject.org/wiki/Architectures/ARM/HowToQemu
-
-. $(dirname $0)/qemu-common
-
-# do the job
-${QEMU_EXEC} ${QEMU_NOGRAPHIC} \
- -M ${QEMU_MACHINE} \
- -m 1024 \
- -no-reboot \
- -net nic,vlan=1 \
- ${QEMU_NET} \
- ${QEMU_REDIR} \
- -kernel ${PTXDIST_PLATFORMDIR}/images/linuximage \
- -dtb ${PTXDIST_PLATFORMDIR}/images/vexpress-v2p-ca9.dtb \
- -drive if=sd,file=${PTXDIST_PLATFORMDIR}/images/hd.img,format=raw \
- -smp 1 \
- -append "console=ttyAMA0 root=/dev/mmcblk0p2 rootfs=ext2 rw mem=1024M rootwait loglevel=5 rootfstype=ext4 systemd.log_level=warning systemd.show_status=auto"
+if [ ! -e "$platformconfig" ]; then
+ echo "error: selected_platformconfig does not exist"
+ echo " please use 'ptxdist platform ...' or 'ptxdist --platformconfig=...'"
+ exit 1
+fi
+
+source $platformconfig
+
+if [ -n "${PTXCONF_PLATFORM}" ]; then
+ PTXDIST_PLATFORMDIR="./platform-${PTXCONF_PLATFORM}"
+else
+ PTXDIST_PLATFORMDIR="."
+fi
+
+if [ ! -e "${PTXDIST_PLATFORMDIR}/images/linuximage" ]; then
+ echo "error: run 'ptxdist go' first"
+ exit 1
+fi
+
+# the emulator to run
+QEMU_EXEC="${PTXDIST_PLATFORMDIR}/sysroot-host/bin/qemu-system-arm"
+
+if [ ! -e "${QEMU_EXEC}" ]; then
+ echo "error: enable and install 'host-qemu' first"
+ exit 1
+fi
+
+# the port a 'telned' would connect to (in the emulated sysem)
+TELNET_INTERNAL_PORT=23
+# port QEMU opens at the host side to give access to the ${TELNET_INTERNAL_PORT}
+TELNET_EXTERNAL_PORT=4444
+
+# check if vde is available for networking
+if [ -z "${VDE_SOCKET}" ]; then
+ for dir in $(ls -d /var/run/vde2/*.ctl 2>/dev/null); do
+ if [ -r "${dir}" ]; then
+ VDE_SOCKET="${dir}"
+ fi
+ done
+fi
+if [ -n "${VDE_SOCKET}" ]; then
+ # make sure qemu supports vde networking
+ if ${QEMU_EXEC} --help | grep -q -- '-net.*vde'; then
+ QEMU_NET=( -net vde,vlan=1,sock=${VDE_SOCKET} )
+ fi
+fi
+
+# fall back to user network if necessary
+if [ -z "${QEMU_NET}" ]; then
+ QEMU_NET=(-net user,vlan=1,hostfwd=tcp:127.0.0.1:${TELNET_EXTERNAL_PORT}-:${TELNET_INTERNAL_PORT} )
+fi
+
+BASE_CMDLINE="console=ttyAMA0,115200 loglevel=5 systemd.log_level=warning systemd.show_status=auto"
+
+# Machine to emulate
+QEMU_ARGS=( -machine vexpress-a9 -cpu cortex-a9 -m 1024M )
+# disable graphics output
+QEMU_ARGS[${#QEMU_ARGS[@]}]="-nographic"
+# Exit qemu on reboot
+QEMU_ARGS[${#QEMU_ARGS[@]}]="-no-reboot"
+# Configure networking
+QEMU_ARGS=( "${QEMU_ARGS[@]}" -net nic,vlan=1 "${QEMU_NET[@]}" )
+# Set base time to test NTP and time handling
+QEMU_ARGS=( "${QEMU_ARGS[@]}" -rtc base=2000-01-01 )
+# Configure watchdog
+# no watchdog available on vexpress
+#QEMU_ARGS=( "${QEMU_ARGS[@]}" -watchdog i6300esb -watchdog-action poweroff )
+# SCSI bus
+QEMU_ARGS=( "${QEMU_ARGS[@]}" -device virtio-scsi-device,id=scsi )
+# Add virtual SCSI device if available
+if [ -e "${PTXDIST_PLATFORMDIR}/images/usbstick.img" ]; then
+ echo "SCSI unplug/plug in the QEMU console (C-a c):"
+ echo
+ echo "device_del plug"
+ echo
+ echo "drive_add 0 if=none,format=raw,id=scsiplug,file=${PTXDIST_PLATFORMDIR}/images/usbstick.img"
+ echo "device_add scsi-hd,drive=scsiplug,removable=true,id=plug"
+ echo
+ QEMU_EXTRA_ARGS=( \
+ -drive if=none,format=raw,id=scsiplug,file=${PTXDIST_PLATFORMDIR}/images/usbstick.img \
+ -device scsi-hd,drive=scsiplug,removable=true,id=plug )
+fi
+QEMU_LINUX_ARGS=( -kernel ${PTXDIST_PLATFORMDIR}/images/linuximage -dtb ${PTXDIST_PLATFORMDIR}/images/vexpress-v2p-ca9.dtb )
+# the barebox device tree has a state node for bootchooser
+QEMU_BAREBOX_ARGS=( -dtb ${PTXDIST_PLATFORMDIR}/build-target/barebox-${PTXCONF_BAREBOX_VERSION}/arch/arm/dts/vexpress-v2p-ca9.dtb )
+
+check_hd() {
+ if [ ! -e "${PTXDIST_PLATFORMDIR}/images/hd.img" ]; then
+ echo "error: hd.img is missing. Run 'ptxdist images' first"
+ exit 1
+ fi
+}
+
+check_flash() {
+ if [ ! -e "${PTXDIST_PLATFORMDIR}/images/flash.img" ]; then
+ echo "error: flash.img is missing. Run 'ptxdist images' first"
+ exit 1
+ fi
+}
+
+#
+# This needs:
+# CONFIG_NET_9P_VIRTIO=y
+# CONFIG_9P_FS=y
+#
+run_qemu_9p() {
+ exec ${QEMU_EXEC} \
+ "${QEMU_ARGS[@]}" \
+ -fsdev local,id=rootfs,path=${PTXDIST_PLATFORMDIR}/root,security_model=none \
+ -device virtio-9p-device,fsdev=rootfs,mount_tag=/dev/root \
+ "${QEMU_EXTRA_ARGS[@]}" \
+ "${QEMU_LINUX_ARGS[@]}" \
+ -append "root=/dev/root rootfstype=9p rootflags=trans=virtio ${BASE_CMDLINE}"
+}
+
+run_qemu_nfs() {
+ exec ${QEMU_EXEC} \
+ "${QEMU_ARGS[@]}" \
+ "${QEMU_EXTRA_ARGS[@]}" \
+ "${QEMU_LINUX_ARGS[@]}" \
+ -append "root=/dev/nfs nfsroot=/root,v3,tcp,port=2049,mountport=2049 ip=dhcp ${BASE_CMDLINE}"
+}
+
+run_qemu_scsi() {
+ check_hd
+ exec ${QEMU_EXEC} \
+ "${QEMU_ARGS[@]}" \
+ -drive if=none,format=raw,file=${PTXDIST_PLATFORMDIR}/images/hd.img,id=disk0 \
+ -device scsi-hd,drive=disk0 \
+ "${QEMU_EXTRA_ARGS[@]}" \
+ "${QEMU_LINUX_ARGS[@]}" \
+ -append "root=/dev/sda1 rootfstype=ext4 rootwait ${BASE_CMDLINE}"
+}
+
+run_qemu_mmc() {
+ check_hd
+ exec ${QEMU_EXEC} \
+ "${QEMU_ARGS[@]}" \
+ -drive if=sd,format=raw,file=${PTXDIST_PLATFORMDIR}/images/hd.img,id=mmc0 \
+ "${QEMU_EXTRA_ARGS[@]}" \
+ "${QEMU_LINUX_ARGS[@]}" \
+ -append "root=/dev/mmcblk0p1 rootfstype=ext4 rootwait ${BASE_CMDLINE}"
+}
+
+run_qemu_barebox() {
+ check_hd
+ check_flash
+ exec ${QEMU_EXEC} \
+ "${QEMU_ARGS[@]}" \
+ -fsdev local,id=rootfs,path=${PTXDIST_PLATFORMDIR}/root,security_model=none \
+ -device virtio-9p-device,fsdev=rootfs,mount_tag=/dev/root \
+ -drive if=sd,format=raw,file=${PTXDIST_PLATFORMDIR}/images/hd.img,id=mmc0 \
+ -drive if=pflash,format=raw,file=${PTXDIST_PLATFORMDIR}/images/flash.img,id=nor0 \
+ "${QEMU_EXTRA_ARGS[@]}" \
+ "${QEMU_BAREBOX_ARGS[@]}"
+}
+
+target="${1:-9p}"
+#set -x
+run_qemu_${target}