Zynq App Debug

This page outlines the process of creating a "hello world" application and debugging it with gdb command line.

Table of Contents

Task Dependencies (Pre-requisites)

This page assumes that a qemu environment is setup (root filesystem, compiled kernel, installed qemu). It also assumes that a copy of the Xilinx Code Sourcery Toolchain is installed and added to the PATH.

Tools Required

  • Xilinx SDK

Input Files Required

  • Application code

Output Files Produced

  • None

Task Description

Writing Hello World

Create a file named "hello.c" containing the following:

Compiling the application

Compile the application using the Xilinx CodeSourcery ARM cross compiler with the following command:

Copying files to the Virtual Target

To copy files to the target use ftp. When running QEMU make sure that the ftp port is redirected to an open port on the host machine. Make sure the QEMU command line includes "-redir tcp:10021::21" for example.

There are multiple tools that can be used to upload a file.

If the host machine has curl installed simply issuing the following command will upload the file to the root folder. Before running the command below make sure the environment variables HTTP_PROXY, FTP_PROXY, http_proxy, and ftp_proxy are not set.
If curl is not available a safe fallback is to use the standard ftp command. The steps to upload with ftp are as follows:
Keep in mind that when the target is shutdown any changes to the root filesystem will be lost since this is a RAM based filesystem.

Running the first application

Now that the compiled application has been uploaded to the target via ftp, the permissions need to be fixed with chmod. Run the following commands:
With the permissions set properly the application can be run simply with:

Debugging the first application

In order to debug the application a GDB server must be run on the target machine. Execute the following command to start a GDB server:
At this point the target shell output should look similar to the following:
Now that the server is running a GDB client can connect to perform debugging:

Once GDB is running instruct it to connect to a remote server:
Set a breakpoint on "main" and "cont"inue the application:
At this point the host machine terminal should look similar to the following:
The next line of code "printf("Hello World!\n");" can be run with the "next" or "n" command: