[Solved] USB Bluetooth support on Synology DSM 7.1 and DSM 7.2

I managed to compile the bluetooth kernel modules (bluetooth.ko and btusb.ko) for Synology DSM 7.1 kernel 4.4.180+, geminilake (x86_64). Models like DS220+, 720, 920.

You can download them from here: geminilake DSM 7.1 - Google Drive

To install them and run them automatically on boot:

  • copy bluetooth.ko and btusb.ko to nas /lib/modules/

sudo cp bluetooth.ko btusb.ko /lib/modules/

  • create a startup file on nas to load them on boot

echo -e "#!/bin/sh\ncase \$1 in\n start)\n insmod /lib/modules/bluetooth.ko > /dev/null 2>&1\n insmod /lib/modules/btusb.ko > /dev/null 2>&1\n ;;\n stop)\n exit 0\n ;;\n *)\n exit 1\n ;;\nesac" | sudo tee /usr/local/etc/rc.d/bluetooth-modules.sh

sudo chmod 755 /usr/local/etc/rc.d/bluetooth-modules.sh

  • execute manually this time

sudo /usr/local/etc/rc.d/bluetooth-modules.sh start

To test if the module is loaded:
lsmod | grep bt

I am using a Sena UD100 usb bluetooth adapter with my docker installation of Home Assistant and that is working fine. The container is running in privileged mode.

You can verify that in the docker container:
docker exec -it homeassistant /bin/sh

then in the container

I will try to find some spare time to document this so others can build for different architectures or for DSM 7.2 that is currently in beta.

The main purpose of this is to allow you to run HA in docker on Synology NAS and having access to a usb bluetooth dongle.

I have noticed that after reboot, the nas is not bringing the bluetooth interface up.
Also the ble_monitor component can’t do it, maybe related to setcap.
[custom_components.ble_monitor] HCIdump thread: Something wrong - interface hci0 not ready
So you might need to do this from HA docker: hciconfig hci0 up
You can do this automatically from HA by creating a shell command and running that command as an automation on HA startup.


Thanks for working on this. So I tired this on my RS818 (Avoton) and I get an error loading, going to assume because these were not compiled for this particular platform. Any way to compile for that?

insmod: ERROR: could not insert module /lib/modules/bluetooth.ko: Invalid module format
insmod: ERROR: could not insert module /lib/modules/btusb.ko: Invalid module format

The files that I’ve provided are for geminilake, it is written in the very first sentence.

Sadly I don’t have an avoton device at hand.
Also I couldn’t find the kernel sources v4.4.x for avoton.

What DSM version and kernel version is your device running? (uname -a)

Correct, but figured I would just try them quickly.

It appears you can compile for any platform based on GitHub - SynologyOpenSource/pkgscripts-ng at DSM7.1. I have kernel version 3.10.108 and avoton platform, so I am working on setting this up to see if I can compile the modules. Where did you end up getting bluetooth.c? I can only find it back to bluetooth.c - drivers/usb/bluetooth.c - Linux source code (v2.5.7) - Bootlin and did you end up modifying these? I found btusb.c « bluetooth « drivers - kernel/git/stable/linux.git - Linux kernel stable tree under the general location.

The files are from the kernel source, no changes should be required.

Can you please try these?

Built for avoton kernel 3.10.108.

Sweet thanks. So my system took them and looks like I can configure them. Changes HA to —privileged and hciconfig hci0 up but seems like HA still can’t find any adapters:

No unconfigured Bluetooth adapters found. There are 0 ignored adapters.

I’ll have play with this more later.

Update: So I did mess with this more and unfortunately didn’t get anywhere;

$ lsmod | grep bt
btusb                  15528  0 
bluetooth             211424  2 btusb
btrfs                1121955  2 nfsd
zstd_decompress        65229  1 btrfs
ecryptfs               88924  1 btrfs
zstd_compress         153729  1 btrfs
raid6_pq               98452  4 async_pq,raid456,btrfs,async_raid6_recov
xor                    10808  2 btrfs,async_xor
zlib_deflate           20604  1 btrfs
usbcore               179491  17 ch341,btusb,etxhci_hcd,usblp,uhci_hcd,usb_storage,cp210x,usbserial,ti_usb_3410_5052,ehci_hcd,ehci_pci,pl2303,usbhid,ftdi_sio,cdc_acm,xhci_hcd

And then inside the container I am able to start up hci0 but HA can’t find any of my BT adapters. I ran in privileged and also volume mounted /var/run/dbus.../run/dbus, etc.

1 Like

I am using it inside HA this way:

I’m running 7.1 kernel 4.4.180+ on DS1819+ denverton
will this work?
Thanks @kcsoft

@oam Probably not. Whenever I’ll have some free time I will try to put together a guide on how to compile the modules for different platforms or to compile for this platform.

I set this up and it looks like it found my adapter, but nothing identified yet. I am assuming this is limited to just sensors and can’t actually control anything (like a lock, etc.). Pretty cool I guess bluetooth is sorta working again native with docker HA, but still would need the full solution.

Thanks for digging into this though.

Thanks, I appreciate that

Same here.

DS620slim (apollolake), DSM 7.1.1. BT Dongle can be seen as connected USB device in control panel. Was able to insmod provided modules for geminilake without errors (lsmod shows them in use) and bring hci interface up in docker container. But nothing happens after that. RT/TX counter doesn’t increase at all. Errors counter stays at 0. HA doesn’t see any BT devices, neither I able to add “bluetooth” integration, not any btle devices announcements shows up (I know they are broadcasting, because when I’ve tried esphome’s bluetooth proxy feature before, HA identified and suggested to add some of btle devices around). HA container running high privilege.

But I’m guessing, maybe DSM missing some BT packets, like bluez/dbus mentioned in BT integration guide? Haven’t come around guides how to add them to DSM.

Would be grateful for any solution or guidance to this problem. Not wiling to move from docker to VM because of this.

the hci tools are available in the HA docker so you can use those to debug your issue:

For example I did:

(executed hciconfig hci0 down first because HA was already using the bt device)

I use dsm 7.1 x86 ds920, the configuration is the same as yours, I follow your operation all the way until hciconfig hci0. It prompts me that command not found. My ha is installed through vmm.Snipaste_2023-05-17_22-33-48

@makiyd6 If you are using vmm, you don’t need the bluetooth kernel modules.

For virtual machine, you can install any guest os and either it already supports bluetooth or you can load the bluetooth modules. The host os (synology) provides the generic usb device and the guest os takes care of supporting it as bluetooth.

This thread is about supporting usb+bluetooth in docker on Synology DSM 7.1.
Up to Synology DSM 6, the usb drivers were included in the kernel but then on 7+ Synology decided to remove usb support as I imagine it isn’t easy to provide technical support for different usb devices.

So for docker there is no guest os, instead docker uses the host os kernel. So to have usb support in the docker container, you need to have usb (usb+bluetooth) support in the host that is Synology DSM.

Also please note that the hciconfig command was executed inside the docker container:

  • ssh into you synology, then execute on the synology: sudo docker exec -it myHA sh (replace myHA with the name of your HA container). This will run the shell from the docker container where you can run the hciconfig


great job!

can I kindly ask you to compile modules for synology_apollolake_718+ 4.4.180+ ?

Well done - Working great with supported “SABRENT BT-UB40 (CSR8510A10)”
v4.0 Class 2 with Low Energy Technology

Can control (limited control supported by integration) the Govee Bluetooth-only light strip through Sabrent dongle within HA

When trying to add a second Govee Bluetooth integration, it shows that HA can now see all of the other advertising devices through the BT dongle , which tells me all is working great
Thank you for your drivers !

The following appears to work well in automating the “bring up” of the BT dongle hci0 interface on HA-docker start up event.

In automations.yaml or through the ha automation visual gui:

# Bring Bluetooth dongle hci0 interface up command
  - alias: bring_bluetooth_dongle_if_up
      - platform: homeassistant
        event: start
      service: shell_command.bluetooth_dongle_hci0_up

In configuration.yaml:

  bluetooth_dongle_hci0_up: 'hciconfig hci0 up'

I have created a guide on how to compile the kernel modules here:

In this thread I have uploaded the compiled modules for geminilake and avoton, if anyone compiles them for other architectures, it would be nice to share.