RPU / Zephyr RTOS

In this section we show you how to run Zephyr RTOS on RPU in lock-step mode.

Setup the Development Environment

This section is mostly the same as the "Getting Started Guide" from the Zephyr official documentation. If you are already familiar with Zephyr development environment, you can safely skip this section.

Install Required Dependencies

$ sudo apt update && sudo apt upgrade
$ sudo apt install --no-install-recommends git cmake ninja-build gperf \
    ccache dfu-util device-tree-compiler wget \
    python3-dev python3-venv python3-pip python3-setuptools python3-tk \
    python3-wheel xz-utils file \
    make gcc gcc-multilib g++-multilib libsdl2-dev libmagic1

Setup a Workspace

Create your working directory and a new virtual environment.

$ mkdir -p ~/myproject && cd ~/myproject
$ python3 -m venv .venv
$ source .venv/bin/activate

Install the West

Once venv is activated, we can install West locally.

$ pip install west

Clone Zephyr Repository

From here, we can use west to do most of the works.

$ west init -m https://github.com/zephyrproject-rtos/zephyr
$ west update
$ west zephyr-export

Install the Python Requirements

$ west packages pip --install

Install the Zephyr SDK

$ west sdk install

Install Udev Rules

Install the udev rules, which allow you to flash most Zephyr boards as a regular user.

sudo cp ~/zephyr-sdk-[VERSION]/sysroots/x86_64-pokysdk-linux/usr/share/openocd/contrib/60-openocd.rules \
        /etc/udev/rules.d
sudo udevadm control --reload

Install the tio Package

Although there are several tools available for working with a serial console, this document uses tio, a serial device I/O tool.

sudo apt install tio

Building and Running Zephyr RTOS for SC-OBC Module V1

Building Zephyr RTOS for SC-OBC Module V1

To build Zephyr RTOS for SC-OBC Module V1 is the same as any other board. All you have to do is to specify SC-OBC Module V1 (scobc_v1) with the -b option to west build.

$ cd ~/myproject/zephyr
$ west build -b scobc_v1 samples/hello_world

Running Zephyr RTOS on SC-OBC Module V1

To run Zephyr RTOS, you can use west flash.

For this step, we assume assume that the boot MODE is set to JTAG, which means that SW1 is set to all ON. See SC-OBC Module V1 Product Manual for more details.

Currently, for any AMD Versal based board including SC-OBC Module V1, west flash requires you to have a valid PDI.

$ source /path/to/xilinx/2025.1/Vivado/settings64.sh
$ west flash --pdi /path/to/your.pdi

The command first load the specified PDI file, then load Zephyr RTOS ELF file, and run it.

west flash for Versal-based board uses xsdb, instead of popular OpenOCD, for it’s backend. This means that you must have xsdb in one of your PATH environment variable directories.

Creating a PDI with Zephyr RTOS

You can create a PDI with Zephyr RTOS in it. The PDI, then, can be load from any boot device Versal supports.

To create a PDI, you use bootgen.

bootgen requires a .bif file. A sample .bif file is:

new_bif:
{
    image
    {
        { type = bootimage, file = /path/to/your.pdi }
    }
    image
    {
        name = apu_ss, id = 0x1c000000
        { core = r5-lockstep, file = ~/myproject/zephyr/build/zephyr/zephyr.elf }
    }
}

Save it as, say, mytest.bif, then:

$ source /path/to/xilinx/2025.1/Vivado/settings64.sh
$ bootgen -arch versal -image mytest.bif -w -o boot.bin

bootgen is provided by AMD (Vivado or Vitis). Make sure you have installed it and source the setup script before use.

Generated boot.bin can be placed on a SD card or can be written to one of the SPI NOR flash memories.

To load the PDI from SD card, you have to set the boot MODE [3:0] pins to "SD0 v3.0" or "0011" by setting SW1 of V1 Carrier Board SC-MPN-0062A to "OFF OFF ON ON".

To load the PDI from one of the SPI Flash memories , you have to set the boot MODE [3:0] pins to "QSPI32" or "0010" by setting SW1 of V1 Carrier Board SC-MPN-0062A to "OFF OFF ON OFF".

See Versal documentations for more details.