WR Switch: How-To Cross Compile Hello World
THIS HOWTO IS DEPRECATED
This describes how I cross compiled
hello world
for switch
This assumes a White Rabbit switch version 3.2 using White Rabbit switch software 3.1. Development machine is Debian Squeeze. The switch software and the documentation is available on the
Open Hardware Repository.
- Read the documentation.
- Download the switch software.
- Install the switch software according the documentation.
-
gunzip
and tar -xf
the tarball.
- I renamed the top directory to
wr-switch-sw
, but I don't know if this is good practice.
- Build the switch software according to the documentation.
- I created a folder
wr-switch-build
on the same level as wr-swtich=sw
-
#cd wr-switch-build
- try
#../wr-switch-sw/build/wrs_build-all --list
to get familiar with the build script.
- do
#../wr-switch-sw/build/wrs_build-all
to build the switch software
As by-product of building the switch software, the build script also installs the
arm-unknown-linux-uclibcgnueabi
tools required for cross compiling to my
wr-switch-build
folder.
Remark: The build scripts don't like local paths
.
in the environment variables
PATH
and
LD_LIBRARY_PATH
. These environment variables must be modfied accordingly.
Cross Compile Hello World by Hand
This is my
helloWorld.c
.
#include <stdio.h>
main()
{
printf("hello world \n");
}
The following needs to be done.
- Include
SOMEPATH/wr-switch-build/build/buildroot-2011.11/output/host/usr/bin
to the environment variable PATH
, where SOMEPATH
is just the path where the switch software was untarred.
-
#arm-unknown-linux-uclibcgnueabi-gcc -g -o helloWorld helloWorld.c
cross compiles hello world.
Another way for cross compiling is using the tool-chain of the WR Switch Software already installed on the computer (see above).
- put
helloWorld.c
in SOMEPATH/wr-switch-sw/userspace/tools
- modify
SOMEPATH/wr-switch-sw/userspace/tools/Makefile
TOOLS = rtu_stat wr_mon wr_phytool spll_dbg_proxy load-lm32 load-virtex com
TOOLS += mapper wmapper <b>helloWorld</b>
...
wr_mon: wr_mon.o term.o
${CC} -o $@ $^ $(LDFLAGS)
helloWorld: helloWorld.o
${CC} -o $@ $^ $(LDFLAGS)
...
- cd to
SOMEPATH/wr-switch-build
-
../wr-switch-sw/build/wrs_build-all --step=07
cross compiles helloWorld in about 5 seconds.
Run Hello World on a White Rabbit Switch
- Log on to the switch
-
#cd /wr/bin
-
use #scp username@myLinuxBox:hellowWorld .
to copy the cross compiled binary from the linux box to the switch.
Try if this works
wrs-192.168.20.4#helloWorld
hello world
wrs-192.168.20.4#
--
DietrichBeck - 30 Jan 2013