Bananian
Bananian on BPI-Router - Discussion
99
32335
|
[Bananian]
Bananian on BPI-Router - Discussion
[Copy link]
|
|
Hello,
I got the swconfig working - but I use rasperian and I compiled the kernel
with the b53 driver myself
(I reproduced the steps mattrix posted during the time, his repostitory was unvailable and he wasn't responsive).
(Perhaps, if there is a significant difference, I will aso post how I compiled the kernel.)
But first I will describe how I compiled the swconfig
Get the sources
git clone git://git.openwrt.org/openwrt.git
git clone git://nbd.name/uci.git as root - install needed packages and copy the correct switch.h to the system includes
apt-get install liblua5.1-0-dev cmake
cp openwrt/target/linux/generic/files/include/uapi/linux/switch.h /usr/include/linux/switch.h
chmod 644 /usr/include/linux/switch.h a few symlinks to the parts of the source-trees we need
ln -s openwrt/package/network/config/swconfig/src swconfig
ln -s openwrt/package/libs/libnl-tiny libnl-tiny
SRCDIR=`pwd`
in $SRCDIR/uci
git checkout v0.8.0 # trunk does not work
in lua/uci.c change line 24 to
#include <lua5.1/lauxlib.h>
and compile it
cd $SRCDIR/uci
cmake .
make
rm libuci.so # to get swconfig linked static
cd $SRCDIR/libnl-tiny/src
make
rm libnl-tiny.so # again, to get swconfig linked static, and build a static lib
ar rcs libnl-tiny.a nl.o handlers.o msg.o attr.o cache.o cache_mngt.o object.o socket.o \
error.o genl.o genl_family.o genl_ctrl.o genl_mngt.o unl.o
cd $SRCDIR/swconfig
CFLAGS="-I $SRCDIR/uci -I $SRCDIR/libnl-tiny/src/include -D_GNU_SOURCE" LDFLAGS="-L $SRCDIR/uci -L $SRCDIR/libnl-tiny/src" make
make # linking will fail, due to wrong lib names, so do it by hand
cc -L $SRCDIR/libnl-tiny/src -L $SRCDIR/uci -o swconfig cli.o swlib.o uci.o -lnl-tiny -luci -ldl Thats it.
A few tests:
one finds the following mapping between physical ports and the port numbers swconfig uses:
ethernet ports of the bp-r1 (seen from outside)
---------------------------
| P4 | P3 | P2 | P1 || P0 |
---------------------------
swconfig 0 -> P2
swconfig 1 -> P3
swconfig 2 -> P4
swconfig 3 -> P0
swconfig 4 -> P1
swconfig 8 -> host port I also tried to define some vlans - a few commands I used
apt-get install vlan
man vconfig
man vlan-interfaces
swconfig dev eth0 set reset_mib 1
vconfig add eth0 101
vconfig add eth0 102
ifconfig eth0 down
ifconfig eth0.101 up 192.168.154.9
ifconfig eth0.102 up 192.168.155.9
swconfig dev eth0 set enable_vlan 1
swconfig dev eth0 vlan 101 set ports "2 8t"
swconfig dev eth0 vlan 102 set ports "4 8t"
swconfig dev eth0 set apply 1
swconfig dev eth0 show It seems to work - only the behavior of the link-leds at the ethernet ports is curious
|
Rate
-
1
View Rating Log
-
|
|
|
|
|
|
|
Edited by mattrix at Tue Dec 16, 2014 23:37
GREAT WORK!
I get errors all over the show.
Can't make uci- CMake Error at lua/CMakeLists.txt:23 (IF):
- if given arguments:
- "NOT" "No such file or directory" "EQUAL" "0" "OR" "EQUAL" "1"
- Unknown arguments specified
Copy the Code Can't make libnl-tiny
- gcc -shared -o libnl-tiny.so nl.o handlers.o msg.o attr.o cache.o cache_mngt.o object.o socket.o error.o genl.o genl_family.o genl_ctrl.o genl_mngt.o unl.o
- /usr/bin/ld: msg.o: relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
- msg.o: could not read symbols: Bad value
- collect2: ld returned 1 exit status
- make: *** [libnl-tiny.so] Error 1
Copy the Code Can't make swconfig- /usr/include/linux/switch.h:19:27: fatal error: net/genetlink.h: No such file or directory
- compilation terminated.
- In file included from swlib.c:25:0:
- /usr/include/linux/switch.h:19:27: fatal error: net/genetlink.h: No such file or directory
- compilation terminated.
Copy the Code |
|
|
|
|
|
|
|
OK
because I use raperian and not bananian I now installed bananian and reproduced it.
1) lua5.1 is missing - so "apt-get install lua5.1" fix the problem
2) there is a litte difference in the gcc: "gcc version 4.6.3 (Debian 4.6.3-14+rpi1) " vs "gcc version 4.6.3 (Debian 4.6.3-14)"
I had to a add a -fPIC to CFLAGS in the Makefile
3) you use the wrong switch.h - in openwrt there are two:
openwrt/target/linux/generic/files/include/linux/switch.h
openwrt/target/linux/generic/files/include/uapi/linux/switch.h
I think the first is for kernel compilation, the 2nd for user space.
The compiled swconfig on my bananian@bpi works on my rasperian@pi-r1 |
|
|
|
|
|
|
|
Hi,
I was able to recompile swconfig according the howto from x4711. It seems that the freezing at the "apply" command may have caused by a too new libnl library and/or dynamic linking.
In the attachement there is my compiled swconfig (compiled under bananian) included with the swconfig sources. |
|
|
|
|
|
|
|
So,
You can SWCONFIG working fine in Bananian?
All OK?
Once compiled, does it still require libnl-tiny? or is it completely stand-alone? |
|
|
|
|
|
|
|
As far as I know (please see the comments of x4711) the libraries has been built statically (the compiled dynamic libraries has been deleted), which means they are also linked statically to the swconfig executable. So the command should be now standalone (without any further library dependencies). The static linking is also responsible for the current size of swconfig. My first successful build (with dynamic libraries) was pretty small. |
|
|
|
|
|
|
|
I think static would be the way to go for what we want then.
Sorry, I don't know much about compiling - pretty NOOB in that area.
Will have a play tonight after work  |
|
|
|
|
|
|
|
still no luck compiling libnl-tiny
Even after -fPIC, is still tells me to add it??- gcc -shared -o libnl-tiny.so -fPIC nl.o handlers.o msg.o attr.o cache.o cache_mngt.o object.o socket.o error.o genl.o genl_family.o genl_ctrl.o genl_mngt.o unl.o
Copy the Code- /usr/bin/ld: msg.o: relocation R_ARM_THM_MOVW_ABS_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
Copy the Code Shadowmaster - Can you tell me how you got it to compile in Bananaian on the router?? |
|
|
|
|
|
|
|
Edited by mattrix at Wed Dec 17, 2014 22:52
Nevermind got it.
Had to do a clean first 
Ok, here is a new swconfig source.
https://mega.co.nz/#!6RZw0KKJ!9- ... jajL8Hfila92jO6TLkY
I have removed the code that relates to UCI so that is no longer needed.
So, to compile:- git clone git://git.openwrt.org/openwrt.git
- cp openwrt/target/linux/generic/files/include/uapi/linux/switch.h /usr/include/linux/switch.h
- chmod 644 /usr/include/linux/switch.h
- ln -s openwrt/package/network/config/swconfig/src swconfig
- ln -s openwrt/package/libs/libnl-tiny libnl-tiny
- SRCDIR=`pwd`
- cd $SRCDIR/libnl-tiny/src
- ## Add -fPIC to CFLAGS in makefile
- make
- rm libnl-tiny.so
- ar rcs libnl-tiny.a nl.o handlers.o msg.o attr.o cache.o cache_mngt.o object.o socket.o error.o genl.o genl_family.o genl_ctrl.o genl_mngt.o unl.o
- cd $SRCDIR/swconfig
- CFLAGS="-I $SRCDIR/libnl-tiny/src/include -D_GNU_SOURCE" LDFLAGS="-L $SRCDIR/libnl-tiny/src" make
- cc -L $SRCDIR/libnl-tiny/src -o swconfig cli.o swlib.o -lnl-tiny -ldl
Copy the Code |
|
|
|
|
|
|
|
Haha. I thought the apply was killing my BPI as well.
But, as I'm using SSH, it's just killing my connection to it (changing the network settings)
Got me confused.
Sometimes I forget i'm SSHing. |
|
|
|
|
|
|