UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

Adam Taylor’s MicroZed Chronicles Part 151: ZynqBerry & SDSoC

by Xilinx Employee ‎10-10-2016 10:12 AM - edited ‎10-11-2016 05:46 PM (10,976 Views)

 

By Adam Taylor

 

(Note: This is a re-written and improved version of the original blog post that appeared on October 10.)

 

 

We are currently looking at Trenz Electronic’s ZynqBerry, which is intended for the maker end of the market. With this blog, I am going to go right back to the beginning to demonstrate how we can create a “hello world” program for this board. However, I want to do this with a twist. I want to use SDSoC to create the “hello world” program. SDSoC allows people not familiar with FPGA design to benefit from the Zynq SoC’s PL (programmable logic) performance without the need to be FPGA experts.

 

The first thing we need to do is create an SDSoC platform. The platform tells SDSoC what resources are available to it within the Zynq SoC and it configures the processor in terms of peripherals and memory addresses.

 

To get started, we need to download the demo SDSoC application from the Trenz Wiki. I downloaded the file including the pre-built directory. With the Zip file downloaded, I extracted the files to a directory (note make sure to use a shorter name for the extraction to ensure that the provided TCL scripts run properly). The directory contains a number of folders and batch files and looks like this:

 

 

Image 1.jpg 

 

 

The first step in creating a platform is to define the hardware side of it. We start this by running the following scripts:

 

  • Run design_basic_settings.cmd
  • Run Vivado_create_project_guimode.cmd

 

To define an SDSoC Platform, we need to define both the software and hardware environments. Two XML files provide these definitions. One XML file describes the hardware (clocks, AXI Ports, and available interrupts) and the other file defines the software libraries.

 

To define the hardware platform, we need to use the Xilinx Vivado HL Design Suite. Hence the need to create the project using the cmd files. Trenz provides all of the information we need to define the software under the settings/SDSOC folder in an XML file called sdsoc_sw.pfm.

 

With the project open in Vivado, we need to run a few provided scripts using the TCL command line. Enter and execute the following.

 

 

  • TE::ADV::beta_util_sdsoc_project -check_only
  • TE::ADV::beta_util_sdsoc_project

 

These commands create a new SDSoC folder in the directory’s top level. Under the SDSoC directory, you will see another directory with the project name; in this case it’s te0726_m_sdsoc. You will now find within this directory all of the files we need to create an SDSoC Platform.

 

 

Image 2.jpg 

 

Resultant SDSoC folder

 

 

Now it’s time to co-locate the files in a directory so that we can use it within SDSoC. For this example, because the platform is very simple and hence very flexible, I am going to create a generic platform within the SDSoC installation. This way we can reuse it for different projects on the same platform. The catch with this is we cannot easily see the provided demo applications. I will address that next time.

 

We can define a new SDSoC platform by moving the directory te0726_m_sdoc and its contents that we just created in Vivado under our <SDSOC Installation Path>/platforms/ as shown below.

 

 

Image 3.jpg 

 

With this complete, we are now ready to create our first application. For those who want to skip these steps and use the predefined SDSoC platform that I have created, you can download the zip file from my Github. Just unzip the file into your SDSoC platforms directory.

 

Now, when we fire up SDSoC we will be able to create an application running on our newly defined ZynqBerry platform.

 

Selecting file new -> SDSOC application will bring up the dialog box shown below. From the platform box, we should be able to select the platform that we just created. As this is just our first example, we will stick to using the bare metal OS.

 

 

Image 4.jpg

 

 

One we’ve created the project, you will see a project overview that defines the platform. We can use this overview to select the functions we want to accelerate.

 

 

Image 5.jpg

 

 

For now, we will write a simple program that loops “hello world.”

 

Create a C file under the source and add the code shown below (again you can download this from the GitHub if you want):

 

 

Image 6.jpg

 

The final step is to generate the boot files. To do this click on project-> build project. This may take a few minutes. The resulting programming files will be located under the SD Card directory within the debug or release folders (depending upon what you set in the SDSoC project overview) within your project.

 

This is where the ZynqBerry configuration is a little different compared to approaches that we have used before. The ZynqBerry uses the Zynq Z-7010 SoC in the CLG225 footprint. In this package, it is not possible to boot directly from the SD Card. The ZynqBerry addresses this by using a QSPI Flash device that contains the FSBL (first-stage boot loader) bit file and, if you’re using Linux, a second-stage boot loader like U-Boot while the application, OS, and the Linux file system sit on the SD Card, which is accessed by the either the FSBL or the second-stage boot loader.

 

This means that for our example, we need to use the Flash programmer to program the boot.bin file onto the QSPI Flash memory. We cannot do this within SDSoC. However we can use the Xilinx SDK in Vivado to do this. We need to use a hardware definition that’s available under the prebuilt\hardware\te0726_m directory.

 

We can import this definition within SDK using file-> new -> other and selecting hardware platform specification in the dialog box:

 

 

 

Image 7.jpg 

 

 

Image 8.jpg 

 

We want to select the HDF file, which is the hardware definition file. Clicking on finish will import this file into the workspace.

 

From the Xilinx tools option within SDK, select program flash and ensure that the ZynqBerry is connected over the micro USB port:

 

 

Image 9.jpg 

 

 

For the image file, browse to the boot.bin file created by the SDSoc build. While you’re burning this file into the QSPI Flash memory, copy the other bin file (named <project>.elf.bin) to the SD Card.

 

Once the Flash programming is complete, turn off the ZynqBerry and insert the SD Card before repowering it. When I did this for the application in hand, my terminal window showed the following:

 

 

Image 10.jpg 

 

We now have a simple SDSoC platform that we can use with the ZynqBerry board, although we do need to re-program the QSPI Flash memory and the SD Card for each new application.

 

 

 

Code is available on Github as always.

 

If you want E book or hardback versions of previous MicroZed chronicle blogs, you can get them below.

 

 

 

  • First Year E Book here
  • First Year Hardback here.

 

 

Image 10.jpg 

 

 

 

  • Second Year E Book here
  • Second Year Hardback here

 

 

 

Image 12.jpg 

 

 

 

All of Adam Taylor’s MicroZed Chronicles are cataloged here.

 

 

 

 

 

 

Labels
About the Author
  • Be sure to join the Xilinx LinkedIn group to get an update for every new Xcell Daily post! ******************** Steve Leibson is the Director of Strategic Marketing and Business Planning at Xilinx. He started as a system design engineer at HP in the early days of desktop computing, then switched to EDA at Cadnetix, and subsequently became a technical editor for EDN Magazine. He's served as Editor in Chief of EDN Magazine, Embedded Developers Journal, and Microprocessor Report. He has extensive experience in computing, microprocessors, microcontrollers, embedded systems design, design IP, EDA, and programmable logic.