diff mbox series

[meta-zephyr,master] zephyr-qemuboot: use stable ELF symlink to avoid broken runqemu rootfs

Message ID 20260208164458.101865-1-charles.embedded@gmail.com
State New
Headers show
Series [meta-zephyr,master] zephyr-qemuboot: use stable ELF symlink to avoid broken runqemu rootfs | expand

Commit Message

Charles Dias Feb. 8, 2026, 4:44 p.m. UTC
From: Charles Dias <charlesdias.cd@outlook.com>

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.

Signed-off-by: Charles Dias <charlesdias.cd@outlook.com>
---
 meta-zephyr-core/classes-recipe/zephyr-qemuboot.bbclass | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Gundlupet Raju, Sandeep Feb. 14, 2026, 6:43 p.m. UTC | #1
On 2/8/2026 9:44 AM, charles.embedded@gmail.com wrote:
> From: Charles Dias <charlesdias.cd@outlook.com>
>
> 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

$

>
> 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.
>
> Signed-off-by: Charles Dias <charlesdias.cd@outlook.com>
> ---
>   meta-zephyr-core/classes-recipe/zephyr-qemuboot.bbclass | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/meta-zephyr-core/classes-recipe/zephyr-qemuboot.bbclass b/meta-zephyr-core/classes-recipe/zephyr-qemuboot.bbclass
> index ab0a281..4d8920f 100644
> --- a/meta-zephyr-core/classes-recipe/zephyr-qemuboot.bbclass
> +++ b/meta-zephyr-core/classes-recipe/zephyr-qemuboot.bbclass
> @@ -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)
Charles Dias Feb. 14, 2026, 9:14 p.m. UTC | #2
On Sat, Feb 14, 2026 at 3:43 PM Gundlupet Raju, Sandeep
<sandeep.gundlupet-raju@amd.com> wrote:
>
> [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
diff mbox series

Patch

diff --git a/meta-zephyr-core/classes-recipe/zephyr-qemuboot.bbclass b/meta-zephyr-core/classes-recipe/zephyr-qemuboot.bbclass
index ab0a281..4d8920f 100644
--- a/meta-zephyr-core/classes-recipe/zephyr-qemuboot.bbclass
+++ b/meta-zephyr-core/classes-recipe/zephyr-qemuboot.bbclass
@@ -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)