Skip to content

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

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.

  1. Connect the Sonoff Zigbee USB Dongle to your NAS.
  2. SSH into your Synology NAS following the instructions in the previous section.
  3. Run the following commands in this order:

    lsusb
    cd /dev
    ls
    
    • lsusb to 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 /dev to change directory to the /dev directory. This directory contains special files that represent devices connected to your system.
    • ls to list the files in the current directory and confirm there is no ttyUSB0 visible yet. This is the file that represents the USB-to-serial converter.

    Important

    You should not see /dev/ttyUSB0 listed in the list generated by ls. 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.
  1. Next we must insert the modules ch341.ko, cp210x.ko, pl2303.ko, and ti_usb_3410_5052.ko into the kernel. These modules are drivers for USB-to-serial converters. Specifically, it's the insmod command that inserts a module into the kernel, and the sudo command is used to run the command with root privileges. We will copy the driver we downloaded earlier to the correct location /lib/modules and 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:

  1. Create a new file start-usb-drivers.sh containing 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/sh program.
    • case $1 in - A case statement. The $1 variable contains the first argument passed to the script.
    • start) - This line starts another case statement.
    • insmod you are already familiar with. The > /dev/null 2>&1 part 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 of 0, 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 of 1, which means that the script failed.
    • esac - This line ends the case statement.
  2. Now copy the start-usb-drivers.sh to 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.sh
    
    • cd /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 file start-usb-drivers.sh to make it executable. The chmod +x command adds execute permissions, and sudo is 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

cd /dev

ls
* 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:

cd /dev
ls
You should now see 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!