mirror of
https://github.com/flipperdevices/flipperzero-firmware.git
synced 2025-12-12 12:51:22 +04:00
Lock core2 when reinitialising bt
This commit is contained in:
@@ -87,10 +87,9 @@ static bool furi_hal_bt_radio_stack_is_supported(const BleGlueC2Info* info) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool furi_hal_bt_start_radio_stack(void) {
|
bool furi_hal_bt_start_radio_stack(void) {
|
||||||
bool res = false;
|
furi_hal_bt_lock_core2();
|
||||||
furi_check(furi_hal_bt.core2_mtx);
|
|
||||||
|
|
||||||
furi_mutex_acquire(furi_hal_bt.core2_mtx, FuriWaitForever);
|
bool res = false;
|
||||||
|
|
||||||
// Explicitly tell that we are in charge of CLK48 domain
|
// Explicitly tell that we are in charge of CLK48 domain
|
||||||
furi_check(LL_HSEM_1StepLock(HSEM, CFG_HW_CLK48_CONFIG_SEMID) == 0);
|
furi_check(LL_HSEM_1StepLock(HSEM, CFG_HW_CLK48_CONFIG_SEMID) == 0);
|
||||||
@@ -123,7 +122,8 @@ bool furi_hal_bt_start_radio_stack(void) {
|
|||||||
}
|
}
|
||||||
res = true;
|
res = true;
|
||||||
} while(false);
|
} while(false);
|
||||||
furi_mutex_release(furi_hal_bt.core2_mtx);
|
|
||||||
|
furi_hal_bt_unlock_core2();
|
||||||
|
|
||||||
gap_extra_beacon_init();
|
gap_extra_beacon_init();
|
||||||
return res;
|
return res;
|
||||||
@@ -198,6 +198,8 @@ FuriHalBleProfileBase* furi_hal_bt_start_app(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_bt_reinit(void) {
|
void furi_hal_bt_reinit(void) {
|
||||||
|
furi_hal_bt_lock_core2();
|
||||||
|
|
||||||
furi_hal_power_insomnia_enter();
|
furi_hal_power_insomnia_enter();
|
||||||
FURI_LOG_I(TAG, "Disconnect and stop advertising");
|
FURI_LOG_I(TAG, "Disconnect and stop advertising");
|
||||||
furi_hal_bt_stop_advertising();
|
furi_hal_bt_stop_advertising();
|
||||||
@@ -229,6 +231,7 @@ void furi_hal_bt_reinit(void) {
|
|||||||
furi_hal_bus_disable(FuriHalBusCRC);
|
furi_hal_bus_disable(FuriHalBusCRC);
|
||||||
|
|
||||||
furi_hal_bt_init();
|
furi_hal_bt_init();
|
||||||
|
furi_hal_bt_unlock_core2();
|
||||||
furi_hal_bt_start_radio_stack();
|
furi_hal_bt_start_radio_stack();
|
||||||
furi_hal_power_insomnia_exit();
|
furi_hal_power_insomnia_exit();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,25 +262,39 @@ bool furi_hal_crypto_enclave_load_key(uint8_t slot, const uint8_t* iv) {
|
|||||||
|
|
||||||
furi_hal_bus_enable(FuriHalBusAES1);
|
furi_hal_bus_enable(FuriHalBusAES1);
|
||||||
|
|
||||||
|
bool success = false;
|
||||||
|
|
||||||
|
furi_hal_bt_lock_core2();
|
||||||
|
|
||||||
|
do {
|
||||||
if(!furi_hal_bt_is_alive()) {
|
if(!furi_hal_bt_is_alive()) {
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
furi_hal_crypto_mode_init_done = false;
|
furi_hal_crypto_mode_init_done = false;
|
||||||
crypto_key_init(NULL, (uint32_t*)iv);
|
crypto_key_init(NULL, (uint32_t*)iv);
|
||||||
|
|
||||||
if(SHCI_C2_FUS_LoadUsrKey(slot) == SHCI_Success) {
|
if(SHCI_C2_FUS_LoadUsrKey(slot) == SHCI_Success) {
|
||||||
return true;
|
success = true;
|
||||||
} else {
|
} else {
|
||||||
CLEAR_BIT(AES1->CR, AES_CR_EN);
|
CLEAR_BIT(AES1->CR, AES_CR_EN);
|
||||||
furi_check(furi_mutex_release(furi_hal_crypto_mutex) == FuriStatusOk);
|
furi_check(furi_mutex_release(furi_hal_crypto_mutex) == FuriStatusOk);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} while(false);
|
||||||
|
|
||||||
|
furi_hal_bt_unlock_core2();
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool furi_hal_crypto_enclave_unload_key(uint8_t slot) {
|
bool furi_hal_crypto_enclave_unload_key(uint8_t slot) {
|
||||||
|
furi_hal_bt_lock_core2();
|
||||||
|
|
||||||
|
bool success = false;
|
||||||
|
|
||||||
|
do {
|
||||||
if(!furi_hal_bt_is_alive()) {
|
if(!furi_hal_bt_is_alive()) {
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CLEAR_BIT(AES1->CR, AES_CR_EN);
|
CLEAR_BIT(AES1->CR, AES_CR_EN);
|
||||||
@@ -291,7 +305,11 @@ bool furi_hal_crypto_enclave_unload_key(uint8_t slot) {
|
|||||||
|
|
||||||
furi_check(furi_mutex_release(furi_hal_crypto_mutex) == FuriStatusOk);
|
furi_check(furi_mutex_release(furi_hal_crypto_mutex) == FuriStatusOk);
|
||||||
|
|
||||||
return (shci_state == SHCI_Success);
|
success = (shci_state == SHCI_Success);
|
||||||
|
} while(false);
|
||||||
|
|
||||||
|
furi_hal_bt_unlock_core2();
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool furi_hal_crypto_load_key(const uint8_t* key, const uint8_t* iv) {
|
bool furi_hal_crypto_load_key(const uint8_t* key, const uint8_t* iv) {
|
||||||
|
|||||||
Reference in New Issue
Block a user