Compile swconfig for r64


(Frank W.) #1

Hi,

i’m trying to compile swconfig for r64, but i’m stuck

i take source from openwrt (seems the only source for it): https://github.com/openwrt-mirror/openwrt/tree/master/package/network/config/swconfig

and rewrote makefile

there are many type-mismatches and still some missing files…

is it compatible with kernel 4.19 or is it kernel-independed and needs only additional sources e.g. from https://github.com/openwrt-mirror/openwrt/tree/master/package/libs/libnl-tiny/src

tried also to clone openwrt directly and build only swconfig/src

frank@frank-N56VZ:/media/data_ext/openwrt/package/network/config/swconfig
[16:26:47]$ make
Makefile:8: /rules.mk: No such file or directory
Makefile:16: /package.mk: No such file or directory
Makefile:17: /kernel.mk: No such file or directory
make: *** No rule to make target '/kernel.mk'.  Stop.
frank@frank-N56VZ:/media/data_ext/openwrt/package/network/config/swconfig
[16:26:50]$ cd src
frank@frank-N56VZ:/media/data_ext/openwrt/package/network/config/swconfig/src
[16:27:06]$ make
cc -O2 -g -I ../src -fPIC -c -o swlib.o swlib.c
swlib.c:26:10: fatal error: linux/switch.h: No such file or directory
 #include <linux/switch.h>
          ^~~~~~~~~~~~~~~~
compilation terminated.
Makefile:9: recipe for target 'swlib.o' failed
make: *** [swlib.o] Error 1

anyone has an idea?


(August) #2

Copy https://github.com/openwrt-mirror/openwrt/blob/master/target/linux/generic/files/include/uapi/linux/switch.h to /usr/include/linux/ on the build machine


(Frank W.) #3

same as after i copied id to local source:

cc -O2 -g -I ../src -fPIC -c -o swlib.o swlib.c
In file included from swlib.c:26:0:
/usr/include/linux/switch.h:25:10: fatal error: netlink/netlink.h: No such file or directory
 #include <netlink/netlink.h>
          ^~~~~~~~~~~~~~~~~~~

seems it requires libnl

./package/libs/libnl-tiny/src/include/netlink/netlink.h

i created include-dir in src and copied libnl-tiny/src/include/netlink to it…

frank@frank-N56VZ:/media/data_ext/openwrt/package/network/config/swconfig/src
[16:53:14]$ CFLAGS=-Iinclude make
cc -Iinclude -fPIC -c -o swlib.o swlib.c
In file included from include/netlink/genl/genl.h:16:0,
                 from /usr/include/linux/switch.h:26,
                 from swlib.c:26:
include/netlink/msg.h:52:16: error: field 'nm_creds' has incomplete type
  struct ucred  nm_creds;
                ^~~~~~~~
include/netlink/msg.h: In function 'nlmsg_set_creds':
include/netlink/msg.h:207:39: error: dereferencing pointer to incomplete type 'struct ucred'
  memcpy(&msg->nm_creds, creds, sizeof(*creds));
                                       ^~~~~~

it seems that “struct ucred;” is only forward-declared in msg.h but nowhere declared with fields

tried to build it like this (only with crosscompiler, currently arm-linux-gnueabihf-gcc):

but make in swconfig failes on

make: libsw.a: Command not found

libsw.a exists in swconfig/src

currently hang here:

cli.c:26:10: fatal error: uci.h: No such file or directory
 #include <uci.h>
          ^~~~~~~

i don’t find an uci.h in openwrt-source


(moore liu) #4

I’ll suggest …

  1. download openwrt 18.06 stable branch, and build image (it can boot to shell without network support) https://github.com/openwrt/openwrt/tree/openwrt-18.06 https://downloads.openwrt.org/releases/18.06.0/targets/mediatek/mt7622/
  2. refer to below github to add missing network parts and enable swconfig in menuconfig https://github.com/objelf/linux/commits/linux-4.14.y-mediatek

(Frank W.) #5

Isn’t there a way to compile sw-config outside openwrt? I want to use it in debian…


(moore liu) #6

swconfig / uci are openwrt proprietary way to configure device, it needs patch kernel and prepare related library/app as well. I will suggest you use normal way to configure network in debian.

https://github.com/openwrt-mirror/openwrt/blob/master/target/linux/generic/patches-4.4/700-swconfig.patch


(Frank W.) #7

I only know dsa to configure separate ports and switchconfig…as there is no dsa-driver for r64 i tried to get swconfig working


(moore liu) #8

there is no need to enable DSA or swconfig tool, just use below code base with ifconfig command to enable ethernet, thanks.

notes: swconfig is advanced feature to help hou set vlan member, pvid…etc easily.

https://github.com/objelf/linux/commits/linux-4.14.y-mediatek


(Frank W.) #9

I have ethernet working, but lan-ports are 1 nic so i cannot configure them separately…currently it works like r2 with kernel 4.4


(moore liu) #10

I will suggest you can verify other parts first, and wait until new switch ic with DSA driver to meet your requirement. :wink:


(Frank W.) #11

wifi-driver is actually not compilable with gcc >6 so i’m stuck here (tried to compile full r64-bsp-repo on ubuntu 18.4 with all available gcc cross-compilers, on ubuntu 14.4 it works)