12

How to install Kernel modules on Synology DS1010

This is how I installed usb serial modules on my Synology SAN (my version is the DS1010+ and also a DS106)   All stuff source is grabbed from here, well documented by Davy, but just in case it dissapears one day and for my own informations, I add to my blog.

This is for DSM 4.0, since DSM 4.1 is now out, this procedure do not apply because Synology switched linux kernel 2.6 to 3.x, if you want the DSM 4.1 version, checkout this other post

What do you need ?

  • A linux box with at least 5GB free drive do host all Synology linux sources and development tools
  • The latest toolchains for your synology
  • The latest Synology source code

for my DS1010 (DSM 4) I took gcc420_glibc236_x64-GPL.tgz for the toolchain so Intel x86 Linux 2.6.32 (Pineview) and synogpl-2198-x64.tbz so DSM 4.0 and  2198 Branch x64 version)

for my DS106 (DSM 4) I took gcc334_glibc233_ppc-GPL.tgz] for the toolchain so PowerPC 824x Linux 2.4.22 and synogpl-2198-824x.tbz so DMS 4 and 2198 Branch for PowerPc

Go for compilation

assuming you put the two files on you linux box, now unzip them

tar -xvzf gcc420_glibc236_x64-GPL.tgz -C /usr/local/ tar -xvzf gcc334_glibc233_ppc824x-GPL.tgz -C /usr/local/

now you have a folder named x86_64-linux-gnu under /usr/local/ and a folder powerpc-linux

tar -xvjf synogpl-2198-x64.tbz -C /usr/local/x86_64-linux-gnu/ tar -xvjf synogpl-2198-824x.tbz -C /usr/local/powerpc-linux-gnu/

go for a coffe….wait…

get which Linux kernel we have on the two Synology to compile the correct version. in the examples below the command prefix design on which synology the command has been issued (ds1010 or ds106) ssh to your Synology and issue a

ds1010 # uname -a
Linux DiskStation 2.6.32.12 #2219 SMP Fri Apr 13 04:27:48 CST 2012 x86_64 GNU/Linux synology_x86_1010+ 
ds106 # uname -a
Linux ds106 2.4.22-uc0 #2219 Fri Apr 13 04:29:23 CST 2012 ppc GNU/Linux synology_powerpc_106

Our kernel is 2.6.32 for DS1010 and 2.4.22 for DS106, now get back to the linux box and go to the Synology NAS GPL source folder corresponding to your Synology Linux kernel

For DS1010 (adapt it for the DS106)

linuxbox # cd /usr/local/x86_64-linux-gnu/source/linux-2.6.32

Copy the config file created by Synology to configure the kernel (the one corresponding to your synology architecture here x86_64)

linuxbox # cp synoconfigs/x86_64 .config

Edit the Makefile ARCH and CROSS_COMPILE variables to compile for the right architecture and use the right tool chains. The following two lines need to be modified in the file named Makefile

ARCH=x86_64
CROSS_COMPILE=/usr/local/x86_64-linux-gnu/bin/x86_64-linux-gnu-

Check the config file we just copied

make oldconfig

Edit the config file add needed modules.

make menuconfig

I went to Device Driver / USB Support / USB Serial Converter support and checked all as Module

Compile all modules

make modules

Your modules are in the corresponding subfolder drivers/usb/serial/

/usr/local/x86_64-linux-gnu/source/linux-2.6.32/drivers/usb/serial# ls *.ko
aircable.ko   cypress_m8.ko       hp4x.ko         iuu_phoenix.ko  mos7720.ko     option.ko       sierra.ko            visor.ko
ark3116.ko    digi_acceleport.ko  io_edgeport.ko  keyspan.ko      mos7840.ko     oti6858.ko      spcp8x5.ko           whiteheat.ko
belkin_sa.ko  empeg.ko            io_ti.ko        keyspan_pda.ko  moto_modem.ko  pl2303.ko       symbolserial.ko
ch341.ko      ftdi_sio.ko         ipaq.ko         kl5kusb105.ko   navman.ko      qcserial.ko     ti_usb_3410_5052.ko
cp210x.ko     funsoft.ko          ipw.ko          kobil_sct.ko    omninet.ko     safe_serial.ko  usb_debug.ko
cyberjack.ko  garmin_gps.ko       ir-usb.ko       mct_u232.ko     opticon.ko     siemens_mpi.ko  usbserial.ko

Installation of the modules on the synology

I have ipkg optware installed to my Synology so you need it if you want to do the following. The procedure is located on another post on my blog

You can do it without ipkg also, copying the module into /lib/modules/ of the synology and adding the startup script (see below) into /usr/syno/etc/rc.d/

go ssh to your Synology box

create the folder hierarchy under /opt/lib/

mkdir /opt/lib/modules 
mkdir /opt/lib/modules/2.6.32

copy the needed modules to this folder (unfortunatly synology can’t do native scp) so I copied then from my linux box to the Synology share NetBackup (/volume1/NetBackup/modules/) and then issued from the Synology

cp /volume1/NetBackup/modules/*.ko /opt/lib/modules/2.6.32/

Remember I just needed USB serial converter, Prolific and FTDI so as the Synology do not populate /dev/ttyUSBx we need to create them (here for 3 simultaned devices)

mknod /dev/ttyUSB0 c 188 0 
mknod /dev/ttyUSB1 c 188 1 
mknod /dev/ttyUSB2 c 188 2

then issued a insmod for the needed modules (usbserial first !!!)

insmod /opt/lib/modules/2.6.32/usbserial.ko
insmod /opt/lib/modules/2.6.32/ftdi_sio.ko
insmod /opt/lib/modules/2.6.32/pl2303.ko

Then I plugged one PL2303 chip and one FTDI and voila !!!

#dmesg
[423700.733757] usbcore: registered new interface driver usbserial
[423700.740088] USB Serial support registered for generic
[423700.745734] usbcore: registered new interface driver usbserial_generic
[423700.752621] usbserial: USB Serial Driver core
[423707.532975] USB Serial support registered for pl2303
[423707.538493] usbcore: registered new interface driver pl2303
[423707.544403] pl2303: Prolific PL2303 USB to serial adaptor driver
[423727.083297] USB Serial support registered for FTDI USB Serial Device
[423727.090326] usbcore: registered new interface driver ftdi_sio
[423727.096325] ftdi_sio: v1.5.0:USB FTDI Serial Converters Driver
[427041.198512] usb 7-1: new full speed USB device using uhci_hcd and address 3
[427041.353494] Got empty serial number. Generate serial number from product.
[427041.361047] usb 7-1: configuration #1 chosen from 1 choice
[427041.370793] pl2303 7-1:1.0: pl2303 converter detected
[427041.388470] usb 7-1: pl2303 converter now attached to ttyUSB0
[427856.592812] usb 8-2: new full speed USB device using uhci_hcd and address 2
[427856.747130] Got empty serial number. Generate serial number from product.
[427856.754245] drivers/usb/core/hub.c (1970) Same device found. Change serial to ffffffc6ffffffa3ffffffcfffffffa0
[427856.765288] usb 8-2: configuration #1 chosen from 1 choice
[427856.773506] pl2303 8-2:1.0: pl2303 converter detected
[427856.791078] usb 8-2: pl2303 converter now attached to ttyUSB1

Auto load modules on boot

May be you want the modules to be loaded at boot time, sure this is what I wanted

create the following script S50modules in /opt/etc/init.d/ folder. Change the MODULES_DIR and MODULES var to fit with your configuration.

#!/bin/sh
# Original script has been written by Davy Leggieri (hey another French guy :-)
# Modified by Charles-Henri Hallard on April 2012 to fit with my configuration
#
MODULES_DIR="/opt/lib/modules/2.6.32"
MAINMODULE="usbserial.ko"
SUBMODULES="ftdi_sio.ko pl2303.ko"

start_modules(){
        echo "--- Load modules ---"
        for i in $MAINMODULE $SUBMODULES; do
                echo "Loading $i"
                insmod $MODULES_DIR/$i
        done

        # Create the ttyUSB (7 should be enought for me)
        if [ ! -c /dev/ttyUSB0 ]; then
                mknod /dev/ttyUSB0 c 188 0
                mknod /dev/ttyUSB1 c 188 1
                mknod /dev/ttyUSB2 c 188 2
                mknod /dev/ttyUSB3 c 188 3
                mknod /dev/ttyUSB4 c 188 4
                mknod /dev/ttyUSB5 c 188 5
                mknod /dev/ttyUSB6 c 188 6
        fi
}

stop_modules(){
        echo "--- Unload modules ---"
        for i in $SUBMODULES $MAINMODULE; do
                echo "Unloading $i"
                rmmod $MODULES_DIR/$i
        done
}

case "$1" in
start)
        start_modules
        ;;
stop)
        stop_modules
        ;;
*)
        echo "usage: $0 { start | stop }" >&2
        exit 1
        ;;
esac

Do not forget to set this script executable with

chmod ug+x S50modules

PS : I would like to thanks Greg Numan who noticed me errors located on my original script

Do not want to to this stuff, I’ve done it for this documentation

So you can download all compiled modules ds1010-dsm40 (for DS1010 DSM 4.0 Only). The archive contains all USB Serial Modules compiled during this topic (may be you will need to change the .gz extension to .tgz after download).

Charles

You can discuss about this article or other project using the community forum