Monday, March 7, 2016

Assembly Code from the Zynq 'C' Code

Introduction


For those who made the first steps in microprocessor's programming using assembly language, still today is nice to see what is assembly code generated from the 'C' code. On the other hand, sometimes it's necessary to write a specific very high speed routine using assembly language. 
The SDK tool in the Vivado (Xilinx) development suite, has a command line that execute a utility that generates the assembly code from the written 'C' code. 

Use of the Xilinx Microprocessor Debugger (XMD) Engine


The XMD is a tool that facilitates debugging programs and verifying systems using the Dual ARM Cortex-A9 (as well as the MicroBlaze and Power PC).
The SDK provides what is called an XMD console, where it is posible to type an XMD command using a Tool Command Language (Tcl) kind of language. 
The XMD console can be open in two different ways: 
  1. When the Debug perspective is activated, the XMD console is automatically open. 
  2. In the C/C++ perspective, do Xilinx Tool -> XMD Console.
An screenshot of the XMD console (in the Debug perspective)  is shows below. 


The XMD console is an standard Tcl console, where it is possible to run any available Tcl commands. The command should be typed following the XMD% prompt. 
Note: there is a more complete (and newer) tool that replaces XMD in some aspects: the Xilinx System Debugger Command-line Interface (XSDB). SDK also provides an XSDB console (this will be explained in a short future). However, there are some commands that are exclusively executed in the XMD console, such as the command we will see next. 

So, getting back to the point of this post, to be able to see the assembly language (and even the machine code) generated from the 'C' code, the XMD command line to type the following: 

arm-xilinx-eabi-objdump -S <complete_path_of_my_project_name>.elf

Here is the complete XMD command typed in the XMD console, no executed yet (note the doble back slash symbol):


The result of this XMD command it shows below, along with titles explaining each part of the file: 


If you browse the resultant file, you will see that is a huge file. But, it's easy to follow if you have some experience in assembly language. 

So, I hope you like this post, moreover, I hope it's somehow useful ! ...

Wednesday, March 2, 2016

Error (in some versions): "undefined reference to Xil_ICacheDisable"

Introduction

This problem happened to me more than a year ago, and I've been asked about it for several other colleagues, so I post it now.... l 
Trying of doing the simplest project ever in Vivado, using the ZedBaord, I run into a problem that made me feel very bad.... 
How can I get 10 error messages ? !? !?  from the 'Hello World' project !

Finding the Problem 

So, I followed all the steps that many of the on-line tutorials explains to build the hardware for the 'Hello World' project... here is my design: 


I did the necessary steps in Vivado to open the SDK environment. Then in the SDK, I created a new Application Project based in the Hello World template. 
When I executed Build Project for the simple Hello World project, I got the following errors: 


I did a search in the web, nothing related came out. So, I investigated on my side and I found out that there is a kind of 'bug' for this version of the Vivado, 2015.1, that even though the DDR interface is not configured in the hardware, it is generated incompletely in the software. 

Thinking on this simple project, there is no need for using the external DDR available in the ZedBoard. Therefore, there is no need for enabling the DDR controller from the Zynq configuration window. However, solve the problem that generates the error messages you do need to enable the DDR interface even though you don't do any read/write to the DDR. 
Important Note: other versions of Vivado do not generate these errors. 

Once you enable the DDR interface in the Vivado environment and go back to the SDK, create a new Hello World application project and then execute a Build Project.... no errors should be generated this time...