Origin:                  https://gist.github.com/pelwell/c8230c48ea24698527cd

diff -ur bluez-5.40-orig/tools/hciattach_bcm43xx.c bluez-5.40/tools/hciattach_bcm43xx.c
--- bluez-5.40-orig/tools/hciattach_bcm43xx.c	2015-03-11 10:01:57.000000000 +0000
+++ bluez-5.40/tools/hciattach_bcm43xx.c	2016-06-03 19:44:08.726997105 +0100
@@ -43,7 +43,7 @@
 #include "hciattach.h"
 
 #ifndef FIRMWARE_DIR
-#define FIRMWARE_DIR "/etc/firmware"
+#define FIRMWARE_DIR "/lib/firmware/brcm"
 #endif
 
 #define FW_EXT ".hcd"
@@ -366,11 +366,8 @@
 		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;
 
@@ -380,6 +377,7 @@
 			return -1;
 		}
 
+		sleep(1);
 		if (bcm43xx_reset(fd))
 			return -1;
 	}
diff -ur bluez-5.40-orig/tools/hciattach.c bluez-5.40/tools/hciattach.c
--- bluez-5.40-orig/tools/hciattach.c	2016-05-26 17:51:11.000000000 +0100
+++ bluez-5.40/tools/hciattach.c	2016-06-03 19:44:08.716997563 +0100
@@ -1090,6 +1090,9 @@
 	{ "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  },
 
@@ -1236,7 +1239,7 @@
 {
 	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;
--- a/src/shared/util.h	2020-06-27 14:59:15.658492350 +0530
+++ b/src/shared/util.h	2020-06-27 14:59:56.525772841 +0530
@@ -26,6 +26,7 @@
 #include <alloca.h>
 #include <byteswap.h>
 #include <string.h>
+#include <endian.h>
 
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #define le16_to_cpu(val) (val)
