This description guides you through getting Valgrind up and running with Linux on a ZC702 board.
Valgrind is a GPL'd system for debugging and profiling Linux programs.
With Valgrind's tool suite you can automatically detect many memory management and threading bugs, avoiding hours of frustrating bug-hunting, making your programs more stable.
You can also perform detailed profiling to help speed up your programs.Why should you use Valgrind?
This Answer Record covers how to do the following:
There are different tools you can use to build file systems, like Yocto, Buildroot and others.
In this example I will be using Buildroot:
1) Get Buildroot:
2) Configure for the platform you will be running on:
Target options --->
3) Select root filesystem types:
Filesystem images --->
4) Select to use a static dev management as below: -> system_configuration
4) Enter ttyPS0 for TTY port, as below: -> system_configuration --> getty options ->
Make sure the libraries are not stripped.
Build options --->
1) Target packages -> Debugging, profiling and benchmark
Exit the menuconfig and save changes.
Within the buildroot filesystem, add "ttyPS" option to the static device table as seen below:
Exit and build with the following command:
Final images are located in <path>/Buildroot/output/images/
Setting up and building Linux with PetaLinux:
Create a Petalinux project:
Change the Root filesystem type to SD card as in the example below:
Image Packaging Configuration --->
Build the Linux image image.ub with the following command:
Partition the SD-card which will be used with the filesystem:
We will be booting Linux into a filesystem residing on an EXT3 partition on the SD card.
Therefore, partition the SD card for FAT and EXT3 using a partitioning software tool.
In this case I used EaseUS Partition Master Free edition.
Copy "BOOT.BIN" and "image.ub" from the "Xilinx-ZC702-2014.4/pre-built/linux/images/" directory to the FAT filesystem within the Petalinux project and "rootfs.tar" from the Buildroot project "buildroot/output/images".
Insert the SD CARD in the windows machine and use Windows Explorer to copy the files to the SD card.
Put the SD card into the slot on the ZC702 board and boot from the SD-card.
To boot from an SD card, flip bit 3 and 4 to "1", the rest "0", on the SW16 switch on the ZC702 board.
When booted, log in with user and password "root" and install the filesystem onto the EXT3 partition.
See the following example:
Now we want to change out the image.ub from the SD card to the new one, which will be using the ext3 filesystem instead of the image.ub on the SD card.
Copy "image.ub" from the "Xilinx-ZC702-2014.4/images/linux" directory to the SD-card.
If there would be any problems with the new image, it would make sense to rename the old image so you can revert to it again.
Put the SD card back into the development board and boot from SD card.
You should now be able to boot Linux and Valgrind should be installed. You can test it on a binary file like this:
Analyzing the following code will give the results below:
To create a trace dump of the program, execute the following command:
This will create a file named callgrind.out.<pid>, for example callgrind.out.27005.
Copy this file (callgrind.out.27005) to where you have kcachegrind installed and start it with the file create above.
For example, Kcachegrind callgrind.out.27005
It should look similar to the following:
If you do not have Kcachegrind installed, this can be done on an Ubuntu machine using the following command: