xapp
xapp
© Copyright 2013 Xilinx, Inc. Xilinx, the Xilinx logo, Artix, ISE, Kintex, Spartan, Virtex, Vivado, Zynq, and other designated brands included herein are trademarks of Xilinx in the
United States and other countries. All other trademarks are the property of their respective owners.
Hardware Requirements
• Xilinx ZC702 Development Board
• Ethernet Cable
• USB UART Cable
Introduction The Zynq-7000 AP SOC devices takes advantage of the on-chip CPU to facilitate configuration.
Initial device configuration of the processing system (PS) and the programmable logic (PL)
must take place through the PS when not using JTAG.
Two major blocks control the configuration:
• The first is the BootROM which is a static block of memory that is executed by the
multiprocessor core after power-on reset and warm reset.
• The second major block is the device configuration unit which controls JTAG debug
access and provides an interface to the AES, HMAC, and PCAP blocks for PL
configuration and data decryption.
Both the PS and PL can be configured under PS control either securely or non-securely.
Configuration under external host control is also possible using JTAG.
Unlike other Xilinx 7 series devices, Zynq-7000 AP SOC devices do not support initial PL
controlled configuration. Configuration on the Zynq-7000 AP SOC devices is a multi-step
process. The configuration process involves a minimum of two stages, but generally requires
three stages.
The stages are:
• Stage 0: BootROM, page 3: Referred to as the BootROM, this stage controls initial device
startup. The BootROM is non-modifiable code executed by the processor after power-on
reset and warm reset.
• Stage 1: First Stage Bootloader, page 4: This is generally a first stage boot loader (FSBL),
but it can be any user-controlled code. See the Zynq-7000 AP SOC Software Developers
Guide (UG821) [Ref 1] for details about FSBL.
• Stage 2: VxWorks Bootloader, page 4: This is generally user-configurable software that
can act as a second stage boot loader (SSBL). This stage is completely within user
control. In the case of this document, it is part of the VxWorks bootloader.
Figure 1, page 3 illustrates a non-secure boot process for typical Linux system. Uboot is an
example for higher-level boot loader and can be exchanged by VxWorks bootloader.
Stage 0: BootROM
The Zynq-7000 AP SoC processor subsystem configuration starts after power-on reset. The
ARM® CPU starts executing code from the on-chip BootROM with JTAG disabled. The
BootROM contains code for base drivers for NAND, NOR, Quad-SPI, SD, and PCAP. DDR and
other peripheral initializations are not performed from the BootROM and must be done in the
Stage 1 image, First Stage Bootload (FSBL) or later.
For security, the CPU is always the first device out of reset among all master modules within the
PS. When the BootROM is running the JTAG is disabled to ensure security.
The BootROM code is also responsible for loading the FSBL. Zynq-7000 AP SoC architecture
supports multi-stage user boot image loading; any further user boot image loading after FSBL
is the responsibility of the user. When the BootROM releases control to FSBL, user software
assumes full control of entire system. The only way to execute the BootROM again is by
performing a reset.
The PS boot source is selected using the mode-pin signals (indicated by a weak pull-up or
pull-down applied to specific pins), which are sampled after during power-on reset. The
sampled value is stored in the BOOT_MODE register.
The BootROM supports encrypted and unencrypted images referred to as secure boot and
non-secure boot, respectively. Additionally, the BootROM supports beginning execution of the
stage 1 image from OCM after copying the image or executing direct from linear flash (NOR or
QSPI) when using the execute-in-place (XIP) feature.
• In secure boot the CPU, running from secure BootROM code, decrypts and authenticates
the incoming user PS image, stores it in the OCM RAM, and then branches into that RAM.
• In non-secure boot the CPU, running from BootROM code, disables all secure boot
features including the AES engine within the PL before branching to the user image in the
OCM RAM or flash, if XIP is used. The Processor System (PS) boot image is limited to
192 KB unless booting with XIP.
Any subsequent boot stages for either the PS or the PL are the responsibility of the user and
are under user control. The BootROM code is not accessible to the user.
• Following the stage 1 secure boot, you can proceed with either secure or non-secure
subsequent boot stages.
• Following a non-secure first stage boot, only non-secure subsequent stage boots are
possible.
For secure boot decryption and authentication, the PS uses the hard-wired AES-256 and
SHA-256 modules within the PL. For this reason, the PL must be powered up during any secure
boot, even if only the PS is configured. The device encryption key is user-selectable from either
the on-chip eFUSE unit or the on-chip block RAM.
The possible boot sources are: NAND, NOR, SD, Quad-SPI, and JTAG. The first four boot
sources are used in master boot methods in which the CPU loads the external boot image from
nonvolatile memory into the PS.
The VxWorks product installation includes default bootloader images for each installed BSP. If
they do not meet your needs, you can create a custom bootloader.
The Zynq-7000 BSP is a standard part of the 6.9.3.1 install, as shown in Figure 3:
X-Ref Target - Figure 3
3. Because of the asynchronous nature of VxWorks BSPs, verify that you install the latest
Xilinx BSP. The link is provided at [Ref 4].
4. Install the BSP patches as described in the BSP download link: VxWorks 6.9.3.1 BSP
Driver Source Patch for BSP, The link is provided at [Ref 5].
5. Complete all details of the build steps to apply the patch into the source tree.
#define INCLUDE_FS_EVENT_UTIL
#define INCLUDE_ERF
#define INCLUDE_XBD
#define INCLUDE_XBD_BLKDEV
#define INCLUDE_XBD_TRANS
#define INCLUDE_DEVICE_MANAGER
#define INCLUDE_XBD_BLK_DEV
#define INCLUDE_XBD_PART_LIB
#define INCLUDE_DISK_UTIL
This enables the SDHC controller, as well as drivers for the FAT file system.
To use the VxWorks BSP with the Wind River Workbench to create a VxWorks Kernel
Image, do the following:
2. Start the Wind River Workbench tool and select a workspace.
The Wind River SDK opens.
3. In the main context menu select File > New > Project.
The New Project Wizard opens.
4. Under VxWorks 6.x, select the VxWorks Image Project, as shown in Figure 4.
X-Ref Target - Figure 4
8. Click Finish.
9. Open the Kernel configuration. Change the configuration to include the symbol table in the
Kernel image (Figure 7, page 10).
2. When the project build is complete, start a Wind River VxWorks development shell.
Use this shell to build a bootROM binary. The bootROM binary is the VxWorks bootloader
(similar to Uboot); it is not within the Zynq-7000 device ROM.
3. Within the shell, type:
cd ..\<install_dir>\Wind
River\vxworks-6.9\target\config\xlnx_zynq7k\
make clean make bootROM
The commands generate a file with the name bootROM. Rename the file to bootROM.elf
4. Create a boot.bif and a zynq_fsbl_0.elf file, with the following format:
ZC702_bif_for_VxWorks:
{
[bootloader]zynq_fsbl_0.elf
bootROM.elf
}
5. Copy the bootROM.elf, zynq_fsbl_0.elf, and the boot.bif file to the /bootgen
directory.
Alternatively, you can copy the bootgen.exe tool to the current installation directory.
C:\<install_dir>\Wind
River\vxworks-6.9\target\config\xlnx_zynq7k\
4. Start an FTP server. You can use the server delivered with the Wind River tool chain.
If you use the Wind River FTP server, select Security > User/rights.
5. Click New User and type a name; for example, Zynq and a password.
6. Type the home directory of the VxWorks image, then click Done.
7. Switch on the board.
8. Stop the Autoboot process by pressing Return.
The VxWorks bootROM prompt opens.
9. At the boot prompt, type c then press Return to start the boot configuration.
10. Type gem0 to change boot device then press Return until you reach File Name.
11. Type VxWorks, then press Return until you reach inet on ethernet (e).
12. Change the inet on ethernet (e) to IP address 192.168.1.2:0xffffff00, then press Return
until you reach host inet (h).
13. Change host inet (h) IP address 192.169.1.1, then press Return until you reach user.
14. Type the user name you choose for the server then press Return until you reach
password (pw).
15. Type password you choose for the server, then press Return until you reach
other (o).
21. If no entry exists, type gem0, then press Return.
The boot prompt opens.
22. Type @ to start the boot process.
VxWorks boots from the image using the terminal (Figure 12, page 16).
2. Click Next and enter a project name; for example, hello_world, (Figure 14, page 18), then
press Finish.
7. Select Build Options > Set Active Build Spec > ARMARCH7<gnu|diab>.
A message opens that asks if you want to set the active build spec to
ARMARCH7<gnu|diab> (Figure 16).
X-Ref Target - Figure 16
8. Select YES.
9. Build the project. A message opens.
10. Click Continue.
11. In the bottom-left corner of the Wind River Workbench, go to Remote Systems.
12. In the window, right-click and select New > Connection.
13. Select Wind River VxWorks 6.x Target Server Connection, and click Next.
14. Type the target IP address of 192.168.1.2, and the path to the kernel image (in this case
type: \..\<project_name>\default). Click Finish.
15. Right-click the new connection, and click Connect.
16. In the Project Explorer window, right-click Build Targets, then select Debug VxWorks
Kernel Task.
14. The Debug Configuration window opens, as shown in Figure 17, page 20.
17. From General > Entry, type hello to locate the hello world project.
Alternatively, you can use the Browse button to find the hello world project.
18. Click Debug.
The terminal window that is connected to the board issue the following message:
>> Break at 0x0144accc: hello +0x4 Task: 0x14cdfc0 (Hello)
Note: The message can differ slightly from yours as it depends on your Kernel settings. It just gives
you the hint that a task was downloaded and stopped for debug.
19. In the debug window, click the Run button.
The terminal window displays: Hello Wind River.
20. Type i to see the tasks in the VxWorks task list.
21. Type repeat 10,hello to repeat the task 10 times.
Accessing a In the ARM® Cortex™ A9 processor, every peripheral is memory mapped. The address map for
Peripheral in the Zynq-7000 AP SoC processor, for example, is listed in the Zynq-7000 AP SoC Technical
Reference Manual (UG585) [Ref 2].
the Processing
System
Modifying the Hello World Application
Modify the "Hello World" application to access the GPIO peripheral. On the ZC702 board, MIO
pin 10 is connected to an LED (DS12).
From the Zynq-7000 AP SoC Technical Reference Manual, (UG585) [Ref 6], you see that the
base address of the GPIO peripheral is 0XE000A000. To access pin 10 as an output, you must
configure this peripheral first:
1. Set the direction to output by writing a 1 to bit 10 of the gpio.DIRM_0 register.
2. Enable the output by writing a 1 to bit 10 of the gpio.OEN_0 register.
3. Write to bit 10 of the gpio.DATA_0 register to control the LED.
The updated source code of the hello world application now looks like the following:
#include <stdio.h>
#include <sys/mman.h>
int main(void)
{
printf("Hello World!\n");
while (1) {
sysOutLong(GPIO_BASE + GPIO_DATA_0, val);
sleep(1);
val ^= 0xffffffff;
}
return 0;
}
4. Save this file, then build and debug this application following steps 9 to 19 of the previous
section. The result is that the LED toggles every second.
Accessing a Accessing a peripheral in the Programmable Logic is very similar to accessing a peripheral in
Peripheral in the processing system: both master GP AXI interfaces have an address space of 1GB, as can
be seen in the Address Map table in the Zynq-7000 AP SoC Technical Reference Manual
the (UG585) [Ref 6]. The differences are:
Programmable • You must first program the PL with a BIT file containing the AXI_GPIO peripheral.
Logic • You must modify the VxWorks BSP to allow access to the address range that you
configured for that peripheral.
The design created for this section contains an AXI_GPIO peripheral connected to the
M_AXI_GP0 port of the PS.
The four GPIO pins of the AXI_GPIO peripheral are connected to the DS15 to DS18 LEDs on
the ZC702 board.
The Address Editor shows the base address where this peripheral is mapped, as shown in
Figure 19.
X-Ref Target - Figure 19
After implementing this design, you generate a new FSBL, and use this FSBL, together
with the generated BIT file, to create a new boot.bin file to download to the SD card.
5. Follow the same steps as you used but use a slightly modified boot.bif file, as follows:
//ZC702_bif_for_VxWorks:
{
[bootloader]fsbl.elf
bitfile.bit
bootROM.elf
}
Where:
- fsbl.elf is the new FSBL.
- bitfile.bit is the BIT created by the hardware design.
This produces a new boot.bin file to boot the ZC702 board.
6. To access the peripheral from within a VxWorks kernel module, first modify the BSP.
The default configuration of the VxWorks BSP configures the MMU to allow access to a
limited set of addresses, listed in the documentation of the BSP.
3. In the syslib.c file, scroll down to line 109, find the struct containing the MMU
configuration.
For example, on line 225, find the mapping for the GPIO peripheral used in the previous
example:
{
ZYNQ7K_GPIO_BASE,/* Zynq-7000 gpio */ ZYNQ7K_GPIO_BASE,
PAGE_SIZE,
MMU_ATTR_VALID_MSK | MMU_ATTR_PROT_MSK |
MMU_ATTR_DEVICE_SHARED_MSK,
MMU_ATTR_VALID |MMU_ATTR_SUP_RWX|
MMU_ATTR_DEVICE_SHARED
},
4. Add the mapping for the AXI_GPIO peripheral by adding the following line:
{
0x41200000,/* My AXI gpio */
0x41200000, PAGE_SIZE,
MMU_ATTR_VALID_MSK | MMU_ATTR_PROT_MSK |
MMU_ATTR_DEVICE_SHARED_MSK,
MMU_ATTR_VALID| MMU_ATTR_SUP_RWX|
MMU_ATTR_DEVICE_SHARED
},
5. Save the file, and rebuild the VxWorks project.
6. Use this VxWorks image, and either:
- Put the image on the SD card to boot from SD, or
- When fetching the VxWorks image over FTP, boot the board with the updated
boot.bin file.
7. After booting the ZC702 board with this SD card, the FSBL configures the PL before
launching the VxWorks BootROM.
The BootROM then loads the updated VxWorks image.
printf("Hello World!\n");
int val = 0;
sysOutLong(AXI_GPIO_BASE + AXI_GPIO_TRI, 0);
while (1) {
Conclusion This application note has provided step-by-step instructions for running the VxWorks 6.9.3.1
BSP on the Zynq-7000 SoC All Programmable device platform, and additionally provided an
overview of the boot process for the Zynq-7000 AP SoC platform.
You now know the steps for using VxWorks RTOS on the Zynq-7000 AP SoC platform.
Additional The following links are to additional resources referenced in this document:
Resources 1. Zynq-7000 AP SOC - Concepts, Tools and Techniques User Guide (UG837)
2. Zynq-7000 All Programmable SoC Software Developers Guide (UG821)
3. Zynq-7000 AP SoC Technical Reference Manual, (UG585)
4. Xilinx BSP: gppve_6_9_xlnx_zynq7k_6_9_2:
https://portal.windriver.com/cgi-bin/windsurf/bsp/infoBSP.cgi?id=12020
5. VxWorks 6.9.3.1 BSP Driver Source Patch:
https://support.windriver.com/olsPortal/faces/maintenance/downloadDetails.jspx?contentId=041654
6. VxWorks 6.9.3.1 USB L2 Cache Source Patch:
https://support.windriver.com/olsPortal/faces/maintenance/downloadDetails.jspx?contentId=041575
Revision The following table shows the revision history for this document.
History
Date Version Description of Revisions
09/27/2013 1.0 Initial Xilinx release.
Notice of The information disclosed to you hereunder (the “Materials”) is provided solely for the selection and use of
Xilinx products. To the maximum extent permitted by applicable law: (1) Materials are made available "AS
Disclaimer IS" and with all faults, Xilinx hereby DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS,
IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and (2)
Xilinx shall not be liable (whether in contract or tort, including negligence, or under any other theory of
liability) for any loss or damage of any kind or nature related to, arising under, or in connection with, the
Materials (including your use of the Materials), including for any direct, indirect, special, incidental, or
consequential loss or damage (including loss of data, profits, goodwill, or any type of loss or damage
suffered as a result of any action brought by a third party) even if such damage or loss was reasonably
foreseeable or Xilinx had been advised of the possibility of the same. Xilinx assumes no obligation to
correct any errors contained in the Materials or to notify you of updates to the Materials or to product
specifications. You may not reproduce, modify, distribute, or publicly display the Materials without prior
written consent. Certain products are subject to the terms and conditions of the Limited Warranties which
can be viewed at http://www.xilinx.com/warranty.htm; IP cores may be subject to warranty and support
terms contained in a license issued to you by Xilinx. Xilinx products are not designed or intended to be
fail-safe or for use in any application requiring fail-safe performance; you assume sole risk and liability for
use of Xilinx products in Critical Applications: http://www.xilinx.com/warranty.htm#critapps.