After reading Pomprocker's excellent posts and several other publications on the web I decided to order a cheap USB Serial converter from
http://www.dealextreme.com. The chip used in the converter was advertised as a pl2303 however after receiving the actual item it appeared that they changed it to the ch341 Winchiphead chip. As already mentioned by Pomprocker, Synology doesn't provide USB serial kernel drivers so you need to compile your own drivers. For those who would like to use their Synology Diskstation to control their X-10 equipment using a CM11A, I thought it would be useful to combine the information already published by Pomprocker with my own steps and experience to create a working system.
I used the following procedure to compile kernel modules for a USB serial converter based on the CH341 chipset. The serial converter is to be used on a Synology DS110j with kernel source Linux-2.6.32 and firmware version 3.0.
First create an Operation Environment for compilation, e.g. virtual machine (VirtualBox) Ubuntu 10.10 Desktop.
After the installation of Ubuntu check in Synaptic Package Manager if the following packages are installed:
libncurses5 libncurses5-dev
Open a browser and download the latest Synology Tool Chain for your platform e.g. gcc421_glibc25_88f628x.tgz for the DS209, DS110j at
http://sourceforge.net/projects/dsgpl/files/DSM 3.0 Tool Chains/
Next, download the correct Synology NAS GPL Source for your platform e.g. 1337Branch > synogpl-1337b-6281.tbz for the DS209, DS110j at
http://sourceforge.net/projects/dsgpl/files/Synology NAS GPL Source/
Unpack the GPL to your preferred directory e.g. /home/<userdir>:
# tar xvf synogpl-1337b-6281.tbz
Unpack the toolchain package as follows to /usr/local
# tar zxvf gcc421_glibc25_88f628x.tgz -C /usr/local
Edit the Makefile and change the CROSS_COMPILE variable:
# vi /home/<userdir>/source/linux-2.6.32/Makefile
CROSS_COMPILE = /usr/local/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-
Setup and loading the kernel config GUI:
# cd /home/<userdir>/source/linux-2.6.32/synoconfigs
# cp 88f6281 ../.config
# make ARCH=arm menuconfig
To compile a module for a ch341 serial converter, lookup and highlight the feature and then press ‘M’
Device Drivers ---> USB support ---> USB Serial Converter support ---> USB Winchiphead ch341..
(press M)
Exit the GUI and start compiling the kernel modules:
# make ARCH=arm modules
The compiled usbserial.ko and ch341.ko drivers can now be found in /home/<userdir>/source/linux-2.6.32/drivers/usb/serial/
The next step is to load the compiled modules into the kernel of the Synology Diskstation, create the devices and make the configuration persistent after a reboot.
Before inserting the USB serial converter, create a shared folder on volume1 (the default Synology volume) e.g. setup. Next, create a folder called “drivers” and transfer or upload the earlier created usbserial.ko and ch341.ko files to this new folder on the DS110j. Use a terminal application, such as PuTTY, to login as root to the DiskStation and load the modules into the kernel as follows:
insmod /volume1/setup/drivers/usbserial.ko
insmod /volume1/setup/drivers/ch341.ko
and create the following devices:
mknod /dev/usb/ttyUSB0 c 188 0
mknod /dev/usb/ttyUSB1 c 188 1
Now plug-in your USB serial converter and run 'dmesg' from the command line to check if everything works. You should see something like this:
[ 25.750000] usb 1-1.2: new full speed USB device using orion-ehci and address 3
[ 25.870000] usb 1-1.2: configuration #1 chosen from 1 choice
[ 25.990000] Got empty serial number. Generate serial number from product.
[ 37.240000] NET: Registered protocol family 5
[ 41.390000] findhostd uses obsolete (PF_INET,SOCK_PACKET)
[ 3747.350000] usbcore: registered new interface driver usbserial
[ 3747.350000] USB Serial support registered for generic
[ 3747.400000] usbcore: registered new interface driver usbserial_generic
[ 3747.400000] usbserial: USB Serial Driver core
[ 3765.600000] USB Serial support registered for ch341-uart
[ 3765.600000] ch341 1-1.2:1.0: ch341-uart converter detected
[ 3765.630000] usb 1-1.2: ch341-uart converter now attached to ttyUSB0
[ 3765.670000] usbcore: registered new interface driver ch341
To make the modules persistent over a reboot, add the following lines to /etc/rc.local:
insmod /volume1/setup/drivers/usbserial.ko
insmod /volume1/setup/drivers/ch341.ko
mknod /dev/usb/ttyUSB0 c 188 0
mknod /dev/usb/ttyUSB1 c 188 1
Next we are going to install Heyu on the DS110j
Heyu is a text-based command line program for remotely controlling lights and appliances in the home or office. The complete source is made available under the free Heyu License. Heyu uses the CM11A computer interface to send and receive X10 control signals over the AC power lines to modules which can turn On, Off, or Dim attached lamps or appliances. It can store a schedule of timed events in the CM11A memory for execution when the computer is turned off or disconnected.
We could compile Heyu from source but luckily there is a precompiled ipkg. To install the package please first install the ipkg bootstrap which can be found here:
http://forum.synology.com/wiki/index.ph ... ,_ipkg_etc ipkg install heyu
Heyu will install in /opt/bin and /opt/etc/heyu. To make things work go to /opt/etc/heyu and do:
cp x10.conf.sample x10.conf
vi x10.conf
and modify the TTY entry to:
TTY /dev/usb/ttyUSB0 # [serial port device]
Configure the HOUSE code and save the file. Next type:
heyu info
The output should look something like this:
Heyu version 2.8.0
Configuration at /opt/etc/heyu/x10.conf
Powerline interface on /dev/usb/ttyUSB0
Firmware revision Level = 8
Interface battery usage = 1:44 (hh:mm)
Raw interface clock: Tue, Day 017, 22:54:00
(--> Civil Time: Tue 18 Jan 2011 22:54:00 CET)
No schedule has been uploaded by Heyu.
Housecode = M
0 = off, 1 = on, unit 16.......8...4..1
Last addressed device = 0x0020 (0000000001000000)
Status of monitored devices = 0x0130 (0110000001000000)
Status of dimmed devices = 0x0000 (0000000000000000)
Adding domus.Link web front-end to Heyu
domus.Link is a web-based frontend for Heyu. The design focuses on separating configuration from actual controls thus giving the user a simple and user friendly GUI. The primary concern being that anyone with little or no knowledge of home automation systems can easily manage/administer the system.
The first step is to enable Webstation on your Synology box and check that your webpage is showing by entering
http://<your DS ip address>/ in your browser.
Next, download the latest release of the domus.Link software go to:
http://domus.link.co.pt/Copy domuslink-1.2.tar.gz to the directory /volume1/web/ on the DS110j. Login to the server with PuTTY and extract the .tar.gz file using the following command:
tar xfvz domuslink-1.2.tar.gz
To set the permissions to the entire domus.Link directory and its subdirectories and files, do the following:
chown -R root domus*
chgrp -R root domus*
Go to the /volume1/web/domus.Link/doc directory and follow the installation instructions.
To use domus.Link together with Heyu do the following:
mkdir /etc/heyu
cp /opt/etc/heyu/x10.conf /etc/heyu/
mkdir /volume1/web/heyu
cp /opt/bin/heyu /volume1/web/heyu/
Next, change the permissions on the directories and files as follows:
chmod 777 /etc/heyu
chmod 777 /etc/heyu/x10.conf
chmod 777 /volume1/web/heyu
chmod 777 /volume1/web/heyu/heyu
Now go to the
http://<your DS ipaddress>/domus.Link home page and check the Heyu status on the bottom left. If the status is down, click on it and click on start. If an error message appears, login to your Diskstation with PuTTY, and do the following:
heyu restart
heyu stop
Now select start again on the domus.Link status page. If everything went well, the status should now show Running and the modules should be visible on the home and lights tabs.
Enjoy!
