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 Dec 18, 2024
1 parent 847e4fb commit e523710
Show file tree
Hide file tree
Showing 10 changed files with 235 additions and 45 deletions.
25 changes: 16 additions & 9 deletions zephyr/esp32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,6 @@ if(CONFIG_SOC_SERIES_ESP32)
../../components/esp_phy/src/phy_common.c
)

zephyr_sources_ifdef(
CONFIG_BUILD_ONLY_NO_BLOBS
../port/wifi/wifi_stubs.c
../port/phy/phy_stubs.c
)

zephyr_link_libraries_ifndef(
CONFIG_BUILD_ONLY_NO_BLOBS
net80211
Expand All @@ -380,16 +374,23 @@ if(CONFIG_SOC_SERIES_ESP32)
## esp-idf wifi libs refer gcc libs symbols, so linked in libgcc
gcc
-L${CMAKE_CURRENT_SOURCE_DIR}/../blobs/lib/esp32
)

)
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_BUILD_ONLY_NO_BLOBS
../port/bluetooth/bt_stubs.c
../port/phy/phy_stubs.c
)

zephyr_link_libraries_ifndef(
CONFIG_BUILD_ONLY_NO_BLOBS
## ble
btdm_app
-L${CMAKE_CURRENT_SOURCE_DIR}/../blobs/lib/esp32
Expand All @@ -400,6 +401,12 @@ if(CONFIG_SOC_SERIES_ESP32)
## WIFI definitions
if (CONFIG_WIFI_ESP32)

zephyr_sources_ifdef(
CONFIG_BUILD_ONLY_NO_BLOBS
../port/wifi/wifi_stubs.c
../port/phy/phy_stubs.c
)

set(WPA_SUPPLICANT_COMPONENT_DIR "../../components/wpa_supplicant")
#TODO: Additional WPA supplicant feature like Enterprise mode etc. are yet to be supported.
set(WPA_SUPPLICANT_SRCS "../port/wifi/wpa_supplicant/os_xtensa.c"
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
22 changes: 15 additions & 7 deletions zephyr/esp32c3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,6 @@ if(CONFIG_SOC_SERIES_ESP32C3)
../../components/efuse/src/efuse_controller/keys/with_key_purposes/esp_efuse_api_key.c
)

zephyr_sources_ifdef(
CONFIG_BUILD_ONLY_NO_BLOBS
../port/wifi/wifi_stubs.c
../port/phy/phy_stubs.c
)

zephyr_link_libraries_ifndef(
CONFIG_BUILD_ONLY_NO_BLOBS
net80211
Expand All @@ -388,10 +382,18 @@ if(CONFIG_SOC_SERIES_ESP32C3)

## 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_BUILD_ONLY_NO_BLOBS
../port/bluetooth/bt_stubs.c
../port/phy/phy_stubs.c
)

zephyr_link_libraries_ifndef(
CONFIG_BUILD_ONLY_NO_BLOBS
## ble
btbb
btdm_app
Expand All @@ -402,6 +404,12 @@ if(CONFIG_SOC_SERIES_ESP32C3)
## WIFI definitions
if (CONFIG_WIFI_ESP32)

zephyr_sources_ifdef(
CONFIG_BUILD_ONLY_NO_BLOBS
../port/wifi/wifi_stubs.c
../port/phy/phy_stubs.c
)

zephyr_sources(
../../components/efuse/${CONFIG_SOC_SERIES}/esp_efuse_rtc_calib.c
../../components/hal/adc_hal_common.c
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
22 changes: 15 additions & 7 deletions zephyr/esp32s3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -400,12 +400,6 @@ if(CONFIG_SOC_SERIES_ESP32S3)
../../components/efuse/src/efuse_controller/keys/with_key_purposes/esp_efuse_api_key.c
)

zephyr_sources_ifdef(
CONFIG_BUILD_ONLY_NO_BLOBS
../port/wifi/wifi_stubs.c
../port/phy/phy_stubs.c
)

zephyr_link_libraries_ifndef(
CONFIG_BUILD_ONLY_NO_BLOBS
net80211
Expand All @@ -420,10 +414,18 @@ if(CONFIG_SOC_SERIES_ESP32S3)

## 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_BUILD_ONLY_NO_BLOBS
../port/bluetooth/bt_stubs.c
../port/phy/phy_stubs.c
)

zephyr_link_libraries_ifndef(
CONFIG_BUILD_ONLY_NO_BLOBS
## ble
btbb
btdm_app
Expand All @@ -434,6 +436,12 @@ if(CONFIG_SOC_SERIES_ESP32S3)
## WIFI definitions
if (CONFIG_WIFI_ESP32)

zephyr_sources_ifdef(
CONFIG_BUILD_ONLY_NO_BLOBS
../port/wifi/wifi_stubs.c
../port/phy/phy_stubs.c
)

set(WPA_SUPPLICANT_COMPONENT_DIR "../../components/wpa_supplicant")
#TODO: Additional WPA supplicant feature like Enterprise mode etc. are yet to be supported.
set(WPA_SUPPLICANT_SRCS "../port/wifi/wpa_supplicant/os_xtensa.c"
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
Loading

0 comments on commit e523710

Please sign in to comment.