Synology NAS USB port activation for Sonoff Zigbee Dongle and Zigbee2MQTT¶
This guide will help you activate the USB port on your Synology NAS. This is required for the Sonoff Zigbee Dongle to work alongside the Zigbee2MQTT docker container. Ideal if you are running Home Assistant on your Synology NAS.
Prerequisites¶
- A Synology NAS with a USB port. This guide was tested on a Synology DS216+.
- SSH access to your Synology NAS. You can find instructions on how to do this here: https://www.synology.com/en-global/knowledgebase/DSM/tutorial/General_Setup/How_to_login_to_DSM_with_root_permission_via_SSH_Telnet - note that you do not need to get root access, just regular SSH access is fine.
Step 1: Identify your NAS¶
Determine your NAS model and CPU architecture at Synology Knowledge Base.
Example: Synology DS216+ has a Braswell CPU.
Step 2: Download the drivers¶
Visit GitHub - DSM7 USB Serial Drivers to download the appropriate drivers for your CPU architecture and DSM version. Place them in /volume1/homes/USERNAME/drivers/.
Example: For a Synology DS216+ with DSM 7.2, download ch341.ko, cp210x.ko, pl2303.ko, and ti_usb_3410_5052.ko.
Important
Make sure you also download the right files for your Synology NAS version. In this example, we are using DSM 7.2, so we downloaded the files for DSM 7.2. If you are using a different version of DSM, you should download the files for that version instead.
Step 3: Installing the drivers¶
Important
You will have to execute the following steps every time you update Synology DSM.
- Connect the Sonoff Zigbee USB Dongle to your NAS.
- SSH into your Synology NAS following the instructions in the previous section.
-
Run the following commands in this order:
lsusbto make sure the USB dongle is detected. This command lists USB devices that are currently connected to your system. It shows information such as the ID and manufacturer of the device, which can be useful for troubleshooting or identifying devices. While the dongle might be detected, it will not be usable yet.cd /devto change directory to the/devdirectory. This directory contains special files that represent devices connected to your system.lsto list the files in the current directory and confirm there is nottyUSB0visible yet. This is the file that represents the USB-to-serial converter.
Important
You should not see
/dev/ttyUSB0listed in the list generated byls. If you do, then the USB-to-serial converter is already connected to your system, and you should already be able to use the USB port on your Synology NAS.
If you do not see /dev/ttyUSB0 listed, then run the following commands in the following order:
``` shell
sudo su
modprobe usbserial
modprobe ftdi_sio
modprobe cdc-acm
```
These are a series of Linux commands related to USB devices:
* `sudo su` followed by your Synology user's password to get root access. The `sudo` command is used to run commands with root privileges, and the `su` command is used to switch to the root user.
* `modprobe usbserial` - This command loads the `usbserial` module into the kernel. The `usbserial` module is a generic USB serial driver that supports a wide range of USB-to-serial converters.
* `modprobe ftdi_sio` - This command loads the `ftdi_sio` module into the kernel. The `ftdi_sio` module is a USB Serial Convertor driver, specifically for devices using the FTDI USB to serial chip.
* `modprobe cdc-acm` - This command loads the cdc-acm module into the kernel. The cdc-acm module is a driver for USB devices such as modems and ISDN adapters that use the Communication Device Class Abstract Control Model (CDC ACM) protocol.
-
Next we must insert the modules
ch341.ko,cp210x.ko,pl2303.ko, andti_usb_3410_5052.kointo the kernel. These modules are drivers for USB-to-serial converters. Specifically, it's theinsmodcommand that inserts a module into the kernel, and thesudocommand is used to run the command with root privileges. We will copy the driver we downloaded earlier to the correct location/lib/modulesand then insert it into the kernel:cp /volume1/homes/USERNAME/drivers/ch341.ko /lib/modules/ch341.ko sudo insmod /lib/modules/ch341.ko cp /volume1/homes/USERNAME/drivers/cp210x.ko /lib/modules/cp210x.ko sudo insmod /lib/modules/cp210x.ko cp /volume1/homes/USERNAME/drivers/pl2303.ko /lib/modules/pl2303.ko sudo insmod /lib/modules/pl2303.ko cp /volume1/homes/USERNAME/drivers/ti_usb_3410_5052.ko /lib/modules/ti_usb_3410_5052.ko sudo insmod /lib/modules/ti_usb_3410_5052.ko
Step 4: Configure an autoload script¶
Next we want to make sure that these modules are loaded automatically when the NAS boots. To do this:
-
Create a new file
start-usb-drivers.shcontaining the following command and place it in the same folder on the server where you originally placed the USB drivers:#!/bin/sh case $1 in start) insmod /lib/modules/usbserial.ko > /dev/null 2>&1 insmod /lib/modules/ftdi_sio.ko > /dev/null 2>&1 insmod /lib/modules/cdc-acm.ko > /dev/null 2>&1 insmod /lib/modules/cp210x.ko > /dev/null 2>&1 insmod /lib/modules/ch341.ko > /dev/null 2>&1 insmod /lib/modules/pl2303.ko > /dev/null 2>&1 insmod /lib/modules/ti_usb_3410_5052.ko > /dev/null 2>&1 ;; stop) exit 0 ;; *) exit 1 ;; esac#!/bin/sh- This line tells the system that this is a shell script and that it should be run with the/bin/shprogram.case $1 in- A case statement. The$1variable contains the first argument passed to the script.start)- This line starts another case statement.insmodyou are already familiar with. The> /dev/null 2>&1part of the command redirects the output of the command to/dev/null, which is a special file that discards all data written to it. This means that the output of the command will not be displayed on the screen.;;- These lines end the case statements.stop)- This line starts another case statement.exit 0- This line exits the script with a status code of0, which means that the script was successful.*)- This line starts, you guessed it, a case statement.exit 1- Exits the script with a status code of1, which means that the script failed.esac- This line ends the case statement.
-
Now copy the
start-usb-drivers.shto the/usr/local/etc/rc.d/folder:cp /volume1/homes/USERNAME/drivers/start-usb-drivers.sh /usr/local/etc/rc.d/start-usb-drivers.sh cd /usr/local/etc/rc.d/ sudo chmod +x start-usb-drivers.shcd /usr/local/etc/rc.d/- This command changes the current directory to/usr/local/etc/rc.d/. This directory typically contains scripts that are run at startup or when the system state changes.sudo chmod +x start-usb-drivers.sh- This command changes the permissions of the filestart-usb-drivers.shto make it executable. Thechmod +xcommand adds execute permissions, andsudois used again to run the command with root privileges.
Step 5: Make sure your devices are recognized¶
Now let's make sure that the USB-to-serial converter is recognized by the system. To do this, run the following commands in this order:
*sudo /usr/local/etc/rc.d/start-usb-drivers.sh start - This command runs the start-usb-drivers.sh script with root privileges.
Step 6: Verify the USB-to-serial converter is recognized¶
Run the following command to switch to the /dev directory and list the files in the directory:
ttyUSB0 listed. This means that the USB-to-serial converter is now connected to your system, and you should be able to use the USB port on your Synology NAS.
You can now use the USB port on your Synology NAS to connect the Sonoff Zigbee Dongle to your Synology NAS and use it with Zigbee2MQTT!