Skip to content

Commit c0efc25

Browse files
committed
Merge branch 'bugfix/fix_hw_ralunderrun_assert_v4.4' into 'release/v4.4'
Fixed BLE HW RAL_UNDERRUN asser and backport some bug fix 23-03-30 (back port v4.4) See merge request espressif/esp-idf!23004
2 parents ea51ee1 + db3e673 commit c0efc25

File tree

21 files changed

+436
-2770
lines changed

21 files changed

+436
-2770
lines changed

components/bt/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ if(CONFIG_BT_ENABLED)
66
elseif(CONFIG_IDF_TARGET_ESP32C3)
77
set(srcs "controller/esp32c3/bt.c")
88
elseif(CONFIG_IDF_TARGET_ESP32S3)
9-
set(srcs "controller/esp32s3/bt.c")
9+
set(srcs "controller/esp32c3/bt.c")
1010
endif()
1111

1212
set(include_dirs common/osi/include)
@@ -16,7 +16,7 @@ if(CONFIG_BT_ENABLED)
1616
elseif(CONFIG_IDF_TARGET_ESP32C3)
1717
list(APPEND include_dirs include/esp32c3/include)
1818
elseif(CONFIG_IDF_TARGET_ESP32S3)
19-
list(APPEND include_dirs include/esp32s3/include)
19+
list(APPEND include_dirs include/esp32c3/include)
2020
endif()
2121

2222
list(APPEND priv_include_dirs

components/bt/common/api/include/api/esp_blufi_api.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ typedef enum {
8686
ESP_BLUFI_DATA_FORMAT_ERROR,
8787
ESP_BLUFI_CALC_MD5_ERROR,
8888
ESP_BLUFI_WIFI_SCAN_FAIL,
89+
ESP_BLUFI_MSG_STATE_ERROR,
8990
} esp_blufi_error_state_t;
9091

9192
/**

components/bt/common/btc/profile/esp/blufi/blufi_prf.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ void btc_blufi_recv_handler(uint8_t *data, int len)
144144

145145
if (BLUFI_FC_IS_FRAG(hdr->fc)) {
146146
if (blufi_env.offset == 0) {
147+
/*
148+
blufi_env.aggr_buf should be NULL if blufi_env.offset is 0.
149+
It is possible that the process of sending fragment packet
150+
has not been completed
151+
*/
152+
if (blufi_env.aggr_buf) {
153+
BTC_TRACE_ERROR("%s msg error, blufi_env.aggr_buf is not freed\n", __func__);
154+
btc_blufi_report_error(ESP_BLUFI_MSG_STATE_ERROR);
155+
return;
156+
}
147157
blufi_env.total_len = hdr->data[0] | (((uint16_t) hdr->data[1]) << 8);
148158
blufi_env.aggr_buf = osi_malloc(blufi_env.total_len);
149159
if (blufi_env.aggr_buf == NULL) {
@@ -163,6 +173,18 @@ void btc_blufi_recv_handler(uint8_t *data, int len)
163173

164174
} else {
165175
if (blufi_env.offset > 0) { /* if previous pkt is frag */
176+
/* blufi_env.aggr_buf should not be NULL */
177+
if (blufi_env.aggr_buf == NULL) {
178+
BTC_TRACE_ERROR("%s buffer is NULL\n", __func__);
179+
btc_blufi_report_error(ESP_BLUFI_DH_MALLOC_ERROR);
180+
return;
181+
}
182+
/* payload length should be equal to total_len */
183+
if ((blufi_env.offset + hdr->data_len) != blufi_env.total_len) {
184+
BTC_TRACE_ERROR("%s payload is longer than packet length, len %d \n", __func__, blufi_env.total_len);
185+
btc_blufi_report_error(ESP_BLUFI_DATA_FORMAT_ERROR);
186+
return;
187+
}
166188
memcpy(blufi_env.aggr_buf + blufi_env.offset, hdr->data, hdr->data_len);
167189

168190
btc_blufi_protocol_handler(hdr->type, blufi_env.aggr_buf, blufi_env.total_len);

components/bt/controller/esp32c3/Kconfig.in

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ config BT_CTRL_MODE_EFF
44

55
config BT_CTRL_BLE_MAX_ACT
66
int "BLE Max Instances"
7-
default 10
7+
default 6
88
range 1 10
99
help
1010
BLE maximum activities of bluetooth controller,both of connections,
11-
scan , sync and adv(periodic adv, multi-adv).
11+
scan , sync and adv(periodic adv, multi-adv). Each instance needs to
12+
consume 828 bytes, you can save RAM by modifying the instance value
13+
according to actual needs.
1214

1315
config BT_CTRL_BLE_MAX_ACT_EFF
1416
int
@@ -24,8 +26,24 @@ config BT_CTRL_BLE_STATIC_ACL_TX_BUF_NB
2426
(alloate when controller initialise, never free until controller de-initialise)
2527
another is dynamically allocating (allocate before TX and free after TX).
2628

29+
choice BT_CTRL_PINNED_TO_CORE_CHOICE
30+
prompt "The cpu core which bluetooth controller run"
31+
depends on !FREERTOS_UNICORE
32+
help
33+
Specify the cpu core to run bluetooth controller.
34+
Can not specify no-affinity.
35+
36+
config BT_CTRL_PINNED_TO_CORE_0
37+
bool "Core 0 (PRO CPU)"
38+
config BT_CTRL_PINNED_TO_CORE_1
39+
bool "Core 1 (APP CPU)"
40+
depends on !FREERTOS_UNICORE
41+
endchoice
42+
2743
config BT_CTRL_PINNED_TO_CORE
2844
int
45+
default 0 if BT_CTRL_PINNED_TO_CORE_0
46+
default 1 if BT_CTRL_PINNED_TO_CORE_1
2947
default 0
3048

3149
choice BT_CTRL_HCI_MODE_CHOICE
@@ -36,7 +54,7 @@ choice BT_CTRL_HCI_MODE_CHOICE
3654
config BT_CTRL_HCI_MODE_VHCI
3755
bool "VHCI"
3856
help
39-
Normal option. Mostly, choose this VHCI when bluetooth host run on ESP32C3, too.
57+
Normal option. Mostly, choose this VHCI when bluetooth host run on ESP32S3 or ESP32C3.
4058

4159
config BT_CTRL_HCI_MODE_UART_H4
4260
bool "UART(H4)"
@@ -395,7 +413,6 @@ menu "MODEM SLEEP Options"
395413
selects an external 32kHz crystal but the external 32kHz crystal does not exist or the low power clock
396414
selects the main crystal.
397415

398-
399416
endmenu
400417

401418
config BT_CTRL_SLEEP_MODE_EFF

0 commit comments

Comments
 (0)