board/qemu/post-image.sh: start from a shell
PATCH v2 1/2 board/qemu/post-image.sh: start from a shell
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].
The start-qemu.sh script fail to start qemu since it use exec on the "cd" command. To work around this issue, use "exec sh -c":
exec sh -c "${QEMU_CMD_LINE} \${EXTRA_ARGS}"
---
v2: escape double quote for -append
--- board/qemu/post-image.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
board/qemu/post-image.sh +4 -1
@@ -27,6 +27,9 @@ QEMU_CMD_LINE="${QEMU_CMD_LINE//output\/images/\${IMAGE_DIR\}}" DEFAULT_ARGS="$(sed -r -e '/-serial stdio/!d; s/.*(-serial stdio).*/\1/' <<<"${QEMU_CMD_LINE}")" QEMU_CMD_LINE="${QEMU_CMD_LINE//-serial stdio/}" +# Escape -append double quotes +QEMU_CMD_LINE=$(echo ${QEMU_CMD_LINE} | sed "s%\"%\\\\\"%g") + # Disable graphical output and redirect serial I/Os to console case ${DEFCONFIG_NAME} in (qemu_sh4eb_r2d_defconfig|qemu_sh4_r2d_defconfig)
@@ -49,7 +52,7 @@ cat <<-_EOF_ > "${START_QEMU_SCRIPT}" fi export PATH="${HOST_DIR}/bin:\${PATH}" - exec ${QEMU_CMD_LINE} \${EXTRA_ARGS} + exec sh -c "${QEMU_CMD_LINE} \${EXTRA_ARGS}" _EOF_ chmod +x "${START_QEMU_SCRIPT}"
Signature · 1 line
2.25.4
PATCH v2 1/2 board/qemu/post-image.sh: start from a shell
Hi Etienne, All,
Le 22/05/2020 ? 23:51, Romain Naour a ?crit?:
Quoted 7 lines
Usually the qemu command line start directly with "qemu-system-<arch> ...". But the command line for
qemu_arm_vexpress_tz_defconfigstart 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].
Quoted 5 lines
The
start-qemu.shscript fail to start qemu since it use exec on the "cd" command. To work around this issue, use "exec sh -c":
exec sh -c "${QEMU_CMD_LINE} \${EXTRA_ARGS}"
What do you think we can switch to boot via flash based firmwares method ? [1] It would avoid the constraint of running qemu from the directory where all binaries reside. This is mainly to allow testing this defconfig in gitlab-ci.
It would require to update the uboot boot command, the post-image script and the qemu command line etc...
[1]
https://trustedfirmware-a.readthedocs.io/en/latest/plat/qemu.html#booting-via-flash-based-firmwares
Best regards,
Romain
Quoted 33 lines
Signed-off-by Romain Naour <[email protected]>Cc Yann E. MORIN <[email protected]>---
v2: escape double quote for -append--- board/qemu/post-image.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)board/qemu/post-image.sh +4
-1@@ -27,6 +27,9 @@ QEMU_CMD_LINE="${QEMU_CMD_LINE//output\/images/\${IMAGE_DIR\}}" DEFAULT_ARGS="$(sed -r -e '/-serial stdio/!d; s/.*(-serial stdio).*/\1/' <<<"${QEMU_CMD_LINE}")" QEMU_CMD_LINE="${QEMU_CMD_LINE//-serial stdio/}" +# Escape -append double quotes +QEMU_CMD_LINE=$(echo ${QEMU_CMD_LINE} | sed "s%\"%\\\\\"%g") + # Disable graphical output and redirect serial I/Os to console case ${DEFCONFIG_NAME} in (qemu_sh4eb_r2d_defconfig|qemu_sh4_r2d_defconfig)@@ -49,7 +52,7 @@ cat <<-_EOF_ > "${START_QEMU_SCRIPT}" fi export PATH="${HOST_DIR}/bin:\${PATH}" - exec ${QEMU_CMD_LINE} \${EXTRA_ARGS} + exec sh -c "${QEMU_CMD_LINE} \${EXTRA_ARGS}" _EOF_ chmod +x "${START_QEMU_SCRIPT}"
PATCH v2 2/2 configs/qemu_arm_vexpress_tz_defconfig: build start-qemu.sh
In reply to Romain NaourWhen tags was added by commit 011206b2bffd509b29365bc1eaa761414ee13726 to detect the qemu command line, the qemu_arm_vexpress_tz_defconfig was ignored due to a build issue.
This build issue has been fixed by previous patches, so we can enable the runtime testing by adding the tag in the readme.txt and the post-image script in the defconfig.
--- board/qemu/arm-vexpress-tz/readme.txt | 2 +- configs/qemu_arm_vexpress_tz_defconfig | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
board/qemu/arm-vexpress-tz/readme.txt +1 -1
@@ -18,7 +18,7 @@ secure and non-secure worlds. -serial stdio \ -netdev user,id=vmnic -device virtio-net-device,netdev=vmnic \ -semihosting-config enable,target=native \ - -bios bl1.bin + -bios bl1.bin # qemu_arm_vexpress_tz_defconfig The boot stage traces (if any) followed by the login prompt will appear in the terminal that started QEMU.
configs/qemu_arm_vexpress_tz_defconfig +4 -0
@@ -47,6 +47,10 @@ BR2_PACKAGE_HOST_PYTHON3=y BR2_TOOLCHAIN_BUILDROOT_WCHAR=y BR2_PACKAGE_PYTHON3=y +# Image +BR2_ROOTFS_POST_IMAGE_SCRIPT="board/qemu/post-image.sh" +BR2_ROOTFS_POST_SCRIPT_ARGS="$(BR2_DEFCONFIG)" + # U-boot for booting the dear Linux kernel BR2_TARGET_UBOOT=y BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
Signature · 1 line
2.25.4