How to Build and Boot Zephyr Hello-World Application

Overview

The Zephyr hello-world application is a minimal reference example from the Zephyr Project. It validates the development environment and confirms basic build and boot behavior on Versal Gen 2 platforms.

The application initializes the Zephyr Real-Time Operating System (RTOS) and prints a simple Hello World message to the system console. It is the first functional checkpoint for new boards, toolchains, and build flows in AMD Embedded Development Framework (EDF).

The default EDF prebuilt Board Support Package (BSP) includes a libmetal hello-world application on the R52_1 core. To run Zephyr hello-world on R52_1 instead, complete the steps in this section.

Yocto Build Environment Setup

Before building the Zephyr hello-world application, set up the Yocto EDF build environment.

Refer to Operating System Integration and Development.

Steps to Build Zephyr Hello-World Application

Create the Include File

Create file versal-2ve-2vm-hello-world-r52-1-zephyr.inc with the following content:

$ cat sources/meta-amd-adaptive-socs/meta-amd-adaptive-socs-bsp/dynamic-layers/meta-amd-edf/recipes-bsp/bootbin/versal-2ve-2vm-hello-world-r52-1-zephyr.inc
APP = "zephyr-helloworld"

FHW_DEPENDS = ""
FHW_MCDEPENDS = "mc::${MACHINE}-cortexr52-1-zephyr:${APP}:do_deploy"

DEPENDS:remove = "${APP}"
do_compile[mcdepends] += "${FHW_MCDEPENDS}"

FHW_DEPLOY_DIR = "${TMPDIR}-${MACHINE}-cortexr52-1-zephyr/deploy/images/${MACHINE}"

BIF_PARTITION_ATTR:append = " ${APP}"
BIF_PARTITION_ATTR[zephyr-helloworld] = "destination_cpu=r52-1"
BIF_PARTITION_IMAGE[zephyr-helloworld] = "${FHW_DEPLOY_DIR}/${APP}-${MACHINE}.elf"
BIF_PARTITION_ID[zephyr-helloworld] = "0x1c000000"

Configure VEK385 Multidomain

R52_1 uses the bare-metal multiconfig by default. To enable Zephyr hello-world on R52_1, edit versal-2ve-2vm-vek385-multidomain.yaml and set CONFIG_YOCTO_BBMC_CORTEXR52_1_ZEPHYR: y. Then set BOOTBIN_INC to versal-2ve-2vm-hello-world-r52-1-zephyr.inc.

$ vim sources/meta-amd-adaptive-socs/meta-amd-adaptive-socs-bsp/conf/machineyaml/versal-2ve-2vm-vek385-multidomain.yaml
# Enable multiconfig targets
kconfig:
   CONFIG_YOCTO_BBMC_CORTEXR52_1_ZEPHYR: y

Set BOOTBIN_INC to include Zephyr hello-world in edf-ospi.bin for VEK385 multi-domain builds. Replace default file versal-2ve-2vm-hello-world-r52-1-baremetal.inc with versal-2ve-2vm-hello-world-r52-1-zephyr.inc.

BOOTBIN_INC:
   comment: Enable hello-world application
   op: '='
   val: versal-2ve-2vm-hello-world-r52-1-zephyr.inc

Regenerate Machine Configuration

After updating versal-2ve-2vm-vek385-multidomain.yaml, rerun gen-machine-conf to regenerate machine configuration. This step enables CONFIG_YOCTO_BBMC_CORTEXR52_1_ZEPHYR: y and applies the Zephyr include file.

$ gen-machine-conf --template ../sources/meta-amd-adaptive-socs/meta-amd-adaptive-socs-bsp/conf/machineyaml/versal-2ve-2vm-vek385-multidomain.yaml

Build the edf-ospi Image

Build edf-ospi with:

$ MACHINE=versal-2ve-2vm-vek385-multidomain bitbake edf-ospi

This command builds board-specific boot artifacts for VEK385 multi-domain and compiles Zephyr hello-world.

The build creates the Zephyr hello-world Executable and Linkable Format (ELF) file at:

tmp-${MACHINE}-cortexr52-1-zephyr/deploy/images/${MACHINE}/zephyr-helloworld-${MACHINE}.elf

The edf-ospi configuration packages this ELF into edf-ospi.bin.

Boot Steps for VEK385

  1. Follow the board boot instructions in: Discovery and Evaluation AMD Versal Device Portfolio

  2. Launch XSDB.

  3. In XSDB, connect and select the R52_1 target used by destination_cpu=r52-1 in the BIF.

    xsdb% connect
    xsdb% targets
         1  Versal Gen 2 xc2ve3858
            2  RPU (PS POR is active)
               3  RPU Cluster #0 (PS POR is active)
                  4  Cortex-R52 #0.0 (PS POR is active)
                  5* Cortex-R52 #0.1 (PS POR is active)
               6  RPU Cluster #1 (PS POR is active)
                  7  Cortex-R52 #1.0 (PS POR is active)
                  8  Cortex-R52 #1.1 (PS POR is active)
    

    Target index 5 corresponds to Cortex-R52 #0.1, which matches destination_cpu=r52-1.