Description: Patches for compatibility with on-board Bluetooth on RPi 3
Author: Simon Long <simon@raspberrypi.org>
Last-Update: 2017-04-05

Index: bluez-5.55/tools/hciattach.c
===================================================================
--- bluez-5.55.orig/tools/hciattach.c
+++ bluez-5.55/tools/hciattach.c
@@ -1091,6 +1091,9 @@ struct uart_t uart[] = {
 	{ "bcm43xx",    0x0000, 0x0000, HCI_UART_H4,   115200, 3000000,
 				FLOW_CTL, DISABLE_PM, NULL, bcm43xx, NULL  },
 
+	{ "bcm43xx-3wire",    0x0000, 0x0000, HCI_UART_3WIRE,   115200, 3000000,
+				0, DISABLE_PM, NULL, bcm43xx, NULL  },
+
 	{ "ath3k",    0x0000, 0x0000, HCI_UART_ATH3K, 115200, 115200,
 			FLOW_CTL, DISABLE_PM, NULL, ath3k_ps, ath3k_pm  },
 
@@ -1237,7 +1240,7 @@ int main(int argc, char *argv[])
 {
 	struct uart_t *u = NULL;
 	int detach, printpid, raw, opt, i, n, ld, err;
-	int to = 10;
+	int to = 30;
 	int init_speed = 0;
 	int send_break = 0;
 	pid_t pid;
Index: bluez-5.55/tools/hciattach_bcm43xx.c
===================================================================
--- bluez-5.55.orig/tools/hciattach_bcm43xx.c
+++ bluez-5.55/tools/hciattach_bcm43xx.c
@@ -44,7 +44,7 @@
 #include "hciattach.h"
 
 #ifndef FIRMWARE_DIR
-#define FIRMWARE_DIR "/etc/firmware"
+#define FIRMWARE_DIR "/lib/firmware"
 #endif
 
 #define FW_EXT ".hcd"
@@ -367,11 +367,8 @@ int bcm43xx_init(int fd, int def_speed,
 		return -1;
 
 	if (bcm43xx_locate_patch(FIRMWARE_DIR, chip_name, fw_path)) {
-		fprintf(stderr, "Patch not found, continue anyway\n");
+		fprintf(stderr, "Patch not found for %s, continue anyway\n", chip_name);
 	} else {
-		if (bcm43xx_set_speed(fd, ti, speed))
-			return -1;
-
 		if (bcm43xx_load_firmware(fd, fw_path))
 			return -1;
 
@@ -381,6 +378,7 @@ int bcm43xx_init(int fd, int def_speed,
 			return -1;
 		}
 
+		sleep(1);
 		if (bcm43xx_reset(fd))
 			return -1;
 	}
