Xilinx SoCs on-board support for x-heep.
This repository provides the software interface and drivers required to integrate the x-heep RISC-V system with the Processing System (PS) of Xilinx SoCs.
Acting as a bridge between the Xilinx ARM-based Processing System and the FPGA Programmable Logic (PL) hosting x-heep, this framework enables a fully remote development. Users can deploy, test, and debug the core via SSH, entirely eliminating the need for physical access to on-board JTAG or UART headers.
- Remote Deployment via SSH: Manage the entire development cycle (programming, execution, and monitoring) over a network connection.
- Remote Bitstream Loading: Deploy x-heep hardware designs directly from Python using PYNQ-based drivers.
- OpenOCD & XVC Integration: Leverages OpenOCD 0.12.0 and the Xilinx Virtual Cable (XVC) protocol to load
.elffirmware over AXI JTAG. - Dynamic UART Overlay: Automatically patches, compiles, and loads a Linux Device Tree Overlay (DTO) to expose the AXI UART as a system device.
- Dynamic SPI Overlay: Automatically manages the AXI Quad SPI device tree overlay to expose the SPI bus for flash programming.
- Direct Flash Programming: Programs external SPI NOR flash via direct MMIO access, without requiring kernel SPI drivers.
- Execution Control: Full remote control over the core lifecycle, including reset, boot mode selection, and exit status monitoring via GPIO.
- Bitstream Change Detection: SHA256-based tracking avoids unnecessary PL resets when the same bitstream is reused.
| Board | SoC | Status | Notes |
|---|---|---|---|
| PYNQ-Z2 | Zynq-7000 (XC7Z020) | Supported | Requires PS_ENABLE to be active in the x-heep bitstream. |
| AUP-ZU3 | ZynqMP (XCZU3EG) | Supported | Requires PS_ENABLE to be active in the x-heep bitstream. |
Important: Ensure that the Vivado version used to implement x-heep is consistent with the PYNQ distribution installed on the board. Mismatched versions may cause issues with JTAG TAP identification and bitstream loading.
The installation process is fully automated through a single command. This script installs system dependencies, builds OpenOCD with specific patches, and configures the Python environment.
make installNote: To work directly in the configured root environment, run
sudo -i. The shell is configured to automatically source the PYNQ virtual environment and place you in/home/xilinx.
Warning:
make installperforms large downloads and compilation (cloning and building OpenOCD, etc.). Depending on your network and CPU it can take a long time. It's recommended to runmake installinside atmuxsession so the long-running process continues if your SSH session disconnects.
During installation, the script automatically:
- Clones OpenOCD from the official repository at version v0.12.0.
- Applies a Custom Patch (
patch/openocd.patch) required for correct operation with the x-heep RISC-V core:- Disables
vlenbregister probing unless the vector extension (V) is present in MISA. - Disables
MTOPI/MTOPEIprivileged interrupt register probing. - Replaces hard assertions with warnings for graceful degradation.
- Disables
- Builds OpenOCD with the following features enabled:
- FTDI interface support (
--enable-ftdi) - Bitbang driver support (
--enable-bitbang) - Xilinx AXI XVC support (
--enable-xlnx-axi-xvc) - Internal JimTcl interpreter (
--enable-internal-jimtcl)
- FTDI interface support (
- Installs OpenOCD system-wide at
/usr/local/bin/openocd.
To install the Jupyter notebook interface to the board's default notebook directory:
make install-notebookThis copies all necessary files (notebook, drivers, config, DTS templates) to ~/jupyter_notebooks/xheep.
The target user can be customized with USER=<username>.
device-tree-compiler— compiles.dtstemplates into.dtbobinaries.picocom— serial terminal for UART monitoring.
pynq— FPGA bitstream management and MMIO access. (Required)pyserial— UART serial communication.ipywidgets— interactive widgets for the Jupyter notebook.serial— serial module dependency used by runtime tooling.
- OpenOCD v0.12.0 (built and patched during
make install). - Vivado-generated
.bitbitstream with the x-heep design andPS_ENABLEactive.
The xheepRun.py script supports three execution modes controlled via the --linker flag:
The fastest execution mode, suitable for small programs that fit in internal RAM.
- UART Cleanup: Before any hardware changes, the script checks if the AXI UART is active. It performs a driver unbind and removes the existing overlay to prevent kernel hangs during PL reset.
- PL Reset & Programming: The Programmable Logic is reset and the new bitstream is loaded via the PYNQ Overlay manager.
- Dynamic Overlay Injection: The driver retrieves the AXI UART physical address from the bitstream, patches the
uartlite-overlay.tplfile, compiles it into a.dtbo, and injects it into the live kernel via ConfigFS. This re-attaches the UART, creating/dev/ttyUL0. - User Confirmation: The system halts and waits for the user to press Enter.
- JTAG Firmware Load: OpenOCD starts an XVC server using the AXI JTAG base address. The script connects via Telnet to halt the core and load the
.elffirmware into memory. - Monitoring: Once execution begins, the script monitors GPIO signals. Upon completion, it displays the Exit Valid and Exit Value codes.
Programs the external flash memory and loads/executes via JTAG.
- UART Cleanup: Unbinds the driver and removes the existing overlay.
- PL Reset & Programming: Resets PL and loads the new bitstream.
- Dynamic Overlay Injection: Injects the
.dtboto re-attach the UART (/dev/ttyUL0). - User Confirmation: Halts and waits for the user to press Enter.
- Flash Programming: The firmware binary is programmed into external SPI NOR flash using direct MMIO.
- Flash Boot Configuration: GPIO is configured to boot from flash.
- JTAG Loading: Firmware is loaded and executed the same as on-chip mode.
Boots and executes directly from flash without JTAG loading.
- UART Cleanup: Unbinds the driver and removes the existing overlay.
- PL Reset & Programming: Resets PL and loads the new bitstream.
- Dynamic Overlay Injection: Injects the
.dtboto re-attach the UART (/dev/ttyUL0). - Flash Boot Configuration: GPIO is configured to execute directly from flash.
- Direct Execution: X-HEEP boots from flash and executes immediately without JTAG intervention.
- Monitoring: The script monitors exit codes via GPIO.
The repository uses a specific OpenOCD configuration (cfg/xheep_xilinx_xvc.cfg) to enable the Xilinx Virtual Cable. This configuration allows OpenOCD to communicate with the axi_jtag IP inside the FPGA by mapping JTAG operations to memory-mapped I/O (MMIO) registers at the address specified by XVC_DEV_ADDR.
The configuration exposes the following network ports:
- 4444 — Telnet command interface
- 3333 — GDB remote debugging
- 6666 — TCL RPC interface
The xheepGPIO class manages the following control signals via the axi_gpio IP:
| Bit / Channel | Signal | Description |
|---|---|---|
| Bit 0 | rst_ni |
Active-low reset for the x-heep core |
| Bit 1 | boot_select_i |
Selects JTAG (0) or Flash (1) boot mode |
| Bit 2 | execute_from_flash_i |
Enables direct execution from Flash memory |
| Bit 3 | jtag_trst_ni |
Active-low reset for the JTAG TAP controller |
| Bit 4 | spi_sel |
Selects SPI flash access: PS (0) or X-HEEP (1) |
| Channel 2 | Exit Status | Reads exit_valid and exit_value after execution |
make install # Install dependencies and OpenOCD
make uninstall # Remove OpenOCD and shell hooks (requires sudo)
make install-notebook # Install Jupyter notebook interface to ~/jupyter_notebooks/xheep
make uninstall-notebook # Remove the Jupyter notebook interface
make run # Run with default parameters
make run APP=path/to/firmware.elf LINKER=flash_load OVERLAY=xilinx_core_v_mini_mcu_wrapper.bit
make help # Show all available targets and parametersMakefile Parameters:
| Variable | Default | Description |
|---|---|---|
OVERLAY |
xilinx_core_v_mini_mcu_wrapper.bit |
Path to the FPGA bitstream |
APP |
(empty) | Path to the firmware image (.elf or .bin) |
LINKER |
on_chip |
Execution mode: on_chip, flash_load, flash_exec |
USER |
xilinx |
Username for notebook installation path |
To program the FPGA and run a firmware image remotely:
python src/xheepRun.py \
-o path/to/xheep_top.bit \
-f path/to/firmware.elf \
-l on_chipArgument Details:
-o, --overlay: Path to the FPGA bitstream (.bit) [required]-f, --firmware: Path to the compiled RISC-V.elfor.binfirmware [required]-l, --linker: Execution mode:on_chip(default),flash_load, orflash_exec--verify: Verify the loaded firmware against the source file after programming--force: Force a full PL reset and UART reconfiguration even if the bitstream hasn't changed
Once the dynamic overlay is injected (Step 3 of the Execution Flow), the AXI UART is exposed as /dev/ttyUL0. You can connect to it using picocom at the default baud rate of 9600:
sudo picocom -b 9600 --imap lfcrlf /dev/ttyUL0An interactive Jupyter notebook is available at notebook/xheepNotebook.ipynb. It provides the same functionality as the CLI but with an interactive widget-based UI, including:
- Bitstream and firmware path configuration
- One-click initialization and UART setup
- Interactive serial terminal with start/stop controls
- Buttons for each execution mode (on-chip, flash load, flash execute)
- Force reload and verification options
After running make install-notebook, the notebook is available at ~/jupyter_notebooks/xheep/xheepNotebook.ipynb on the board's Jupyter server.
