From 696fbe733b96e3f2d23ff53a8e8db2303fbd00fe Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Mon, 11 Nov 2013 22:19:46 +0100 Subject: Properly handle missing firmwares This requires to set FW_PATCHFILE_CHIP_NAME properly for each device. Change-Id: Iba7ea481a9a8a859c622bdca349c9371e11e1cd1 Signed-off-by: Paul Kocialkowski --- libbt/include/bt_vendor_brcm.h | 6 ++++++ libbt/src/bt_vendor_brcm.c | 10 ++++++++++ libbt/src/hardware.c | 27 +++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/libbt/include/bt_vendor_brcm.h b/libbt/include/bt_vendor_brcm.h index 9531df5..5b41268 100644 --- a/libbt/include/bt_vendor_brcm.h +++ b/libbt/include/bt_vendor_brcm.h @@ -63,6 +63,12 @@ #define BLUETOOTH_UART_DEVICE_PORT "/dev/ttyO1" /* maguro */ #endif +/* Firmware patch file chip name */ + +#ifndef FW_PATCHFILE_CHIP_NAME +#define FW_PATCHFILE_CHIP_NAME "bcm4330" /* maguro */ +#endif + /* Location of firmware patch files */ #ifndef FW_PATCHFILE_LOCATION #define FW_PATCHFILE_LOCATION "/vendor/firmware/" /* maguro */ diff --git a/libbt/src/bt_vendor_brcm.c b/libbt/src/bt_vendor_brcm.c index eb9856d..04dabcf 100644 --- a/libbt/src/bt_vendor_brcm.c +++ b/libbt/src/bt_vendor_brcm.c @@ -46,6 +46,7 @@ ******************************************************************************/ void hw_config_start(void); +uint8_t hw_config_checkpatches(void); uint8_t hw_lpm_enable(uint8_t turn_on); uint32_t hw_lpm_get_idle_timeout(void); void hw_lpm_set_wake_state(uint8_t wake_assert); @@ -90,6 +91,8 @@ static const tUSERIAL_CFG userial_init_cfg = static int init(const bt_vendor_callbacks_t* p_cb, unsigned char *local_bdaddr) { + uint8_t check; + ALOGI("init"); if (p_cb == NULL) @@ -111,6 +114,13 @@ static int init(const bt_vendor_callbacks_t* p_cb, unsigned char *local_bdaddr) ALOGW("*****************************************************************"); #endif + check = hw_config_checkpatches(); + if (check == FALSE) + { + ALOGE("init failed to check patches, firmwares are probably missing"); + return -1; + } + userial_vendor_init(); upio_init(); diff --git a/libbt/src/hardware.c b/libbt/src/hardware.c index df20c9f..0a4f063 100644 --- a/libbt/src/hardware.c +++ b/libbt/src/hardware.c @@ -513,6 +513,33 @@ static uint8_t hw_config_findpatch(char *p_chip_id_str) return (retval); } +uint8_t hw_config_checkpatches(void) +{ + char fw_patchfile_chip_name[256] = FW_PATCHFILE_CHIP_NAME; + struct stat fw_prepatch_stat; + uint8_t found; + int rc; + + if (strlen(fw_prepatch_name) > 0) + { + rc = stat(fw_prepatch_name, &fw_prepatch_stat); + if (rc < 0) + { + ALOGE("Prepatch firmware is missing"); + return FALSE; + } + } + + found = hw_config_findpatch(fw_patchfile_chip_name); + if (found == FALSE) + { + ALOGE("Patch firmware is missing"); + return FALSE; + } + + return TRUE; +} + /******************************************************************************* ** ** Function hw_config_set_bdaddr -- cgit v1.1