Although, this dongle works (for awhile), there is a problem with the bluetooth driver. After streaming for about an hour, the driver eats up all the Pi memory and the Pi stops responding. Power cycling is the only fix. This may be related to the flood of messages it puts out on dmesg. I tried clearing dmesg, but that does not recover the lost memory. You can watch the memory slowly decrease by running htop while streaming to a bluetooth speaker. I think the memory problem is with the bluetooth driver, because the problem does not occur when using a different bluetooth dongle.
Maybe someone with driver coding experience could find a solution. Please post any ideas you might have regarding the memory problem.
#the bluetooth driver floods dmesg with about 10 messages per second...
dmesg|tail
[ 329.685269] rtk_btcoex: count_pan_packet_timeout: pan_packet_count 0
[ 329.765265] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 37
[ 330.725279] rtk_btcoex: count_pan_packet_timeout: pan_packet_count 0
[ 330.805278] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 38
[ 331.765273] rtk_btcoex: count_pan_packet_timeout: pan_packet_count 0
[ 331.845278] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 37
[ 332.805301] rtk_btcoex: count_pan_packet_timeout: pan_packet_count 0
[ 332.885305] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 38
[ 333.845301] rtk_btcoex: count_pan_packet_timeout: pan_packet_count 0
[ 333.925309] rtk_btcoex: count_a2dp_packet_timeout: a2dp_packet_count 37
Steps to compile the bluetooth and wifi drivers for EDIMAX EW-7611ULB on Raspberry Pi
The compile process:
First, install the headers for your OS
sudo apt-get install raspberrypi-kernel-headers
--- the system is now ready to compile ---
BLUETOOTH DRIVER
#get bluetooth driver from the Edimax site
wget http://www.edimax.us/download/drivers/EW-7611ULB/EW-7611ULB_Bluetooth_driver.zip
unzip EW-7611ULB_Bluetooth_driver.zip
cd EW-7611ULB_Bluetooth_driver
cd Linux_BT_USB_v3.1_20150526_8723BU_BTCOEX_20150119-5844_Edimax
Fix source file so will compile with >= 4.9.x kernels
In Section "(II.) Bluetooth Driver Installation", before running "sudo make install -s", you need to edit the file bluetooth_usb_driver/rtk_coex.c At line 448, change:
#if HCI_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
#if HCI_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
bt_cb(skb)->req.start = true;
#else
bt_cb(skb)->hci.req_start = true;
#endif
#endif
to:
#if HCI_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
#if HCI_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
bt_cb(skb)->req.start = true;
#elif HCI_VERSION_CODE >= KERNEL_VERSION(4,9,0)
bt_cb(skb)->hci.req_flags |= HCI_REQ_START;
#else
bt_cb(skb)->hci.req_start = true;
#endif
#endif
Fix the Makefile
change depmod line to in TWO places, BOTH the install and uninstall sections:
depmod -a -v
Compile and install the driver
sudo make install -s
sudo reboot
This completes the bluetooth driver install. If you want, you can test by connecting something using bluetoothctl. Read the Bluetooth driver info below to prevent your logfiles from filling up.
If you later want to use a different Bluetooth dongle, you'll need to revert to the stock Bluetooth driver as follows:
cd EW-7611ULB_Bluetooth_driver
cd Linux_BT_USB_v3.1_20150526_8723BU_BTCOEX_20150119-5844_Edimax
sudo make uninstall -s
sudo reboot
WIFI DRIVER
sudo apt update
#get the wifi driver
sudo apt install git
git clone https://github.com/lwfinger/rtl8723bu.git
#### optional ###################################################
#if you don't want TWO wlan devices (wlan0 and wlan1) in ifconfig #
#disable concurrent mode, by commenting out the line in the Makefile #
#cd rtl8723bu #
#nano Makefile #
#(put # in front of this line): #
#EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE #
######################################################################
#make the driver
sudo make
sudo make install
sudo modprobe -v 8723bu
#This driver cannot work with the standard driver rtl8xxxu
#so create 50-rtl8xxxu.conf with one line:
blacklist rtl8xxxu
sudo nano /etc/modprobe.d/50-rtl8xxxu.conf
This completes the WIFI driver install
Bluetooth Driver Info
The bluetooth driver floods the message log with some info, so to prevent it overloading your logfile, edit /etc/rsyslog.conf and add the following line to discard those messages:
:msg, contains, "rtk_btcoex" ~
Log file example snip shown below:
...snip from /etc/rsyslog.conf.........................
###############
#### RULES ####
###############
#
# First some standard log files. Log by facility.
#
auth,authpriv.* /var/log/auth.log
:msg, contains, "rtk_btcoex" ~
*.*;auth,authpriv.none -/var/log/syslog
#cron.* /var/log/cron.log
daemon.* -/var/log/daemon.log
kern.* -/var/log/kern.log
lpr.* -/var/log/lpr.log
mail.* -/var/log/mail.log
user.* -/var/log/user.log
#kern.info -/var/log/kern.info