[FL-1811] FuriHal: move core2 startup to hal init stage, prevent working with flash controller till core2 startup finish. #704
This commit is contained in:
		
							parent
							
								
									95d9140d24
								
							
						
					
					
						commit
						3db456da98
					
				| @ -62,7 +62,6 @@ Bt* bt_alloc() { | |||||||
| int32_t bt_srv() { | int32_t bt_srv() { | ||||||
|     Bt* bt = bt_alloc(); |     Bt* bt = bt_alloc(); | ||||||
|     furi_record_create("bt", bt); |     furi_record_create("bt", bt); | ||||||
|     furi_hal_bt_init(); |  | ||||||
| 
 | 
 | ||||||
|     if(!furi_hal_bt_wait_startup()) { |     if(!furi_hal_bt_wait_startup()) { | ||||||
|         FURI_LOG_E(BT_SERVICE_TAG, "Core2 startup failed"); |         FURI_LOG_E(BT_SERVICE_TAG, "Core2 startup failed"); | ||||||
|  | |||||||
| @ -138,8 +138,10 @@ static void APPE_SysUserEvtRx( void * pPayload ) { | |||||||
|   // APPD_EnableCPU2( );
 |   // APPD_EnableCPU2( );
 | ||||||
|    |    | ||||||
|   if (APP_BLE_Init()) { |   if (APP_BLE_Init()) { | ||||||
|  |     FURI_LOG_I("Core2", "BLE stack started"); | ||||||
|     ble_glue_status = BleGlueStatusStarted; |     ble_glue_status = BleGlueStatusStarted; | ||||||
|   } else { |   } else { | ||||||
|  |     FURI_LOG_E("Core2", "BLE stack startup failed"); | ||||||
|     ble_glue_status = BleGlueStatusBroken; |     ble_glue_status = BleGlueStatusBroken; | ||||||
|   } |   } | ||||||
|   furi_hal_power_insomnia_exit(); |   furi_hal_power_insomnia_exit(); | ||||||
|  | |||||||
| @ -46,7 +46,7 @@ bool furi_hal_bt_is_alive() { | |||||||
| 
 | 
 | ||||||
| bool furi_hal_bt_wait_startup() { | bool furi_hal_bt_wait_startup() { | ||||||
|     uint8_t counter = 0; |     uint8_t counter = 0; | ||||||
|     while (APPE_Status() == BleGlueStatusStartup) { |     while (!(APPE_Status() == BleGlueStatusStarted || APPE_Status() == BleGlueStatusBroken)) { | ||||||
|         osDelay(10); |         osDelay(10); | ||||||
|         counter++; |         counter++; | ||||||
|         if (counter > 1000) { |         if (counter > 1000) { | ||||||
| @ -60,27 +60,23 @@ bool furi_hal_bt_lock_flash() { | |||||||
|     if (!furi_hal_bt_wait_startup()) { |     if (!furi_hal_bt_wait_startup()) { | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|     if (APPE_Status() == BleGlueStatusUninitialized) { |      | ||||||
|         HAL_FLASH_Unlock(); |     while (HAL_HSEM_FastTake(CFG_HW_FLASH_SEMID) != HAL_OK) { | ||||||
|     } else { |         osDelay(1); | ||||||
|         while (HAL_HSEM_FastTake(CFG_HW_FLASH_SEMID) != HAL_OK) { |  | ||||||
|             osDelay(1); |  | ||||||
|         } |  | ||||||
|         SHCI_C2_FLASH_EraseActivity(ERASE_ACTIVITY_ON); |  | ||||||
|         HAL_FLASH_Unlock(); |  | ||||||
|         while(LL_FLASH_IsOperationSuspended()) {}; |  | ||||||
|     } |     } | ||||||
|  |      | ||||||
|  |     SHCI_C2_FLASH_EraseActivity(ERASE_ACTIVITY_ON); | ||||||
|  |     HAL_FLASH_Unlock(); | ||||||
|  | 
 | ||||||
|  |     while(LL_FLASH_IsOperationSuspended()) {}; | ||||||
|  | 
 | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_bt_unlock_flash() { | void furi_hal_bt_unlock_flash() { | ||||||
|     if (APPE_Status() == BleGlueStatusUninitialized) { |     SHCI_C2_FLASH_EraseActivity(ERASE_ACTIVITY_OFF); | ||||||
|         HAL_FLASH_Lock(); |     HAL_FLASH_Lock(); | ||||||
|     } else { |     HAL_HSEM_Release(CFG_HW_FLASH_SEMID, HSEM_CPU1_COREID); | ||||||
|         SHCI_C2_FLASH_EraseActivity(ERASE_ACTIVITY_OFF); |  | ||||||
|         HAL_FLASH_Lock(); |  | ||||||
|         HAL_HSEM_Release(CFG_HW_FLASH_SEMID, HSEM_CPU1_COREID); |  | ||||||
|     } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_bt_start_tone_tx(uint8_t channel, uint8_t power) { | void furi_hal_bt_start_tone_tx(uint8_t channel, uint8_t power) { | ||||||
|  | |||||||
| @ -59,6 +59,7 @@ void furi_hal_init() { | |||||||
|     furi_hal_subghz_init(); |     furi_hal_subghz_init(); | ||||||
|     furi_hal_nfc_init(); |     furi_hal_nfc_init(); | ||||||
|     furi_hal_rfid_init(); |     furi_hal_rfid_init(); | ||||||
|  |     furi_hal_bt_init(); | ||||||
| 
 | 
 | ||||||
|     // FreeRTOS glue
 |     // FreeRTOS glue
 | ||||||
|     furi_hal_os_init(); |     furi_hal_os_init(); | ||||||
|  | |||||||
| @ -138,8 +138,10 @@ static void APPE_SysUserEvtRx( void * pPayload ) { | |||||||
|   // APPD_EnableCPU2( );
 |   // APPD_EnableCPU2( );
 | ||||||
|    |    | ||||||
|   if (APP_BLE_Init()) { |   if (APP_BLE_Init()) { | ||||||
|  |     FURI_LOG_I("Core2", "BLE stack started"); | ||||||
|     ble_glue_status = BleGlueStatusStarted; |     ble_glue_status = BleGlueStatusStarted; | ||||||
|   } else { |   } else { | ||||||
|  |     FURI_LOG_E("Core2", "BLE stack startup failed"); | ||||||
|     ble_glue_status = BleGlueStatusBroken; |     ble_glue_status = BleGlueStatusBroken; | ||||||
|   } |   } | ||||||
|   furi_hal_power_insomnia_exit(); |   furi_hal_power_insomnia_exit(); | ||||||
|  | |||||||
| @ -46,7 +46,7 @@ bool furi_hal_bt_is_alive() { | |||||||
| 
 | 
 | ||||||
| bool furi_hal_bt_wait_startup() { | bool furi_hal_bt_wait_startup() { | ||||||
|     uint8_t counter = 0; |     uint8_t counter = 0; | ||||||
|     while (APPE_Status() == BleGlueStatusStartup) { |     while (!(APPE_Status() == BleGlueStatusStarted || APPE_Status() == BleGlueStatusBroken)) { | ||||||
|         osDelay(10); |         osDelay(10); | ||||||
|         counter++; |         counter++; | ||||||
|         if (counter > 1000) { |         if (counter > 1000) { | ||||||
| @ -60,27 +60,23 @@ bool furi_hal_bt_lock_flash() { | |||||||
|     if (!furi_hal_bt_wait_startup()) { |     if (!furi_hal_bt_wait_startup()) { | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|     if (APPE_Status() == BleGlueStatusUninitialized) { |      | ||||||
|         HAL_FLASH_Unlock(); |     while (HAL_HSEM_FastTake(CFG_HW_FLASH_SEMID) != HAL_OK) { | ||||||
|     } else { |         osDelay(1); | ||||||
|         while (HAL_HSEM_FastTake(CFG_HW_FLASH_SEMID) != HAL_OK) { |  | ||||||
|             osDelay(1); |  | ||||||
|         } |  | ||||||
|         SHCI_C2_FLASH_EraseActivity(ERASE_ACTIVITY_ON); |  | ||||||
|         HAL_FLASH_Unlock(); |  | ||||||
|         while(LL_FLASH_IsOperationSuspended()) {}; |  | ||||||
|     } |     } | ||||||
|  |      | ||||||
|  |     SHCI_C2_FLASH_EraseActivity(ERASE_ACTIVITY_ON); | ||||||
|  |     HAL_FLASH_Unlock(); | ||||||
|  | 
 | ||||||
|  |     while(LL_FLASH_IsOperationSuspended()) {}; | ||||||
|  | 
 | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_bt_unlock_flash() { | void furi_hal_bt_unlock_flash() { | ||||||
|     if (APPE_Status() == BleGlueStatusUninitialized) { |     SHCI_C2_FLASH_EraseActivity(ERASE_ACTIVITY_OFF); | ||||||
|         HAL_FLASH_Lock(); |     HAL_FLASH_Lock(); | ||||||
|     } else { |     HAL_HSEM_Release(CFG_HW_FLASH_SEMID, HSEM_CPU1_COREID); | ||||||
|         SHCI_C2_FLASH_EraseActivity(ERASE_ACTIVITY_OFF); |  | ||||||
|         HAL_FLASH_Lock(); |  | ||||||
|         HAL_HSEM_Release(CFG_HW_FLASH_SEMID, HSEM_CPU1_COREID); |  | ||||||
|     } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_hal_bt_start_tone_tx(uint8_t channel, uint8_t power) { | void furi_hal_bt_start_tone_tx(uint8_t channel, uint8_t power) { | ||||||
|  | |||||||
| @ -59,6 +59,7 @@ void furi_hal_init() { | |||||||
|     furi_hal_subghz_init(); |     furi_hal_subghz_init(); | ||||||
|     furi_hal_nfc_init(); |     furi_hal_nfc_init(); | ||||||
|     furi_hal_rfid_init(); |     furi_hal_rfid_init(); | ||||||
|  |     furi_hal_bt_init(); | ||||||
| 
 | 
 | ||||||
|     // FreeRTOS glue
 |     // FreeRTOS glue
 | ||||||
|     furi_hal_os_init(); |     furi_hal_os_init(); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 あく
						あく