EinSoldiatGott
Posts: 10
Joined: Sat May 27, 2017 5:24 am

Bluetooth with cf-wu910a 8821CU RBPI3B+ Kernel 4.14

Sat Jan 05, 2019 8:35 pm

Hi, I have a COMFAST cf-wu910a USB dongle with the chipset 8821CU, this is a WIfi + Bluetooth dongle which at the beginning is recognized like a USB storage which includes the Windows Drivers on a .exe but any Linux drivers.

The dongle is connected on my RBPI 3B+, the driver is not included on my Raspbian Stretch with desktop, Version: November 2018, Release date:2018-11-13, Kernel version:4.14. It's only recognized like USB storage.

I upgraded to kernel 4.19 with:

Code: Select all

sudo BRANCH=next rpi-update
But the driver is not yet included, this post says that it's included on 4.17, but once updated to 4.19 my dongle still not recognized
This Linux kernel change "Bluetooth: btrtl: Add RTL8723D and RTL8821C devices" is included in the Linux 4.17 release. This change is authored by Alex Lu <alex_lu [at] realsil.com.cn> on Sun Feb 11 12:24:33 2018 -0600. The commit for this change in Linux stable tree is 907f849 (patch).
Then I tried to compile the driver with this git:
https://github.com/whitebatman2/rtl8821CU

But on /lib/modules/4.19xx/ the build or source folder was missing even using

Code: Select all

apt-get install raspberrypi-kernel-headers
, I tried multiple options to get the headers without success (rpi-source only installs the 3.xx source) and (https://www.raspberrypi.org/documentati ... uilding.md gave me compilations errors)

I also update to BlueZ 4.49 and the Bluetooth dongle was not recognized

So I came back to a fresh image with 4.14 kernel, after installing the headers I was able to compile the driver, these are my steps:

Code: Select all

echo When a new kernel release is made, you will need the headers that match that kernel version. It can take several weeks for the repo to be updated to reflect the latest kernel version. If this happens, the best approach is to clone the kernel as described in the Build Section.
# Your kernel headers for kernel 4.x cannot be found at

sudo apt-get update
# sudo apt-get dist-upgrade
sudo apt-get install raspberrypi-kernel-headers
sudo apt-get install bc


DRV_NAME=rtl8821CU
DRV_VERSION=5.2.5.3
git https://github.com/whitebatman2/rtl8821CU
cd rtl8821CU/
sudo rm -r /usr/src/${DRV_NAME}-${DRV_VERSION}
sudo mkdir /usr/src/${DRV_NAME}-${DRV_VERSION}
git archive master | sudo tar -x -C /usr/src/${DRV_NAME}-${DRV_VERSION}
echo in the Makefile change CONFIG_PLATFORM_I386_PC = n, CONFIG_PLATFORM_ARM_RPI = n, CONFIG_PLATFORM_ARM_RPI3 = y
sudo leafpad /usr/src/rtl8821CU-5.2.5.3/Makefile
cd /usr/src/rtl8821CU-5.2.5.3
sudo make ARCH=arm
sudo make install
during the compilation I get the warnings:
/usr/src/rtl8821CU-5.2.5.3/hal/phydm/phydm_hwconfig.c:1310:45: warning: ‘EVM’ may be used uninitialized in this function [-Wmaybe-uninitialized] p_phy_info->rx_mimo_signal_quality = EVM;

/usr/src/rtl8821CU-5.2.5.3/hal/phydm/phydm_adc_sampling.c: In function ‘phydm_la_buffer_allocate’: /usr/src/rtl8821CU-5.2.5.3/hal/phydm/phydm_adc_sampling.c:46:5: warning: this ‘else’ clause does not guard... [-Wmisleading-indentation] } else ^~~~ /usr/src/rtl8821CU-5.2.5.3/hal/phydm/phydm_adc_sampling.c:48:4: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘else’ ret = true;

/usr/src/rtl8821CU-5.2.5.3/hal/btc/halbtc8821c2ant.c: In function ‘halbtc8821c2ant_monitor_wifi_ctr’:
/usr/src/rtl8821CU-5.2.5.3/hal/btc/halbtc8821c2ant.c:454:2: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]
if ((coex_dm->bt_status ==
^~
/usr/src/rtl8821CU-5.2.5.3/hal/btc/halbtc8821c2ant.c:461:3: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’
if (cck_cnt > 250) {
^~


After build finishes I run:

Code: Select all

$ lsusb | grep Realtek
Bus 001 Device 005: ID 0bda:1a2b Realtek Semiconductor Corp. 
$ sudo modprobe 8821cu
$ lsmod | grep 8821cu
8821cu               1953792  0
cfg80211              573440  2 brcmfmac,8821cu
$ sudo usb_modeswitch -KW -v 0bda -p 1a2b
Take all parameters from the command line


 * usb_modeswitch: handle USB devices with multiple modes
 * Version 2.5.0 (C) Josua Dietze 2017
 * Based on libusb1/libusbx

 ! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor=  0x0bda
DefaultProduct= 0x1a2b

StandardEject=1

Look for default devices ...
  found USB ID 0bda:1a2b
   vendor ID matched
   product ID matched
  found USB ID 0bda:1a2b
   vendor ID matched
   product ID matched
  found USB ID 4555:1031
  found USB ID 0424:7800
  found USB ID 0424:2514
  found USB ID 0424:2514
  found USB ID 1d6b:0002
 Found devices in default mode (2)
Access device 004 on bus 001
Get the current device configuration ...
Current configuration number is 1
Use interface number 0
 with class 8
Use endpoints 0x0b (out) and 0x8a (in)

USB description data (for identification)
-------------------------
Manufacturer: Realtek
     Product: DISK
  Serial No.: not provided
-------------------------
Sending standard EJECT sequence
Looking for active driver ...
 OK, driver detached
Set up interface 0
Use endpoint 0x0b for message sending ...
Trying to send message 1 to endpoint 0x0b ...
 OK, message successfully sent
Read the response to message 1 (CSW) ...
 Response successfully read (13 bytes), status 1
Trying to send message 2 to endpoint 0x0b ...
 OK, message successfully sent
Read the response to message 2 (CSW) ...
 Response successfully read (13 bytes), status 0
Trying to send message 3 to endpoint 0x0b ...
 Sending the message returned error -1. Try to continue
Read the response to message 3 (CSW) ...
 Response reading failed (error -1)
 Device is gone, skip any further commands
-> Run lsusb to note any changes. Bye!
The switch mode is working.
I'm not interested in using the dongle as wifi, but with iw I can see the internal interface with a valid MAC:

Code: Select all

$ sudo iw 
dev phy#1 
Interface wlan1 ifindex 4 wdev 0x100000001 
addr 40:a5:ef:f4:67:11 
ssid punto3
type managed 
txpower 12.00 dBm 

phy#0 
Unnamed/non-netdev 
interface wdev 0x2 
addr fa:d3:44:2a:fe:ce 
type P2P-device 
txpower 31.00 dBm 

Interface wlan0 
ifindex 3 
wdev 0x1 
addr b8:27:eb:ae:ff:e9 
ssid punto3 
type managed channel 11 (2462 MHz), width: 20 MHz, center1: 2462 MHz 
txpower 31.00 dBm
But for Bluetooth wich is what I need, the module is visible but it is DOWN, and it cannot start it:
hci0 = RPBI internal Bluetooth
hci1 = Dongle

Code: Select all

$ sudo hciconfig
hci1:	Type: Primary  Bus: USB
	BD Address: 00:00:00:00:00:00  ACL MTU: 0:0  SCO MTU: 0:0
	DOWN 
	RX bytes:504 acl:0 sco:0 events:71 errors:0
	TX bytes:17714 acl:0 sco:0 commands:72 errors:0

hci0:	Type: Primary  Bus: UART
	BD Address: B8:27:EB:51:00:16  ACL MTU: 1021:8  SCO MTU: 64:1
	UP RUNNING 
	RX bytes:799 acl:0 sco:0 events:52 errors:0
	TX bytes:2520 acl:0 sco:0 commands:52 errors:0
$ sudo hciconfig hci1 up
**Can't init device hci1: Cannot assign requested address (99)**
$ sudo hciconfig hci1 down
$ sudo hciconfig hci1 up
**Can't init device hci1: Cannot assign requested address (99)**
$ sudo hciconfig hci1 reset
**Can't init device hci1: Cannot assign requested address (99)**
$ sudo hcitool -i hci0 lescan
LE Scan ...
74:1A:6D:A2:6D:88 (unknown)
55:00:14:AC:88:2B (unknown)
55:00:14:AC:88:2B (unknown)
74:1A:6D:A2:6D:88 (unknown)
49:95:9A:1E:1C:37 (unknown)
$ sudo hcitool -i hci1 lescan
**Invalid device: Network is down**
The output of btmon for hciconfig hci1 up is:
= Open Index: 00:00:00:00:00:00 [hci1] 6.985557
= Index Info: 00:00:00:0.. (Realtek Semiconductor Corporation) [hci1] 6.985576
< HCI Command: Read Local Version In.. (0x04|0x0001) plen 0 #1 [hci1] 6.985686
> HCI Event: Command Complete (0x0e) plen 12 #2 [hci1] 7.582466
Read Local Version Information (0x04|0x0001) ncmd 2
Status: Success (0x00)
HCI version: Bluetooth 4.2 (0x08) - Revision 12 (0x000c)
LMP version: Bluetooth 4.2 (0x08) - Subversion 34849 (0x8821)
Manufacturer: Realtek Semiconductor Corporation (93)
< HCI Command: Vendor (0x3f|0x006d) plen 0 #3 [hci1] 7.582567
> HCI Event: Command Complete (0x0e) plen 5 #4 [hci1] 7.583455
Vendor (0x3f|0x006d) ncmd 2
Status: Success (0x00)
01 .
= Close Index: 00:00:00:00:00:00 [hci1] 7.583560
@ RAW Close: hciconfig {0x0003} 7.583979

I repeated the test with Bluez 4.49 after compiling but again without success.

Are the warnings related to Bluetooth functionality? I cannot understand them

Bluetooth 4.2 is supported since Bluez 4.3 AFAIK, and the internal RBPI3+ is a BT4.2 chipset, so I think that the dongle should work, but I cannot turn the dongle ON.

On Windows, the BT functionality is working.

Thanks for your help

Return to “Device Tree”