Skip to content
soccentric-zionPublic

About

Zion RPU firmware (FreeRTOS, Cortex-R5F): real-time I/O and RPMsg/FlatBuffers heartbeat link to the APU

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

Zion-RPU

Real-time half of the Zion APU <-> RPU link for the AMD Zynq UltraScale+ (Kria KV260 / K26): FreeRTOS firmware for the Cortex-R5F cores, plus the portable protocol library it is built from.

The firmware talks to Zion-APU (zion-apud on Linux) over an OpenAMP RPMsg endpoint named zion-link, using FlatBuffers messages. Both sides send a heartbeat to each other and log what they receive.

MIT licensed. Part of the Zion platform.

What it does

  • Real-time I/O task. Fixed-period sampling of four input pins with debounce and edge capture; four output pins the APU can drive (only the pins the firmware marks writable). Period jitter and overruns are measured and reported.
  • Bidirectional heartbeat. Sends a Heartbeat every period and prints each one received from the APU on the UART.
  • Handshake, liveness and control. Hello/HelloAck (re-sent until acknowledged), the shared link state machine, GetStatus, SetOutput, SetConfig (validated as a whole, rejected atomically when out of range).
  • Diagnostics. Abort/undefined-instruction handlers and the FreeRTOS stack-overflow / malloc-failed hooks write a fault record to a .noinit region that survives a remoteproc stop/start; the next boot prints it and counts it in Status.faults.
  • No allocation after start-up. The FlatBuffers builder is warmed up once; the engine and RPMsg ring use static storage.

Layout

lib/               zion_rpu_lib (portable C11, no OS calls): codec, link FSM, I/O sampler, config, protocol engine
app/host/          zion-rpu-sim: the same engine on a PC over a Unix datagram socket (pairs with zion-apud's sim transport)
app/xilinx_r5/     Cortex-R5F firmware: FreeRTOS tasks, OpenAMP RPMsg port, GPIO, UART log, fault capture,
                   resource table, linker script, compile-check stubs
schema/            zion_link.fbs  (identical copy lives in Zion-APU; CI checks they match)
test/              unit tests (codec round trips, malformed input, fuzz-lite, FSM, I/O, config, engine with fake ports)
scripts/           ARM cross-compile and port syntax checks, schema sync check
doc/               architecture, protocol, KV260 bring-up

Try it on a PC

make build                                   # library, simulator, tests
./build/app/host/zion-rpu-sim --help

Pair it with zion-apud as described in the Zion-APU README. kill -USR1 <pid> toggles simulated input pin 0.

Build and test

make test         # unit tests
make sanitize     # tests under ASan + UBSan
make coverage     # gcov, fails under 80 % lines
make lint         # clang-format, cppcheck
make arm-lib      # cross-compile lib/ for Cortex-R5F with -Werror, print code size
make r5-syntax    # syntax-check the R5 port against stub headers
make r5 BSP_DIR=... GLUE_DIR=... FLATCC_RT_DIR=...   # real firmware image, see doc/bringup-kv260.md

Dependencies: CMake >= 3.16 and a C11 compiler. flatcc is used for the FlatBuffers C code (fetched automatically when it is not installed). Cross checks use arm-none-eabi-gcc.

Status and limits

  • Tested on the host: the library (32 unit tests under ASan/UBSan, coverage ~87 %), the engine against fake ports, and the full link against the real zion-apud through the simulator.
  • Cross-compiled, not run: lib/ builds for Cortex-R5F with -Werror (about 16 KB of code).
  • Compile-checked against stubs only: the Cortex-R5F port in app/xilinx_r5/. It uses the FreeRTOS, XGpioPs and OpenAMP APIs as written from the AMD embeddedsw sources; it has not been built against the real BSP and has not run on a KV260. Treat the first hardware bring-up as part of the work: the MIO pin assignment, the memory layout and the OpenAMP platform glue are the likely places to need adjustment (all listed in doc/bringup-kv260.md).
  • With the 1 kHz FreeRTOS tick the smallest I/O period is 1 ms. Faster loops need a hardware-timer driven task.

Contributing

See the organisation's contributing guide. Any change to schema/zion_link.fbs must land in both Zion-APU and Zion-RPU together.

About

Zion RPU firmware (FreeRTOS, Cortex-R5F): real-time I/O and RPMsg/FlatBuffers heartbeat link to the APU

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages