Getting started with IAR Embedded Workbench and Xilinx Zynq 7000

Getting started guide

This guide familiarizes you with IAR Embedded Workbench for Arm and how to get started with it using a Zynq-7000 Xilinx Demonstration Kit ZC-702.

This is the first step in understanding how to develop complete programs with IAR Embedded Workbench for Arm. In this guide, you will get a quick insight in how to build and run a dual-core program on Xilinx Zynq 7000. Xilinx Zynq 7000 is equipped with dualcore Arm Cortex-A9 processors. The guide will go through the following steps:

  • Generate a project
  • Power up the board and prepare an example project
  • Set up multicore debugging
  • Run an example program

For this project, you need an Xilinx Zynq-7000 ZC-702 evaluation kit.

Generate a project

  1. Create a new folder and name it, for example Training Lab. Then, start IAR Embedded Workbench for Arm. Once the toolchain is running, you will notice that the Information Center is displayed. From the Information Center, you can view the example workspaces for your board. To begin this project, you will start from an example project made for the ZC702 evaluation board.

  2. Select the Example Projects icon and scroll down to the bottom and you should see the selection for Xilinx:
  3. Click on the download button and select Download from IAR Systems

  4. Scroll up and see that you have example programs from Xilinx installed. Click on the green button to go to the Xilinx examples and then click the green button on the Zynq 7020 project and finally click on the Open Project button.

  5. You will be asked where you would like to store your project. Navigate into your newly-made folder and click Choose. You now have a project with a main.c file and a cstartup.s file. Double click the main.c file to open it:

  6. Now, build the project by clicking the Make icon or by selecting Project->Make. The project should build without errors and remove the red dots next to the source files in the Project Explorer window.

Next step is to download and run the project, but first you will need to set up the board.

Power up the board and prepare example project

The project you are about to load will execute from the on-chip RAM on the Zynq 7020. Because of this, there is no concern about erasing the demonstration programs delivered with the ZC-702 evaluation kit.

  1. Connect the debug probe I-jet to the board via the JTAG debug connector J58. This connector is a 20 pin Arm-20 connector and you should use the Arm-20 to MIPI-20 adapter block included with I-jet to make this connection. Plug the USB cable from the probe into your PC to power it up.

  2. Connect the Power adapter included with the ZC-702 evaluation kit to the power input connector J60, with the power switch SW11 in the off position away from the power connector.

  3. Power up the board by moving the power switch SW11 to the up or on position.

Get to know the example project

The Example Project for the Xilinx Zynq 7020 is a simple multicore project which starts up the chip, recognizes both Arm Cortex-A9 CPU cores on chip and starts a task on each core. The code which runs on each core is the same. However, the startup code recognizes which core it is running on and only initializes one core based on its ID. The program on core 0 continues on to its main() function, while the program on core 1 waits for the task on core 0 to set a variable before proceeding on to the main() entry point in its program.

  1. When the debugger is started, the chip will be prepared to start execution on the first line in the cstartup.s assembly language program. The debugger will be focused on one core at a time and when it first starts the debugger that will be core 0.

  2. Download the program to your board and start the debugger by clicking the green Download and Debug icon or by entering Project->Download and Debug from the menu.

Set up multicore debugging

When your program is downloaded the debugger will start and make some controls available. The screen should look something like this:

The program is now loaded and ready to start the execution at the entry point of cstartup.s. The first few lines of code set up the interrupt vector table in the on-chip RAM, and then it clears a variable to 0. This is the variable that the second core will check to wait to start, and the first core will write with a value in its task to release the second core to run. Note that since both cores run this startup code and set the semaphore to 0, it does not matter which core starts first.

Additional icons in the toolbar

Now, there are some additional icons on the toolbar related to multicore debugging:

The two squares, in this case both Red, are status indicators for the two cores. The left icon is a deep red. The deep color indicates that this is the current focus core, in this case core 0.  The Red color indicates that this core is currently stopped and not executing. The next square is a light Red. The light color indicates that this core, in this case core 1, is not the current focus core. However, its state is also indicated by its color Red so it is also stopped. Clicking the second core’s icon will cause it to be highlighted and change the debugger’s focus from core 0 to core 1:
The next icon buttons control the execution of the two cores.  The first button will start execution of both cores. 
The following button will halt execution on both cores.
The last icon is a pulldown menu which allows you to select the behavior of the Run, Step and Stop buttons in the main execution control field on the toolbar. These can be set either to affect only the core in focus, or to effect both cores together.
In addition a core status window can be openend by selecting View->cores:

Run an example program

First, make sure that you are focused on core 0, and the execution control is set to have Run, Stop and Step affect the current core only.

  1. Click the single step over button to run through the initial code.

  2. Open a register window to see the values changing:
  3. Set a breakpoint on the first executable line in the main() function:
  4. Select the Run button on the toolbar and note that the program executes and stops before execution of the first line in main() where you set the breakpoint:

Up until now only core 0 has been executing code. It has run through the startup functions and successfully jumped to the initial line of code in the main() function.

Now, change the focus to core 1:

  1. Click the core 1 button in the toolbar.

  2. Note that the source code window has switched back to the first line of the startup code.
  3. This is where the second core is ready to execute since it has not yet run any code

  4. Now, you can now step through the startup code on core 1. Note that this time the code recognizes that it is running on core 1 and jumps to the core1_setup label instead of the core0_setup label.
    If you continue to step through the initialization you will see that this processor remains in a loop waiting for the core 0 processor to change the semaphore variable.
  5. Switch focus back to core 0, step one instruction to write the semaphore flag and switch back to core 1.

  6. Now, when you continue to step through the wait loop on core 1, it will exit the loop and branch to the main() entry point.
  7. Step a couple of more times and you will see that you are in the main() routine:
  8. Now, you can experiment with the programs running on both cores. Switch back and forth and see how core 0 jumps to the task for core 0 while core 1 jumps to its correct task.

You can extend this startup project to make the tasks for core 0 and 1 into complete independent programs which will start up and execute on the two cores.

© IAR Systems 1995-2018 - All rights reserved.

We use cookies on this website to provide you with a better experience. You need to accept cookies to continue using this site. Cookies