WR Switch: How-To Cross Compile Hello World

THIS HOWTO IS DEPRECATED

This describes how I cross compiled hello world for switch

Getting the Tools

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.

  1. Read the documentation.
  2. Download the switch software.
  3. 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.
  4. 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.
  1. 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.
  2. #arm-unknown-linux-uclibcgnueabi-gcc -g -o helloWorld helloWorld.c cross compiles hello world.

Cross Compile Hello World by Using the Tool-Chain of the WR Switch Software

Another way for cross compiling is using the tool-chain of the WR Switch Software already installed on the computer (see above).

  1. put helloWorld.c in SOMEPATH/wr-switch-sw/userspace/tools
  2. 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)
           ...
          
  3. cd to SOMEPATH/wr-switch-build
  4. ../wr-switch-sw/build/wrs_build-all --step=07 cross compiles helloWorld in about 5 seconds.

Run Hello World on a White Rabbit Switch

  1. Log on to the switch
  2. #cd /wr/bin
  3. 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

This topic: Timing > WebHome > TimingSystemDocumentation > TimingSystemHowTo > TimingSystemDeprecatedHowTo > TimingSystemSwitchHowToHelloWorld
Topic revision: 19 Jun 2019, DietrichBeck
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback