From a51f98cded3cf7ea58ac324fd631efca28a34aab Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Sun, 10 Jan 2021 12:42:00 -0700 Subject: [PATCH 1/2] boot-qemu.sh: Account for dtb after smart kernel image finding KBUILD_DIR is no longer defined, meaning we look for the required dtb in /arch/arm/boot/dts, which obviously does not exist. Do something similar for dtbs like the kernel image, where we look for either a dts (kbuild output) or dtbs (tuxmake output) folder and error if it cannot be found in either location. Fixes: cc703a8 ("boot-qemu.sh: Allow the user to supply a kernel image directly") Signed-off-by: Nathan Chancellor --- boot-qemu.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/boot-qemu.sh b/boot-qemu.sh index 99c81af..34591ca 100755 --- a/boot-qemu.sh +++ b/boot-qemu.sh @@ -108,8 +108,8 @@ function setup_qemu_args() { case ${ARCH} in arm32_v5) ARCH=arm + DTB=aspeed-bmc-opp-palmetto.dtb QEMU_ARCH_ARGS=( - -dtb "${KBUILD_DIR}"/arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dtb -machine palmetto-bmc -no-reboot) QEMU=(qemu-system-arm) @@ -117,8 +117,8 @@ function setup_qemu_args() { arm32_v6) ARCH=arm + DTB=aspeed-bmc-opp-romulus.dtb QEMU_ARCH_ARGS=( - -dtb "${KBUILD_DIR}"/arch/arm/boot/dts/aspeed-bmc-opp-romulus.dtb -machine romulus-bmc -no-reboot) QEMU=(qemu-system-arm) @@ -231,6 +231,18 @@ function setup_qemu_args() { KERNEL=${KERNEL_LOCATION}/${BOOT_DIR}${KIMAGE} fi [[ -f ${KERNEL} ]] || die "${KERNEL} does not exist!" + if [[ -n ${DTB} ]]; then + # If we are in a boot folder, look for them in the dts folder in it + if [[ $(basename "${KERNEL%/*}") = "boot" ]]; then + DTB_FOLDER=dts/ + # Otherwise, assume there is a dtbs folder in the same folder as the kernel image (tuxmake) + else + DTB_FOLDER=dtbs/ + fi + DTB=${KERNEL%/*}/${DTB_FOLDER}${DTB} + [[ -f ${DTB} ]] || die "${DTB##*/} is required for booting but it could not be found at ${DTB}!" + QEMU_ARCH_ARGS+=(-dtb "${DTB}") + fi } # Invoke QEMU From cd8e4915cbed09d2de2df5dc5ce2ebba908b79fd Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Sun, 10 Jan 2021 12:44:59 -0700 Subject: [PATCH 2/2] boot-qemu.sh: Break apart decomp_rootfs There is no point in decompressing the rootfs before we make sure that the kernel image and dtb can be found. Break this function apart because we need to know the image location before ${ARCH} is reassigned but we can decompress the image once we know we are actually going to call the QEMU binary. Signed-off-by: Nathan Chancellor --- boot-qemu.sh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/boot-qemu.sh b/boot-qemu.sh index 34591ca..a1d058a 100755 --- a/boot-qemu.sh +++ b/boot-qemu.sh @@ -83,20 +83,14 @@ function sanity_check() { checkbin zstd } -# Decompress rootfs images -function decomp_rootfs() { +# Boot QEMU +function setup_qemu_args() { # All arm32_* options share the same rootfs, under images/arm [[ ${ARCH} =~ arm32 ]] && ARCH_RTFS_DIR=arm IMAGES_DIR=${BASE}/images/${ARCH_RTFS_DIR:-${ARCH}} ROOTFS=${IMAGES_DIR}/rootfs.cpio - rm -rf "${ROOTFS}" - zstd -d "${ROOTFS}".zst -o "${ROOTFS}" -} - -# Boot QEMU -function setup_qemu_args() { APPEND_STRING="" if ${INTERACTIVE:=false}; then APPEND_STRING+="rdinit=/bin/sh " @@ -247,6 +241,9 @@ function setup_qemu_args() { # Invoke QEMU function invoke_qemu() { + rm -rf "${ROOTFS}" + zstd -d "${ROOTFS}".zst -o "${ROOTFS}" + [[ -z ${QEMU_RAM} ]] && QEMU_RAM=512m if ${GDB:=false}; then while true; do @@ -301,6 +298,5 @@ function invoke_qemu() { parse_parameters "${@}" sanity_check -decomp_rootfs setup_qemu_args invoke_qemu