Skip to content

Commit

Permalink
drivers: bt: add stubs to allow CI testing without blobs
Browse files Browse the repository at this point in the history
Update BT driver and add necessary stubs so that
CI can run without binay blobs.

Signed-off-by: Sylvio Alves <[email protected]>
  • Loading branch information
sylvioalves committed Nov 3, 2024
1 parent 2bc9c60 commit fab21da
Show file tree
Hide file tree
Showing 11 changed files with 210 additions and 61 deletions.
29 changes: 16 additions & 13 deletions zephyr/esp32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -367,18 +367,20 @@ if(CONFIG_SOC_SERIES_ESP32)
../../components/esp_phy/src/phy_common.c
)

zephyr_sources_ifdef(CONFIG_WIFI_BUILD_ONLY_MODE ../port/wifi/wifi_stubs.c)

zephyr_link_libraries_ifndef(CONFIG_WIFI_BUILD_ONLY_MODE
net80211
core
pp
phy
rtc
## esp-idf wifi libs refer gcc libs symbols, so linked in libgcc
gcc
-L${CMAKE_CURRENT_SOURCE_DIR}/../blobs/lib/esp32
)
if (CONFIG_WIFI_BUILD_ONLY_MODE OR CONFIG_BT_BUILD_ONLY_MODE)
zephyr_sources_ifdef(CONFIG_WIFI_BUILD_ONLY_MODE ../port/wifi/wifi_stubs.c)
else()
zephyr_link_libraries(
net80211
core
pp
phy
mesh
## esp-idf wifi libs refer gcc libs symbols, so linked in libgcc
gcc
-L${CMAKE_CURRENT_SOURCE_DIR}/../blobs/lib/esp32c3
)
endif()

endif()

Expand All @@ -387,7 +389,8 @@ if(CONFIG_SOC_SERIES_ESP32)
zephyr_sources(src/bt/esp_bt_adapter.c)
zephyr_compile_definitions(CONFIG_BT_ENABLED)

zephyr_link_libraries(
zephyr_sources_ifdef(CONFIG_BT_BUILD_ONLY_MODE ../port/wifi/wifi_stubs.c)
zephyr_link_libraries_ifndef(CONFIG_BT_BUILD_ONLY_MODE
## ble
btdm_app
-L${CMAKE_CURRENT_SOURCE_DIR}/../blobs/lib/esp32
Expand Down
2 changes: 2 additions & 0 deletions zephyr/esp32/include/bt/esp_bt.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,8 @@ typedef struct esp_vhci_host_callback {
int (*notify_host_recv)(uint8_t *data, uint16_t len); /*!< Callback to notify the Host that the Controller has a packet to send */
} esp_vhci_host_callback_t;

typedef void (*workitem_handler_t)(void *arg);

/**
* @brief Check whether the Controller is ready to receive the packet
*
Expand Down
2 changes: 0 additions & 2 deletions zephyr/esp32/src/bt/esp_bt_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ struct osi_funcs_t {
uint32_t _magic;
};

typedef void (*workitem_handler_t)(void *arg);

/* OSI */
extern int btdm_osi_funcs_register(void *osi_funcs);
/* Initialise and De-initialise */
Expand Down
31 changes: 17 additions & 14 deletions zephyr/esp32c3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -361,26 +361,29 @@ if(CONFIG_SOC_SERIES_ESP32C3)
../../components/efuse/src/efuse_controller/keys/with_key_purposes/esp_efuse_api_key.c
)

zephyr_sources_ifdef(CONFIG_WIFI_BUILD_ONLY_MODE ../port/wifi/wifi_stubs.c)

zephyr_link_libraries_ifndef(CONFIG_WIFI_BUILD_ONLY_MODE
net80211
core
pp
phy
mesh
## esp-idf wifi libs refer gcc libs symbols, so linked in libgcc
gcc
-L${CMAKE_CURRENT_SOURCE_DIR}/../blobs/lib/esp32c3
)
if (CONFIG_WIFI_BUILD_ONLY_MODE OR CONFIG_BT_BUILD_ONLY_MODE)
zephyr_sources_ifdef(CONFIG_WIFI_BUILD_ONLY_MODE ../port/wifi/wifi_stubs.c)
else()
zephyr_link_libraries(
net80211
core
pp
phy
mesh
## esp-idf wifi libs refer gcc libs symbols, so linked in libgcc
gcc
-L${CMAKE_CURRENT_SOURCE_DIR}/../blobs/lib/esp32c3
)
endif()
endif()

## BT definitions
if (CONFIG_BT)
zephyr_sources(src/bt/esp_bt_adapter.c)
zephyr_compile_definitions(CONFIG_BT_ENABLED)

zephyr_link_libraries(

zephyr_sources_ifdef(CONFIG_BT_BUILD_ONLY_MODE ../port/wifi/wifi_stubs.c)
zephyr_link_libraries_ifndef(CONFIG_BT_BUILD_ONLY_MODE
## ble
btbb
btdm_app
Expand Down
9 changes: 9 additions & 0 deletions zephyr/esp32c3/include/bt/esp_bt.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,22 @@ enum {
ESP_BT_COEX_PHY_CODED_TX_RX_TIME_LIMIT_FORCE_ENABLE, /*!< Always Enable the limit */
};

/* vendor dependent signals to be posted to controller task */
typedef enum {
BTDM_VND_OL_SIG_WAKEUP_TMR = 0,
BTDM_VND_OL_SIG_NUM,
} btdm_vnd_ol_sig_t;

#define ESP_BT_HCI_TL_STATUS_OK (0) /*!< HCI_TL Tx/Rx operation status OK */

/**
* @brief callback function for HCI Transport Layer send/receive operations
*/
typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);

/* prototype of function to handle vendor dependent signals */
typedef void (* btdm_vnd_ol_task_func_t)(void *param);

#ifdef CONFIG_BT_ENABLED

#define BT_CTRL_BLE_MAX_ACT_LIMIT 10 //Maximum BLE activity limitation
Expand Down
12 changes: 2 additions & 10 deletions zephyr/esp32c3/src/bt/esp_bt_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,6 @@ typedef union {

#define BLE_PWR_HDL_INVL 0xFFFF

typedef enum {
BTDM_VND_OL_SIG_WAKEUP_TMR = 0,
BTDM_VND_OL_SIG_NUM,
} btdm_vnd_ol_sig_t;

/* prototype of function to handle vendor dependent signals */
typedef void (* btdm_vnd_ol_task_func_t)(void *param);

typedef void (* irq_handler_t)(const void *param);

/* VHCI function interface */
Expand Down Expand Up @@ -235,7 +227,7 @@ extern int btdm_hci_tl_io_event_post(int event);
/* VHCI */
extern bool API_vhci_host_check_send_available(void);
extern void API_vhci_host_send_packet(uint8_t *data, uint16_t len);
extern int API_vhci_host_register_callback(const vhci_host_callback_t *callback);
extern int API_vhci_host_register_callback(const esp_vhci_host_callback_t *callback);
/* TX power */
extern int ble_txpwr_set(int power_type, int power_level);
extern int ble_txpwr_get(int power_type);
Expand Down Expand Up @@ -1013,7 +1005,7 @@ esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callba
return ESP_FAIL;
}

return API_vhci_host_register_callback((const vhci_host_callback_t *)callback) == 0 ? ESP_OK : ESP_FAIL;
return API_vhci_host_register_callback((const esp_vhci_host_callback_t *)callback) == 0 ? ESP_OK : ESP_FAIL;
}


Expand Down
27 changes: 15 additions & 12 deletions zephyr/esp32s3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -403,25 +403,28 @@ if(CONFIG_SOC_SERIES_ESP32S3)
../../components/efuse/src/efuse_controller/keys/with_key_purposes/esp_efuse_api_key.c
)

zephyr_sources_ifdef(CONFIG_WIFI_BUILD_ONLY_MODE ../port/wifi/wifi_stubs.c)

zephyr_link_libraries_ifndef(CONFIG_WIFI_BUILD_ONLY_MODE
net80211
core
pp
phy
## esp-idf wifi libs refer gcc libs symbols, so linked in libgcc
gcc
-L${CMAKE_CURRENT_SOURCE_DIR}/../blobs/lib/esp32s3
)
if (CONFIG_WIFI_BUILD_ONLY_MODE OR CONFIG_BT_BUILD_ONLY_MODE)
zephyr_sources_ifdef(CONFIG_WIFI_BUILD_ONLY_MODE ../port/wifi/wifi_stubs.c)
else()
zephyr_link_libraries_ifndef(CONFIG_WIFI_BUILD_ONLY_MODE
net80211
core
pp
phy
## esp-idf wifi libs refer gcc libs symbols, so linked in libgcc
gcc
-L${CMAKE_CURRENT_SOURCE_DIR}/../blobs/lib/esp32s3
)
endif()
endif()

## BT definitions
if (CONFIG_BT)
zephyr_sources(src/bt/esp_bt_adapter.c)
zephyr_compile_definitions(CONFIG_BT_ENABLED)

zephyr_link_libraries(
zephyr_sources_ifdef(CONFIG_BT_BUILD_ONLY_MODE ../port/wifi/wifi_stubs.c)
zephyr_link_libraries_ifndef(CONFIG_BT_BUILD_ONLY_MODE
## ble
btbb
btdm_app
Expand Down
9 changes: 9 additions & 0 deletions zephyr/esp32s3/include/bt/esp_bt.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,22 @@ enum {
ESP_BT_COEX_PHY_CODED_TX_RX_TIME_LIMIT_FORCE_ENABLE, /*!< Always Enable the limit */
};

/* vendor dependent signals to be posted to controller task */
typedef enum {
BTDM_VND_OL_SIG_WAKEUP_TMR = 0,
BTDM_VND_OL_SIG_NUM,
} btdm_vnd_ol_sig_t;

#define ESP_BT_HCI_TL_STATUS_OK (0) /*!< HCI_TL Tx/Rx operation status OK */

/**
* @brief callback function for HCI Transport Layer send/receive operations
*/
typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status);

/* prototype of function to handle vendor dependent signals */
typedef void (* btdm_vnd_ol_task_func_t)(void *param);

#ifdef CONFIG_BT_ENABLED

#define BT_CTRL_BLE_MAX_ACT_LIMIT 10 //Maximum BLE activity limitation
Expand Down
12 changes: 2 additions & 10 deletions zephyr/esp32s3/src/bt/esp_bt_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,6 @@ typedef union {

#define BLE_PWR_HDL_INVL 0xFFFF

typedef enum {
BTDM_VND_OL_SIG_WAKEUP_TMR = 0,
BTDM_VND_OL_SIG_NUM,
} btdm_vnd_ol_sig_t;

/* prototype of function to handle vendor dependent signals */
typedef void (* btdm_vnd_ol_task_func_t)(void *param);

/* VHCI function interface */
typedef struct vhci_host_callback {
/* callback used to notify that the host can send packet to controller */
Expand Down Expand Up @@ -235,7 +227,7 @@ extern int btdm_hci_tl_io_event_post(int event);
/* VHCI */
extern bool API_vhci_host_check_send_available(void);
extern void API_vhci_host_send_packet(uint8_t *data, uint16_t len);
extern int API_vhci_host_register_callback(const vhci_host_callback_t *callback);
extern int API_vhci_host_register_callback(const esp_vhci_host_callback_t *callback);
/* TX power */
extern int ble_txpwr_set(int power_type, int power_level);
extern int ble_txpwr_get(int power_type);
Expand Down Expand Up @@ -1007,7 +999,7 @@ esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callba
return ESP_FAIL;
}

return API_vhci_host_register_callback((const vhci_host_callback_t *)callback) == 0 ? ESP_OK : ESP_FAIL;
return API_vhci_host_register_callback((const esp_vhci_host_callback_t *)callback) == 0 ? ESP_OK : ESP_FAIL;
}


Expand Down
Empty file.
138 changes: 138 additions & 0 deletions zephyr/port/wifi/wifi_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1220,3 +1220,141 @@ void phy_init_param_set(uint8_t param) {
void phy_wifi_enable_set(uint8_t enable) {
ARG_UNUSED(enable);
}



// ################### BLE
#include "esp_bt.h"

int btdm_osi_funcs_register(void *osi_funcs) {
return ESP_OK;
}

int btdm_controller_init(uint32_t config_mask, esp_bt_controller_config_t *config_opts) {
return ESP_OK;
}

void btdm_controller_deinit(void) {
// No-op
}

int btdm_controller_enable(esp_bt_mode_t mode) {
return ESP_OK;
}

void btdm_controller_disable(void) {
// No-op
}

uint8_t btdm_controller_get_mode(void) {
return 0;
}

const char *btdm_controller_get_compile_version(void) {
return "dummy_version";
}

void btdm_rf_bb_init_phase2(void) {
// No-op
}

#ifdef CONFIG_SOC_SERIES_ESP32
int btdm_dispatch_work_to_controller(workitem_handler_t callback, void *arg, bool blocking) {
return ESP_OK;
}
#endif

void btdm_controller_enable_sleep(bool enable) {
// No-op
}

void btdm_controller_set_sleep_mode(uint8_t mode) {
// No-op
}

uint8_t btdm_controller_get_sleep_mode(void) {
return 0;
}

bool btdm_power_state_active(void) {
return true;
}

void btdm_wakeup_request(void) {
// No-op
}

void btdm_in_wakeup_requesting_set(bool in_wakeup_requesting) {
// No-op
}

#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h" // Include relevant headers if needed

#ifndef CONFIG_SOC_SERIES_ESP32

int btdm_vnd_offload_task_register(btdm_vnd_ol_sig_t sig, btdm_vnd_ol_task_func_t func) {
return ESP_OK;
}

int btdm_vnd_offload_task_deregister(btdm_vnd_ol_sig_t sig) {
return ESP_OK;
}

int r_btdm_vnd_offload_post(btdm_vnd_ol_sig_t sig, void *param) {
return ESP_OK;
}

#endif /* CONFIG_SOC_SERIES_ESP32 */
uint8_t btdm_sleep_clock_sync(void) {
return 0;
}

bool btdm_lpclk_select_src(uint32_t sel) {
return true;
}

bool btdm_lpclk_set_div(uint32_t div) {
return true;
}

int btdm_hci_tl_io_event_post(int event) {
return ESP_OK;
}

bool API_vhci_host_check_send_available(void) {
return true;
}

void API_vhci_host_send_packet(uint8_t *data, uint16_t len) {
// No-op
}

int API_vhci_host_register_callback(const esp_vhci_host_callback_t *callback) {
return ESP_OK;
}

void coex_pti_v2(void) {
// No-op
}

void sdk_config_set_bt_pll_track_enable(bool enable) {
// No-op
}

void sdk_config_set_uart_flow_ctrl_enable(bool enable) {
// No-op
}

void config_bt_funcs_reset(void) {
// No-op
}

void config_ble_funcs_reset(void) {
// No-op
}

void config_btdm_funcs_reset(void) {
// No-op
}

0 comments on commit fab21da

Please sign in to comment.