Skip to contentSkip to conversation

zephyr-qemuboot: use stable ELF symlink to avoid broken runqemu rootfs

PATCH In review [email protected] 2 participants 3 messages Feb 8 – Feb 14

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 zephyr-qemuboot: use stable ELF symlink to avoid broken runqemu rootfs

From: Charles Dias <[email protected]>

do_bootconf_write() may update qemuboot.conf and the QEMU ELF symlink to a new timestamped name while the ELF itself is reused from sstate and not deployed, leaving a broken symlink and causing runqemu to fail with "Can't find rootfs: ... .elf".

Fix by making zephyr-qemuboot use the stable link name (${ZEPHYR_IMAGE_LINK_NAME}.elf / ${PN}-${MACHINE}.elf), which is guaranteed to exist as a symlink created by zephyr-image.inc and always points at the most recently deployed ELF.

---
 meta-zephyr-core/classes-recipe/zephyr-qemuboot.bbclass | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
meta-zephyr-core/classes-recipe/zephyr-qemuboot.bbclass +3 -3
index ab0a281..4d8920f 100644
@@ -1,8 +1,8 @@
 inherit qemuboot
 
-ZEPHYR_IMAGE_BASE_NAME ?= "${PN}-${MACHINE}${IMAGE_VERSION_SUFFIX}"
+ZEPHYR_IMAGE_LINK_NAME ?= "${PN}-${MACHINE}"
 
-KERNEL_IMAGETYPE = "${ZEPHYR_IMAGE_BASE_NAME}.elf"
+KERNEL_IMAGETYPE = "${ZEPHYR_IMAGE_LINK_NAME}.elf"
 QB_DEFAULT_FSTYPE = "elf"
 QB_NETWORK_DEVICE = "none"
 QB_NET = "none"
@@ -29,7 +29,7 @@ python bootconf_clean() {
 python do_bootconf_write() {
     bb.build.exec_func("do_write_qemuboot_conf", d)
 
-    qemuimage = "%s/%s.elf" % (d.getVar('DEPLOY_DIR_IMAGE', True), d.getVar('ZEPHYR_IMAGE_BASE_NAME', True))
+    qemuimage = "%s/%s.elf" % (d.getVar('DEPLOY_DIR_IMAGE', True), d.getVar('ZEPHYR_IMAGE_LINK_NAME', True))
     qemuimage_link = d.getVar('QEMU_IMAGE_LINK', True)
     if os.path.lexists(qemuimage_link):
         os.remove(qemuimage_link)
#1 lore raw
Quoted 6 lines · On 2/8/2026 9:44 AM, [email protected] wrote:

From: Charles Dias <[email protected]>

do_bootconf_write() may update qemuboot.conf and the QEMU ELF symlink to a new timestamped name while the ELF itself is reused from sstate and not deployed, leaving a broken symlink and causing runqemu to fail with "Can't find rootfs: ... .elf".

[Sandeep]: Can you provide me the reproducibility steps for this issue. I didn't see this issue when I run the test a month ago.

 $ MACHINE=qemu-cortex-a9 runqemu nographic
runqemu - INFO - Running MACHINE=qemu-cortex-a9 bitbake -e  ...
runqemu - INFO - Continuing with the following parameters:
KERNEL: [/scratch/sandeep/yocto/yp-master/build-zep/tmp/deploy/images/qemu-cortex-a9/zephyr-helloworld-qemu-cortex-a9-20260116230612.elf]
MACHINE: [qemu-cortex-a9]
FSTYPE: [elf]
ROOTFS: [/scratch/sandeep/yocto/yp-master/build-zep/tmp/deploy/images/qemu-cortex-a9/zephyr-helloworld-image-qemu-cortex-a9.elf]
Disabled. Changes on rootfs will be kept after QEMU shutdown.
CONFFILE: [/scratch/sandeep/yocto/yp-master/build-zep/tmp/deploy/images/qemu-cortex-a9/zephyr-helloworld-image-qemu-cortex-a9-20260116230612.qemuboot.conf]

runqemu - INFO - Running /scratch/sandeep/yocto/yp-master/build-zep/tmp/work/x86_64-linux/qemu-helper-native/1.0/recipe-sysroot-native/usr/bin/qemu-system-arm -nic none   -icount shift=3,align=off,sleep=off -rtc clock=vm -machine xilinx-zynq-a9 -cpu cortex-a9  -m 256 -serial mon:stdio -serial null -nographic -nographic -vga none -kernel /scratch/sandeep/yocto/yp-master/build-zep/tmp/deploy/images/qemu-cortex-a9/zephyr-helloworld-qemu-cortex-a9-20260116230612.elf -append '  mem=256M swiotlb=0 '

runqemu - INFO - Host uptime: 2514957.76

*** Booting Zephyr OS build v4.2.0 ***
Hello World! qemu_cortex_a9/xc7z007s
QEMU: Terminated
runqemu - INFO - Cleaning up
runqemu - INFO - Host uptime: 2514968.61

$

Quoted 35 lines

Fix by making zephyr-qemuboot use the stable link name (${ZEPHYR_IMAGE_LINK_NAME}.elf / ${PN}-${MACHINE}.elf), which is guaranteed to exist as a symlink created by zephyr-image.inc and always points at the most recently deployed ELF.

---
  meta-zephyr-core/classes-recipe/zephyr-qemuboot.bbclass | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
meta-zephyr-core/classes-recipe/zephyr-qemuboot.bbclass +3 -3
index ab0a281..4d8920f 100644
@@ -1,8 +1,8 @@
  inherit qemuboot
 
-ZEPHYR_IMAGE_BASE_NAME ?= "${PN}-${MACHINE}${IMAGE_VERSION_SUFFIX}"
+ZEPHYR_IMAGE_LINK_NAME ?= "${PN}-${MACHINE}"
 
-KERNEL_IMAGETYPE = "${ZEPHYR_IMAGE_BASE_NAME}.elf"
+KERNEL_IMAGETYPE = "${ZEPHYR_IMAGE_LINK_NAME}.elf"
  QB_DEFAULT_FSTYPE = "elf"
  QB_NETWORK_DEVICE = "none"
  QB_NET = "none"
@@ -29,7 +29,7 @@ python bootconf_clean() {
  python do_bootconf_write() {
      bb.build.exec_func("do_write_qemuboot_conf", d)
 
-    qemuimage = "%s/%s.elf" % (d.getVar('DEPLOY_DIR_IMAGE', True), d.getVar('ZEPHYR_IMAGE_BASE_NAME', True))
+    qemuimage = "%s/%s.elf" % (d.getVar('DEPLOY_DIR_IMAGE', True), d.getVar('ZEPHYR_IMAGE_LINK_NAME', True))
      qemuimage_link = d.getVar('QEMU_IMAGE_LINK', True)
      if os.path.lexists(qemuimage_link):
          os.remove(qemuimage_link)
#2 lore raw
Quoted 4 lines · Sandeep

[Sandeep]: Can you provide me the reproducibility steps for this issue. I didn't see this issue when I run the test a month ago.

Thank you for your reply.

Please note this has already been merged. For reference, below are the steps to reproduce the previous issue (before the merge):
1. Revert/remove the merged commit.
2. Build zephyr-helloworld for the qemu-x86 machine:
3. After the build, edit machine/qemu-x86.conf and change any QB_*/QEMU machine setting, then rebuild:
4. Check bitbake-builds/zephyr-master/build/tmp/deploy/images/qemu-x86/:
zephyr-helloworld-image-qemu-x86.elf is updated to point to a new timestamped ELF name, but the new timestamped .elf is not present (broken symlink).

Best regards,
Charles Dias