Hallo Forum,

I had some (solved) problems with my Raspberry Pi, and a Linksys USB3GIGV1 Gigabit Ethernet USB device under OpenWrt 15.05.1.
Maybe someone is interested how I have solved the problem of the adapter is not recognized by the linux operating system.

Here is exactly what I did:

OpenWrt on a RaspBerry Pi 2 Model B
===================================

References
==========
Images:                https://wiki.openwrt.org/toh/raspberry_pi_foundation/raspberry_pi
Image build instructions:    https://wiki.openwrt.org/doc/howto/buildroot.exigence
Image build instructions:    https://wiki.openwrt.org/doc/howto/build
OPKG Package Manager:        https://wiki.openwrt.org/doc/techref/opkg
Image build instructions:    http://ljdelight.com/compiling-openwrt-from-source
Driver description:        https://github.com/rickhofstede/linksys_usb3gigv1_linux

Project
=======
Creating a personal firewall for a 100-Mbit internet uplink with low
power consumption and maximum troughput.

my Pi
=====
Regarding to the following WEB-page I need the following subtree of the
OpenWrt system:

https://wiki.openwrt.org/toh/raspberry_pi_foundation/raspberry_pi

Target:        brcm2708
Subtarget:    bcm2709

includet extra hardware
=======================

1.) Gigabit Ethernet USB Controller
    Name:        Linksys USB3GIGV1
    Chipset:        Realtek RTL8153
    Driver description:    https://github.com/rickhofstede/linksys_usb3gigv1_linux

2.) WLAN USB Controller
    Name:    TP-LINK TL-WN725N [V1] (Realtek RTL8188CUS 802.11n WLAN) Adapter
    Chipset:    RTL8188CUS

preparation
===========

We need some preparation before we can start to install a precompiled image to
our Raspberry Pi 2 Model B.
Unfortunately my gigabit ethernet adapter Linksys USB3GIGV1 is not supported in
the standard installation images.
So I have to cross-compile the OpenWrt-system with includet support for the
missing device.

installing prerequisites and their corresponding packages under Fedora 23
=========================================================================

This step is described very good under:

https://wiki.openwrt.org/doc/howto/buildroot.exigence

That means in my case:

→ installing prerequisites under Fedora 23:
sudo dnf install -v subversion binutils bzip2 gcc gcc-c++ gawk gettext \
    git-core flex ncurses-devel zlib-devel zlib-static make patch unzip \
    perl-ExtUtils-MakeMaker glibc glibc-devel glibc-static quilt sed \
    sdcc intltool sharutils bison wget openssl-devel
← installing prerequisites under Fedora 23:

let's do some cross-compile
===========================

Fortunately the OpenWrt crew distributes an easy way to adapt images to the
peronal requirements. The "OpenWrt build system".

https://wiki.openwrt.org/doc/howto/build

In my case the OpenWrt build system should be installed on a Fedora release 23
(Twenty Three) with kernel 4.5.6-200.fc23.x86_64.

I do some changes in the obove described build process, because I do not like
to install the current snapshot of the OpenMrt sources.
I would like to build the current stable version.

→ Update OpenWrt sources with Git::
mkdir ~/HUsFiles/tmp1/OpenWrt-Raspberry-Pi2B-15.05
cd ~/HUsFiles/tmp1/OpenWrt-Raspberry-Pi2B-15.05
git clone https://git.openwrt.org/15.05/openwrt.git
cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
← Update OpenWrt sources with Git:

The OpenWrt build system configuration interface handles the selection of the
target platform, packages to be compiled, packages to be included in the
firmware file, some kernel options, etc.
I started the OpenWrt build system configuration interface with the following
steps:

→ Image Configuration, menuconfig part 1:
wget https://downloads.openwrt.org/chaos_calmer/15.05.1/brcm2708/bcm2709/config.diff
cp config.diff .config
make defconfig
make menuconfig (just save and exit menuconfig)
← Image Configuration, menuconfig part 1:

Next is:
* produce a general purpose configuration of the build system including a
  check of dependencies and prerequisites for the build environment etc
  and
* check for dependencies

→ defconfig:
make defconfig
← defconfig:

Run menuconfig again:

make menuconfig

→ Image Configuration, menuconfig part 2:
... make your changes ...
For me ... I do nothing, because I would like to create a standard build
with all packages.
← Image Configuration, menuconfig part 2:

→ Creating a diff file and saving everything we have done jet:
./scripts/diffconfig.sh > diffconfig."`date "+%Y%m%d"`"
cp .config .config."`date "+%Y%m%d"`"
cp diffconfig."`date "+%Y%m%d"`" diffconfig
← Creating a diff file and saving everything we have done jet:


Run defconfig again:

→ defconfig:
make defconfig
← defconfig:

Building Images

Everything is now ready for building the image(s), which is done with one
single command: 

→ make anything:
make world
← make anything:

... some hours later ...

Problem
=======
→ output of: make -j1 V=s world
Compiler source for libpri ERROR 404: Not Found. (libpri-1.4.15.tar.gz)
← output of: make -j1 V=s world

see:    https://dev.openwrt.org/ticket/22598

Repository URL changed.

→ edit the corresponding Makefile:
cp feeds/telephony/libs/libpri/Makefile feeds/telephony/libs/libpri/Makefile.orig
vi feeds/telephony/libs/libpri/Makefile

diff feeds/telephony/libs/libpri/Makefile feeds/telephony/libs/libpri/Makefile.orig
15c15
< PKG_SOURCE_URL:=http://downloads.asterisk.org/pub/telephony/libpri/old/
---
> PKG_SOURCE_URL:=http://downloads.asterisk.org/pub/telephony/libpri/
← edit the corresponding Makefile:

Problem
=======
→ output of: make -j1 V=s world
Checking out files from the git repository...
Cloning into 'libvorbisidec-1.0.3-20150104'...
fatal: read error: Connection reset by peer
← output of: make -j1 V=s world

see:    https://dev.openwrt.org/ticket/20493

Repository URL changed.

→ edit the corresponding Makefile:
cp package/feeds/packages/libvorbisidec/Makefile package/feeds/packages/libvorbisidec/Makefile.orig
vi package/feeds/packages/libvorbisidec/Makefile

diff package/feeds/packages/libvorbisidec/Makefile package/feeds/packages/libvorbisidec/Makefile.orig
16c16
< PKG_SOURCE_URL:=https://git.xiph.org/tremor.git
---
> PKG_SOURCE_URL:=git://git.xiph.org/tremor.git
← edit the corresponding Makefile:

Problem
=======
→ output of: make -j1 V=s world
--2016-06-29 00:34:17--  https://downloads.openwrt.org/sources/irssi-0.8.17.tar.bz2
Resolving downloads.openwrt.org (downloads.openwrt.org)... 78.24.191.177
Connecting to downloads.openwrt.org (downloads.openwrt.org)|78.24.191.177|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2016-06-29 00:34:17 ERROR 404: Not Found.

Download failed.
← output of: make -j1 V=s world

see: https://gitlab.com/db260179/openwrt-bpi-r1/issues/18

Repository URL changed.

→ edit the corresponding Makefile:
cp package/feeds/packages/irssi/Makefile  package/feeds/packages/irssi/Makefile.orig
vi package/feeds/packages/irssi/Makefile

diff package/feeds/packages/irssi/Makefile  package/feeds/packages/irssi/Makefile.orig
15c15
< PKG_SOURCE_URL:=http://pkgs.fedoraproject.org/lookaside/pkgs/irssi/irssi-0.8.17.tar.bz2/ecf64be47978d89a742b435a81cb47db
/
---
> PKG_SOURCE_URL:=http://irssi.org/files/
← edit the corresponding Makefile:

Problem
=======
→ output of: make -j1 V=s world
--2016-06-29 07:35:28--  https://github.com/downloads/mpruett/audiofile/audiofile-0.3.6.tar.gz
Resolving github.com (github.com)... 192.30.253.113
Connecting to github.com (github.com)|192.30.253.113|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2016-06-29 07:35:28 ERROR 404: Not Found.

Download failed.
← output of: make -j1 V=s world

Repository URL changed.

→ edit the corresponding Makefile:
cp package/feeds/packages/libaudiofile/Makefile  package/feeds/packages/libaudiofile/Makefile.orig
vi package/feeds/packages/libaudiofile/Makefile

diff package/feeds/packages/libaudiofile/Makefile  package/feeds/packages/libaudiofile/Makefile.orig
16d15
<     http://pkgs.fedoraproject.org/repo/pkgs/audiofile/audiofile-0.3.6.tar.gz/2731d79bec0acef3d30d2fc86b0b72fd/ \
← edit the corresponding Makefile:

Problem
=======
→ output of: make -j1 V=s world
--2016-06-29 10:17:58--  https://download.libsodium.org/libsodium/releases/libsodium-1.0.2.tar.gz
Resolving download.libsodium.org (download.libsodium.org)... 37.59.238.213
Connecting to download.libsodium.org (download.libsodium.org)|37.59.238.213|:443... connected.
#
HTTP request sent, awaiting response... 404 Not Found
2016-06-29 10:17:58 ERROR 404: Not Found.

Download failed.
← output of: make -j1 V=s world

Repository URL changed.

→ edit the corresponding Makefile:
cp package/feeds/packages/libsodium/Makefile package/feeds/packages/libsodium/Makefile.orig
vi package/feeds/packages/libsodium/Makefile

diff package/feeds/packages/libsodium/Makefile package/feeds/packages/libsodium/Makefile.orig
15c15
< PKG_SOURCE_URL:=https://download.libsodium.org/libsodium/releases/old
---
> PKG_SOURCE_URL:=https://download.libsodium.org/libsodium/releases
← edit the corresponding Makefile:

Problem
=======
→ output of: make -j1 V=s world
--2016-06-29 18:30:30--  http://www.cpan.org/authors/id/T/TI/TIMB/DBI-1.633.tar.gz
Resolving www.cpan.org (www.cpan.org)... 2607:f238:3::91:1, 94.242.223.198
Connecting to www.cpan.org (www.cpan.org)|2607:f238:3::91:1|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2016-06-29 18:30:30 ERROR 404: Not Found.

Download failed.
← output of: make -j1 V=s world

Repository URL changed.

→ edit the corresponding Makefile:
cp package/feeds/packages/perl-dbi/Makefile package/feeds/packages/perl-dbi/Makefile.orig
vi package/feeds/packages/perl-dbi/Makefile

diff package/feeds/packages/perl-dbi/Makefile package/feeds/packages/perl-dbi/Makefile.orig
14c14
< PKG_SOURCE_URL:=http://pkgs.fedoraproject.org/repo/pkgs/perl-DBI/DBI-1.633.tar.gz/b4fe13b9a51c1446c5f3cf93e69a2044/
---
> PKG_SOURCE_URL:=http://www.cpan.org/authors/id/T/TI/TIMB/
← edit the corresponding Makefile:

Problem
=======
→ output of: make -j1 V=s world
not collected
← output of: make -j1 V=s world

Repository URL changed.

→ edit the corresponding Makefile:
cp package/feeds/packages/perl-uri/Makefile package/feeds/packages/perl-uri/Makefile.orig
vi package/feeds/packages/perl-uri/Makefile

diff package/feeds/packages/perl-uri/Makefile package/feeds/packages/perl-uri/Makefile.orig
14c14
< PKG_SOURCE_URL:=http://pkgs.fedoraproject.org/repo/pkgs/perl-URI/URI-1.67.tar.gz/d0ef53b6c63bcc02ba55f405c30741e3/
---
> PKG_SOURCE_URL:=http://www.cpan.org/authors/id/E/ET/ETHER/
← edit the corresponding Makefile:

Problem
=======
Problems like: GIT repository offline, and different compile errors
solved with:    disable package

freecwmp:    Utilities    < > freecwmp...................... CWMP client
        Libraries    < > libfreecwmp.................. CWMP library    
microxml:    Libraries    < > libmicroxml................... XML library
netconf:    Libraries    < > libnetconf................ NETCONF library
crtmpserver:    Multimedia    < > crtmpserver............... C++ RTMP Server
libsodium:    Libraries    < > libzmq-curve....... ZeroMQ - Message Queue
        Network;IP Addr < > dnscrypt-proxy
                < > hostip........... Resolver to IPv4 or IPv6
        Libraries    < > libsodium........... P(ortable|ackageable)
krb5:        Network        < > krb5-client............. Kerberos 5 Client
                < > krb5-libs..... Kerberos 5 Shared Libraries
                < > krb5-server............. Kerberos 5 Server
pthsem:        Network        < > knxd....................... EIB KNX daemon
                < > knxd-too.................... EIB KNX Utils
                < > linknx....... KNX home automation platform
        Libraries    < > pthsem..GNU pth extended with semaphore su
ldns:        Network;IP Addr    < > drill........... DNS(SEC) information tool
        Network;Tele-
        phony;freesw    < > freeswitch.. FreeSWITCH open source teleph
                < > libldns..A library to simplify DNS program
libesmtp:    Libraries    < > libesmtp... Library for Posting Electronic
libnfc:        Utilities    < > nfc-utils... A open source library for Nea
        Libraries    < > libnfc..A open source library for Near Fie
libupm        Libraries;IoT    < > libupm.... Intel IoT sensor library - Full
lpeg        Languages;Lua    < > lpeg................................. LPeg
lua-sha2    LuCI; App    < > luci-app-cjdns... Encrypted near-zero-conf
        Network;Routing    < > cjdns............ Encrypted near-zero-conf
        Languages;LuA    < > lua-sha2......... Lua binding for Aaron Gi
oggfwd        Multim; Stream    < > oggfwd............ Pipe media into icecast
rtklib        Utils;RTKLIB Su    < > convbin.................. RINEX  Converter
                < > pos2kml....... Solution to  KML  converter
                < > rnx2rtkp........ Post-Processing  Analysis
                < > rtkrcv............. Real-Time  Positioning
                < > str2str............. Communication  Server
stm32flash    Utilities    < > stm32flash.. Firmware flash tool for STM32
stunnel        Network        < > stunnel................... SSL TCP Wrapper
tor        Network        < > tor... An anonymous Internet communication  
                < > tor-fw-helper..... Firewall helper for tor
                < > tor-geoip................ GeoIP db for tor
tracertools    Utilities    < > tracertools.. Tracer MPPT monitoring and c
umurmur        Network;Instant    < > umurmur-openssl.. uMurmur (with OpenSSL su
        Network;Instant    < > umurmur-polarssl... uMurmur (with PolarSSL
wifidog        Network;Captive    < > wifidog.. A wireless captive portal soluti
                < > wifidog-tls..... A wireless captive portal
xupnpd        Multimedia    < > xupnpd.............. eXtensible UPnP agent
b43legacy-firmw Firmware        < > b43legacy-firmware.. Broadcom bcm43xx b43l
batman        (look for batman and for B.A.T.M.A.N.!)
        Network        < > batctl... B.A.T.M.A.N. Advanced user space
        Kernel mod;Net    < > kmod-batman-adv.............. B.A.T.M.A.N.
        Network;Routing    < > batmand...... B.A.T.M.A.N. layer 3 routing
        Network;Routing    < > vis.. visualization server for B.A.T.M.A.N
minimalist-pcpr    Network        < > minimalist-pcproxy.. Lightweight PCP proxy
                < > hnet-full........ HNCP Homenet metapackage
                < > hnet-full-secure. HNCP Homenet metapackage
ndppd        Network        < > ndppd.................... NDP Proxy Daemon
kamilio        Network;Telepho    < > kamailio3.. Mature and flexible open sourc
                < > kamailio4.. Mature and flexible open sourc

→ continue compiling:
make defconfig
# make without a cleaning before
# "make world" would make aditionaly
#    make target/compile
#    make package/cleanup
# at the begin of the make-process
make package/compile
← continue compiling:

If everything is compiled, just:

→ finish compiling:
make world
← finish compiling:

There might be a high number of packages/feeds. The build process will
cost you many time especially if there are errors.

Number of feeds in my case: "find feeds -name Makefile -print | wc -l": 700
Number of packages in my case: "find package -name Makefile -print | wc -l": 243

Just take the "make world" make[3]-output in a file and count what you have done
jet with: "cat make_world.out | sort | uniq | wc -l": 797

Compile additional net-devices hard into the kernel
===================================================
After the build process described above, whe have a more or less standard
OpenWrt Image for our Raspberry Pi 2 Model B with all packages.

I prefere to build in the drivers for my two additional network-interfaces
direct into the kernel and not to build them as kernel-modules and load
them later as IPKs.

So we have to reconfigure the build process.

make menuconfig

→ Image Configuration, menuconfig:

Kernel modules → USB Support selection:
<*> kmod-usb-net.................. Kernel modules for USB-to-Ethernet convertors
<*> kmod-usb-net-rtl8152......... Realtek driver for RTL8152/RTL8153 (USB3GIGV1)

Kernel modules → Wireless Drivers selection
<*> kmod-rtl8192cu.......................... Realtek RTL8192CU/RTL8188CU support

← Image Configuration, menuconfig:

Run defconfig again:

→ defconfig:
make defconfig
← defconfig:

Building Images

Everything is now ready for building the image(s), which is done with one
single command:

→ make anything:
make world
← make anything:

Problem
=======

see: https://github.com/rickhofstede/linksys_usb3gigv1_linux

"The Linksys USB3GIGV1 is based on the Realtek RTL8153, for which Realtek
provides Linux drivers. For the Linux kernel to be able to connect drivers
to hardware devices, the drivers need to carry the USB vendor ID and product
ID of the hardware. However, since the Linksys adapter announces itself to
the OS as a Linksys device (and not as a Realtek device), the Realtek driver
will never be attached to the Linksys hardware."

OK, so we have to patch the Realtek RTL8153 module to get it running. There
is a clean way to do that I know, but I have no time to get an idea how to
do a clean install (eventually over the git-repositories).
So here the my quick and dirty way.

A quick but diry way to get the Linksys USB3GIGV1 USB Gigabit ethernet adapter
running under OpenWrt 15.05.1
------------------------------------------------------------------------------

There is a git repository, with a new version of the RealTec r8152 driver
which is adapted to our Linksys USB3GIGV1.
It is quiet easy to integrate it into our image.

→ get the new RealTec r8152 kernel driver:
cd /tmp
git clone https://github.com/rickhofstede/linksys_usb3gigv1_linux.git

Klone nach 'linksys_usb3gigv1_linux' ...
remote: Counting objects: 17, done.
remote: Total 17 (delta 0), reused 0 (delta 0), pack-reused 16
Entpacke Objekte: 100% (17/17), Fertig.
Prüfe Konnektivität ... Fertig.

cd -
← get the new RealTec r8152 kernel driver:

→ backup the old RealTec r8152 kernel driver:
cp ./build_dir/target-arm_cortex-a7+vfp_uClibc-0.9.33.2_eabi/linux-brcm2708_bcm2709/linux-3.18.29/drivers/net/usb/r8152.c 
./build_dir/target-arm_cortex-a7+vfp_uClibc-0.9.33.2_eabi/linux-brcm2708_bcm2709/linux-3.18.29/drivers/net/usb/r8152.c.ori
g
cp ./build_dir/target-arm_cortex-a7+vfp_uClibc-0.9.33.2_eabi/linux-brcm2708_bcm2709/linux-3.18.29/drivers/net/usb/r8152.mo
d.c ./build_dir/target-arm_cortex-a7+vfp_uClibc-0.9.33.2_eabi/linux-brcm2708_bcm2709/linux-3.18.29/drivers/net/usb/r8152.m
od.c.orig
← backup the old RealTec r8152 kernel driver:

→ integrate the new RealTec r8152 kernel driver:
cp /tmp/linksys_usb3gigv1_linux/compatibility.h ./build_dir/target-arm_cortex-a7+vfp_uClibc-0.9.33.2_eabi/linux-brcm2708_b
cm2709/linux-3.18.29/drivers/net/usb/.
cp /tmp/linksys_usb3gigv1_linux/r8152.c ./build_dir/target-arm_cortex-a7+vfp_uClibc-0.9.33.2_eabi/linux-brcm2708_bcm2709/l
inux-3.18.29/drivers/net/usb/.
cp /tmp/linksys_usb3gigv1_linux/r8152.mod.c ./build_dir/target-arm_cortex-a7+vfp_uClibc-0.9.33.2_eabi/linux-brcm2708_bcm27
09/linux-3.18.29/drivers/net/usb/.
← integrate the new RealTec r8152 kernel driver:

Everything is now realy ready for rebuilding the image(s), which is done with
"make" again: 

→ make anything:
make world
← make anything:

... some minutes later ... my image is ready to install ...

Locating the freshly created installation-image
===============================================

After a successful build, the freshly built image(s) can be found in the newly
created <buildroot_dir>/bin directory. The compiled files are additionally
classified by the target platform, so in my case a firmware built for an
brcm2708 device will be located in
<buildroot_dir>./bin/brcm2708/openwrt-15.05.1-brcm2708-bcm2709-sdcard-vfat-ext4.img
.

flash the newly created OpenWrt image to a SD card
==================================================

according to:
https://wiki.openwrt.org/toh/raspberry_pi_foundation/raspberry_pi
I did:

insert your SD card and run: 

→ flash the newly created OpenWrt image to a SD card:
sudo fdisk -l
# ...
# Festplatte /dev/mmcblk0: 7,4 GiB, 7948206080 Bytes, 15523840 Sektoren
# ...
sudo umount -v    /run/media/hu/CED3-0E5B \
        /run/media/hu/57f8f4bc-abf4-655f-bf67-946fc0f9f25b
sudo dd if=~/HUsFiles/tmp1/OpenWrt-Raspberry-Pi2B-15.05/openwrt/bin/brcm2708/openwrt-15.05.1-brcm2708-bcm2709-sdcard-vfat-
ext4.img of=/dev/mmcblk0 bs=2M conv=fsync
← flash the newly created OpenWrt image to a SD card:

Adjust Repositories
===================
according to: https://wiki.openwrt.org/doc/techref/opkg

The only configuration file is /etc/opkg.conf. It could look like this:

src/gz snapshots http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages
dest root /
dest ram /tmp
lists_dir ext /var/opkg-lists
option overlay_root /overlay

Local Repositories

You can configure opkg to fetch the packages locally:

src/gz local file:///path/to/packagesDirectory

Speed-Test
==========

before (without personal firewall OpenWrt 15.05.1 on a RaspBerry Pi 2 Model B):
===============================================================================

Unitymedia Speedtest:    http://speedtest.unitymedia.de/
            Download:    104.46 Mbit/s
            Upload:          4.88 Mbit/s
            Ping:         16.00 ms
            Jitter:          8.00 ms

iperf Speedtest between 2 Gigabit connected laptops directly
to the Unitymedia router:
------------------------------------------------------------
Client connecting to 192.168.178.21, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[  3] local 192.168.178.22 port 38846 connected with 192.168.178.21 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.07 GBytes   920 Mbits/sec

after (with personal firewall OpenWrt 15.05.1 on a RaspBerry Pi 2 Model B):
===========================================================================

Unitymedia Speedtest:    http://speedtest.unitymedia.de/
            Download:     94.04 Mbit/s
            Upload:          4.88 Mbit/s
            Ping:         18.00 ms
            Jitter:          2.00 ms

iperf Speedtest between 2 Gigabit connected laptops. One directly
to the Unitymedia router and the other to the gigabit port on the
RaspBerry Pi 2:
------------------------------------------------------------
Client connecting to 192.168.178.21, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[  3] local 192.168.177.180 port 50186 connected with 192.168.178.21 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec   114 MBytes  95.0 Mbits/sec

(Last edited by huwrt on 3 Jul 2016, 15:31)