[PATCH 65/67] scripts: Update qemu script to support specifying a UPL

Simon Glass sjg at chromium.org
Wed Jan 1 23:09:51 CET 2025


Add a -u option to specify a UPL to load. This is made available in a
separate virtio device. Allow this to work even if the -B flag is
provided, to allow iterating on the payload, without changing U-Boot

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 scripts/build-qemu.sh | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/scripts/build-qemu.sh b/scripts/build-qemu.sh
index 10ea99982d2..b92623c9bc5 100755
--- a/scripts/build-qemu.sh
+++ b/scripts/build-qemu.sh
@@ -30,6 +30,7 @@ usage() {
 	echo "   -R <os>   - Select OS release (e.g. 24.04)"
 	echo "   -s        - Use serial only (no display)"
 	echo "   -S <seq>  - Select SCT sequence-file"
+	echo "   -u <file> - Run Universal Payload (UPL) file"
 	echo "   -w        - Use word version (32-bit)" ) >&2
 	exit 1
 }
@@ -69,11 +70,14 @@ serial=
 # Use kvm
 kvm=
 
+# Use UPL
+upl=
+
 # Set ubdir to the build directory where you build U-Boot out-of-tree
 # We avoid in-tree build because it gets confusing trying different builds
 ubdir=${ubdir-/tmp/b}
 
-while getopts "a:Beko:rR:sS:w" opt; do
+while getopts "a:Beko:rR:sS:u:w" opt; do
 	case "${opt}" in
 	a)
 		arch=$OPTARG
@@ -113,6 +117,9 @@ while getopts "a:Beko:rR:sS:w" opt; do
 	S)
 		seq=$OPTARG
 		;;
+	u)
+		upl=$OPTARG
+		;;
 	w)
 		bitness=32
 		;;
@@ -140,11 +147,24 @@ update_sct_seq() {
 	sudo losetup -d ${LOOP}
 }
 
+# Add a Universal Payload into the image
+add_upl() {
+	if [[ -z "${upl}" ]]; then
+		return
+	fi
+	qemu-img create upl.img 8M
+	mkfs.fat upl.img
+	mcopy -vs -i upl.img "${upl}" ::/upl.fit
+}
+
 # Run QEMU with U-Boot
 run_qemu() {
 	if [[ -n "${os_image}" ]]; then
 		extra+=" -drive if=virtio,file=${os_image},format=raw,id=hd0"
 	fi
+	if [[ -n "${upl}" ]]; then
+		extra+=" -drive if=virtio,file=upl.img,format=raw,id=hd0"
+	fi
 	if [[ -n "${serial}" ]]; then
 		extra+=" -display none -serial mon:stdio"
 	else
@@ -204,8 +224,9 @@ DIR=${ubdir}/${BOARD}
 
 if [[ -n "${build}" ]]; then
 	build_u_boot
-	update_sct_seq
 fi
+update_sct_seq
+add_upl
 
 if [[ -n "${run}" ]]; then
 	run_qemu
-- 
2.43.0



More information about the U-Boot mailing list