diff --git a/doc/manual/docs/how_to.md b/doc/manual/docs/how_to.md index ba835c27c..c1c118560 100644 --- a/doc/manual/docs/how_to.md +++ b/doc/manual/docs/how_to.md @@ -98,7 +98,7 @@ ENABLE_HCI_CONTROLLER_TO_HOST_FLOW_CONTROL | Enable HCI Controller to Host Flow ENABLE_CC256X_BAUDRATE_CHANGE_FLOWCONTROL_BUG_WORKAROUND | Enable workaround for bug in CC256x Flow Control during baud rate change, see chipset docs. ENABLE_CYPRESS_BAUDRATE_CHANGE_FLOWCONTROL_BUG_WORKAROUND | Enable workaround for bug in CYW2070x Flow Control during baud rate change, similar to CC256x. ENABLE_TLV_FLASH_EXPLICIT_DELETE_FIELD | Enable use of explicit delete field in TLV Flash implemenation - required when flash value cannot be overwritten with zero - +ENABLE_CONTROLLER_WARM_BOOT | Enable stack startup without power cycle (if supported/possible) Notes: diff --git a/port/raspi/btstack_config.h b/port/raspi/btstack_config.h index 9b62948e0..6ebdbf78e 100644 --- a/port/raspi/btstack_config.h +++ b/port/raspi/btstack_config.h @@ -26,6 +26,9 @@ #define ENABLE_SCO_OVER_HCI #define ENABLE_SDP_DES_DUMP +// Warm Boot needed if connected via Wifi on Raspberry Pi 3A+ or 3B+ +// #define ENABLE_CONTROLLER_WARM_BOOT + // BTstack configuration. buffers, sizes, ... #define HCI_INCOMING_PRE_BUFFER_SIZE 14 // sizeof benep heade, avoid memcpy #define HCI_ACL_PAYLOAD_SIZE (1691 + 4) diff --git a/port/raspi/main.c b/port/raspi/main.c index d77c85ddb..004c14d24 100644 --- a/port/raspi/main.c +++ b/port/raspi/main.c @@ -306,6 +306,7 @@ int main(int argc, const char * argv[]){ // set UART config based on raspi Bluetooth UART type int bt_reg_en_pin = -1; + bool power_cycle = true; switch (raspi_get_bluetooth_uart_type()){ case UART_INVALID: fprintf(stderr, "can't verify HW uart, %s\n", strerror( errno ) ); @@ -319,24 +320,37 @@ int main(int argc, const char * argv[]){ case UART_HARDWARE_NO_FLOW: // Raspberry Pi 3 A // Raspberry Pi 3 B + // power up with H5 and without power cycle untested/unsupported bt_reg_en_pin = 128; transport_config.baudrate_main = 921600; transport_config.flowcontrol = 0; break; case UART_HARDWARE_FLOW: - // Raspberry Pi Zero W gpio 45 + // Raspberry Pi Zero W gpio 45, 3 mbps does not work (investigation pending) // Raspberry Pi 3A+ vgpio 129 but WLAN + BL // Raspberry Pi 3B+ vgpio 129 but WLAN + BL - transport_config.baudrate_main = 3000000; transport_config.flowcontrol = 1; - - // 3 mbps does not work on Zero W (investigation pending) - if (raspi_get_model() == MODEL_ZERO_W){ - transport_config.baudrate_main = 921600; + int model = raspi_get_model(); + if (model == MODEL_ZERO_W){ + bt_reg_en_pin = 45; + transport_config.baudrate_main = 921600; + } else { + bt_reg_en_pin = 129; + transport_config.baudrate_main = 3000000; } + +#ifdef ENABLE_CONTROLLER_WARM_BOOT + power_cycle = false; +#else + // warn about power cycle on devices with shared reg_en pins + if (model == MODEL_3APLUS || model == MODEL_3BPLUS){ + printf("Wifi and Bluetooth share a single RESET line and BTstack needs to reset Bluetooth -> SSH over Wifi will fail\n"); + printf("Please add ENABLE_CONTROLLER_WARM_BOOT to btstack_config.h to enable startup without RESET\n"); + } +#endif break; } - printf("%s, %u, BT_REG_EN at GPIO %u\n", transport_config.flowcontrol ? "H4":"H5", transport_config.baudrate_main, bt_reg_en_pin); + printf("%s, %u, BT_REG_EN at GPIO %u, %s\n", transport_config.flowcontrol ? "H4":"H5", transport_config.baudrate_main, bt_reg_en_pin, power_cycle ? "Reset Controller" : "Warm Boot"); // get BCM chipset driver const btstack_chipset_t * chipset = btstack_chipset_bcm_instance(); @@ -379,24 +393,27 @@ int main(int argc, const char * argv[]){ main_argc = argc; main_argv = argv; - if (transport_config.flowcontrol){ - - // re-use current terminal speed - raspi_get_terminal_params( &transport_config ); - - // with flowcontrol, we use h4 and are done - btstack_main(main_argc, main_argv); - - } else { - - // power cycle Bluetooth controller on older models without flowcontrol - printf("Power Cycle Controller\n"); + // power cycle Bluetooth controller on older models without flowcontrol + if (power_cycle){ btstack_control_raspi_set_bt_reg_en_pin(bt_reg_en_pin); btstack_control_t *control = btstack_control_raspi_get_instance(); control->init(NULL); control->off(); usleep( 100000 ); control->on(); + } + + if (transport_config.flowcontrol){ + + // re-use current terminal speed (if there was no power cycle) + if (!power_cycle){ + raspi_get_terminal_params( &transport_config ); + } + + // with flowcontrol, we use h4 and are done + btstack_main(main_argc, main_argv); + + } else { // assume BCM4343W used in Pi 3 A/B. Pi 3 A/B+ have a newer controller but support H4 with Flowcontrol btstack_chipset_bcm_set_device_name("BCM43430A1");