From ce197893220f79b467f7abc1a19e62049ed5ef5f Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Wed, 21 Sep 2022 10:00:16 -0400 Subject: [PATCH 1/7] Bluetooth refactor to use SLC generation --- examples/chef/efr32/src/AppTask.cpp | 2 - .../light-switch-app/efr32/src/AppTask.cpp | 1 - examples/lighting-app/efr32/src/AppTask.cpp | 2 - examples/lock-app/efr32/src/AppTask.cpp | 2 - examples/platform/efr32/BaseApplication.cpp | 1 - examples/platform/efr32/MemMonitoring.cpp | 1 - examples/thermostat/efr32/src/AppTask.cpp | 1 - src/platform/EFR32/BLEManagerImpl.cpp | 290 ++++++-------- src/platform/EFR32/BLEManagerImpl.h | 29 +- src/platform/EFR32/BUILD.gn | 2 - src/platform/EFR32/EFR32Config.cpp | 88 +++++ src/platform/EFR32/freertos_bluetooth.c | 366 ------------------ src/platform/EFR32/freertos_bluetooth.h | 84 ---- third_party/silabs/efr32_sdk.gni | 2 + 14 files changed, 223 insertions(+), 648 deletions(-) delete mode 100644 src/platform/EFR32/freertos_bluetooth.c delete mode 100644 src/platform/EFR32/freertos_bluetooth.h diff --git a/examples/chef/efr32/src/AppTask.cpp b/examples/chef/efr32/src/AppTask.cpp index 9b2593f4736ef8..a14eece74d85d3 100644 --- a/examples/chef/efr32/src/AppTask.cpp +++ b/examples/chef/efr32/src/AppTask.cpp @@ -49,8 +49,6 @@ #include #include -#include - #include #include diff --git a/examples/light-switch-app/efr32/src/AppTask.cpp b/examples/light-switch-app/efr32/src/AppTask.cpp index 9fddca1d1aa98c..96459f9a188bb1 100644 --- a/examples/light-switch-app/efr32/src/AppTask.cpp +++ b/examples/light-switch-app/efr32/src/AppTask.cpp @@ -47,7 +47,6 @@ #include #include #include -#include #include #include diff --git a/examples/lighting-app/efr32/src/AppTask.cpp b/examples/lighting-app/efr32/src/AppTask.cpp index 820cbe7049f44f..5735943282d21c 100644 --- a/examples/lighting-app/efr32/src/AppTask.cpp +++ b/examples/lighting-app/efr32/src/AppTask.cpp @@ -40,8 +40,6 @@ #include #include -#include - #include #include diff --git a/examples/lock-app/efr32/src/AppTask.cpp b/examples/lock-app/efr32/src/AppTask.cpp index c39b109fb6a2af..f624eb50073234 100644 --- a/examples/lock-app/efr32/src/AppTask.cpp +++ b/examples/lock-app/efr32/src/AppTask.cpp @@ -51,8 +51,6 @@ #include #include -#include - #include #include diff --git a/examples/platform/efr32/BaseApplication.cpp b/examples/platform/efr32/BaseApplication.cpp index 517f53de08a04d..bef8eb6ef54e0c 100644 --- a/examples/platform/efr32/BaseApplication.cpp +++ b/examples/platform/efr32/BaseApplication.cpp @@ -46,7 +46,6 @@ #include #include #include -#include #include #include diff --git a/examples/platform/efr32/MemMonitoring.cpp b/examples/platform/efr32/MemMonitoring.cpp index db8e3b752033fd..dff743aa17711e 100644 --- a/examples/platform/efr32/MemMonitoring.cpp +++ b/examples/platform/efr32/MemMonitoring.cpp @@ -21,7 +21,6 @@ #include "AppConfig.h" #include "FreeRTOS.h" #include -#include static StackType_t monitoringStack[MONITORING_STACK_SIZE_byte / sizeof(StackType_t)]; static StaticTask_t monitoringTaskStruct; diff --git a/examples/thermostat/efr32/src/AppTask.cpp b/examples/thermostat/efr32/src/AppTask.cpp index 2b518669162649..37ab028045fe35 100644 --- a/examples/thermostat/efr32/src/AppTask.cpp +++ b/examples/thermostat/efr32/src/AppTask.cpp @@ -46,7 +46,6 @@ #include #include #include -#include #include #include diff --git a/src/platform/EFR32/BLEManagerImpl.cpp b/src/platform/EFR32/BLEManagerImpl.cpp index 344d6c58a7d362..91de55f6698473 100644 --- a/src/platform/EFR32/BLEManagerImpl.cpp +++ b/src/platform/EFR32/BLEManagerImpl.cpp @@ -32,6 +32,9 @@ #include "FreeRTOS.h" #include "rail.h" +extern "C" { +#include "sl_bluetooth.h" +} #include "sl_bt_api.h" #include "sl_bt_stack_config.h" #include "sl_bt_stack_init.h" @@ -41,7 +44,7 @@ #include #include #include -#include +#include #if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING #include @@ -95,10 +98,6 @@ namespace { TimerHandle_t sbleAdvTimeoutTimer; // FreeRTOS sw timer. -StackType_t bluetoothEventStack[CHIP_DEVICE_CONFIG_BLE_APP_TASK_STACK_SIZE / sizeof(StackType_t)]; -StaticTask_t bluetoothEventTaskStruct; -static TaskHandle_t BluetoothEventTaskHandle; - const uint8_t UUID_CHIPoBLEService[] = { 0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0xF6, 0xFF, 0x00, 0x00 }; const uint8_t ShortUUID_CHIPoBLEService[] = { 0xF6, 0xFF }; @@ -111,32 +110,9 @@ const ChipBleUUID ChipUUID_CHIPoBLEChar_TX = { { 0x18, 0xEE, 0x2E, 0xF5, 0x26, 0 BLEManagerImpl BLEManagerImpl::sInstance; -/***************************************************************************/ -/** - * Setup the bluetooth init function. - * - * @return none - * - * All bluetooth specific initialization - * code should be here like sl_bt_init_stack(), - * sl_bt_init_multiprotocol() and so on. - ******************************************************************************/ -extern "C" sl_status_t initialize_bluetooth() -{ -#if !defined(SL_CATALOG_KERNEL_PRESENT) - NVIC_ClearPendingIRQ(PendSV_IRQn); - NVIC_EnableIRQ(PendSV_IRQn); -#endif - sl_status_t err = sl_bt_stack_init(); - EFM_ASSERT(err == SL_STATUS_OK); - - return err; -} - CHIP_ERROR BLEManagerImpl::_Init() { CHIP_ERROR err; - sl_status_t ret; // Initialize the CHIP BleLayer. err = BleLayer::Init(this, this, &DeviceLayer::SystemLayer()); @@ -146,22 +122,6 @@ CHIP_ERROR BLEManagerImpl::_Init() memset(mIndConfId, kUnusedIndex, sizeof(mIndConfId)); mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Enabled; - // Start Bluetooth Link Layer and stack tasks - ret = - bluetooth_start(CHIP_DEVICE_CONFIG_BLE_LL_TASK_PRIORITY, CHIP_DEVICE_CONFIG_BLE_STACK_TASK_PRIORITY, initialize_bluetooth); - - VerifyOrExit(ret == SL_STATUS_OK, err = MapBLEError(ret)); - - // Create the Bluetooth Application task - BluetoothEventTaskHandle = - xTaskCreateStatic(bluetoothStackEventHandler, /* Function that implements the task. */ - CHIP_DEVICE_CONFIG_BLE_APP_TASK_NAME, /* Text name for the task. */ - ArraySize(bluetoothEventStack), /* Number of indexes in the xStack array. */ - this, /* Parameter passed into the task. */ - CHIP_DEVICE_CONFIG_BLE_APP_TASK_PRIORITY, /* Priority at which the task is created. */ - bluetoothEventStack, /* Pointer to task heap */ - &bluetoothEventTaskStruct); /* Variable that holds the task struct */ - // Create FreeRTOS sw timer for BLE timeouts and interval change. sbleAdvTimeoutTimer = xTimerCreate("BleAdvTimer", // Just a text name, not used by the RTOS kernel 1, // == default timer period (mS) @@ -192,129 +152,6 @@ uint16_t BLEManagerImpl::_NumConnections(void) return numCons; } -void BLEManagerImpl::bluetoothStackEventHandler(void * p_arg) -{ - EventBits_t flags = 0; - - while (1) - { - // wait for Bluetooth stack events, do not consume set flag - flags = xEventGroupWaitBits(bluetooth_event_flags, /* The event group being tested. */ - BLUETOOTH_EVENT_FLAG_EVT_WAITING, /* The bits within the event group to wait for. */ - pdFALSE, /* Dont clear flags before returning */ - pdFALSE, /* Any flag will do, dont wait for all flags to be set */ - portMAX_DELAY); /* Wait for maximum duration for bit to be set */ - - if (flags & BLUETOOTH_EVENT_FLAG_EVT_WAITING) - { - flags &= ~BLUETOOTH_EVENT_FLAG_EVT_WAITING; - xEventGroupClearBits(bluetooth_event_flags, BLUETOOTH_EVENT_FLAG_EVT_WAITING); - - // As this is running in a separate thread, we need to block CHIP from operating, - // until the events are handled. - PlatformMgr().LockChipStack(); - - // handle bluetooth events - switch (SL_BT_MSG_ID(bluetooth_evt->header)) - { - case sl_bt_evt_system_boot_id: { - ChipLogProgress(DeviceLayer, "Bluetooth stack booted: v%d.%d.%d-b%d", bluetooth_evt->data.evt_system_boot.major, - bluetooth_evt->data.evt_system_boot.minor, bluetooth_evt->data.evt_system_boot.patch, - bluetooth_evt->data.evt_system_boot.build); - sInstance.HandleBootEvent(); - - RAIL_Version_t railVer; - RAIL_GetVersion(&railVer, true); - ChipLogProgress(DeviceLayer, "RAIL version:, v%d.%d.%d-b%d", railVer.major, railVer.minor, railVer.rev, - railVer.build); - sl_bt_connection_set_default_parameters(BLE_CONFIG_MIN_INTERVAL, BLE_CONFIG_MAX_INTERVAL, BLE_CONFIG_LATENCY, - BLE_CONFIG_TIMEOUT, BLE_CONFIG_MIN_CE_LENGTH, BLE_CONFIG_MAX_CE_LENGTH); - } - break; - - case sl_bt_evt_connection_opened_id: { - sInstance.HandleConnectEvent(bluetooth_evt); - } - break; - case sl_bt_evt_connection_parameters_id: { - // ChipLogProgress(DeviceLayer, "Connection parameter ID received"); - } - break; - case sl_bt_evt_connection_phy_status_id: { - // ChipLogProgress(DeviceLayer, "PHY update procedure is completed"); - } - break; - case sl_bt_evt_connection_closed_id: { - sInstance.HandleConnectionCloseEvent(bluetooth_evt); - } - break; - - /* This event indicates that a remote GATT client is attempting to write a value of an - * attribute in to the local GATT database, where the attribute was defined in the GATT - * XML firmware configuration file to have type="user". */ - case sl_bt_evt_gatt_server_attribute_value_id: { - sInstance.HandleWriteEvent(bluetooth_evt); - } - break; - - case sl_bt_evt_gatt_mtu_exchanged_id: { - sInstance.UpdateMtu(bluetooth_evt); - } - break; - - // confirmation of indication received from remote GATT client - case sl_bt_evt_gatt_server_characteristic_status_id: { - sl_bt_gatt_server_characteristic_status_flag_t StatusFlags; - - StatusFlags = (sl_bt_gatt_server_characteristic_status_flag_t) - bluetooth_evt->data.evt_gatt_server_characteristic_status.status_flags; - - if (sl_bt_gatt_server_confirmation == StatusFlags) - { - sInstance.HandleTxConfirmationEvent(bluetooth_evt->data.evt_gatt_server_characteristic_status.connection); - } - else if ((bluetooth_evt->data.evt_gatt_server_characteristic_status.characteristic == gattdb_CHIPoBLEChar_Tx) && - (bluetooth_evt->data.evt_gatt_server_characteristic_status.status_flags == gatt_server_client_config)) - { - sInstance.HandleTXCharCCCDWrite(bluetooth_evt); - } - } - break; - - /* Software Timer event */ - case sl_bt_evt_system_soft_timer_id: { - sInstance.HandleSoftTimerEvent(bluetooth_evt); - } - break; - - case sl_bt_evt_gatt_server_user_read_request_id: { - ChipLogProgress(DeviceLayer, "GATT server user_read_request"); -#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING - if (bluetooth_evt->data.evt_gatt_server_user_read_request.characteristic == gattdb_CHIPoBLEChar_C3) - { - HandleC3ReadRequest(bluetooth_evt); - } -#endif // CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING - } - break; - - case sl_bt_evt_connection_remote_used_features_id: { - // ChipLogProgress(DeviceLayer, "link layer features supported by the remote device"); - } - break; - - default: - ChipLogProgress(DeviceLayer, "evt_UNKNOWN id = %08" PRIx32, SL_BT_MSG_ID(bluetooth_evt->header)); - break; - } - } - - PlatformMgr().UnlockChipStack(); - - vRaiseEventFlagBasedOnContext(bluetooth_event_flags, BLUETOOTH_EVENT_FLAG_EVT_HANDLED); - } -} - CHIP_ERROR BLEManagerImpl::_SetAdvertisingEnabled(bool val) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -531,6 +368,8 @@ CHIP_ERROR BLEManagerImpl::MapBLEError(int bleErr) return CHIP_ERROR_INVALID_ARGUMENT; case SL_STATUS_INVALID_STATE: return CHIP_ERROR_INCORRECT_STATE; + case SL_STATUS_NOT_SUPPORTED: + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; default: return CHIP_ERROR(ChipError::Range::kPlatform, bleErr + CHIP_DEVICE_CONFIG_EFR32_BLE_ERROR_MIN); } @@ -638,12 +477,14 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void) ChipLogError(DeviceLayer, "sl_bt_advertiser_create_set() failed: %s", ErrorStr(err)); ExitNow(); } - ret = sl_bt_advertiser_set_data(advertising_set_handle, CHIP_ADV_DATA, index, (uint8_t *) advData); + + ret = sl_bt_legacy_advertiser_set_data(advertising_set_handle, sl_bt_advertiser_advertising_data_packet, index, + (uint8_t *) advData); if (ret != SL_STATUS_OK) { err = MapBLEError(ret); - ChipLogError(DeviceLayer, "sl_bt_advertiser_set_data() failed: %s", ErrorStr(err)); + ChipLogError(DeviceLayer, "sl_bt_legacy_advertiser_set_data() - Advertising Data failed: %s", ErrorStr(err)); ExitNow(); } @@ -659,12 +500,13 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void) memcpy(&responseData[index], mDeviceName, mDeviceNameLength); // AD value index += mDeviceNameLength; - ret = sl_bt_advertiser_set_data(advertising_set_handle, CHIP_ADV_SCAN_RESPONSE_DATA, index, (uint8_t *) responseData); + ret = sl_bt_legacy_advertiser_set_data(advertising_set_handle, sl_bt_advertiser_scan_response_packet, index, + (uint8_t *) responseData); if (ret != SL_STATUS_OK) { err = MapBLEError(ret); - ChipLogError(DeviceLayer, "sl_bt_advertiser_set_data() failed: %s", ErrorStr(err)); + ChipLogError(DeviceLayer, "sl_bt_legacy_advertiser_set_data() - Scan Response failed: %s", ErrorStr(err)); ExitNow(); } @@ -719,8 +561,8 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) err = MapBLEError(ret); SuccessOrExit(err); - sl_bt_advertiser_set_configuration(advertising_set_handle, 1); - ret = sl_bt_advertiser_start(advertising_set_handle, sl_bt_advertiser_user_data, connectableAdv); + sl_bt_advertiser_configure(advertising_set_handle, 1); + ret = sl_bt_legacy_advertiser_start(advertising_set_handle, connectableAdv); if (SL_STATUS_OK == ret) { @@ -1146,4 +988,106 @@ void BLEManagerImpl::DriveBLEState(intptr_t arg) } // namespace Internal } // namespace DeviceLayer } // namespace chip + +extern "C" void sl_bt_on_event(sl_bt_msg_t * evt) +{ + // As this is running in a separate thread, we need to block CHIP from operating, + // until the events are handled. + chip::DeviceLayer::PlatformMgr().LockChipStack(); + + // handle bluetooth events + switch (SL_BT_MSG_ID(evt->header)) + { + case sl_bt_evt_system_boot_id: { + ChipLogProgress(DeviceLayer, "Bluetooth stack booted: v%d.%d.%d-b%d", evt->data.evt_system_boot.major, + evt->data.evt_system_boot.minor, evt->data.evt_system_boot.patch, evt->data.evt_system_boot.build); + chip::DeviceLayer::Internal::BLEMgrImpl().HandleBootEvent(); + + RAIL_Version_t railVer; + RAIL_GetVersion(&railVer, true); + ChipLogProgress(DeviceLayer, "RAIL version:, v%d.%d.%d-b%d", railVer.major, railVer.minor, railVer.rev, railVer.build); + sl_bt_connection_set_default_parameters(BLE_CONFIG_MIN_INTERVAL, BLE_CONFIG_MAX_INTERVAL, BLE_CONFIG_LATENCY, + BLE_CONFIG_TIMEOUT, BLE_CONFIG_MIN_CE_LENGTH, BLE_CONFIG_MAX_CE_LENGTH); + } + break; + + case sl_bt_evt_connection_opened_id: { + chip::DeviceLayer::Internal::BLEMgrImpl().HandleConnectEvent(evt); + } + break; + case sl_bt_evt_connection_parameters_id: { + // ChipLogProgress(DeviceLayer, "Connection parameter ID received"); + } + break; + case sl_bt_evt_connection_phy_status_id: { + // ChipLogProgress(DeviceLayer, "PHY update procedure is completed"); + } + break; + case sl_bt_evt_connection_closed_id: { + chip::DeviceLayer::Internal::BLEMgrImpl().HandleConnectionCloseEvent(evt); + } + break; + + /* This event indicates that a remote GATT client is attempting to write a value of an + * attribute in to the local GATT database, where the attribute was defined in the GATT + * XML firmware configuration file to have type="user". */ + case sl_bt_evt_gatt_server_attribute_value_id: { + chip::DeviceLayer::Internal::BLEMgrImpl().HandleWriteEvent(evt); + } + break; + + case sl_bt_evt_gatt_mtu_exchanged_id: { + chip::DeviceLayer::Internal::BLEMgrImpl().UpdateMtu(evt); + } + break; + + // confirmation of indication received from remote GATT client + case sl_bt_evt_gatt_server_characteristic_status_id: { + sl_bt_gatt_server_characteristic_status_flag_t StatusFlags; + + StatusFlags = (sl_bt_gatt_server_characteristic_status_flag_t) evt->data.evt_gatt_server_characteristic_status.status_flags; + + if (sl_bt_gatt_server_confirmation == StatusFlags) + { + chip::DeviceLayer::Internal::BLEMgrImpl().HandleTxConfirmationEvent( + evt->data.evt_gatt_server_characteristic_status.connection); + } + else if ((evt->data.evt_gatt_server_characteristic_status.characteristic == gattdb_CHIPoBLEChar_Tx) && + (evt->data.evt_gatt_server_characteristic_status.status_flags == gatt_server_client_config)) + { + chip::DeviceLayer::Internal::BLEMgrImpl().HandleTXCharCCCDWrite(evt); + } + } + break; + + /* Software Timer event */ + case sl_bt_evt_system_soft_timer_id: { + chip::DeviceLayer::Internal::BLEMgrImpl().HandleSoftTimerEvent(evt); + } + break; + + case sl_bt_evt_gatt_server_user_read_request_id: { + ChipLogProgress(DeviceLayer, "GATT server user_read_request"); +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + if (evt->data.evt_gatt_server_user_read_request.characteristic == gattdb_CHIPoBLEChar_C3) + { + chip::DeviceLayer::Internal::BLEMgrImpl().HandleC3ReadRequest(evt); + } +#endif // CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + } + break; + + case sl_bt_evt_connection_remote_used_features_id: { + // ChipLogProgress(DeviceLayer, "link layer features supported by the remote device"); + } + break; + + default: + ChipLogProgress(DeviceLayer, "evt_UNKNOWN id = %08" PRIx32, SL_BT_MSG_ID(evt->header)); + break; + } + + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); +} + #endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/src/platform/EFR32/BLEManagerImpl.h b/src/platform/EFR32/BLEManagerImpl.h index 1d557d134f252b..0f1d478f179b61 100644 --- a/src/platform/EFR32/BLEManagerImpl.h +++ b/src/platform/EFR32/BLEManagerImpl.h @@ -42,6 +42,22 @@ using namespace chip::Ble; */ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePlatformDelegate, private BleApplicationDelegate { + +public: + void HandleBootEvent(void); + void HandleConnectEvent(volatile sl_bt_msg_t * evt); + void HandleConnectionCloseEvent(volatile sl_bt_msg_t * evt); + void HandleWriteEvent(volatile sl_bt_msg_t * evt); + void UpdateMtu(volatile sl_bt_msg_t * evt); + void HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId); + void HandleTXCharCCCDWrite(volatile sl_bt_msg_t * evt); + void HandleSoftTimerEvent(volatile sl_bt_msg_t * evt); + +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + static void HandleC3ReadRequest(volatile sl_bt_msg_t * evt); +#endif + +private: // Allow the BLEManager interface class to delegate method calls to // the implementation methods provided by this class. friend BLEManager; @@ -137,28 +153,15 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla #if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING CHIP_ERROR EncodeAdditionalDataTlv(); #endif - void UpdateMtu(volatile sl_bt_msg_t * evt); - void HandleBootEvent(void); - void HandleConnectEvent(volatile sl_bt_msg_t * evt); - void HandleConnectionCloseEvent(volatile sl_bt_msg_t * evt); - void HandleWriteEvent(volatile sl_bt_msg_t * evt); - void HandleTXCharCCCDWrite(volatile sl_bt_msg_t * evt); void HandleRXCharWrite(volatile sl_bt_msg_t * evt); - void HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId); - void HandleSoftTimerEvent(volatile sl_bt_msg_t * evt); bool RemoveConnection(uint8_t connectionHandle); void AddConnection(uint8_t connectionHandle, uint8_t bondingHandle); void StartBleAdvTimeoutTimer(uint32_t aTimeoutInMs); void CancelBleAdvTimeoutTimer(void); CHIPoBLEConState * GetConnectionState(uint8_t conId, bool allocate = false); static void DriveBLEState(intptr_t arg); - static void bluetoothStackEventHandler(void * p_arg); static void BleAdvTimeoutHandler(TimerHandle_t xTimer); uint8_t GetTimerHandle(uint8_t connectionHandle, bool allocate); - -#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING - static void HandleC3ReadRequest(volatile sl_bt_msg_t * evt); -#endif }; /** diff --git a/src/platform/EFR32/BUILD.gn b/src/platform/EFR32/BUILD.gn index 1b5d6c45bbe3ba..7840c503ed17ef 100644 --- a/src/platform/EFR32/BUILD.gn +++ b/src/platform/EFR32/BUILD.gn @@ -57,8 +57,6 @@ static_library("EFR32") { "PlatformManagerImpl.cpp", "PlatformManagerImpl.h", "SystemPlatformConfig.h", - "freertos_bluetooth.c", - "freertos_bluetooth.h", "gatt_db.c", "gatt_db.h", ] diff --git a/src/platform/EFR32/EFR32Config.cpp b/src/platform/EFR32/EFR32Config.cpp index 1abd6cfbd6c00c..e5c8a2073ef1c4 100644 --- a/src/platform/EFR32/EFR32Config.cpp +++ b/src/platform/EFR32/EFR32Config.cpp @@ -29,6 +29,7 @@ #include #include +#include "AppConfig.h" #include "FreeRTOS.h" #include "nvm3.h" #include "nvm3_default.h" @@ -533,3 +534,90 @@ void EFR32Config::RepackNvm3Flash(void) } // namespace Internal } // namespace DeviceLayer } // namespace chip + +extern "C" { + +void vApplicationMallocFailedHook(void) +{ + /* Called if a call to pvPortMalloc() fails because there is insufficient + free memory available in the FreeRTOS heap. pvPortMalloc() is called + internally by FreeRTOS API functions that create tasks, queues, software + timers, and semaphores. The size of the FreeRTOS heap is set by the + configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */ + + EFR32_LOG("Failed do a malloc on HEAP. Is it too small ?"); + + /* Force an assert. */ + configASSERT((volatile void *) NULL); +} +/*-----------------------------------------------------------*/ + +void vApplicationStackOverflowHook(TaskHandle_t pxTask, char * pcTaskName) +{ + //(void) pcTaskName; + (void) pxTask; + + /* Run time stack overflow checking is performed if + configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook + function is called if a stack overflow is detected. */ + EFR32_LOG("TASK OVERFLOW"); + EFR32_LOG(pcTaskName); + /* Force an assert. */ + configASSERT((volatile void *) NULL); +} + +void vApplicationTickHook(void) {} + +/*-----------------------------------------------------------*/ + +/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an +implementation of vApplicationGetIdleTaskMemory() to provide the memory that is +used by the Idle task. */ +void vApplicationGetIdleTaskMemory(StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, + uint32_t * pulIdleTaskStackSize) +{ + /* If the buffers to be provided to the Idle task are declared inside this + function then they must be declared static - otherwise they will be allocated on + the stack and so not exists after this function exits. */ + static StaticTask_t xIdleTaskTCB; + static StackType_t uxIdleTaskStack[configMINIMAL_STACK_SIZE]; + + /* Pass out a pointer to the StaticTask_t structure in which the Idle task's + state will be stored. */ + *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; + + /* Pass out the array that will be used as the Idle task's stack. */ + *ppxIdleTaskStackBuffer = uxIdleTaskStack; + + /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. + Note that, as the array is necessarily of type StackType_t, + configMINIMAL_STACK_SIZE is specified in words, not bytes. */ + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; +} +/*-----------------------------------------------------------*/ + +/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the +application must provide an implementation of vApplicationGetTimerTaskMemory() +to provide the memory that is used by the Timer service task. */ +void vApplicationGetTimerTaskMemory(StaticTask_t ** ppxTimerTaskTCBBuffer, StackType_t ** ppxTimerTaskStackBuffer, + uint32_t * pulTimerTaskStackSize) +{ + /* If the buffers to be provided to the Timer task are declared inside this + function then they must be declared static - otherwise they will be allocated on + the stack and so not exists after this function exits. */ + static StaticTask_t xTimerTaskTCB; + static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH]; + + /* Pass out a pointer to the StaticTask_t structure in which the Timer + task's state will be stored. */ + *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; + + /* Pass out the array that will be used as the Timer task's stack. */ + *ppxTimerTaskStackBuffer = uxTimerTaskStack; + + /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. + Note that, as the array is necessarily of type StackType_t, + configMINIMAL_STACK_SIZE is specified in words, not bytes. */ + *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; +} +} diff --git a/src/platform/EFR32/freertos_bluetooth.c b/src/platform/EFR32/freertos_bluetooth.c deleted file mode 100644 index 79562021149448..00000000000000 --- a/src/platform/EFR32/freertos_bluetooth.c +++ /dev/null @@ -1,366 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "AppConfig.h" -#include -#include -#include -#include - -#include "sl_bt_api.h" -#include "sl_bt_ncp_host.h" -#include "sl_status.h" - -#ifdef CONFIGURATION_HEADER -#include CONFIGURATION_HEADER -#endif // CONFIGURATION_HEADER - -void BluetoothUpdate(); -static sl_bt_msg_t ble_evt; -volatile sl_bt_msg_t * bluetooth_evt = &ble_evt; -SemaphoreHandle_t BluetoothMutex = NULL; - -static volatile uint32_t command_header; -static volatile void * command_data; -static volatile sl_bgapi_handler command_handler_func = NULL; - -// Bluetooth task -#ifndef BLUETOOTH_STACK_SIZE -#define BLUETOOTH_STACK_SIZE (1024) -#endif -static void BluetoothTask(void * p_arg); -static TaskHandle_t BluetoothTaskHandle = NULL; - -StackType_t bluetoothStack[BLUETOOTH_STACK_SIZE / sizeof(StackType_t)]; -StaticTask_t bluetoothTaskStruct; - -void sli_bt_cmd_handler_rtos_delegate(uint32_t header, sl_bgapi_handler handler, const void * payload); -extern void sli_bgapi_cmd_handler_delegate(uint32_t header, sl_bgapi_handler, const void *); -extern uint32_t sli_bt_can_sleep_ticks(); - -// Linklayer task -#ifndef LINKLAYER_STACK_SIZE -#define LINKLAYER_STACK_SIZE (1024) -#endif -static void LinklayerTask(void * p_arg); -static TaskHandle_t LinklayerTaskHandle = NULL; -StackType_t linkLayerStack[LINKLAYER_STACK_SIZE / sizeof(StackType_t)]; -StaticTask_t linkLayerTaskStruct; -StaticSemaphore_t bluetoothMutexStruct; -// -#define RTOS_TICK_HZ 1024 -#define BLUETOOTH_TICK_HZ 32768 -#define BLUETOOTH_TO_RTOS_TICK (BLUETOOTH_TICK_HZ / RTOS_TICK_HZ) - -EventGroupHandle_t bluetooth_event_flags; - -sl_status_t bluetooth_start(UBaseType_t ll_priority, UBaseType_t stack_priority, - bluetooth_stack_init_func initialize_bluetooth_stack) -{ - sl_status_t err; - bluetooth_event_flags = xEventGroupCreate(); - configASSERT(bluetooth_event_flags); - - BluetoothMutex = xSemaphoreCreateMutexStatic(&bluetoothMutexStruct); - - err = initialize_bluetooth_stack(); - - if (err == SL_STATUS_OK) - { - // create tasks for Bluetooth host stack - BluetoothTaskHandle = - xTaskCreateStatic(BluetoothTask, /* Function that implements the task. */ - BLE_STACK_TASK_NAME, /* Text name for the task. */ - BLUETOOTH_STACK_SIZE / sizeof(StackType_t), /* Number of indexes in the xStack array. */ - NULL, /* Parameter passed into the task. */ - stack_priority, /* Priority at which the task is created. */ - bluetoothStack, /* Pointer to task heap */ - &bluetoothTaskStruct); /* Variable that holds the task struct */ - - // create tasks for Linklayer - LinklayerTaskHandle = - xTaskCreateStatic(LinklayerTask, /* Function that implements the task. */ - BLE_LINK_TASK_NAME, /* Text name for the task. */ - LINKLAYER_STACK_SIZE / sizeof(StackType_t), /* Number of indexes in the xStack array. */ - NULL, /* Parameter passed into the task. */ - ll_priority, /* Priority at which the task is created. */ - linkLayerStack, /* Pointer to task heap */ - &linkLayerTaskStruct); /* Variable that holds the task struct */ - - if (BluetoothTaskHandle == NULL || LinklayerTaskHandle == NULL) - { - err = SL_STATUS_FAIL; - } - } - - return err; -} - -void BluetoothLLCallback() -{ - vRaiseEventFlagBasedOnContext(bluetooth_event_flags, BLUETOOTH_EVENT_FLAG_LL); -} - -void BluetoothUpdate() -{ - vRaiseEventFlagBasedOnContext(bluetooth_event_flags, BLUETOOTH_EVENT_FLAG_STACK); -} -// Bluetooth task, it waits for events from bluetooth and handles them -void BluetoothTask(void * p) -{ - EventBits_t flags = BLUETOOTH_EVENT_FLAG_EVT_HANDLED | BLUETOOTH_EVENT_FLAG_STACK; - TickType_t xTicksToWait; - - sli_bgapi_set_cmd_handler_delegate(sli_bt_cmd_handler_rtos_delegate); - - while (1) - { - // Command needs to be sent to Bluetooth stack - if (flags & BLUETOOTH_EVENT_FLAG_CMD_WAITING) - { - uint32_t header = command_header; - sl_bgapi_handler cmd_handler = command_handler_func; - sli_bgapi_cmd_handler_delegate(header, cmd_handler, (void *) command_data); - command_handler_func = NULL; - flags &= ~BLUETOOTH_EVENT_FLAG_CMD_WAITING; - vRaiseEventFlagBasedOnContext(bluetooth_event_flags, BLUETOOTH_EVENT_FLAG_RSP_WAITING); - } - - // Run Bluetooth stack. Pop the next event for application - sl_bt_run(); - // Bluetooth stack needs updating, and evt can be used - if (sl_bt_event_pending() && (flags & BLUETOOTH_EVENT_FLAG_EVT_HANDLED)) - { // update bluetooth & read event - sl_status_t status = sl_bt_pop_event((sl_bt_msg_t *) bluetooth_evt); - if (SL_STATUS_OK != status) - { - continue; - } - flags &= ~BLUETOOTH_EVENT_FLAG_EVT_HANDLED; - vRaiseEventFlagBasedOnContext(bluetooth_event_flags, BLUETOOTH_EVENT_FLAG_EVT_WAITING); - } - - xTicksToWait = sli_bt_can_sleep_ticks(); - if (xTicksToWait == 0 && (flags & BLUETOOTH_EVENT_FLAG_EVT_HANDLED)) - { - flags |= BLUETOOTH_EVENT_FLAG_STACK; - continue; - } - flags |= xEventGroupWaitBits(bluetooth_event_flags, /* The event group being tested. */ - (BLUETOOTH_EVENT_FLAG_STACK + BLUETOOTH_EVENT_FLAG_EVT_HANDLED + - BLUETOOTH_EVENT_FLAG_CMD_WAITING), /* The bits within the event group to wait for. */ - pdTRUE, /* BLUETOOTH_EVENT_FLAG_LL should be cleared before returning. */ - pdFALSE, /* Wait for all the bits to be set, not needed for single bit. */ - portMAX_DELAY); /* Wait for maximum duration for bit to be set. With 1 ms tick, - portMAX_DELAY will result in wait of 50 days*/ - if (((flags & BLUETOOTH_EVENT_FLAG_STACK) == 0) && ((flags & BLUETOOTH_EVENT_FLAG_EVT_HANDLED) == 0) && - ((flags & BLUETOOTH_EVENT_FLAG_CMD_WAITING) == 0)) - { - // timeout occurred, set the flag to update the Bluetooth stack - flags |= BLUETOOTH_EVENT_FLAG_STACK; - } - } -} - -static void LinklayerTask(void * p_arg) -{ - (void) p_arg; - - while (1) - { - EventBits_t uxBits; - - uxBits = xEventGroupWaitBits(bluetooth_event_flags, /* The event group being tested. */ - BLUETOOTH_EVENT_FLAG_LL, /* The bits within the event group to wait for. */ - pdTRUE, /* BLUETOOTH_EVENT_FLAG_LL should be cleared before returning. */ - pdTRUE, /* Wait for all the bits to be set, not needed for single bit. */ - portMAX_DELAY); /* Wait for maximum duration for bit to be set. With 1 ms tick, - portMAX_DELAY will result in wait of 50 days*/ - - if (uxBits & BLUETOOTH_EVENT_FLAG_LL) - { - sl_bt_priority_handle(); - } - } -} - -// hooks for API -// called from tasks using BGAPI -void sli_bt_cmd_handler_rtos_delegate(uint32_t header, sl_bgapi_handler handler, const void * payload) -{ - EventBits_t uxBits; - - command_header = header; - command_handler_func = handler; - command_data = (void *) payload; - // Command structure is filled, notify the stack - vRaiseEventFlagBasedOnContext(bluetooth_event_flags, BLUETOOTH_EVENT_FLAG_CMD_WAITING); - - // wait for response - uxBits = xEventGroupWaitBits(bluetooth_event_flags, /* The event group being tested. */ - BLUETOOTH_EVENT_FLAG_RSP_WAITING, /* The bits within the event group to wait for. */ - pdTRUE, /* BLUETOOTH_EVENT_FLAG_LL should be cleared before returning. */ - pdTRUE, /* Wait for all the bits to be set, not needed for single bit. */ - portMAX_DELAY); /* Wait for maximum duration for bit to be set. With 1 ms tick, - portMAX_DELAY will result in wait of 50 days*/ - (void) uxBits; -} - -void BluetoothPend(void) -{ - xSemaphoreTake(BluetoothMutex, portMAX_DELAY); -} -void BluetoothPost(void) -{ - xSemaphoreGive(BluetoothMutex); -} - -void vApplicationMallocFailedHook(void) -{ - /* Called if a call to pvPortMalloc() fails because there is insufficient - free memory available in the FreeRTOS heap. pvPortMalloc() is called - internally by FreeRTOS API functions that create tasks, queues, software - timers, and semaphores. The size of the FreeRTOS heap is set by the - configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */ - - EFR32_LOG("Failed do a malloc on HEAP. Is it too small ?"); - - /* Force an assert. */ - configASSERT((volatile void *) NULL); -} -/*-----------------------------------------------------------*/ - -void vApplicationStackOverflowHook(TaskHandle_t pxTask, char * pcTaskName) -{ - //(void) pcTaskName; - (void) pxTask; - - /* Run time stack overflow checking is performed if - configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook - function is called if a stack overflow is detected. */ - EFR32_LOG("TASK OVERFLOW"); - EFR32_LOG(pcTaskName); - /* Force an assert. */ - configASSERT((volatile void *) NULL); -} - -void vApplicationTickHook(void) {} - -/*-----------------------------------------------------------*/ - -/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an -implementation of vApplicationGetIdleTaskMemory() to provide the memory that is -used by the Idle task. */ -void vApplicationGetIdleTaskMemory(StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, - uint32_t * pulIdleTaskStackSize) -{ - /* If the buffers to be provided to the Idle task are declared inside this - function then they must be declared static - otherwise they will be allocated on - the stack and so not exists after this function exits. */ - static StaticTask_t xIdleTaskTCB; - static StackType_t uxIdleTaskStack[configMINIMAL_STACK_SIZE]; - - /* Pass out a pointer to the StaticTask_t structure in which the Idle task's - state will be stored. */ - *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; - - /* Pass out the array that will be used as the Idle task's stack. */ - *ppxIdleTaskStackBuffer = uxIdleTaskStack; - - /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. - Note that, as the array is necessarily of type StackType_t, - configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; -} -/*-----------------------------------------------------------*/ - -/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the -application must provide an implementation of vApplicationGetTimerTaskMemory() -to provide the memory that is used by the Timer service task. */ -void vApplicationGetTimerTaskMemory(StaticTask_t ** ppxTimerTaskTCBBuffer, StackType_t ** ppxTimerTaskStackBuffer, - uint32_t * pulTimerTaskStackSize) -{ - /* If the buffers to be provided to the Timer task are declared inside this - function then they must be declared static - otherwise they will be allocated on - the stack and so not exists after this function exits. */ - static StaticTask_t xTimerTaskTCB; - static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH]; - - /* Pass out a pointer to the StaticTask_t structure in which the Timer - task's state will be stored. */ - *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; - - /* Pass out the array that will be used as the Timer task's stack. */ - *ppxTimerTaskStackBuffer = uxTimerTaskStack; - - /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. - Note that, as the array is necessarily of type StackType_t, - configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; -} - -void vRaiseEventFlagBasedOnContext(EventGroupHandle_t xEventGroup, EventBits_t uxBitsToWaitFor) -{ - EventBits_t eventBits; - BaseType_t eventBitsFromISRStatus; - BaseType_t higherPrioTaskWoken = pdFALSE; - - if (xPortIsInsideInterrupt()) - { - eventBitsFromISRStatus = xEventGroupSetBitsFromISR(xEventGroup, uxBitsToWaitFor, &higherPrioTaskWoken); - if (eventBitsFromISRStatus != pdFAIL) - { -#ifdef portYIELD_FROM_ISR - portYIELD_FROM_ISR(higherPrioTaskWoken); -#elif portEND_SWITCHING_ISR // portYIELD_FROM_ISR or portEND_SWITCHING_ISR - portEND_SWITCHING_ISR(higherPrioTaskWoken); -#else // portYIELD_FROM_ISR or portEND_SWITCHING_ISR -#error "Must have portYIELD_FROM_ISR or portEND_SWITCHING_ISR" -#endif // portYIELD_FROM_ISR or portEND_SWITCHING_ISR - } - } - else - { - eventBits = xEventGroupSetBits(xEventGroup, uxBitsToWaitFor); - (void) eventBits; - } -} - -BaseType_t vSendToQueueBasedOnContext(QueueHandle_t xQueue, void * xItemToQueue, TickType_t xTicksToWait, - BaseType_t * pxHigherPriorityTaskWoken) -{ - BaseType_t status; - BaseType_t higherPrioTaskWoken = pdFALSE; - - if (xPortIsInsideInterrupt()) - { - status = xQueueSendFromISR(xQueue, xItemToQueue, &higherPrioTaskWoken); - } - else - { - status = xQueueSend(xQueue, xItemToQueue, xTicksToWait); - } - - if (pxHigherPriorityTaskWoken != NULL) - { - *pxHigherPriorityTaskWoken = higherPrioTaskWoken; - } - - return status; -} diff --git a/src/platform/EFR32/freertos_bluetooth.h b/src/platform/EFR32/freertos_bluetooth.h deleted file mode 100644 index 862b71550ec9f8..00000000000000 --- a/src/platform/EFR32/freertos_bluetooth.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#if __cplusplus -extern "C" { -#endif - -#include "FreeRTOS.h" -#include "event_groups.h" -#include "semphr.h" -#include "task.h" -#include "timers.h" - -#include "sl_bt_api.h" - -#define BLE_STACK_TASK_NAME "BLE_STACK" -#define BLE_LINK_TASK_NAME "BLE_LINK" - -// Bluetooth event flag group -extern EventGroupHandle_t bluetooth_event_flags; -// Bluetooth event flag definitions -#define BLUETOOTH_EVENT_FLAG_STACK (0x01u) // Bluetooth task needs an update -#define BLUETOOTH_EVENT_FLAG_LL (0x02u) // Linklayer task needs an update -#define BLUETOOTH_EVENT_FLAG_CMD_WAITING (0x04u) // BGAPI command is waiting to be processed -#define BLUETOOTH_EVENT_FLAG_RSP_WAITING (0x08u) // BGAPI response is waiting to be processed -#define BLUETOOTH_EVENT_FLAG_EVT_WAITING (0x10u) // BGAPI event is waiting to be processed -#define BLUETOOTH_EVENT_FLAG_EVT_HANDLED (0x20u) // BGAPI event is handled - -// Bluetooth event data pointer -extern volatile sl_bt_msg_t * bluetooth_evt; - -// Function prototype for initializing Bluetooth stack. -typedef sl_status_t (*bluetooth_stack_init_func)(); - -/** - * Start Bluetooth tasks. The given Bluetooth stack initialization function - * will be called at a proper time. Application should not initialize - * Bluetooth stack anywhere else. - * - * @param ll_priority link layer task priority - * @param stack_priority Bluetooth stack task priority - * @param initialize_bluetooth_stack The function for initializing Bluetooth stack - */ -sl_status_t bluetooth_start(UBaseType_t ll_priority, UBaseType_t stack_priority, - bluetooth_stack_init_func initialize_bluetooth_stack); - -// Set the callback for wakeup, Bluetooth task will call this when it has a new event -// It must only used to wake up application task, for example by posting task semaphore -typedef void (*wakeupCallback)(void); -void BluetoothSetWakeupCallback(wakeupCallback cb); -// Bluetooth stack needs an update -extern void BluetoothUpdate(void); -// Linklayer is updated -extern void BluetoothLLCallback(void); - -// Mutex functions for using Bluetooth from multiple tasks -void BluetoothPend(void); -void BluetoothPost(void); - -void vRaiseEventFlagBasedOnContext(EventGroupHandle_t xEventGroup, EventBits_t uxBitsToWaitFor); -BaseType_t vSendToQueueBasedOnContext(QueueHandle_t xQueue, void * xItemToQueue, TickType_t xTicksToWait, - BaseType_t * pxHigherPriorityTaskWoken); - -#if __cplusplus -} -#endif diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 22fa2d0aac59b9..15e66fe7392482 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -438,6 +438,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/service/udelay/src/sl_udelay.c", "${efr32_sdk_root}/platform/service/udelay/src/sl_udelay_armv6m_gcc.S", "${efr32_sdk_root}/protocol/bluetooth/src/sl_bt_mbedtls_context.c", + "${efr32_sdk_root}/protocol/bluetooth/src/sl_bt_rtos_adaptation.c", "${efr32_sdk_root}/protocol/bluetooth/src/sl_bt_stack_init.c", "${efr32_sdk_root}/protocol/bluetooth/src/sli_bt_advertiser_config.c", "${efr32_sdk_root}/protocol/bluetooth/src/sli_bt_connection_config.c", @@ -553,6 +554,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/util/third_party/freertos/kernel/stream_buffer.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/tasks.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/timers.c", + "${sdk_support_root}/matter/efr32/${efr32_family}/${efr32_board}/autogen/sl_bluetooth.c", "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_board_default_init.c", "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_device_init_clocks.c", "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_event_handler.c", From 45d25e988e33a3e086b3eb701e91458f389f055d Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Fri, 23 Sep 2022 09:37:19 -0400 Subject: [PATCH 2/7] Update Submodule to get generated files --- third_party/silabs/matter_support | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index 48483a67a123a4..3421966e966ae9 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit 48483a67a123a4ecd72bbd4f4a201e49ad18e8fd +Subproject commit 3421966e966ae9a6c8c550a0f9d8895ab39ad8ea From 38cd40a8c2707a3d52a0f98af62481c711cf6e0a Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Mon, 26 Sep 2022 15:33:29 -0400 Subject: [PATCH 3/7] Fix conflict error --- third_party/silabs/efr32_sdk.gni | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 15e66fe7392482..f749e4de1f7c00 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -554,7 +554,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/util/third_party/freertos/kernel/stream_buffer.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/tasks.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/timers.c", - "${sdk_support_root}/matter/efr32/${efr32_family}/${efr32_board}/autogen/sl_bluetooth.c", + "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_bluetooth.c", "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_board_default_init.c", "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_device_init_clocks.c", "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_event_handler.c", From 32dae62d65e08aaf5f592a038e82e82c76c66ad6 Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Wed, 28 Sep 2022 10:04:35 -0400 Subject: [PATCH 4/7] move gatt_db files out of csa repo --- src/platform/EFR32/BUILD.gn | 2 - .../EFR32/btconf/gatt_configuration.btconf | 96 ---- .../EFR32/btconf/in_place_ota_dfu.xml | 12 - src/platform/EFR32/gatt_db.c | 410 ------------------ src/platform/EFR32/gatt_db.h | 49 --- 5 files changed, 569 deletions(-) delete mode 100644 src/platform/EFR32/btconf/gatt_configuration.btconf delete mode 100644 src/platform/EFR32/btconf/in_place_ota_dfu.xml delete mode 100644 src/platform/EFR32/gatt_db.c delete mode 100644 src/platform/EFR32/gatt_db.h diff --git a/src/platform/EFR32/BUILD.gn b/src/platform/EFR32/BUILD.gn index 7840c503ed17ef..7e82963582d72e 100644 --- a/src/platform/EFR32/BUILD.gn +++ b/src/platform/EFR32/BUILD.gn @@ -57,8 +57,6 @@ static_library("EFR32") { "PlatformManagerImpl.cpp", "PlatformManagerImpl.h", "SystemPlatformConfig.h", - "gatt_db.c", - "gatt_db.h", ] if (chip_enable_ota_requestor) { diff --git a/src/platform/EFR32/btconf/gatt_configuration.btconf b/src/platform/EFR32/btconf/gatt_configuration.btconf deleted file mode 100644 index 060af956d3893b..00000000000000 --- a/src/platform/EFR32/btconf/gatt_configuration.btconf +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - Abstract: The generic_access service contains generic information about the device. All available Characteristics are readonly. - - - - - Empty Example - - - - - - - - - Abstract: The external appearance of this device. The values are composed of a category (10-bits) and sub-categories (6-bits). - 0000 - - - - - - - - - Abstract: The Device Information Service exposes manufacturer and/or vendor information about a device. Summary: This service exposes manufacturer information about a device. The Device Information Service is instantiated as a Primary Service. Only one instance of the Device Information Service is exposed on a device. - - - - Abstract: The value of this characteristic is a UTF-8 string representing the name of the manufacturer of the device. - Silicon Labs - - - - - - - - Abstract: The value of this characteristic is a UTF-8 string representing the model number assigned by the device vendor. - Blue Gecko - - - - - - - - Abstract: The SYSTEM ID characteristic consists of a structure with two fields. The first field are the LSOs and the second field contains the MSOs. This is a 64-bit structure which consists of a 40-bit manufacturer-defined identifier concatenated with a 24 bit unique Organizationally Unique Identifier (OUI). The OUI is issued by the IEEE Registration Authority (http://standards.ieee.org/regauth/index.html) and is required to be used in accordance with IEEE Standard 802-2001.6 while the least significant 40 bits are manufacturer defined. If System ID generated based on a Bluetooth Device Address, it is required to be done as follows. System ID and the Bluetooth Device Address have a very similar structure: a Bluetooth Device Address is 48 bits in length and consists of a 24 bit Company Assigned Identifier (manufacturer defined identifier) concatenated with a 24 bit Company Identifier (OUI). In order to encapsulate a Bluetooth Device Address as System ID, the Company Identifier is concatenated with 0xFFFE followed by the Company Assigned Identifier of the Bluetooth Address. For more guidelines related to EUI-64, refer to http://standards.ieee.org/develop/regauth/tut/eui64.pdf. Examples: If the system ID is based of a Bluetooth Device Address with a Company Identifier (OUI) is 0x123456 and the Company Assigned Identifier is 0x9ABCDE, then the System Identifier is required to be 0x123456FFFE9ABCDE. - 000102030405 - - - - - - - - - Custom service - - - - Custom characteristic - 00 - - - - - - - - - Custom characteristic - 00 - - - - - - - - - - - Custom characteristic (Additional commissioning- related data) - - - - - - - diff --git a/src/platform/EFR32/btconf/in_place_ota_dfu.xml b/src/platform/EFR32/btconf/in_place_ota_dfu.xml deleted file mode 100644 index 28ca5930597228..00000000000000 --- a/src/platform/EFR32/btconf/in_place_ota_dfu.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - Abstract: The Silicon Labs OTA Service enables in-place over-the-air firmware update of the device. - - Abstract: Silicon Labs OTA Control. - - - - - - - \ No newline at end of file diff --git a/src/platform/EFR32/gatt_db.c b/src/platform/EFR32/gatt_db.c deleted file mode 100644 index 110b069e2c23d7..00000000000000 --- a/src/platform/EFR32/gatt_db.c +++ /dev/null @@ -1,410 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Google LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/******************************************************************** - * Autogenerated file, do not edit. - *******************************************************************/ - -#include "sli_bt_gattdb_def.h" -#include - -#define GATT_HEADER(F) F -#define GATT_DATA(F) F -GATT_DATA(const uint16_t gattdb_uuidtable_16_map[]) = { - 0x2800, 0x2801, 0x2803, 0x2a00, 0x2a01, 0x2a29, 0x2a24, 0x2a23, 0x2a05, 0x2b2a, 0x2b29, 0x2902, -}; - -GATT_DATA(const uint8_t gattdb_uuidtable_128_map[]) = { - 0x11, 0x9d, 0x9f, 0x42, 0x9c, 0x4f, 0x9f, 0x95, 0x59, 0x45, 0x3d, 0x26, 0xf5, 0x2e, 0xee, 0x18, - 0x12, 0x9d, 0x9f, 0x42, 0x9c, 0x4f, 0x9f, 0x95, 0x59, 0x45, 0x3d, 0x26, 0xf5, 0x2e, 0xee, 0x18, - 0x04, 0x8f, 0x21, 0x83, 0x8a, 0x74, 0x7d, 0xb8, 0xf2, 0x45, 0x72, 0x87, 0x38, 0x02, 0x63, 0x64, - 0x63, 0x60, 0x32, 0xe0, 0x37, 0x5e, 0xa4, 0x88, 0x53, 0x4e, 0x6d, 0xfb, 0x64, 0x35, 0xbf, 0xf7, -}; -GATT_DATA(const sli_bt_gattdb_value_t gattdb_attribute_field_28) = { .len = 16, - .data = { - 0xf0, - 0x19, - 0x21, - 0xb4, - 0x47, - 0x8f, - 0xa4, - 0xbf, - 0xa1, - 0x4f, - 0x63, - 0xfd, - 0xee, - 0xd6, - 0x14, - 0x1d, - } }; -GATT_DATA(sli_bt_gattdb_attribute_chrvalue_t - gattdb_attribute_field_24) = { .properties = 0x2e, - .max_len = 247, - .len = 1, - .data = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - } }; -GATT_DATA(sli_bt_gattdb_attribute_chrvalue_t - gattdb_attribute_field_22) = { .properties = 0x0a, - .max_len = 247, - .len = 1, - .data = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - } }; -GATT_DATA(const sli_bt_gattdb_value_t gattdb_attribute_field_20) = { .len = 2, - .data = { - 0xf6, - 0xff, - } }; -GATT_DATA(const sli_bt_gattdb_value_t gattdb_attribute_field_19) = { .len = 6, - .data = { - 0x00, - 0x01, - 0x02, - 0x03, - 0x04, - 0x05, - } }; -GATT_DATA(const sli_bt_gattdb_value_t gattdb_attribute_field_17) = { .len = 10, - .data = { - 0x42, - 0x6c, - 0x75, - 0x65, - 0x20, - 0x47, - 0x65, - 0x63, - 0x6b, - 0x6f, - } }; -GATT_DATA(const sli_bt_gattdb_value_t gattdb_attribute_field_15) = { .len = 12, - .data = { - 0x53, - 0x69, - 0x6c, - 0x69, - 0x63, - 0x6f, - 0x6e, - 0x20, - 0x4c, - 0x61, - 0x62, - 0x73, - } }; -GATT_DATA(const sli_bt_gattdb_value_t gattdb_attribute_field_13) = { .len = 2, - .data = { - 0x0a, - 0x18, - } }; -GATT_DATA(const sli_bt_gattdb_value_t gattdb_attribute_field_12) = { .len = 2, - .data = { - 0x00, - 0x00, - } }; -GATT_DATA(sli_bt_gattdb_attribute_chrvalue_t gattdb_attribute_field_10) = { - .properties = 0x0a, - .max_len = 13, - .data = { 0x45, 0x6d, 0x70, 0x74, 0x79, 0x20, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, }, -}; -GATT_DATA(const sli_bt_gattdb_value_t gattdb_attribute_field_8) = { .len = 2, - .data = { - 0x00, - 0x18, - } }; -GATT_DATA(sli_bt_gattdb_attribute_chrvalue_t gattdb_attribute_field_7) = { - .properties = 0x0a, - .max_len = 1, - .data = { 0x00, }, -}; -GATT_DATA(sli_bt_gattdb_attribute_chrvalue_t gattdb_attribute_field_5) = { - .properties = 0x02, - .max_len = 16, - .data = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, -}; -GATT_DATA(sli_bt_gattdb_attribute_chrvalue_t gattdb_attribute_field_2) = { - .properties = 0x20, - .max_len = 4, - .data = { 0x00, 0x00, 0x00, 0x00, }, -}; -GATT_DATA(const sli_bt_gattdb_value_t gattdb_attribute_field_0) = { .len = 2, - .data = { - 0x01, - 0x18, - } }; - -GATT_DATA(const sli_bt_gattdb_attribute_t gattdb_attributes_map[]) = { - { .handle = 0x01, - .uuid = 0x0000, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x00, - .constdata = &gattdb_attribute_field_0 }, - { .handle = 0x02, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x20, .char_uuid = 0x0008 } }, - { .handle = 0x03, - .uuid = 0x0008, - .permissions = 0x800, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x01, - .dynamicdata = &gattdb_attribute_field_2 }, - { .handle = 0x04, - .uuid = 0x000b, - .permissions = 0x803, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x03, - .configdata = { .flags = 0x02, .clientconfig_index = 0x00 } }, - { .handle = 0x05, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x02, .char_uuid = 0x0009 } }, - { .handle = 0x06, - .uuid = 0x0009, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x01, - .dynamicdata = &gattdb_attribute_field_5 }, - { .handle = 0x07, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x0a, .char_uuid = 0x000a } }, - { .handle = 0x08, - .uuid = 0x000a, - .permissions = 0x803, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x01, - .dynamicdata = &gattdb_attribute_field_7 }, - { .handle = 0x09, - .uuid = 0x0000, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x00, - .constdata = &gattdb_attribute_field_8 }, - { .handle = 0x0a, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x0a, .char_uuid = 0x0003 } }, - { .handle = 0x0b, - .uuid = 0x0003, - .permissions = 0x803, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x01, - .dynamicdata = &gattdb_attribute_field_10 }, - { .handle = 0x0c, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x02, .char_uuid = 0x0004 } }, - { .handle = 0x0d, - .uuid = 0x0004, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x00, - .constdata = &gattdb_attribute_field_12 }, - { .handle = 0x0e, - .uuid = 0x0000, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x00, - .constdata = &gattdb_attribute_field_13 }, - { .handle = 0x0f, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x02, .char_uuid = 0x0005 } }, - { .handle = 0x10, - .uuid = 0x0005, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x00, - .constdata = &gattdb_attribute_field_15 }, - { .handle = 0x11, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x02, .char_uuid = 0x0006 } }, - { .handle = 0x12, - .uuid = 0x0006, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x00, - .constdata = &gattdb_attribute_field_17 }, - { .handle = 0x13, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x02, .char_uuid = 0x0007 } }, - { .handle = 0x14, - .uuid = 0x0007, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x00, - .constdata = &gattdb_attribute_field_19 }, - { .handle = 0x15, - .uuid = 0x0000, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x00, - .constdata = &gattdb_attribute_field_20 }, - { .handle = 0x16, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x0a, .char_uuid = 0x8000 } }, - { .handle = 0x17, - .uuid = 0x8000, - .permissions = 0x803, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x02, - .dynamicdata = &gattdb_attribute_field_22 }, - { .handle = 0x18, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x2e, .char_uuid = 0x8001 } }, - { .handle = 0x19, - .uuid = 0x8001, - .permissions = 0x807, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x02, - .dynamicdata = &gattdb_attribute_field_24 }, - { .handle = 0x1a, - .uuid = 0x000b, - .permissions = 0x803, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x03, - .configdata = { .flags = 0x02, .clientconfig_index = 0x01 } }, - { .handle = 0x1b, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x02, .char_uuid = 0x8002 } }, - { .handle = 0x1c, .uuid = 0x8002, .permissions = 0x801, .caps = 0xffff, .state = 0x00, .datatype = 0x07, .dynamicdata = NULL }, - { .handle = 0x1d, - .uuid = 0x0000, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x00, - .constdata = &gattdb_attribute_field_28 }, - { .handle = 0x1e, - .uuid = 0x0002, - .permissions = 0x801, - .caps = 0xffff, - .state = 0x00, - .datatype = 0x05, - .characteristic = { .properties = 0x08, .char_uuid = 0x8003 } }, - { .handle = 0x1f, .uuid = 0x8003, .permissions = 0x802, .caps = 0xffff, .state = 0x00, .datatype = 0x07, .dynamicdata = NULL }, -}; - -GATT_HEADER(const sli_bt_gattdb_t gattdb) = { - .attributes = gattdb_attributes_map, - .attribute_table_size = 31, - .attribute_num = 31, - .uuid16 = gattdb_uuidtable_16_map, - .uuid16_table_size = 12, - .uuid16_num = 12, - .uuid128 = gattdb_uuidtable_128_map, - .uuid128_table_size = 4, - .uuid128_num = 4, - .num_ccfg = 2, - .caps_mask = 0xffff, - .enabled_caps = 0xffff, -}; -const sli_bt_gattdb_t * static_gattdb = &gattdb; diff --git a/src/platform/EFR32/gatt_db.h b/src/platform/EFR32/gatt_db.h deleted file mode 100644 index e059feda15f0ed..00000000000000 --- a/src/platform/EFR32/gatt_db.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Google LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/******************************************************************** - * Autogenerated file, do not edit. - *******************************************************************/ - -#ifndef __GATT_DB_H -#define __GATT_DB_H - -#if __cplusplus -extern "C" { -#endif - -#include "sli_bt_gattdb_def.h" - -extern const sli_bt_gattdb_t gattdb; - -#define gattdb_generic_attribute 1 -#define gattdb_service_changed_char 3 -#define gattdb_database_hash 6 -#define gattdb_client_support_features 8 -#define gattdb_device_name 11 -#define gattdb_CHIPoBLEChar_Rx 23 -#define gattdb_CHIPoBLEChar_Tx 25 -#define gattdb_CHIPoBLEChar_C3 28 -#define gattdb_ota 29 -#define gattdb_ota_control 31 - -#if __cplusplus -} -#endif - -#endif // __GATT_DB_H From 40f8cc48b5ee200564505c0cd9ea661f2ff1f376 Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Wed, 28 Sep 2022 10:05:15 -0400 Subject: [PATCH 5/7] update sdk build gn --- third_party/silabs/efr32_sdk.gni | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index f749e4de1f7c00..bd7876d48ebb2c 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -80,6 +80,7 @@ template("efr32_sdk") { _include_dirs = [ "${efr32_sdk_root}", "${efr32_sdk_root}/hardware/kit/common/bsp", + "${efr32_sdk_root}/app/common/util/app_assert/", "${efr32_sdk_root}/hardware/board/inc", "${efr32_sdk_root}/hardware/driver/memlcd/inc", "${efr32_sdk_root}/hardware/driver/memlcd/src/ls013b7dh03", @@ -134,6 +135,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/base/hal/plugin/psstore", "${efr32_sdk_root}/platform/base/hal/plugin/antenna", "${efr32_sdk_root}/protocol/bluetooth/inc/", + "${efr32_sdk_root}/app/bluetooth/common/in_place_ota_dfu/", "${efr32_sdk_root}/util/plugin/plugin-common/fem-control", "${efr32_sdk_root}/util/silicon_labs/silabs_core/graphics", "${efr32_sdk_root}/util/silicon_labs/silabs_core/memory_manager", @@ -385,6 +387,7 @@ template("efr32_sdk") { source_set(sdk_target_name) { sources = [ "${chip_root}/third_party/mbedtls/repo/include/mbedtls/platform.h", + "${efr32_sdk_root}/app/bluetooth/common/in_place_ota_dfu/sl_bt_in_place_ota_dfu.c", "${efr32_sdk_root}/hardware/board/src/sl_board_control_gpio.c", "${efr32_sdk_root}/hardware/board/src/sl_board_init.c", "${efr32_sdk_root}/platform/CMSIS/RTOS2/Source/os_systick.c", @@ -554,6 +557,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/util/third_party/freertos/kernel/stream_buffer.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/tasks.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/timers.c", + "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/gatt_db.c", "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_bluetooth.c", "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_board_default_init.c", "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_device_init_clocks.c", @@ -641,6 +645,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_emu_s1.c", "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_hfxo_s1.c", "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_lfxo_s1.c", + "${efr32_sdk_root}/protocol/bluetooth/src/sl_apploader_util_s1.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/portable/GCC/ARM_CM4F/port.c", ] } else if (silabs_family == "efr32mg21") { @@ -688,11 +693,11 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/Device/SiliconLabs/EFR32MG24/Source/system_efr32mg24.c", "${efr32_sdk_root}/platform/radio/rail_lib/plugin/pa-conversions/pa_curves_efr32.c", "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_dcdc_s2.c", - "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_dpll_s2.c", "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_emu_s2.c", "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_hfxo_s2.c", "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_lfxo_s2.c", "${efr32_sdk_root}/platform/service/hfxo_manager/src/sl_hfxo_manager_hal_s2.c", + "${efr32_sdk_root}/protocol/bluetooth/src/sl_apploader_util_s2.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_attestation.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_cipher.c", @@ -732,6 +737,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_hfxo_mgm24.c", "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_lfxo_s2.c", "${efr32_sdk_root}/platform/service/hfxo_manager/src/sl_hfxo_manager_hal_s2.c", + "${efr32_sdk_root}/protocol/bluetooth/src/sl_apploader_util_s2.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_attestation.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_cipher.c", @@ -763,6 +769,11 @@ template("efr32_sdk") { ] } + if (silabs_board == "BRD4186A" || silabs_board == "BRD4186C" || + silabs_board == "BRD4187A" || silabs_board == "BRD4187C") { + sources += [ "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_dpll_s2.c" ] + } + public_deps = [ ":efr32_mbedtls_config", "${segger_rtt_root}:segger_rtt", From d9abf13d95b053dd7f27e5f83eee7af0edebbb0d Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Thu, 29 Sep 2022 10:12:35 -0400 Subject: [PATCH 6/7] Update Submodule --- third_party/silabs/matter_support | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index 3421966e966ae9..d9f3fb767d7b4a 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit 3421966e966ae9a6c8c550a0f9d8895ab39ad8ea +Subproject commit d9f3fb767d7b4a79d664b0c635ffe6d777a812f2 From 5e31b0db974734140db08d89b87c2be6e771aab7 Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Thu, 29 Sep 2022 10:22:56 -0400 Subject: [PATCH 7/7] Move fault logging to better location --- src/platform/EFR32/EFR32Config.cpp | 88 ------------------------------ src/platform/EFR32/Logging.cpp | 84 ++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 88 deletions(-) diff --git a/src/platform/EFR32/EFR32Config.cpp b/src/platform/EFR32/EFR32Config.cpp index e5c8a2073ef1c4..1abd6cfbd6c00c 100644 --- a/src/platform/EFR32/EFR32Config.cpp +++ b/src/platform/EFR32/EFR32Config.cpp @@ -29,7 +29,6 @@ #include #include -#include "AppConfig.h" #include "FreeRTOS.h" #include "nvm3.h" #include "nvm3_default.h" @@ -534,90 +533,3 @@ void EFR32Config::RepackNvm3Flash(void) } // namespace Internal } // namespace DeviceLayer } // namespace chip - -extern "C" { - -void vApplicationMallocFailedHook(void) -{ - /* Called if a call to pvPortMalloc() fails because there is insufficient - free memory available in the FreeRTOS heap. pvPortMalloc() is called - internally by FreeRTOS API functions that create tasks, queues, software - timers, and semaphores. The size of the FreeRTOS heap is set by the - configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */ - - EFR32_LOG("Failed do a malloc on HEAP. Is it too small ?"); - - /* Force an assert. */ - configASSERT((volatile void *) NULL); -} -/*-----------------------------------------------------------*/ - -void vApplicationStackOverflowHook(TaskHandle_t pxTask, char * pcTaskName) -{ - //(void) pcTaskName; - (void) pxTask; - - /* Run time stack overflow checking is performed if - configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook - function is called if a stack overflow is detected. */ - EFR32_LOG("TASK OVERFLOW"); - EFR32_LOG(pcTaskName); - /* Force an assert. */ - configASSERT((volatile void *) NULL); -} - -void vApplicationTickHook(void) {} - -/*-----------------------------------------------------------*/ - -/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an -implementation of vApplicationGetIdleTaskMemory() to provide the memory that is -used by the Idle task. */ -void vApplicationGetIdleTaskMemory(StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, - uint32_t * pulIdleTaskStackSize) -{ - /* If the buffers to be provided to the Idle task are declared inside this - function then they must be declared static - otherwise they will be allocated on - the stack and so not exists after this function exits. */ - static StaticTask_t xIdleTaskTCB; - static StackType_t uxIdleTaskStack[configMINIMAL_STACK_SIZE]; - - /* Pass out a pointer to the StaticTask_t structure in which the Idle task's - state will be stored. */ - *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; - - /* Pass out the array that will be used as the Idle task's stack. */ - *ppxIdleTaskStackBuffer = uxIdleTaskStack; - - /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. - Note that, as the array is necessarily of type StackType_t, - configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; -} -/*-----------------------------------------------------------*/ - -/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the -application must provide an implementation of vApplicationGetTimerTaskMemory() -to provide the memory that is used by the Timer service task. */ -void vApplicationGetTimerTaskMemory(StaticTask_t ** ppxTimerTaskTCBBuffer, StackType_t ** ppxTimerTaskStackBuffer, - uint32_t * pulTimerTaskStackSize) -{ - /* If the buffers to be provided to the Timer task are declared inside this - function then they must be declared static - otherwise they will be allocated on - the stack and so not exists after this function exits. */ - static StaticTask_t xTimerTaskTCB; - static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH]; - - /* Pass out a pointer to the StaticTask_t structure in which the Timer - task's state will be stored. */ - *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; - - /* Pass out the array that will be used as the Timer task's stack. */ - *ppxTimerTaskStackBuffer = uxTimerTaskStack; - - /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. - Note that, as the array is necessarily of type StackType_t, - configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; -} -} diff --git a/src/platform/EFR32/Logging.cpp b/src/platform/EFR32/Logging.cpp index ad0711fe930961..0a3d5025bfa4b9 100644 --- a/src/platform/EFR32/Logging.cpp +++ b/src/platform/EFR32/Logging.cpp @@ -11,6 +11,7 @@ #include #endif +#include "AppConfig.h" #include #include #include @@ -394,4 +395,87 @@ extern "C" __attribute__((naked)) void HardFault_Handler(void) "debugHardfault_address: .word debugHardfault \n"); } +extern "C" void vApplicationMallocFailedHook(void) +{ + /* Called if a call to pvPortMalloc() fails because there is insufficient + free memory available in the FreeRTOS heap. pvPortMalloc() is called + internally by FreeRTOS API functions that create tasks, queues, software + timers, and semaphores. The size of the FreeRTOS heap is set by the + configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */ + + EFR32_LOG("Failed do a malloc on HEAP. Is it too small ?"); + + /* Force an assert. */ + configASSERT((volatile void *) NULL); +} +/*-----------------------------------------------------------*/ + +extern "C" void vApplicationStackOverflowHook(TaskHandle_t pxTask, char * pcTaskName) +{ + //(void) pcTaskName; + (void) pxTask; + + /* Run time stack overflow checking is performed if + configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook + function is called if a stack overflow is detected. */ + EFR32_LOG("TASK OVERFLOW"); + EFR32_LOG(pcTaskName); + /* Force an assert. */ + configASSERT((volatile void *) NULL); +} + +extern "C" void vApplicationTickHook(void) {} + +/*-----------------------------------------------------------*/ + +/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an +implementation of vApplicationGetIdleTaskMemory() to provide the memory that is +used by the Idle task. */ +extern "C" void vApplicationGetIdleTaskMemory(StaticTask_t ** ppxIdleTaskTCBBuffer, StackType_t ** ppxIdleTaskStackBuffer, + uint32_t * pulIdleTaskStackSize) +{ + /* If the buffers to be provided to the Idle task are declared inside this + function then they must be declared static - otherwise they will be allocated on + the stack and so not exists after this function exits. */ + static StaticTask_t xIdleTaskTCB; + static StackType_t uxIdleTaskStack[configMINIMAL_STACK_SIZE]; + + /* Pass out a pointer to the StaticTask_t structure in which the Idle task's + state will be stored. */ + *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; + + /* Pass out the array that will be used as the Idle task's stack. */ + *ppxIdleTaskStackBuffer = uxIdleTaskStack; + + /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. + Note that, as the array is necessarily of type StackType_t, + configMINIMAL_STACK_SIZE is specified in words, not bytes. */ + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; +} +/*-----------------------------------------------------------*/ + +/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the +application must provide an implementation of vApplicationGetTimerTaskMemory() +to provide the memory that is used by the Timer service task. */ +extern "C" void vApplicationGetTimerTaskMemory(StaticTask_t ** ppxTimerTaskTCBBuffer, StackType_t ** ppxTimerTaskStackBuffer, + uint32_t * pulTimerTaskStackSize) +{ + /* If the buffers to be provided to the Timer task are declared inside this + function then they must be declared static - otherwise they will be allocated on + the stack and so not exists after this function exits. */ + static StaticTask_t xTimerTaskTCB; + static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH]; + + /* Pass out a pointer to the StaticTask_t structure in which the Timer + task's state will be stored. */ + *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; + + /* Pass out the array that will be used as the Timer task's stack. */ + *ppxTimerTaskStackBuffer = uxTimerTaskStack; + + /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. + Note that, as the array is necessarily of type StackType_t, + configMINIMAL_STACK_SIZE is specified in words, not bytes. */ + *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; +} #endif // HARD_FAULT_LOG_ENABLE && EFR32_LOG_ENABLED