1.. _kv260_r5:
2
3Xilinx KV260 Development Board RPU Cortex-R5
4############################################
5
6Overview
7********
8This configuration provides support for the RPU, real-time processing unit on Xilinx
9KV260 development board, it can operate as following:
10
11* Two independent R5 cores with their own TCMs (tightly coupled memories)
12* Or as a single dual lock step unit with double the TCM size.
13
14This processing unit is based on an ARM Cortex-R5 CPU, it also enables the following devices:
15
16* ARM PL-390 Generic Interrupt Controller
17* Xilinx Zynq TTC (Cadence TTC)
18* Xilinx Zynq UART
19
20.. figure:: kv260-starter-kit.jpg
21   :align: center
22   :alt: Xilinx KV260 Starter Kit
23
24Hardware
25********
26Supported Features
27==================
28
29The following hardware features are supported:
30
31+--------------+------------+----------------------+
32| Interface    | Controller | Driver/Component     |
33+==============+============+======================+
34| GIC          | on-chip    | generic interrupt    |
35|              |            | controller           |
36+--------------+------------+----------------------+
37| TTC          | on-chip    | system timer         |
38+--------------+------------+----------------------+
39| UART         | on-chip    | serial port          |
40+--------------+------------+----------------------+
41
42The kernel currently does not support other hardware features on this platform.
43
44Devices
45========
46System Timer
47------------
48
49This board configuration uses a system timer tick frequency of 1000 Hz.
50
51Serial Port
52-----------
53
54This board configuration uses a single serial communication channel with the
55on-chip UART1.
56
57Memories
58--------
59
60Although Flash, DDR and OCM memory regions are defined in the DTS file,
61all the code plus data of the application will be loaded in the sram0 region,
62which points to the DDR memory. The ocm0 memory area is currently available
63for usage, although nothing is placed there by default.
64
65Known Problems or Limitations
66==============================
67
68The following platform features are unsupported:
69
70* Dual-redundant Core Lock-step (DCLS) execution is not supported yet.
71* Only the first core of the R5 subsystem is supported.
72* Xilinx Zynq TTC driver does not support tickless mode operation.
73* The Cortex-R5 and the Cortex-A53 shares the same UART controller, more details below.
74
75Programming and Debugging
76*************************
77
78Currently the best way to run this sample is by loading it through remoteproc
79from the APU, running Linux, to the RPU, assuming the target board has a compatible
80Linux kernel.
81Users can make use of Xilinx's pre-built Petalinux reference images as a starting point to enable
82remoteproc support, it is based around 5.15 Xilinx maintained kernel, as described here:
83
84https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/1641152513/Kria+K26+SOM#PetaLinux
85
86The other option is to use the reference image from the openAMP project, the link
87below points, betweem the options, to the kv260 target:
88
89https://github.com/OpenAMP/openamp-ci-builds/releases/tag/v2022.12
90
91Select the option ``xilinx-kv260.tar.gz``, and just decompress it to the target rootfs
92partition of user's SD card:
93
94.. code-block:: console
95
96        $ sudo mount /dev/<user-sd> /media/rootfs
97        $ sudo tar -C /media/rootfs -xzf xilinx-kv260.tar.gz
98        $ sudo umount /media/rootfs
99
100Your SD file may be ready for use, just plug it to the slot located in the board.
101
102After getting the Linux image running on the target board, build a Zephyr application,
103such as the hello world sample shown below:
104
105.. zephyr-app-commands::
106   :zephyr-app: samples/hello_world
107   :host-os: unix
108   :board: kv260_r5
109   :goals: build
110
111Due to a hardware limitation, both Linux and Zephyr share the same UART
112controller, meaning when the Zephyr application is started it will takeover the
113console from Linux.
114
115To avoid this limitation when accessing the Linux shell, the best approach is to
116connect to the board using ``ssh`` over the network (not using the FTDI
117USB interface on the board), with the dev board and the host computer
118connected to the same network.
119
120Assuming you are using the default ``petalinux`` user from the Xilinx
121reference image , open a terminal on the host machine and ssh into the
122development board with the board's IP address (found via ``ifconfig``):
123
124.. code-block:: console
125
126        $ ssh petalinux@<board-ip-address>
127
128The initial password should be ``petalinux``. On another terminal deploy
129the Zephyr application ``.elf`` file using utility like the ``scp`` or ``rsync``,
130for example:
131
132.. code-block:: console
133
134        $ scp /path/to/zephyr_app_elf_file  petalinux@<board-ip-address>:/home/petalinux
135
136After that move the file to ``/lib/firmware`` directory, then you be able to start the firmware
137on the desired RPU via remoteproc with:
138
139.. code-block:: console
140
141        $ sudo -i # You need to operate the remoteproc as root
142        $ echo zephyr.elf > /sys/class/remoteproc/remoteproc0/firmware
143        $ echo start > /sys/class/remoteproc/remoteproc0/state
144
145With another terminal connected to UART1 on the host machine
146(available via one of the tty ports with the on-board FTDI chip),
147you should see the Zephyr application running:
148
149.. code-block:: console
150
151        *** Booting Zephyr OS build v3.4.0  ***
152        Hello World kv260_r5!
153
154References
155**********
156
1571. ARMv7-A and ARMv7-R Architecture Reference Manual (ARM DDI 0406C ID051414)
1582. Cortex-R5 and Cortex-R5F Technical Reference Manual (ARM DDI 0460C ID021511)
1593. Zynq UltraScale+ Device Technical Reference Manual (UG1085)
1604. Kria KV260 Vision AI Starter Kit User Guide (UG1089)
161