Sonoff NSPanel Pro 120: WiFi/BT [Part 2]
![Sonoff NSPanel Pro 120: WiFi/BT [Part 2]](/content/images/size/w1200/2025/03/2020-01-23_12-00-02-3.jpg)
In the previous article, we got the Wi-Fi working and tested. Since the module is a combo Wi-Fi/BT, Bluetooth is part of the same chip. It's time to get Bluetooth up and running.
Bluetooth
In Linux, BlueZ is the official Bluetooth protocol stack. It allows different Bluetooth hardware to be used while providing a consistent API at the user-space level. Take a look at the overall BlueZ architecture diagram below.

Let's check the reference schematics one more time to see what we're dealing with.

The BT control/data part is connected through UART, while the audio input/output connects through the PCM port and should thus be connected to the I2S port on the RK3326. The control signals are as follows:
- HOST_WAKE_BT : The signal that goes from the Host (RK3326) to the BT module to wake it.
- BT_WAKE_HOST : Vice versa, in case the BT module needs to wake the Host (RK3326).
- BT_EN : The primary on/off switch for Bluetooth.
The 32KIN clock input, which comes from the RK809, can be handled either in the Wi-Fi node or the Bluetooth node, but we will handle it in the Bluetooth node.
The DTS node for Bluetooth is more straightforward then for WiFi:
wireless_bluetooth: wireless-bluetooth {
compatible = "bluetooth-platdata";
clocks = <&rk809 1>;
clock-names = "ext_clock";
uart_rts_gpios = <&gpio1 RK_PC3 GPIO_ACTIVE_LOW>;
pinctrl-names = "default","rts_gpio";
pinctrl-0 = <&uart1_rts>;
pinctrl-1 = <&uart1_rts_gpio>;
BT,reset_gpio = <&gpio0 RK_PC1 GPIO_ACTIVE_HIGH>;
BT,wake_gpio = <&gpio0 RK_PA1 GPIO_ACTIVE_HIGH>;
BT,wake_host_irq = <&gpio0 RK_PB2 GPIO_ACTIVE_HIGH>;
status = "okay";
};
When using Realtek Bluetooth, you should disable the CONFIG_BT_HCIUART
option in the kernel menuconfig. This is because Realtek chips use their own hci_uart.ko
module, which is loaded from user space. In the BlueZ stack, this functionality is represented as 'HCI sockets' .
CONFIG_BT=y
CONFIG_BT_BREDR=y
CONFIG_BT_RFCOMM=y
# CONFIG_BT_RFCOMM_TTY is not set
# CONFIG_BT_BNEP is not set
CONFIG_BT_HIDP=y
# CONFIG_BT_HS is not set
CONFIG_BT_LE=y
CONFIG_BT_DEBUGFS=y
#CONFIG_BT_HCIUART is not set
CONFIG_BT_HCIUART_H4=y
The files required for Bluetooth functionality, which should be present in the root filesystem (rootfs), are as follows:
hci_uart.ko
:
A kernel module that must be loaded using theinsmod
command.rtk_hciattach
:
A compiled binary that should be placed in/usr/bin/
.- Bluetooth Firmware Files :
rtl8723d_config
andrtl8723d_fw
:
These firmware files should be copied to/lib/firmware/rtlbt/
or/lib/firmware/
.
- Initialization Script (
init.sh
) :
A script that loads thehci_uart.ko
kernel module and attaches the HCI interface to UART.
The init.sh
script should look similar to the following:

The BlueZ core is included in the kernel, so we just need to ensure it is enabled. Additionally, the bluez-utils user-space package must be added to the rootfs in Configu
r→ Target packages → Networking applications

Great! Lets compile the firmware and upload it. We should see the folowing in kernel bootlog:
[ 0.264705] Bluetooth: Core ver 2.22
[ 0.265136] NET: Registered protocol family 31
[ 0.265555] Bluetooth: HCI device and connection manager initialized
[ 0.266168] Bluetooth: HCI socket layer initialized
[ 0.266627] Bluetooth: L2CAP socket layer initialized
[ 0.267120] Bluetooth: SCO socket layer initialized
[ 2.571725] Bluetooth: RFCOMM socket layer initialized
[ 2.572213] Bluetooth: RFCOMM ver 1.11
[ 2.572597] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[ 2.573135] Bluetooth: HIDP socket layer initialized
[ 2.581487] [BT_RFKILL]: bluetooth_platdata_parse_dt: get property: uart_rts_gpios = 51.
[ 2.582260] [BT_RFKILL]: bluetooth_platdata_parse_dt: get property: BT,reset_gpio = 17.
[ 2.582983] [BT_RFKILL]: bluetooth_platdata_parse_dt: get property: BT,wake_gpio = 1.
[ 2.583708] [BT_RFKILL]: bluetooth_platdata_parse_dt: get property: BT,wake_host_irq = 10.
[ 2.584595] [BT_RFKILL]: Request irq for bt wakeup host
[ 2.585349] [BT_RFKILL]: BT_WAKE_HOST IRQ fired
[ 2.585415] [BT_RFKILL]: ** disable irq
[ 2.586336] [BT_RFKILL]: bt_default device registered.
[ 2.587522] input: bt-powerkey as /devices/platform/wireless-bluetooth/input/input4
And following during rootfs init
Installing hci_uart.ko ...
Realtek Bluetooth :Realtek Bluetooth init uart with init speed:115200, type:HCI UART H5
Realtek Bluetooth :Realtek hciattach version 3.1.390bad8.20220519-142434
Realtek Bluetooth :Use epoll
Realtek Bluetooth :[SYNC] Get SYNC Resp Pkt
Realtek Bluetooth :[CONFIG] Get SYNC pkt
Realtek Bluetooth :[CONFIG] Get CONFG pkt
Realtek Bluetooth :[CONFIG] Get CONFG resp pkt
Realtek Bluetooth :dic is 1, cfg field 0x14
Realtek Bluetooth :H5 init finished
Realtek Bluetooth :Realtek H5 IC
Realtek Bluetooth :Receive cmd complete event of command: 1001
Realtek Bluetooth :HCI Version 0x08
Realtek Bluetooth :HCI Revision 0x000d
Realtek Bluetooth :LMP Subversion 0x8723
Realtek Bluetooth :Receive cmd complete event of command: fc6d
Realtek Bluetooth :Read ROM version 02
Realtek Bluetooth :LMP Subversion 0x8723
Realtek Bluetooth :EVersion 2
Realtek Bluetooth :IC: RTL8723DS
Realtek Bluetooth :Firmware/config: rtl8723d_fw, rtl8723d_config
Realtek Bluetooth :Couldnt open extra config /opt/rtk_btconfig.txt, No such file or directory
Realtek Bluetooth :Couldnt access customer BT MAC file /opt/bdaddr
Realtek Bluetooth :Origin cfg len 33
Realtek Bluetooth :55 ab 23 87 1b 00 0c 00 10 02 80 92 04 50 c5 ea
Realtek Bluetooth :19 e1 1b fd af 5f 01 a4 0b d9 00 01 0f e4 00 01
Realtek Bluetooth :08
Realtek Bluetooth :Config baudrate: 04928002
Realtek Bluetooth :uart flow ctrl: 1
Realtek Bluetooth :Vendor baud from Config file: 04928002
Realtek Bluetooth :New cfg len 33
Realtek Bluetooth :55 ab 23 87 1b 00 0c 00 10 02 80 92 04 50 c5 ea
Realtek Bluetooth :19 e1 1b fd af 5f 01 a4 0b d9 00 01 0f e4 00 01
Realtek Bluetooth :08
Realtek Bluetooth :Load FW /lib/firmware/rtlbt/rtl8723d_fw OK, size 54980
Realtek Bluetooth :rtb_get_fw_project_id: opcode 0, len 1, data 9
Realtek Bluetooth :FW version 0xaaa82df5, Patch num 3
Realtek Bluetooth :Chip id 0x0001
Realtek Bluetooth :Chip id 0x0002
Realtek Bluetooth :Chip id 0x0003
Realtek Bluetooth :Patch length 0x8cfc
Realtek Bluetooth :Start offset 0x00004980
Realtek Bluetooth :Svn version: 24645
Realtek Bluetooth :Coexistence: BTCOEX_20210106-3b3b
Realtek Bluetooth :FW exists, Config file exists
Realtek Bluetooth :Total len 36125 for fwc
Realtek Bluetooth :baudrate in change speed command: 0x02 0x80 0x92 0x04
Realtek Bluetooth :Receive cmd complete event of command: fc17
Realtek Bluetooth :Received cc of vendor change baud
Realtek Bluetooth :Final speed 1500000
Realtek Bluetooth :end_idx: 143, lp_len: 89, additional pkts: 4
Realtek Bluetooth :Start downloading...
Realtek Bluetooth :Send additional packet 17
Realtek Bluetooth :Send additional packet 18
Realtek Bluetooth :Send additional packet 19
Realtek Bluetooth :Last packet 148
Realtek Bluetooth :Send last pkt
Realtek Bluetooth :Enable host hw flow control
Realtek Bluetooth :h5_hci_reset: Issue hci reset cmd
Realtek Bluetooth :Receive cmd complete event of command: 0c03
Realtek Bluetooth :Received cc of hci reset cmd
Realtek Bluetooth :Init Process finished
Realtek Bluetooth :Realtek Bluetooth post process
Realtek Bluetooth :Device setup complete
Successfully init BT for RTL8723DS!
Done
As we can see, after hci_uart
is installed, the rtk_hciattach
tool uploads the firmware file and creates an HCI interface.
So eventually we should see the hci0 device info by running
hciconfig -a hci0

Great! Let's scan for nearby Bluetooth devices. We will use the bluetoothctl
utility, which is the official BlueZ tool. Then, let's type scan on
to start scanning for nearby Bluetooth devices.
bluetoothctl

And finally, let's pair the Bluetooth mouse and check how it works. We will use the trust
command to make the connection automatic whenever the mouse is available.
bluetoothctl
pair CA:50:38:EF:A0:6A
connect CA:50:38:EF:A0:6A
trust CA:50:38:EF:A0:6A
As you may have already noticed, I haven’t touched the audio part (A2DP) here, as I’m not sure whether the PCM port on the RTL8723DS is physically connected to the I2S interface of the RK3326. However, I will give it a try after bringing up the audio subsystem and will most likely create a new article about it. Stay tuned!