1

The hidden question in this post...

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

...snip...............................................

  • 2
    Hello. This reads like an answer to an unasked question or a tutorial/HowTo. If you have a question hidden amongst all that detail (which is usually a good thing) maybe edit the title and first paragraph to indicate what it is a little more clearly? – Roger Jones Apr 6 at 18:22
  • I checked on this before posting, stackoverflow.blog/2011/07/01/…, encourages posting solutions of this type. But, I still need help with the Bluetooth driver. After some time streaming, the bluetooth driver slowly eats up all the Pi memory (run htop to see). The Pi stops responding, and has to be power cycled. If anyone with driver coding experience could find a solution for this, please post an answer. This may be related to the dmesg flooding problem I discussed above, but clearing dmesg does not recover the ate up memory. – Ken H Apr 7 at 0:07
  • 1
    @KenH answering your own question is encouraged, but as the blog post indicates, you should still answer as an answer and not in the body of the question . The question must still be stated clearly – crasic Apr 7 at 16:38
  • In addition to what @crasic said your "answer", it I've read it correctly, is not really answering your question about a memory leak in the Bluetooth driver but is rather a set of instructions on compiling the two drivers for your dongle. – Roger Jones Apr 7 at 16:45
  • My intent was to 1. Provide information to successfully compile the drivers, without having to search for answers when errors occur. 2. Ask for help with the memory leak problem. If someone were interested in working the problem, I didn't want them stalling at the driver install, before they could begin to work the problem. I've already edited to put the question first, and then show the compile steps. If you have a suggestion on a better way to present this, please let me know, and I'll do my best to fix it. – Ken H Apr 8 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.