Skip to content

Commit d65be82

Browse files
committed
ayufan: dev.mk: add qemu-arm64 target to easy testing of images
1 parent 5e668c5 commit d65be82

File tree

4 files changed

+61
-1
lines changed

4 files changed

+61
-1
lines changed

dev-ayufan/boards.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ LOADER_FLASH ?= rksd_loader
5252
IMAGES ?= flash-spi erase-spi
5353
LOADERS ?= rksd_loader rkspi_loader
5454

55+
56+
else ifeq (qemu-arm64,$(BOARD_TARGET))
57+
58+
UBOOT_DEFCONFIG ?= qemu_arm64_defconfig
59+
5560
else
5661
$(error Unsupported BOARD_TARGET)
5762
endif

dev-ayufan/build.mk

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ tmp/u-boot-$(BOARD_TARGET)/.config: configs/$(UBOOT_DEFCONFIG)
1313
$(UBOOT_OUTPUT_DIR):
1414
mkdir -p $@
1515

16-
$(UBOOT_OUTPUT_DIR)/u-boot.itb: .scmversion $(UBOOT_OUTPUT_DIR) tmp/u-boot-$(BOARD_TARGET)/.config $(BL31)
16+
$(UBOOT_OUTPUT_DIR)/u-boot.bin: .scmversion $(UBOOT_OUTPUT_DIR) tmp/u-boot-$(BOARD_TARGET)/.config $(BL31)
1717
$(UBOOT_MAKE) -j $$(nproc)
18+
19+
$(UBOOT_OUTPUT_DIR)/u-boot.itb: $(UBOOT_OUTPUT_DIR)/u-boot.bin
1820
$(UBOOT_MAKE) -j $$(nproc) u-boot.itb
1921

2022
$(UBOOT_TPL) $(UBOOT_SPL): $(UBOOT_OUTPUT_DIR)/u-boot.itb
@@ -53,6 +55,9 @@ u-boot-menuconfig:
5355
.PHONY: u-boot-build # compile u-boot
5456
u-boot-build: $(UBOOT_LOADERS)
5557

58+
.PHONY: u-boot-bin
59+
u-boot-bin: $(UBOOT_OUTPUT_DIR)/u-boot.bin
60+
5661
.PHONY: u-boot-clear
5762
u-boot-clear:
5863
rm -rf $(UBOOT_OUTPUT_DIR)

dev-ayufan/qemu-arm64.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
3+
if [[ $# -lt 1 ]]; then
4+
echo "usage: $0 <image.img> [qemu-args...]"
5+
fi
6+
7+
ROOT=$(dirname "$(readlink -f "$0")")
8+
IMAGE="$1"
9+
shift
10+
11+
BRIDGE=${BRIDGE:-br0}
12+
BIOS=${BIOS:-$ROOT/../tmp/u-boot-qemu-arm64/u-boot.bin}
13+
14+
if [[ ! -e "$BIOS" ]]; then
15+
echo "Missing $BIOS. Run:"
16+
echo "./dev-shell ./dev-make u-boot-bin BOARD_TARGET=qemu-arm64"
17+
exit 1
18+
fi
19+
20+
if ip link show br0 &>/dev/null; then
21+
echo "Attach tap to br0"
22+
NETDEV="tap,script=$ROOT/qemu-ifup"
23+
SUDO="sudo"
24+
else
25+
echo "No br0, using netdev=user"
26+
NETDEV=user
27+
SUDO=""
28+
fi
29+
30+
exec $SUDO qemu-system-aarch64 \
31+
-m 2048 \
32+
-machine virt \
33+
-cpu cortex-a57 \
34+
-bios "$BIOS" \
35+
-device virtio-net-device,netdev=net0 \
36+
-device virtio-gpu-pci \
37+
-device virtio-blk-device,drive=hd0 \
38+
-netdev "$NETDEV,id=net0" \
39+
-serial mon:stdio \
40+
-drive "if=none,file=$IMAGE,id=hd0" \
41+
"$@"

dev-ayufan/qemu-ifup

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
if [[ -n "$1" ]];then
4+
ip link set $1 master br0
5+
exit 0
6+
else
7+
echo "Error: no interface specified"
8+
exit 1
9+
fi

0 commit comments

Comments
 (0)