[FL-3264] Various stop mode fixes (#2584)

* BleGlue: log hci_cmd_resp invocation
* BleGlue: increase BleHciDriver stack size
* ble hid app: increase stack
* ble: comment unnecessary hci reset
* BleGlue: stricter checks in communication with core2, cleanup code
* Furi: enter insomnia when executing from RAM
---------
Co-authored-by: gornekich <n.gorbadey@gmail.com>
This commit is contained in:
あく 2023-04-18 20:38:35 +09:00 committed by GitHub
parent de02a0a25a
commit f68c3b2a65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 22 deletions

View File

@ -68,7 +68,7 @@ static const APPD_GpioConfig_t aGpioConfigList[GPIO_CFG_NBR_OF_FEATURES] = {
{GPIOA, LL_GPIO_PIN_0, 0, 0}, /* END_OF_CONNECTION_EVENT - Set on Entry / Reset on Exit */
{GPIOA, LL_GPIO_PIN_0, 0, 0}, /* TIMER_SERVER_CALLBACK - Toggle on Entry */
{GPIOA, LL_GPIO_PIN_4, 1, 0}, /* PES_ACTIVITY - Set on Entry / Reset on Exit */
{GPIOB, LL_GPIO_PIN_2, 1, 0}, /* MB_BLE_SEND_EVT - Set on Entry / Reset on Exit */
{GPIOC, LL_GPIO_PIN_0, 1, 0}, /* MB_BLE_SEND_EVT - Set on Entry / Reset on Exit */
/* From v1.3.0 */
{GPIOA, LL_GPIO_PIN_0, 0, 0}, /* BLE_NO_DELAY - Set on Entry / Reset on Exit */
{GPIOA, LL_GPIO_PIN_0, 0, 0}, /* BLE_STACK_STORE_NVM_CB - Set on Entry / Reset on Exit */

View File

@ -137,38 +137,33 @@ static int32_t ble_app_hci_thread(void* arg) {
// Called by WPAN lib
void hci_notify_asynch_evt(void* pdata) {
UNUSED(pdata);
if(ble_app) {
FuriThreadId thread_id = furi_thread_get_id(ble_app->thread);
furi_assert(thread_id);
furi_thread_flags_set(thread_id, BLE_APP_FLAG_HCI_EVENT);
}
furi_check(ble_app);
FuriThreadId thread_id = furi_thread_get_id(ble_app->thread);
furi_assert(thread_id);
furi_thread_flags_set(thread_id, BLE_APP_FLAG_HCI_EVENT);
}
void hci_cmd_resp_release(uint32_t flag) {
UNUSED(flag);
if(ble_app) {
furi_semaphore_release(ble_app->hci_sem);
}
furi_check(ble_app);
furi_check(furi_semaphore_release(ble_app->hci_sem) == FuriStatusOk);
}
void hci_cmd_resp_wait(uint32_t timeout) {
UNUSED(timeout);
if(ble_app) {
furi_semaphore_acquire(ble_app->hci_sem, FuriWaitForever);
}
furi_check(ble_app);
furi_check(furi_semaphore_acquire(ble_app->hci_sem, timeout) == FuriStatusOk);
}
static void ble_app_hci_event_handler(void* pPayload) {
SVCCTL_UserEvtFlowStatus_t svctl_return_status;
tHCI_UserEvtRxParam* pParam = (tHCI_UserEvtRxParam*)pPayload;
if(ble_app) {
svctl_return_status = SVCCTL_UserEvtRx((void*)&(pParam->pckt->evtserial));
if(svctl_return_status != SVCCTL_UserEvtFlowDisable) {
pParam->status = HCI_TL_UserEventFlow_Enable;
} else {
pParam->status = HCI_TL_UserEventFlow_Disable;
}
furi_check(ble_app);
svctl_return_status = SVCCTL_UserEvtRx((void*)&(pParam->pckt->evtserial));
if(svctl_return_status != SVCCTL_UserEvtFlowDisable) {
pParam->status = HCI_TL_UserEventFlow_Enable;
} else {
pParam->status = HCI_TL_UserEventFlow_Disable;
}
}

View File

@ -289,8 +289,6 @@ static void gap_init_svc(Gap* gap) {
tBleStatus status;
uint32_t srd_bd_addr[2];
// HCI Reset to synchronise BLE Stack
hci_reset();
// Configure mac address
aci_hal_write_config_data(
CONFIG_DATA_PUBADDR_OFFSET, CONFIG_DATA_PUBADDR_LEN, gap->config->mac_address);

View File

@ -29,6 +29,8 @@ int main() {
FuriThread* main_thread = furi_thread_alloc_ex("Init", 4096, init_task, NULL);
#ifdef FURI_RAM_EXEC
// Prevent entering sleep mode when executed from RAM
furi_hal_power_insomnia_enter();
furi_thread_start(main_thread);
#else
furi_hal_light_sequence("RGB");
@ -44,6 +46,7 @@ int main() {
furi_hal_power_reset();
} else if(boot_mode == FuriHalRtcBootModeUpdate) {
furi_hal_light_sequence("rgb BR");
// Do update
flipper_boot_update_exec();
// if things go nice, we shouldn't reach this point.
// But if we do, abandon to avoid bootloops