94

How to install Kernel modules on Synology DS1010 DSM 4.1, 4.2, 4.3, 5.0, 5.1 or 5.2

This is how I installed USB serial modules on my Synology DS1010+ with DSM 4.1 ,DSM 4.2, DSM 4.3, DSM 5.0, DSM 5.1 and DSM 5.2

Edit 06/12/2015 : Today I updated my Syno to DSM 5.2 and Synology team for this release changed kernel  version from 3.2.40 to 3.10.35. This makes old modules not loadable anymore. I think the procedure described in this post is still working but I needed to remove my old virtual machine so I can’t check anymore and do any compilation to validate. If anyone done it, just let me know so I can update this post according.

I think today it could be easier using new technique such as docker or chrooting a debian environment on the synology. then install all build process and compile the module on the Synology itself.

Anyway, today I just needed all USB serial driver for my Syno and found them working with 5.2 on Synology forum for my DS1010+. Yo can download from there just in case (only x86_64 arch)

Edit 12/27/2014 : Added DSM 5.1, use the same procedure than DSM 5.0. Modules are still compatible.
Edit 03/21/2014 : Added DSM 5.0

I cross-compiled the modules on another box than the Synology box, more safe, I do not want to install all development environement on the Synology box, I like to keep it safe and working.

This is for DSM 4.1, 4.3, 4.3, 5.0 or 5.1, for older DMS version see my other post

What do you need ?

  • A linux box with at least 10GB free drive do host all Synology linux sources and development tools. I used Clouded Virtual Machine Linux Ubuntu 12.04 LTS server provided by Windows Azure. Other distribution could differs in command line and may not work.
  • The latest toolchains for your synology
  • The latest Synology source code

For my DS1010 DSM 4.1 I took gcc420_glibc236_x64-GPL.tgz for the toolchain so Intel x86 Linux 3.2.11 (Pineview) and so DSM 4.1 and  synogpl-2636-x64.tbz 2636 Branch x64 version)

For my DS1010 DSM 4.2 I took gcc420_glibc236_x64-GPL.tgz and synogpl-3201-x64.tbz.

For my DS1010 DSM 4.3 (update 2) I took  gcc420_glibc236_x64-GPL.tgz  and synogpl-3776-x64.tbz

For my DS1010 DSM 5.0/5.1 I took gcc473_glibc217_x86_64-GPL.tgz and synogpl-4458-x64.tbz

Install the building environment on the linux box

sudo apt-get install build-essential ncurses-dev

Go for compilation

assuming you put the two files on you linux box, now unzip them. Take the file name and version of the one you previously downloaded

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

now you have a folder named x86_64-pc-linux-gnu under /usr/local/ (or x86_64-linux-gnu for old version, in this case, change the line below with the correct path)

sudo tar -xvjf synogpl-2636-x64.tbz -C /usr/local/x86_64-pc-linux-gnu/

go for a coffe….wait…

Get which Linux kernel we have on the two Synology to compile the correct version. So ssh to your Synology and issue a :

uname -a
Linux DiskStation 3.2.11 #2636 SMP Thu Aug 30 00:06:04 CST 2012 x86_64 GNU/Linux synology_x86_1010+

Our kernel is 3.2.11, now get back to the linux box and go to the Synology NAS GPL source folder corresponding to your Synology Linux kernel. But before, it is also time to become root to avoid permission denied in the future.

sudo su -
cd /usr/local/x86_64-pc-linux-gnu/source/linux-3.x

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

cp synoconfigs/x86_64 .config

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

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

For DSM 5.0/5.1 : I tried to change the line above, but does not exist and tried to change CONFIG_CROSS_COMPILE didn’t worked either, so I decided to do it dirty way, I added the two following lines directly in the Makefile located in current folder

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

Check the config file we just copied

make oldconfig

DSM 5.0/5.1 : press enter on each question (let default values)

Launch the configuration menu to select what we need.

Take care, the Makefile on DSM 4.2 seems corrupt on line 179 you need to edit it and change the 2 lines

# to the target
architecture. (See arch/* for the possibilities).

by only one line

# to the targetarchitecture. (See arch/* for the possibilities).

Then issue a

make menuconfig

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

Now we can compile all modules (no need to compile all kernel), issue a :

make modules

Here, I went to some file not found problem, my 64 bits compile platform was unable to launch 32 bits applications and fired me a error “file not found on the file x86_64-linux-gnu-gcc even if the file was here. To correct this you need to install 32 bits libraries (yeah, if you don’t know that you’re stuck !!). downloading 64 bits toolchains contains 32 bits programs, and even worse, on the Synology, there are a lot of 32 bits files even if it is a 64 bits kernel.

apt-get install libc6-i386

then re-issue

make modules

If all went fine (and it should :-)) Your modules are in the corresponding subfolder drivers/usb/serial/

/usr/local/x86_64-pc-linux-gnu/source/linux-3.x/drivers/usb/serial# ls *.ko
aircable.ko    digi_acceleport.ko  io_ti.ko        kl5kusb105.ko  omninet.ko   safe_serial.ko       usb_debug.ko
ark3116.ko     empeg.ko            ipaq.ko         kobil_sct.ko   opticon.ko   siemens_mpi.ko       usbserial.ko
belkin_sa.ko   ftdi_sio.ko         ipw.ko          mct_u232.ko    option.ko    sierra.ko            usb_wwan.ko
ch341.ko       funsoft.ko          ir-usb.ko       mos7720.ko     oti6858.ko   spcp8x5.ko           visor.ko
cp210x.ko      garmin_gps.ko       iuu_phoenix.ko  mos7840.ko     pl2303.ko    ssu100.ko            vivopay-serial.ko
cyberjack.ko   hp4x.ko             keyspan.ko      moto_modem.ko  qcaux.ko     symbolserial.ko      whiteheat.ko
cypress_m8.ko  io_edgeport.ko      keyspan_pda.ko  navman.ko      qcserial.ko  ti_usb_3410_5052.ko  zio.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/ But I prefer separate and put them into ipkg, this will prevent erasing the modules with futur firmware update.

So if using ipkg, go ssh to your Synology box and create the folder hierarchy under /opt/lib/. For DSM 4.3 the folder is 3.2.40 (the matching kernel version)

mkdir /opt/lib/modules 
mkdir /opt/lib/modules/3.2.40

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/3.2.40/

Remember I just needed USB serial converter, Prolific, cp210x 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/3.2.40/usbserial.ko
insmod /opt/lib/modules/3.2.40/ftdi_sio.ko
insmod /opt/lib/modules/3.2.40/pl2303.ko
insmod /opt/lib/modules/3.2.40/cp210x.ko

All went fine

#dmesg
[3614241.559823] usbcore: registered new interface driver usbserial
[3614241.566106] USB Serial support registered for generic
[3614241.571638] usbcore: registered new interface driver usbserial_generic
[3614241.578358] usbserial: USB Serial Driver core
[3614248.756928] USB Serial support registered for FTDI USB Serial Device
[3614248.763906] usbcore: registered new interface driver ftdi_sio
[3614248.769921] ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver
[3614253.442812] USB Serial support registered for pl2303
[3614253.448340] usbcore: registered new interface driver pl2303
[3614253.454114] pl2303: Prolific PL2303 USB to serial adaptor driver
[3614259.258426] USB Serial support registered for cp210x
[3614259.263951] usbcore: registered new interface driver cp210x
[3614259.269711] cp210x: v0.09:Silicon Labs CP210x RS232 serial adaptor driver

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 S10modules 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
#
# there is start stop var because at stop modules usbserial should be unloaded last
MODULES_DIR="/opt/lib/modules/3.2.40"
MODULES_START="usbserial.ko ftdi_sio.ko pl2303.ko cp210x.ko"
MODULES_STOP="ftdi_sio.ko pl2303.ko cp210x.ko usbserial.ko"

start_modules(){
        echo "--- Load modules ---"
        for i in $MODULES_START; 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 $MODULES_STOP; 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 S10modules

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

So you can download all compiled modules. 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).

  • DSM 4.1 compiled modules for DS1010
  • DSM 4.2 compiled modules for DS1010
  • DSM 4.3 compiled modules for DS1010
  • DSM 5.0 / 5.1 compiled modules for DS1010

Have fun

I have more and more demand of custom compilation, I can do it when I have time but it take some time to do this, so if you want to donate, feel free to do it using the following paypal button.




Charles




Charles

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