Pages

Showing posts with label arm. Show all posts
Showing posts with label arm. Show all posts

Iperf for ARM: cross-compile

What is Iperf? 
"Iperf was developed by NLANR/DAST as a modern alternative for measuring maximum TCP and UDP bandwidth performance. Iperf allows the tuning of various parameters and UDP characteristics. Iperf reports bandwidth, delay jitter, datagram loss." [1] 

Download Iperf 2.x
Iperf 2.x is hosted in source forge server. The latest stable Iperf 2.x version can be downloaded from here

Compile Iperf for your ARM device
In this example I have used the Iperf version 2.0.5 and the Sourcery G++ Lite 2010q1-188 toolchain [2]

1. Setting up compiler variables
$ export CROSS_COMPILE=arm-none-linux-gnueabi-
$ export CC=${CROSS_COMPILE}gcc
$ export CPP=${CROSS_COMPILE}cpp
$ export CXX=${CROSS_COMPILE}g++
$ export LD=${CROSS_COMPILE}ld
$ export AR=${CROSS_COMPILE}ar
2. Start Iperf configuration
$ configure --build=arm-none-linux-gnueabi \
            --host=armv9-none-linux-gnueabi
3. Compile Iperf tool statically
$ make CFLAGS=-static CXXFLAGS=-static
4. The Iperf executable binary is located at src folder of the root compilation path. The following is an example of the output when the ARM device is acting as a server (This tutorial doesn't cover Iperf measurement process):
bash-4.0# ./iperf -s -w 2M -i 1
-----------------------------------------------------
Server listening on TCP port 5001
TCP window size:  256 KByte (WARNING: requested 2.00 MByte)
-----------------------------------------------------
[  4] local 128.247.75.107 port 5001 connected with 128.247.75.64 port 48647
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0- 1.0 sec  11.0 MBytes  92.0 Mbits/sec
[  4]  1.0- 2.0 sec  11.2 MBytes  94.0 Mbits/sec
[  4]  2.0- 3.0 sec  11.2 MBytes  94.1 Mbits/sec
[  4]  3.0- 4.0 sec  11.2 MBytes  94.1 Mbits/sec
[  4]  4.0- 5.0 sec  11.2 MBytes  93.9 Mbits/sec
[  4]  5.0- 6.0 sec  11.2 MBytes  94.2 Mbits/sec
[  4]  6.0- 7.0 sec  8.42 MBytes  70.7 Mbits/sec
[  4]  7.0- 8.0 sec  11.2 MBytes  93.6 Mbits/sec
[  4]  8.0- 9.0 sec  11.2 MBytes  94.1 Mbits/sec
[  4]  9.0-10.0 sec  11.2 MBytes  94.0 Mbits/sec
[  4]  0.0-10.0 sec   109 MBytes  91.5 Mbits/sec
Troubleshooting
If a undefined reference to 'rpl_malloc' problem occurs during the compilation process you can do the following as mentioned in this forum thread:
$ export ac_cv_func_malloc_0_nonnull=yes
 Note: Preferable to start a clean build after setting up this variable to avoid further errors.


[1] http://sourceforge.net/projects/iperf/
[2] https://sourcery.mentor.com/sgpp/lite/arm/portal/release1294

Valgrind for ARM

This is how I prepared Valgrind for my ARM device:

1. Download valgrind 3.6.1 and untar the package
2. Download a version of the Code Sourcery toolchain
    * I used the Sourcery G++ Lite 2010q1-202 for ARM GNU/Linux
3. Add the Code Sourcery toolchain to the PATH, you'll need it later
$ PATH=<somewhere>/arm-2010q1/bin:$PATH
4. How to cross compile Valgrind:
$ export CROSS_COMPILE=arm-none-linux-gnueabi-
$ export CC=${CROSS_COMPILE}gcc
$ export CPP=${CROSS_COMPILE}cpp
$ export CXX=${CROSS_COMPILE}g++
$ export LD=${CROSS_COMPILE}ld
$ export AR=${CROSS_COMPILE}ar
$
$ ./configure --target=arm-none-linux-gnueabi \
              --host=armv7-none-linux-gnueabi \
              --prefix=<installation-path> \
              CFLAGS=-static
$ make
$ make install
5. Create a directory in your ARM device with the name of the installation path (see above for prefix)  
# mkdir -p  <installation-path>
6. Copy all the content from the installation in your host machine to the installation patch in your ARM device
7. Add Valgrind binary location to the PATH in your device:
# PATH=<installation-path>/bin:$PATH
8. Now, you are ready to play with Valgrind:
# cat /proc/cpuinfo
Processor: ARMv7 Processor rev 10 (v7l)
# valgrind
valgrind: no program specified
valgrind: Use --help for more information.

# valgrind --version
valgrind-3.6.1

9.  Find memory leaks: Quick Start Guide