source: rtems-docs/user/bsps/aarch64/xilinx-zynqmp.rst @ 3348f19

Last change on this file since 3348f19 was 3348f19, checked in by Kinsey Moore <kinsey.moore@…>, on 07/19/22 at 19:41:46

zynqmp: Add commentary about lwIP usage

  • Property mode set to 100644
File size: 10.3 KB
Line 
1.. SPDX-License-Identifier: CC-BY-SA-4.0
2
3.. Copyright (C) 2020 On-Line Applications Research Corporation (OAR)
4
5.. _BSP_aarch64_qemu_xilinx_zynqmp_ilp32_qemu:
6.. _BSP_aarch64_qemu_xilinx_zynqmp_lp64_qemu:
7.. _BSP_aarch64_qemu_xilinx_zynqmp_ilp32_zu3eg:
8.. _BSP_aarch64_qemu_xilinx_zynqmp_lp64_zu3eg:
9
10Qemu Xilinx ZynqMP
11==================
12
13This BSP supports four variants: `xilinx-zynqmp-ilp32-qemu`,
14`xilinx-zynqmp-lp64-qemu`, `xilinx-zynqmp-ilp32-zu3eg`, and
15`xilinx-zynqmp-lp64-zu3eg`. Platform-specific hardware initialization is
16performed by ARM Trusted Firmware (ATF). Other basic hardware initialization is
17performed by the BSP. These BSPs support the GICv2 interrupt controller present
18in all ZynqMP systems. The zu3eg BSPs have also been tested to be fully
19functional on zu2cg boards and should also work on any other ZynqMP chip variant
20since the Processing Subsystem (PS) does not vary among chip variants other than
21the number of CPU cores available.
22
23Boot on QEMU
24------------
25The executable image is booted by Qemu in ELF format.
26
27Boot on ZynqMP Hardware
28-----------------------
29
30On ZynqMP hardware, RTEMS can be started at EL1, EL2, or EL3 by u-boot or
31directly as part of BOOT.bin. Regardless of the exception level at boot, RTEMS
32will drop to EL1 for execution. For quick turnaround during testing, it is
33recommended to use the u-boot BOOT.bin that comes with the PetaLinux prebuilts
34for the board in question.
35
36Hardware Boot Image Generation
37------------------------------
38
39RTEMS expects some hardware initialization to be performed by ATF and expects
40the services it provides to be present, so this must be included when generating
41a direct-boot RTEMS BOOT.bin.
42
43When booting via u-boot, RTEMS must be packaged into a u-boot image or booted
44as a raw binary since u-boot does not currently support ELF64 which is required
45for AArch64 ELF binaries.
46
47Example: Booting a RTEMS image on the ZCU102 ZynqMP board
48---------------------------------------------------------
49
50This example will walk through the steps needed for booting RTEMS from a SD card
51on the
52`ZCU102 ZynqMP board. <https://www.xilinx.com/products/boards-and-kits/ek-u1-zcu102-g.html>`_
53The reference for setting up a SD card and obtaining pre-built boot images is
54`here. <https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18841858/Board+bring+up+using+pre-built+images>`_
55
56Hardware Setup
57^^^^^^^^^^^^^^
58
59Set the dip switch SW6 according to the table below. This will allow the board
60to boot from the SD card. Connect a Micro-USB cable to the USB UART interface
61J83. This is a quad USB UART interface which will show up on the development
62host computer as four different serial or tty devices. Use the first channel
63for the console UART. It should be set to 115k baud.
64
65+---------------------------+
66| Dip Switch JW6            |
67+------+------+------+------+
68|  ON  |  OFF |  OFF |  OFF |
69+------+------+------+------+
70
71Prepare a SD card with a bootable partition
72^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
73
74The goal is to have a bootable SD card with a partition that is formatted with
75the FAT file system. The file system will contain the boot artifacts including
76BOOT.bin and the u-boot image. The RTEMS image will be placed on this volume. To
77create the bootable SD card, follow the directions
78`here. <https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842385/How+to+format+SD+card+for+SD+boot>`_
79
80Once you have the card formatted correctly, you need to place the files from
81`this archive <https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/2202763266/2021.2+Release#Downloads>`_
82on the FAT partition. The following file was used for this example:
83`xilinx-vck190-v2021.2-final.bsp <https://www.xilinx.com/member/forms/download/xef.html?filename=xilinx-vck190-v2021.2-final.bsp>`_
84
85In order to download these files, you need to have a Xilinx account login. As an
86alternative, you can download a bootable image for Ubuntu 20.04 and write it to
87an SD card using a utility such as `Balena Etcher <https://www.balena.io/etcher>`_
88or dd. The Ubuntu image is available `here. <https://ubuntu.com/download/xilinx>`_
89Download the image for the Zynq Ultrascale+ MPSoC Development boards, uncompress
90it and write it to the SD card. This image creates multiple partitions, but we
91only need to use the FAT partition with the boot artifacts on it.
92
93Verify that the board can boot from the SD card
94^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
95
96It is worth booting the board from the SD card before trying to boot RTEMS.
97Insert the card and power on the board. You should see the messages on the first
98console indicating the various boot loader stages and eventually the Linux
99kernel. The goal is to interrupt u-boot when given the chance to access the
100u-boot command prompt.
101
102Build RTEMS with examples
103^^^^^^^^^^^^^^^^^^^^^^^^^
104
105Build the RTEMS `xilinx-zynqmp-lp64-zu3eg` BSP. Use the ticker.exe sample which
106can be found in the directory:
107
108.. code-block:: shell
109
110  build/aarch64/xilinx-zynqmp-lp64-zu3eg/testsuites/samples
111
112Prepare the RTEMS image
113^^^^^^^^^^^^^^^^^^^^^^^
114
115Prepare your RTEMS image to boot from u-boot with the following commands:
116
117.. code-block:: shell
118
119  $ aarch64-rtems6-objcopy -Obinary ticker.exe ticker.bin
120  $ gzip -9 ticker.bin
121  $ mkimage -A arm64 -O rtems -T kernel -a 0x10000000 -e 0x10000000 -n RTEMS -d ticker.bin.gz rtems.img
122
123Boot the RTEMS image
124^^^^^^^^^^^^^^^^^^^^
125Copy the prepared RTEMS image to the SD card and insert the SD crd in the ZCU102
126board. Power on the board. When you see the prompt on the console to interupt
127u-boot, hit a key to bring up the u-boot command prompt. On the u-boot command
128prompt you can boot your RTEMS image:
129
130.. code-block:: shell
131
132  Zynq-MP> fatload mmc 0:1 0x1000 rtems.img
133  Zynq-MP> bootm 0x1000
134
135This is the entire boot sequence:
136
137.. code-block:: shell
138
139  Pre-FSBL boot Started
140  Xilinx Zynq MP First Stage Boot Loader
141  Release 2020.2   Nov 18 2020  -  11:46:01
142  NOTICE:  ATF running on XCZU9EG/silicon v1/RTL5.1 at 0xfffea000
143  NOTICE:  BL31: v2.2(release):xilinx_rebase_v2.2_2020.1-10-ge6eea88b1
144  NOTICE:  BL31: Built : 12:28:45, Nov 17 2020
145
146  U-Boot 2020.01 (Jun 15 2021 - 14:24:32 +0000)
147
148  Model: ZynqMP ZCU102 Rev1.0
149  Board: Xilinx ZynqMP
150  DRAM:  4 GiB
151  PMUFW:  v1.1
152  EL Level:       EL2
153  Chip ID:        zu9eg
154  NAND:  0 MiB
155  MMC:   mmc@ff170000: 0
156  In:    serial@ff000000
157  Out:   serial@ff000000
158  Err:   serial@ff000000
159  Bootmode: SD_MODE1
160  Reset reason:   SOFT
161  Net:
162  ZYNQ GEM: ff0e0000, mdio bus ff0e0000, phyaddr 12, interface rgmii-id
163
164  Warning: ethernet@ff0e0000 (eth0) using random MAC address - 82:32:1d:80:d9:c9
165  eth0: ethernet@ff0e0000
166  Hit any key to stop autoboot:  0
167
168  ZynqMP> fatload mmc 0:1 0x1000 rtems.img
169  46669 bytes read in 27 ms (1.6 MiB/s)
170  ZynqMP> bootm 0x1000
171  ## Booting kernel from Legacy Image at 00001000 ...
172     Image Name:   RTEMS
173     Image Type:   AArch64 RTEMS Kernel Image (gzip compressed)
174     Data Size:    46605 Bytes = 45.5 KiB
175     Load Address: 10000000
176     Entry Point:  10000000
177     Verifying Checksum ... OK
178     Uncompressing Kernel Image
179  ## Transferring control to RTEMS (at address 10000000) ...
180
181  *** BEGIN OF TEST CLOCK TICK ***
182  *** TEST VERSION: 6.0.0.f381e9bab29278e4434b1a93e70d17a7562dc64c
183  *** TEST STATE: EXPECTED_PASS
184  *** TEST BUILD: RTEMS_POSIX_API RTEMS_SMP
185  *** TEST TOOLS: 10.3.1 20210409 (RTEMS 6, RSB ad54d1dd3cf8249d9d39deb1dd28b2f294df062d, Newlib eb03ac1)
186  TA1  - rtems_clock_get_tod - 09:00:00   12/31/1988
187  TA2  - rtems_clock_get_tod - 09:00:00   12/31/1988
188  TA3  - rtems_clock_get_tod - 09:00:00   12/31/1988
189  TA1  - rtems_clock_get_tod - 09:00:05   12/31/1988
190  TA2  - rtems_clock_get_tod - 09:00:10   12/31/1988
191  TA1  - rtems_clock_get_tod - 09:00:10   12/31/1988
192  TA1  - rtems_clock_get_tod - 09:00:15   12/31/1988
193  TA3  - rtems_clock_get_tod - 09:00:15   12/31/1988
194  TA2  - rtems_clock_get_tod - 09:00:20   12/31/1988
195  TA1  - rtems_clock_get_tod - 09:00:20   12/31/1988
196  TA1  - rtems_clock_get_tod - 09:00:25   12/31/1988
197  TA2  - rtems_clock_get_tod - 09:00:30   12/31/1988
198  TA1  - rtems_clock_get_tod - 09:00:30   12/31/1988
199  TA3  - rtems_clock_get_tod - 09:00:30   12/31/1988
200
201  *** END OF TEST CLOCK TICK ***
202
203  [ RTEMS shutdown ]
204
205
206Follow up
207^^^^^^^^^
208
209This is just one possible way to boot the RTEMS image. For a development
210environment you may wish to configure u-boot to boot the RTEMS image from a TFTP
211server. For a production environment, you may wish to download, configure, and
212build u-boot, or develop a BOOT.BIN image with the RTEMS application.
213
214Clock Driver
215------------
216
217The clock driver uses the `ARM Generic Timer`.
218
219Console Driver
220--------------
221
222The console driver supports the default Qemu emulated ARM PL011 PrimeCell UART
223as well as the physical ARM PL011 PrimeCell UART in the ZynqMP hardware.
224
225SDHCI Driver
226------------
227
228The ZynqMP bsp has an SDHCI driver which allows reading to and writing from SD
229cards. These can be tested in qemu using the "-sd" option. For example:
230
231.. code-block:: shell
232
233  qemu-system-aarch64 -no-reboot -nographic -serial mon:stdio \
234   -machine xlnx-zcu102 -m 4096 -kernel media01.exe -sd example.img
235
236The SD card image should have an MSDOS partition table with a single partition
237containing a FAT file system.
238
239Network Configuration
240---------------------
241
242When used with LibBSD, these BSP variants support networking via the four
243Cadence GEM instances present on all ZynqMP hardware variants. All interfaces
244are enabled by default, but only interfaces with operational MII busses will be
245recognized and usable in RTEMS. Most ZynqMP dev boards use CGEM3.
246
247When used with lwIP from the rtems-lwip integration repository, these BSP
248variants support networking via CGEM0 and one of the other CGEM* instances
249simultaneously. This is a limitation of the Xilinx driver, specifically
250in code referring directly to XPAR_XEMACPS_0_BASEADDR. Attempting to use more
251than two interfaces simultaneously may cause unexpected behavior. Attempting to
252use a set of two interfaces that does not include CGEM0 may cause unexpected
253behavior.
254
255The interfaces will not come up by default under lwIP and must be configured
256manually. There are examples of this in the start_networking() implementation
257in netstart.c as used by the network tests.
258
259Running Executables on QEMU
260---------------------------
261
262Executables generated by these BSPs can be run using the following command:
263
264.. code-block:: shell
265
266  qemu-system-aarch64 -no-reboot -nographic -serial mon:stdio \
267   -machine xlnx-zcu102 -m 4096 -kernel example.exe
Note: See TracBrowser for help on using the repository browser.