diff mbox series

[meta-zephyr,master,05/12] zephyr-image: Add image artifacts to output files

Message ID 20250815035449.2816001-6-sandeep.gundlupet-raju@amd.com
State New
Headers show
Series Update for master | expand

Commit Message

Sandeep Gundlupet Raju Aug. 15, 2025, 3:54 a.m. UTC
Inherit image-artifact-names bbclass in zephyr-image.inc and add
image artifacts to output generated files.

Before:
zephyr-helloworld.elf

After:
zephyr-helloworld-{MACHINE}-{DATETIME}.elf

Signed-off-by: Sandeep Gundlupet Raju <sandeep.gundlupet-raju@amd.com>
---
 .../zephyr-kernel/zephyr-image.inc              | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-image.inc b/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-image.inc
index f02270a..61ad90c 100644
--- a/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-image.inc
+++ b/meta-zephyr-core/recipes-kernel/zephyr-kernel/zephyr-image.inc
@@ -1,16 +1,19 @@ 
 require zephyr-kernel-src.inc
 require zephyr-kernel-common.inc
-inherit deploy
+inherit deploy image-artifact-names
 
 OECMAKE_SOURCEPATH = "${ZEPHYR_SRC_DIR}"
 
+ZEPHYR_IMAGE_LINK_NAME ?= "${PN}-${MACHINE}"
+ZEPHYR_IMAGE_BASE_NAME ?= "${PN}-${MACHINE}${IMAGE_VERSION_SUFFIX}"
+
 do_install() {
     install -d ${D}/firmware
 
     for output in ${ZEPHYR_MAKE_OUTPUT}; do
         if [ -f ${B}/zephyr/${output} ];
         then
-          output_img=$(echo ${output} | sed -e "s/zephyr/${PN}/g")
+          output_img=$(echo ${output} | sed -e "s/zephyr/${ZEPHYR_IMAGE_BASE_NAME}/g")
           install -D ${B}/zephyr/${output} ${D}/firmware/${output_img}
         fi
     done
@@ -20,6 +23,14 @@  INSANE_SKIP += "ldflags buildpaths"
 SYSROOT_DIRS += "/firmware"
 
 do_deploy() {
-    cp ${D}/firmware/* ${DEPLOYDIR}/
+    for output in ${ZEPHYR_MAKE_OUTPUT}; do
+        if [ -f ${B}/zephyr/${output} ];
+        then
+          output_img=$(echo ${output} | sed -e "s/zephyr/${ZEPHYR_IMAGE_BASE_NAME}/g")
+          output_img_link=$(echo ${output} | sed -e "s/zephyr/${ZEPHYR_IMAGE_LINK_NAME}/g")
+          cp ${B}/zephyr/${output} ${DEPLOYDIR}/${output_img}
+          ln -sf ${output_img} ${DEPLOYDIR}/${output_img_link}
+        fi
+    done
 }
 addtask deploy after do_install