Adding a USB Ethernet Adapter to a Synology DS413j

27 Aug 2013

Summary: Rough notes made while adding a second USB ethernet NIC to a Synology DS413j NAS (ASIX AX8877X Chipset - AX88772 / AX88178).

This is not a complete "how-to" document. These notes leverage the core steps for installing Synology Kernel Modules documented in Charles-Henri Hallard's excellent step-by-step instructions. However, differences specific to installing the ASIX USB Ethernet NIC modules (rather then the USB serial modules targeted in his instructions) are captured along with any other noted updates/changes in steps.

Resources:
- How to install Kernel modules on Synology DS1010 DSM 4.1 or 4.2
- Compiling Linux Kernel modules for Synology devices
- Synology DiskStation Manager 3rd -Party Apps Developer Guide

Baseline Information

Before we get started - system version info for reference:

Synology Hardware / Software Versions:  Synology DS413j
#=> > uname -a
Linux XDiskStation 2.6.32.12#3211 ... armv5tel GNU/Linux synology_88f6282_413j
#=> > cat /etc/VERSION
majorversion="4"
minorversion="2"
buildphase="hotfix"
buildnumber="3211"
builddate="2013/04/16"
USB to Ethernet Adapter =>  Plugable USB 2.0 Ethernet Adapter ASIX AX88772 Chipset

The ASIX chipset was selected after reading the Synology forum posts by cmb who obviously wanted to do the same thing (and most importantly did so successfully).

Cross Compilation Environment

#=> > $ uname -a
Linux debian 3.2.0-4-686-pae #1 SMP Debian 3.2.46-1 i686 GNU/Linux

(Debian VMware Image.)

DSM Tool Chain Notes:

Synology DS413j => Marvell Kirkwood mv6282 ARMv5te with Package Arch: 6281 6282 
DSM Tool Chain used: gcc421_glibc25_88f6281-GPL.tgz

Synology GPL Kernel source code version used: synogpl-3201-6281.tbz
Local GPL Source location after download:
#=> # pwd
/usr/local/arm-none-linux-gnueabi/source/linux-2.6.32


Config Selection & Makefile Edits

The following Synology created config file was used to configure the kernel (the one corresponding to the Synology DS413j architecture: 6281)

#=> cp synoconfigs/88f6281 .config

Options utilised during Makefile Edit:

ARCH            ?= arm
CROSS_COMPILE   ?= /usr/local/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-

Run the "make menuconfig" command then work through the following menu options:

Device Drivers =>
Network device support =>
USB Network Adapters =>
ASIX AX88xxx Based USB 2.0 Ethernet Adapters  <= Module Select


Config Menu
Run "make modules" - Note: Installing "libc6-i386" was NOT required as per Hallards notes.

My required Modules ended up in the following directory:

/usr/local/arm-none-linux-gnueabi/source/linux-2.6.32# ls -al drivers/net/usb/
<snip>
./drivers/net/usb/asix.ko
./drivers/net/usb/cdc_ether.ko
./drivers/net/usb/usbnet.ko
<snip>


Module Installation on the Synology DS413j

Copy the above 3 modules to your Synology DS413j - use of SCP recommended.

Note: I recommend placing the new modules in a "safe" backup location where they will not be inadvertently overwritten at some point in the future - like a user defined storage volume on the NAS). I believe there is considerable risk that the contents of the /lib/modules/ directory will get overwritten during some future DSM upgrade/update.

Within the "/lib/modules/" directory - I created a new directory called "usb_eth1modules".

mkdir /lib/modules/usb_eth1modules 

From the "safe" location I copied the 3 modules to this new "/lib/modules/usb_eth1modules" directory.

I then also copied a version of the "mii.ko" module from the /lib/modules/ to the new "/lib/modules/usb_eth1modules" directory as well.

cp /lib/modules/mii.ko /lib/modules/usb_eth1modules/mii.ko

This leaves a redundant backup copy in its original location.

Test install the loadable kernel modules:

NOTE: You will get various dependancy errors if you do not first install the "mii.ko" module first. This module is present by default but not installed.

Install the modules in the following order:

#=> XDiskStation> insmod /lib/modules/usb_eth1modules/mii.ko
#=> XDiskStation> insmod /lib/modules/usb_eth1modules/usbnet.ko
#=> XDiskStation> insmod /lib/modules/usb_eth1modules/cdc_ether.ko
#=> XDiskStation> insmod /lib/modules/usb_eth1modules/asix.ko

#=> XDiskStation> lsmod
Module                  Size  Used by    Tainted: P  
asix                   12168  0 
cdc_ether               3047  0 
usbnet                 12093  2 asix,cdc_ether
mii                     3640  2 asix,usbnet

Plug in the USB to Ethernet Adapter and...

#=> XDiskStation> dmesg
[   87.270000] usbcore: registered new interface driver cdc_ether
[   88.130000] eth1: register 'asix' at usb-orion-ehci.0-1.1, ASIX AX88772 USB 2.0 
Ethernet, 8c:ae:4c:fe:04:cb
[   88.170000] usbcore: registered new interface driver asix
…
[  210.140000] eth1: link up, 100Mbps, full-duplex, lpa 0x41E1
[  223.580000] eth1: link up, 100Mbps, full-duplex, lpa 0x41E1
[  297.670000] eth0: link up, full duplex, speed 1 Gbps 

... all should be good.

Auto load modules on boot

To have the new USB Ethernet NIC automatically available after system startup the new modules should be configured to auto load on boot.

To ensure this occurs, I created a script called "S99usb_eth1modules.sh" in the "/usr/syno/etc.defaults/rc.d/" directory. The contents of this script are taken from Charles-Henri Hallard's (version of Davy Leggieri's) script from his above post - with the following minor modifications:

#=> vi /usr/syno/etc.defaults/rc.d/S99usb_eth1modules.sh
...
MODULES_DIR="/lib/modules/usb_eth1modules"
MAINMODULE="mii.ko"
SUBMODULES="usbnet.ko cdc_ether.ko asix.ko"
...

As the Synology boots - this script will run and ensure the modules are loaded in the right order so the eth1 interface can then be configured automatically (see next step).

Auto configure eth1 on boot

To configure the eth1 interface automatically on boot with a useable static IP address I created another script that runs during system boot. This script copies a "ifcfg-eth1" configuration file (that we create below) from a "safe location" on the NAS data volume to the "/etc/sysconfig/network-scripts/" directory and restarts the networking service.

#=> XDiskStation> cat /volume1/safelocation/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=static
ONBOOT=yes
IPADDR=172.16.XXX.XXX       #<= use your required IP address
NETMASK=255.255.255.0
GATEWAY=172.16.XXX.XXX      #<= use your required Gateway IP address

A "S99usb_eth1up.sh" script was then also created and placed in the "/usr/syno/etc.defaults/rc.d/" directory. It contents are as follows:

vi /usr/syno/etc.defaults/rc.d/S99usb_eth1up.sh

#!/bin/sh
cp /volume1/safe_location/ifcfg-eth1 /etc/sysconfig/network-scripts/ifcfg-eth1
/etc/rc.network restart

Be sure your "S99usbeth1up.sh" script (or equivalent) runs after the module loading script (S99usbeth1modules.sh in my case).



comments powered by Disqus