[Solved] USB Bluetooth support on Synology DSM 7.1

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.

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