diff options
| author | Steve Kondik <shade@chemlab.org> | 2013-07-05 14:25:52 -0700 |
|---|---|---|
| committer | Rashed Abdel-Tawab <rashed@linux.com> | 2015-10-17 23:52:38 -0400 |
| commit | 463d8060e2bb8bb64df2e0a97523020471f5d3cd (patch) | |
| tree | 9717f41dd78e95dc5dde665d065d96ae3785729c | |
| parent | 8e215c33a7357d59a50b20d4127446ffe728736d (diff) | |
| download | android_hardware_broadcom_libbt-463d8060e2bb8bb64df2e0a97523020471f5d3cd.tar.gz android_hardware_broadcom_libbt-463d8060e2bb8bb64df2e0a97523020471f5d3cd.tar.bz2 android_hardware_broadcom_libbt-463d8060e2bb8bb64df2e0a97523020471f5d3cd.zip | |
libbt: Add prepatch support
* We need to apply an initial patch to the BCM4335 hardware to prevent
chip crashes, so add support for a prepatch designated by
FW_PRE_PATCH.
Change-Id: I2d2ec59094a1ae2cb39e1f41d4853ac4a45d1902
| -rw-r--r-- | include/bt_vendor_brcm.h | 4 | ||||
| -rwxr-xr-x | src/hardware.c | 42 |
2 files changed, 45 insertions, 1 deletions
diff --git a/include/bt_vendor_brcm.h b/include/bt_vendor_brcm.h index 24df19e..fde9c32 100644 --- a/include/bt_vendor_brcm.h +++ b/include/bt_vendor_brcm.h @@ -72,6 +72,10 @@ #define UART_TARGET_BAUD_RATE 3000000 #endif +#ifndef FW_PRE_PATCH +#define FW_PRE_PATCH "" +#endif + /* The millisecond delay pauses on HCI transport after firmware patches * were downloaded. This gives some time for firmware to restart with * patches before host attempts to send down any HCI commands. diff --git a/src/hardware.c b/src/hardware.c index f88768f..61d41c4 100755 --- a/src/hardware.c +++ b/src/hardware.c @@ -128,7 +128,8 @@ enum { HW_CFG_DL_MINIDRIVER, HW_CFG_DL_FW_PATCH, HW_CFG_SET_UART_BAUD_2, - HW_CFG_SET_BD_ADDR + HW_CFG_SET_BD_ADDR, + HW_CFG_DL_FW_PRE_PATCH #if (USE_CONTROLLER_BDADDR == TRUE) , HW_CFG_READ_BD_ADDR #endif @@ -181,6 +182,7 @@ extern uint8_t vnd_local_bd_addr[BD_ADDR_LEN]; static char fw_patchfile_path[256] = FW_PATCHFILE_LOCATION; static char fw_patchfile_name[128] = { 0 }; +static char fw_prepatch_name[384] = FW_PRE_PATCH; #if (VENDOR_LIB_RUNTIME_TUNING_ENABLED == TRUE) static int fw_patch_settlement_delay = -1; #endif @@ -709,6 +711,44 @@ void hw_config_cback(void *p_mem) line_speed_to_userial_baud(UART_TARGET_BAUD_RATE) \ ); + hw_cfg_cb.fw_fd = -1; + + // load the prepatch + if (strlen(fw_prepatch_name) && + (hw_cfg_cb.fw_fd = open(fw_prepatch_name, O_RDONLY)) > -1) + { + ALOGI("bt vendor lib: loading prepatch %s", fw_prepatch_name); + } + + hw_cfg_cb.state = HW_CFG_DL_FW_PRE_PATCH; + // intentional fallthru + + case HW_CFG_DL_FW_PRE_PATCH: + if (hw_cfg_cb.fw_fd > -1) { + p_buf->len = read(hw_cfg_cb.fw_fd, p, HCI_CMD_PREAMBLE_SIZE); + if (p_buf->len > 0) + { + if ((p_buf->len < HCI_CMD_PREAMBLE_SIZE) || \ + (opcode == HCI_VSC_LAUNCH_RAM)) + { + ALOGW("firmware patch file might be altered!"); + } + else + { + p_buf->len += read(hw_cfg_cb.fw_fd, \ + p+HCI_CMD_PREAMBLE_SIZE,\ + *(p+HCD_REC_PAYLOAD_LEN_BYTE)); + STREAM_TO_UINT16(opcode,p); + is_proceeding = bt_vendor_cbacks->xmit_cb(opcode, \ + p_buf, hw_config_cback); + break; + } + } + + close(hw_cfg_cb.fw_fd); + hw_cfg_cb.fw_fd = -1; + } + /* read local name */ UINT16_TO_STREAM(p, HCI_READ_LOCAL_NAME); *p = 0; /* parameter length */ |
