Skip to content

e-gautier/rc-switch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rc-switch

Not really rc-switch but more like a test I made of the CGO wrapper on a cross-compiled C arm lib.

quick start

wget https://git.io/fjnXH && \
unzip send_sniffer_0.0.1.zip
./send 0 9999
./sniffer 2

TODO

  • more doc
  • more experiment
  • real auto tests

requirements

setup cross compile

get the toolchain

git clone https://github.com/raspberrypi/tools

add toolchain compilers to path

PATH=$PATH:~/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/

build wiring pi lib (command has to be ran on the target)

apt install git && \
cd /tmp && \
git clone https://github.com/WiringPi/WiringPi && \
cd WiringPi && \
./build

repatriate the compiled .so(s) to the compiler

scp <user@pi>:/usr/local/lib/libwiringPi* ~/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/arm-linux-gnueabihf/lib/

cross the hell compile to arm

make

send binary to target

scp build/send build/sniffer <user@pi>:/tmp

run (target)

./sniffer 2
./send 0 9999

tests

easy way to find out if compilation is well made and lib is loaded in the wrapper:

env GOOS=linux GOARCH=arm CC=arm-linux-gnueabihf-gcc CC_FOR_TARGET=arm-linux-gnueabihf-gcc CGO_ENABLED=1 go build -i -v -o build/test tests/testCompilation.go
./build/test 
2019/04/22 15:06:16 calling setup
2019/04/22 15:06:16 calling handler
compilation succeed, lib loaded

sources