board/qemu/post-image.sh: rename IMAGE_DIR to BINARIES_DIR
PATCH v3 1/4 board/qemu/post-image.sh: rename IMAGE_DIR to BINARIES_DIR
The output/images directory is called BINARIES_DIR in the Buildroot manual, not IMAGE_DIR.
--- board/qemu/post-image.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
board/qemu/post-image.sh +3 -3
@@ -19,9 +19,9 @@ if [ -z "${QEMU_CMD_LINE}" ]; then exit 0 fi -# Replace output/images path by ${IMAGE_DIR} since the script +# Replace output/images path by ${BINARIES_DIR} since the script # will be in the same directory as the kernel and the rootfs images. -QEMU_CMD_LINE="${QEMU_CMD_LINE//output\/images/\${IMAGE_DIR\}}" +QEMU_CMD_LINE="${QEMU_CMD_LINE//output\/images/\${BINARIES_DIR\}}" # 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,7 @@ esac cat <<-_EOF_ > "${START_QEMU_SCRIPT}" #!/bin/sh - IMAGE_DIR="\${0%/*}/" + BINARIES_DIR="\${0%/*}/" if [ "\${1}" = "serial-only" ]; then EXTRA_ARGS='${SERIAL_ARGS}'
Signature · 1 line
2.25.4
PATCH v3 2/4 board/qemu/post-image.sh: execute from BINARIES_DIR
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.
--- board/qemu/post-image.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
board/qemu/post-image.sh +6 -3
@@ -19,9 +19,9 @@ if [ -z "${QEMU_CMD_LINE}" ]; then exit 0 fi -# Replace output/images path by ${BINARIES_DIR} since the script -# will be in the same directory as the kernel and the rootfs images. -QEMU_CMD_LINE="${QEMU_CMD_LINE//output\/images/\${BINARIES_DIR\}}" +# Remove output/images path since the script will be in +# the same directory as the kernel and the rootfs images. +QEMU_CMD_LINE="${QEMU_CMD_LINE//output\/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}" #!/bin/sh + ( BINARIES_DIR="\${0%/*}/" + cd \${BINARIES_DIR} if [ "\${1}" = "serial-only" ]; then EXTRA_ARGS='${SERIAL_ARGS}'
@@ -50,6 +52,7 @@ cat <<-_EOF_ > "${START_QEMU_SCRIPT}" export PATH="${HOST_DIR}/bin:\${PATH}" exec ${QEMU_CMD_LINE} \${EXTRA_ARGS} + ) _EOF_ chmod +x "${START_QEMU_SCRIPT}"
Signature · 1 line
2.25.4
PATCH v3 3/4 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.
Since Qemu from HOST_DIR is now executed directly from BINARIES_DIR, we can remove all the string before "qemu-system-*".
---
Tested with: ./support/scripts/boot-qemu-image.py qemu_arm_vexpress_tz_defconfig
--- board/qemu/arm-vexpress-tz/readme.txt | 2 +- board/qemu/post-image.sh | 3 +++ configs/qemu_arm_vexpress_tz_defconfig | 4 ++++ 3 files changed, 8 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.
board/qemu/post-image.sh +3 -0
@@ -27,6 +27,9 @@ QEMU_CMD_LINE="${QEMU_CMD_LINE//output\/images/}" DEFAULT_ARGS="$(sed -r -e '/-serial stdio/!d; s/.*(-serial stdio).*/\1/' <<<"${QEMU_CMD_LINE}")" QEMU_CMD_LINE="${QEMU_CMD_LINE//-serial stdio/}" +# Remove any sting before qemu-system-* +QEMU_CMD_LINE=${QEMU_CMD_LINE##*/} + # Disable graphical output and redirect serial I/Os to console case ${DEFCONFIG_NAME} in (qemu_sh4eb_r2d_defconfig|qemu_sh4_r2d_defconfig)
configs/qemu_arm_vexpress_tz_defconfig +4 -0
@@ -43,6 +43,10 @@ BR2_PACKAGE_OPTEE_BENCHMARK=y BR2_PACKAGE_OPTEE_EXAMPLES=y BR2_PACKAGE_OPTEE_TEST=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
PATCH v3 4/4 support/scripts/boot-qemu-image.py: don't fail if start-qemu.sh is missing
In reply to Romain NaourWhen boot-qemu-image.py script was added, we wanted to run each qemu defconfig in gitlab, so we expect that all qemu defconfig generate the script start-qemu.sh in images directory.
Don't make it a hard requirement even if we prefer to be able to do a runtime test for each qemu defconfig.
--- support/scripts/boot-qemu-image.py | 4 ++++ 1 file changed, 4 insertions(+)
support/scripts/boot-qemu-image.py +4 -0
@@ -18,6 +18,10 @@ def main(): if not sys.argv[1].startswith('qemu_'): sys.exit(0) + if not os.path.exists('output/images/start-qemu.sh'): + print('qemu-start.sh is missing, cannot test.') + sys.exit(0) + qemu_start = os.path.join(os.getcwd(), 'output/images/start-qemu.sh') child = pexpect.spawn(qemu_start, ['serial-only'],
Signature · 1 line
2.25.4
PATCH v3 4/4 support/scripts/boot-qemu-image.py: don't fail if start-qemu.sh is missing
Hello,
This patch should be merged in master in order to avoid this failure in gitlab:
https://gitlab.com/buildroot.org/buildroot/-/jobs/849510085
The previous patches of this series is for next.
Best regards,
Romain
Le 15/11/2020 ? 15:36, Romain Naour a ?crit?:
Quoted 30 lines
When
boot-qemu-image.pyscript was added, we wanted to run each qemu defconfig in gitlab, so we expect that all qemu defconfig generate the scriptstart-qemu.shin images directory.Don't make it a hard requirement even if we prefer to be able to do a runtime test for each qemu defconfig.
Signed-off-by Romain Naour <[email protected]>Cc Yann E. MORIN <[email protected]>--- support/scripts/boot-qemu-image.py | 4 ++++ 1 file changed, 4 insertions(+)support/scripts/boot-qemu-image.py +4
-0@@ -18,6 +18,10 @@ def main(): if not sys.argv[1].startswith('qemu_'): sys.exit(0) + if not os.path.exists('output/images/start-qemu.sh'): + print('qemu-start.sh is missing, cannot test.') + sys.exit(0) + qemu_start = os.path.join(os.getcwd(), 'output/images/start-qemu.sh') child = pexpect.spawn(qemu_start, ['serial-only'],