[Buildroot] [git commit] board/qemu/post-image.sh: execute from BINARIES_DIR

Thomas Petazzoni thomas.petazzoni at bootlin.com
Sat Dec 5 21:34:28 UTC 2020

commit: https://git.buildroot.net/buildroot/commit/?id=3fc3289a3f83e1b8193a34e2b48957034deaa873
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master

Usually the qemu command line start directly with "qemu-system-<arch> ...".
But the command line for qemu_arm_vexpress_tz_defconfig start by doing
"cd output/images && ../host/bin/qemu-system-arm". This is necessary
since boot binaries, except BL1, are primarily loaded via semi-hosting
so all binaries has to reside in the same directory as QEMU is started
from [1].

To order to handle this case correctly, update the post-image.sh used
by all qemu defconfigs to execute qemu from BINARIES_DIR.

Since we have to change the current directory use a subshell to
restore the current directory after Qemu execution.

[1] https://github.com/ARM-software/arm-trusted-firmware/blob/4ebbea9592ab37fc62217d0ac62fa13a3e063527/docs/plat/qemu.rst

Signed-off-by: Romain Naour <romain.naour at gmail.com>
Cc: Yann E. MORIN <yann.morin.1998 at free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
 board/qemu/post-image.sh | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/board/qemu/post-image.sh b/board/qemu/post-image.sh
index f34bf5043a..404f77411c 100755
--- a/board/qemu/post-image.sh
+++ b/board/qemu/post-image.sh
@@ -19,9 +19,9 @@ if [ -z "${QEMU_CMD_LINE}" ]; then
     exit 0
-# Replace output/images path by ${BINARIES_DIR} since the script
-# will be in the same directory as the kernel and the rootfs images.
+# Remove output/images path since the script will be in
+# the same directory as the kernel and the rootfs images.
 # Remove -serial stdio if present, keep it as default args
 DEFAULT_ARGS="$(sed -r -e '/-serial stdio/!d; s/.*(-serial stdio).*/\1/' <<<"${QEMU_CMD_LINE}")"
@@ -40,7 +40,9 @@ esac
 cat <<-_EOF_ > "${START_QEMU_SCRIPT}"
+	(
 	if [ "\${1}" = "serial-only" ]; then
@@ -50,6 +52,7 @@ cat <<-_EOF_ > "${START_QEMU_SCRIPT}"
 	export PATH="${HOST_DIR}/bin:\${PATH}"
+	)
 chmod +x "${START_QEMU_SCRIPT}"

More information about the buildroot mailing list