Remove bluetooth firmware download logic of commit 05bbbec3e1. It is in the wrong place.

This commit is contained in:
Gregory Nutt 2019-09-21 08:51:44 -06:00
parent a9a49f5c12
commit c123967fe9
3 changed files with 0 additions and 179 deletions

View file

@ -54,20 +54,6 @@ menuconfig WIRELESS_BLUETOOTH
if WIRELESS_BLUETOOTH if WIRELESS_BLUETOOTH
config BLUETOOTH_FIRMWARE_DOWNLOAD
bool "Generic firmware download"
default n
---help---
Enables support for generic firmware download in the MAC layer. Do
not enable this option if no download is required OR if the download
if performed by the Bluetooth HCI layer.
If this option is selected, then your board-specific code must
provide the firmware data via:
const uint8_t bt_firmware_hcd[];
const long int bt_firmware_len;
config BLUETOOTH_MAX_CONN config BLUETOOTH_MAX_CONN
int "Maximum number of simultaneous connections" int "Maximum number of simultaneous connections"
default 1 default 1

View file

@ -1186,155 +1186,6 @@ static void le_read_buffer_size_complete(FAR struct bt_buf_s *buf)
g_btdev.le_pkts = rp->le_max_num; g_btdev.le_pkts = rp->le_max_num;
} }
/****************************************************************************
* Name: bt_check_fw_download()
*
* Description:
* This function downloads firmware to the bt device if it is needed.
*
* Input Parameters:
* none
*
* Returned Value:
* None
*
****************************************************************************/
#ifdef CONFIG_BLUETOOTH_FIRMWARE_DOWNLOAD
static int bt_check_fw_download(void)
{
uint8_t *rp = (uint8_t *)bt_firmware_hcd;
FAR uint8_t *bm;
FAR struct bt_buf_s *buf;
FAR struct bt_buf_s *rsp;
uint8_t command;
uint8_t command2;
uint8_t txlen;
uint32_t addr;
int ret = OK;
const uint8_t HCD_PATCHRAM_COMMAND = 0x2e;
const uint8_t HCD_LAUNCH_COMMAND = 0x4e;
const uint8_t HCD_WRITE_COMMAND = 0x4c;
const uint8_t HCD_COMMAND_BYTE2 = 0xfc;
const uint8_t HCD_LAUNCH_LEN = 4;
const uint8_t HCD_LAUNCH_PAYLOAD = 0xff;
ret = bt_hci_cmd_send_sync(HCD_PATCHRAM_COMMAND | (HCD_COMMAND_BYTE2 << 8),
NULL, &rsp);
bt_buf_release(rsp);
if (ret < 0)
{
wlerr("ERROR: HCD_LAUNCH_COMMAND failed: %d\n", ret);
return ret;
}
while (rp < (bt_firmware_hcd + bt_firmware_len))
{
command = rp[0];
command2 = rp[1];
txlen = rp[2];
addr = rp[3] | (rp[4] << 8) | (rp[5] << 16) | (rp[6] << 24);
/* Sanity check on the data as they are read */
if (command == HCD_LAUNCH_COMMAND)
{
break;
}
if ((txlen < 4) || (command2 != HCD_COMMAND_BYTE2) ||
(command != HCD_WRITE_COMMAND))
{
wlerr("ERROR: Firmware file format\n");
return -ENODEV;
}
/* Jump past the header and remove the length from the send amount */
rp += 7;
txlen -= 4;
while (txlen > 0)
{
uint8_t txelement = txlen >
(BLUETOOTH_MAX_MTU - 4) ? (BLUETOOTH_MAX_MTU -
4) : txlen;
buf = bt_hci_cmd_create(command | (command2 << 8), txelement + 4);
if (buf == NULL)
{
wlerr("ERROR: Failed to create buffer\n");
return -ENOBUFS;
}
bm = (uint8_t *)bt_buf_extend(buf, txelement + 4);
bm[0] = addr & 0xff;
bm[1] = (addr >> 8) & 0xff;
bm[2] = (addr >> 16) & 0xff;
bm[3] = (addr >> 24) & 0xff;
memcpy(&bm[4], rp, txelement);
ret = bt_hci_cmd_send_sync(command | (command2 << 8), buf, &rsp);
if (ret < 0)
{
wlerr("ERROR: Upload failed: %d\n", ret);
return ret;
}
bt_buf_release(rsp);
rp += txelement;
txlen -= txelement;
addr += txelement;
}
}
/* To have gotten here we must've uploaded correctly */
buf = bt_hci_cmd_create(HCD_LAUNCH_COMMAND | (HCD_COMMAND_BYTE2 << 8),
HCD_LAUNCH_LEN);
if (buf == NULL)
{
wlerr("ERROR: Failed to create buffer\n");
return -ENOBUFS;
}
bm = (uint8_t *)bt_buf_extend(buf, HCD_LAUNCH_LEN);
memset(bm, HCD_LAUNCH_PAYLOAD, HCD_LAUNCH_LEN);
ret = bt_hci_cmd_send_sync(HCD_LAUNCH_COMMAND | (HCD_COMMAND_BYTE2 << 8),
buf, &rsp);
bt_buf_release(rsp);
if (ret < 0)
{
wlerr("ERROR: HCD_LAUNCH_COMMAND failed: %d\n", ret);
return ret;
}
/* Give everything time to start up */
nxsig_usleep(1000000);
/* Everything happened and the new firmware is launched */
ret = bt_hci_cmd_send_sync(BT_HCI_OP_RESET, NULL, &rsp);
if (ret < 0)
{
wlerr("ERROR: BT_HCI_OP_RESET failed: %d\n", ret);
return ret;
}
bt_buf_release(rsp);
return OK;
}
#else
# define bt_check_fw_download() OK
#endif
/**************************************************************************** /****************************************************************************
* Name: hci_initialize() * Name: hci_initialize()
* *
@ -1368,15 +1219,6 @@ static int hci_initialize(void)
bt_buf_release(rsp); bt_buf_release(rsp);
/* Download new firmware when/if needed */
ret = bt_check_fw_download();
if (ret < 0)
{
wlerr("ERROR: Firmware upload failed: %d\n", ret);
return ret;
}
/* Read Local Supported Features */ /* Read Local Supported Features */
ret = bt_hci_cmd_send_sync(BT_HCI_OP_READ_LOCAL_FEATURES, NULL, &rsp); ret = bt_hci_cmd_send_sync(BT_HCI_OP_READ_LOCAL_FEATURES, NULL, &rsp);

View file

@ -166,13 +166,6 @@ typedef CODE void bt_le_scan_cb_t(FAR const bt_addr_le_t *addr, int8_t rssi,
extern struct bt_dev_s g_btdev; extern struct bt_dev_s g_btdev;
#ifdef CONFIG_BLUETOOTH_FIRMWARE_DOWNLOAD
/* Location and size of HCI firmware download */
extern const uint8_t bt_firmware_hcd[];
extern const long int bt_firmware_len;
#endif
/**************************************************************************** /****************************************************************************
* Inline Functions * Inline Functions
****************************************************************************/ ****************************************************************************/