Skip to content

Commit

Permalink
ayufan: dev.mk: add qemu-arm64 target to easy testing of images
Browse files Browse the repository at this point in the history
  • Loading branch information
ayufan committed Aug 28, 2021
1 parent 5e668c5 commit f128a77
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
5 changes: 5 additions & 0 deletions dev-ayufan/boards.mk
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ LOADER_FLASH ?= rksd_loader
IMAGES ?= flash-spi erase-spi
LOADERS ?= rksd_loader rkspi_loader


else ifeq (qemu-arm64,$(BOARD_TARGET))

UBOOT_DEFCONFIG ?= qemu_arm64_defconfig

else
$(error Unsupported BOARD_TARGET)
endif
7 changes: 6 additions & 1 deletion dev-ayufan/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ tmp/u-boot-$(BOARD_TARGET)/.config: configs/$(UBOOT_DEFCONFIG)
$(UBOOT_OUTPUT_DIR):
mkdir -p $@

$(UBOOT_OUTPUT_DIR)/u-boot.itb: .scmversion $(UBOOT_OUTPUT_DIR) tmp/u-boot-$(BOARD_TARGET)/.config $(BL31)
$(UBOOT_OUTPUT_DIR)/u-boot.bin: .scmversion $(UBOOT_OUTPUT_DIR) tmp/u-boot-$(BOARD_TARGET)/.config $(BL31)
$(UBOOT_MAKE) -j $$(nproc)

$(UBOOT_OUTPUT_DIR)/u-boot.itb: $(UBOOT_OUTPUT_DIR)/u-boot.bin
$(UBOOT_MAKE) -j $$(nproc) u-boot.itb

$(UBOOT_TPL) $(UBOOT_SPL): $(UBOOT_OUTPUT_DIR)/u-boot.itb
Expand Down Expand Up @@ -53,6 +55,9 @@ u-boot-menuconfig:
.PHONY: u-boot-build # compile u-boot
u-boot-build: $(UBOOT_LOADERS)

.PHONY: u-boot-bin
u-boot-bin: $(UBOOT_OUTPUT_DIR)/u-boot.bin

.PHONY: u-boot-clear
u-boot-clear:
rm -rf $(UBOOT_OUTPUT_DIR)
Expand Down
48 changes: 48 additions & 0 deletions dev-ayufan/qemu-arm64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

if [[ $# -lt 1 ]]; then
echo "usage: $0 <image.img> [qemu-args...]"
fi

ROOT=$(dirname "$(readlink -f "$0")")
IMAGE="$1"
shift

BRIDGE=${BRIDGE:-br0}
BIOS=${BIOS:-$ROOT/../tmp/u-boot-qemu-arm64/u-boot.bin}

if [[ ! -e "$BIOS" ]]; then
echo "Missing $BIOS. Run:"
echo "./dev-shell ./dev-make u-boot-bin BOARD_TARGET=qemu-arm64"
exit 1
fi

if ip link show br0 &>/dev/null; then
echo "Attach tap to br0"
NETDEV="tap,script=$ROOT/qemu-ifup"
SUDO="sudo -E"
else
echo "No br0, using netdev=user"
NETDEV=user
SUDO=""
fi

MACADDR=$(echo "$IMAGE"|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/')

exec $SUDO qemu-system-aarch64 \
-m 2048 \
-machine virt \
-cpu cortex-a53 \
-smp 4 \
-bios "$BIOS" \
-device "usb-ehci" \
-device "virtio-keyboard-pci" \
-device "virtio-tablet-pci" \
-device "virtio-balloon-pci" \
-device "virtio-net-device,netdev=net0,mac=$MACADDR" \
-device "virtio-gpu-pci,xres=1920,yres=1080" \
-device "virtio-blk-device,drive=hd0" \
-netdev "$NETDEV,id=net0" \
-serial "mon:stdio" \
-drive "if=none,file=$IMAGE,id=hd0" \
"$@"
10 changes: 10 additions & 0 deletions dev-ayufan/qemu-ifup
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

if [[ -n "$1" ]];then
ip link set "$1" up
ip link set "$1" master br0
exit 0
else
echo "Error: no interface specified"
exit 1
fi

0 comments on commit f128a77

Please sign in to comment.