Skip to content

Commit aba7456

Browse files
authored
Merge branch 'espressif:release/v5.4' into release/v5.4
2 parents 4ab6881 + 8ad0d3d commit aba7456

File tree

464 files changed

+2723
-1562
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

464 files changed

+2723
-1562
lines changed

Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,5 +678,4 @@ mainmenu "Espressif IoT Development Framework Configuration"
678678
- CONFIG_BOOTLOADER_CACHE_32BIT_ADDR_QUAD_FLASH
679679
- CONFIG_ESP_WIFI_EAP_TLS1_3
680680
- CONFIG_ESP_WIFI_ENABLE_ROAMING_APP
681-
- CONFIG_USB_HOST_EXT_PORT_SUPPORT_LS
682681
- CONFIG_USB_HOST_EXT_PORT_RESET_ATTEMPTS
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
2-
| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- | -------- | -------- |
1+
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
2+
| ----------------- | ----- | -------- | -------- | -------- | --------- | -------- | -------- | -------- | -------- |

components/bt/controller/esp32c2/bt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,11 +474,12 @@ static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock = NULL;
474474
#endif // CONFIG_PM_ENABLE
475475
#ifdef CONFIG_XTAL_FREQ_26
476476
#define MAIN_XTAL_FREQ_HZ (26000000)
477+
static DRAM_ATTR uint32_t s_bt_lpclk_freq = 40000;
477478
#else
478479
#define MAIN_XTAL_FREQ_HZ (40000000)
480+
static DRAM_ATTR uint32_t s_bt_lpclk_freq = 32000;
479481
#endif
480482
static DRAM_ATTR modem_clock_lpclk_src_t s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_INVALID;
481-
static DRAM_ATTR uint32_t s_bt_lpclk_freq = 100000;
482483

483484
#define BLE_RTC_DELAY_US (1800)
484485

components/bt/controller/esp32c6/esp_bt_cfg.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ extern "C" {
4040
#define DEFAULT_BT_LE_HCI_EVT_HI_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_COUNT)
4141
#define DEFAULT_BT_LE_HCI_EVT_LO_BUF_COUNT MYNEWT_VAL(BLE_TRANSPORT_EVT_DISCARDABLE_COUNT)
4242
#define DEFAULT_BT_LE_POWER_CONTROL_ENABLED MYNEWT_VAL(BLE_POWER_CONTROL)
43+
#define DEFAULT_BT_LE_SUBRATE_ENABLED MYNEWT_VAL(BLE_CONN_SUBRATING)
4344
#if defined(CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT)
4445
#define DEFAULT_BT_LE_50_FEATURE_SUPPORT (1)
4546
#else
@@ -144,6 +145,8 @@ extern "C" {
144145
#define DEFAULT_BT_LE_HCI_UART_CTS_PIN (-1)
145146
#define DEFAULT_BT_LE_HCI_UART_RTS_PIN (-1)
146147
#endif
148+
149+
#define DEFAULT_BT_LE_SUBRATE_ENABLED 0
147150
#endif
148151

149152
#define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF

components/bt/esp_ble_mesh/core/prov_common.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/*
44
* SPDX-FileCopyrightText: 2017 Intel Corporation
5-
* SPDX-FileContributor: 2018-2023 Espressif Systems (Shanghai) CO LTD
5+
* SPDX-FileContributor: 2018-2025 Espressif Systems (Shanghai) CO LTD
66
*
77
* SPDX-License-Identifier: Apache-2.0
88
*/
@@ -135,6 +135,9 @@ bool bt_mesh_prov_pdu_check(uint8_t type, uint16_t length, uint8_t *reason)
135135
#define CLOSE_XMIT BLE_MESH_TRANSMIT(2, 20)
136136

137137
#define CLOSE_TIMEOUT K_MSEC(100)
138+
#define CLOSE_RETRANS_CNT 3
139+
#define CLOSE_RETRANS_WITH_REASON(cnt, rsn) (((cnt) << 4) | ((rsn) & 0x0f))
140+
#define CLOSE_RETRANS_GET(rsn) ((rsn) >> 4)
138141

139142
#define BUF_TIMEOUT K_MSEC(400)
140143

@@ -457,12 +460,19 @@ static void prov_retransmit(struct k_work *work)
457460
if (link->pb_remote_close) {
458461
link->pb_remote_close(link, link->reason);
459462
}
463+
return;
460464
} else {
461-
if (link->reset_adv_link) {
462-
link->reset_adv_link(link, link->reason);
465+
uint8_t retrans_cnt = CLOSE_RETRANS_GET(link->reason);
466+
if (!retrans_cnt) {
467+
if (link->reset_adv_link) {
468+
link->reset_adv_link(link, link->reason);
469+
}
470+
return;
471+
} else {
472+
retrans_cnt--;
473+
link->reason = CLOSE_RETRANS_WITH_REASON(retrans_cnt, link->reason);
463474
}
464475
}
465-
return;
466476
}
467477

468478
bt_mesh_mutex_lock(&link->buf_lock);
@@ -547,7 +557,14 @@ int bt_mesh_prov_bearer_ctl_send(struct bt_mesh_prov_link *link, uint8_t op,
547557
if (op == LINK_CLOSE) {
548558
bt_mesh_atomic_clear_bit(link->flags, LINK_ACTIVE);
549559
bt_mesh_atomic_set_bit(link->flags, LINK_CLOSING);
550-
link->reason = *((uint8_t *)data);
560+
/** We can also use buf->ref and a flag to decide that
561+
* link close has been sent 3 times.
562+
* Here we use another way: use retransmit timer and need
563+
* to make sure the timer is not cancelled during sending
564+
* link close pdu, Therefore, use the higher four bits
565+
* of reason as a retransmit count.
566+
*/
567+
link->reason = CLOSE_RETRANS_WITH_REASON(CLOSE_RETRANS_CNT, (*((uint8_t *)data)));
551568
}
552569

553570
return 0;

components/bt/esp_ble_mesh/core/transport.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,9 @@ static void schedule_retransmit(struct seg_tx *tx)
388388
* the seg_pending of this segment.
389389
* See BLEMESH25-92 for details */
390390
if (tx->dst == BLE_MESH_ADDR_UNASSIGNED) {
391-
assert(tx->seg_pending == 1);
392-
tx->seg_pending = 0;
391+
if (tx->seg_pending) {
392+
tx->seg_pending--;
393+
}
393394
return;
394395
}
395396

components/bt/host/bluedroid/api/esp_bt_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ esp_err_t esp_bluedroid_init_with_cfg(esp_bluedroid_config_t *cfg)
144144
osi_mem_dbg_init();
145145
#endif
146146

147-
ret = bluedriod_config_init(cfg);
147+
ret = bluedroid_config_init(cfg);
148148
if (ret != BT_STATUS_SUCCESS) {
149149
LOG_ERROR("Bluedroid stack initialize fail, ret:%d", ret);
150150
return ESP_FAIL;
@@ -228,7 +228,7 @@ esp_err_t esp_bluedroid_deinit(void)
228228

229229
btc_deinit();
230230

231-
bluedriod_config_deinit();
231+
bluedroid_config_deinit();
232232

233233
#if (BT_HCI_LOG_INCLUDED == TRUE)
234234
bt_hci_log_deinit();

components/bt/host/bluedroid/api/esp_gap_bt_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ esp_err_t esp_bt_gap_set_security_param(esp_bt_sp_param_t param_type,
322322
return ESP_ERR_INVALID_STATE;
323323
}
324324

325-
if (!(bluedriod_config_get()->get_ssp_enabled())) {
325+
if (!(bluedroid_config_get()->get_ssp_enabled())) {
326326
ESP_LOGE(TAG, "%s is not supported when `ssp_en` in `esp_bluedroid_config_t` is disabled!", __func__);
327327
return ESP_ERR_NOT_SUPPORTED;
328328
}
@@ -347,7 +347,7 @@ esp_err_t esp_bt_gap_ssp_passkey_reply(esp_bd_addr_t bd_addr, bool accept, uint3
347347
return ESP_ERR_INVALID_STATE;
348348
}
349349

350-
if (!(bluedriod_config_get()->get_ssp_enabled())) {
350+
if (!(bluedroid_config_get()->get_ssp_enabled())) {
351351
ESP_LOGE(TAG, "%s is not supported when `ssp_en` in `esp_bluedroid_config_t` is disabled!", __func__);
352352
return ESP_ERR_NOT_SUPPORTED;
353353
}
@@ -371,7 +371,7 @@ esp_err_t esp_bt_gap_ssp_confirm_reply(esp_bd_addr_t bd_addr, bool accept)
371371
return ESP_ERR_INVALID_STATE;
372372
}
373373

374-
if (!(bluedriod_config_get()->get_ssp_enabled())) {
374+
if (!(bluedroid_config_get()->get_ssp_enabled())) {
375375
ESP_LOGE(TAG, "%s is not supported when `ssp_en` in `esp_bluedroid_config_t` is disabled!", __func__);
376376
return ESP_ERR_NOT_SUPPORTED;
377377
}

components/bt/host/bluedroid/config/include/config/stack_config.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ struct bluedroid_config {
1414
bool (*get_ssp_enabled)(void);
1515
};
1616

17-
bt_status_t bluedriod_config_init(esp_bluedroid_config_t *cfg);
17+
bt_status_t bluedroid_config_init(esp_bluedroid_config_t *cfg);
1818

19-
void bluedriod_config_deinit(void);
19+
void bluedroid_config_deinit(void);
2020

21-
const struct bluedroid_config *bluedriod_config_get(void);
21+
const struct bluedroid_config *bluedroid_config_get(void);

components/bt/host/bluedroid/config/stack_config.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static bool get_ssp_enabled(void)
2525
return cfg->ssp_en;
2626
}
2727

28-
bt_status_t bluedriod_config_init(esp_bluedroid_config_t *cfg)
28+
bt_status_t bluedroid_config_init(esp_bluedroid_config_t *cfg)
2929
{
3030
s_stack_config_env = osi_calloc(sizeof(struct stack_config_env_tag));
3131
if (!s_stack_config_env) {
@@ -40,15 +40,15 @@ bt_status_t bluedriod_config_init(esp_bluedroid_config_t *cfg)
4040
return BT_STATUS_SUCCESS;
4141
}
4242

43-
void bluedriod_config_deinit(void)
43+
void bluedroid_config_deinit(void)
4444
{
4545
if (s_stack_config_env) {
4646
osi_free(s_stack_config_env);
4747
s_stack_config_env = NULL;
4848
}
4949
}
5050

51-
const struct bluedroid_config *bluedriod_config_get(void)
51+
const struct bluedroid_config *bluedroid_config_get(void)
5252
{
5353
assert(s_stack_config_env);
5454
return &s_stack_config_env->interface;

components/bt/host/bluedroid/device/controller.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static void start_up(void)
188188
// dependent on what we configure from page 0 and host SSP configuration
189189
controller_param.simple_pairing_supported = HCI_SIMPLE_PAIRING_SUPPORTED(
190190
controller_param.features_classic[0].as_array) &&
191-
(bluedriod_config_get()->get_ssp_enabled());
191+
(bluedroid_config_get()->get_ssp_enabled());
192192
if (controller_param.simple_pairing_supported) {
193193
response = AWAIT_COMMAND(controller_param.packet_factory->make_write_simple_pairing_mode(HCI_SP_MODE_ENABLED));
194194
controller_param.packet_parser->parse_generic_command_complete(response);

components/bt/host/nimble/Kconfig.in

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -689,40 +689,38 @@ if BT_NIMBLE_50_FEATURE_SUPPORT
689689
default n
690690
help
691691
Enable support for Connectionless and Connection Oriented Direction Finding
692-
693-
menuconfig BT_NIMBLE_GATT_CACHING
694-
bool "Enable GATT caching"
695-
depends on BT_NIMBLE_ENABLED && BT_NIMBLE_50_FEATURE_SUPPORT
696-
select BT_NIMBLE_DYNAMIC_SERVICE
697-
help
698-
Enable GATT caching
699-
config BT_NIMBLE_GATT_CACHING_MAX_CONNS
700-
int "Maximum connections to be cached"
701-
depends on BT_NIMBLE_GATT_CACHING
702-
default 1
703-
help
704-
Set this option to set the upper limit on number of connections to be cached.
705-
config BT_NIMBLE_GATT_CACHING_MAX_SVCS
706-
int "Maximum number of services per connection"
707-
depends on BT_NIMBLE_GATT_CACHING
708-
default 64
709-
help
710-
Set this option to set the upper limit on number of services per connection to be cached.
711-
config BT_NIMBLE_GATT_CACHING_MAX_CHRS
712-
int "Maximum number of characteristics per connection"
713-
depends on BT_NIMBLE_GATT_CACHING
714-
default 64
715-
help
716-
Set this option to set the upper limit on number of characteristics per connection to be cached.
717-
config BT_NIMBLE_GATT_CACHING_MAX_DSCS
718-
int "Maximum number of descriptors per connection"
719-
depends on BT_NIMBLE_GATT_CACHING
720-
default 64
721-
help
722-
Set this option to set the upper limit on number of descriptors per connection to be cached.
723692
endif
724693

725-
694+
menuconfig BT_NIMBLE_GATT_CACHING
695+
bool "Enable GATT caching"
696+
depends on BT_NIMBLE_ENABLED
697+
select BT_NIMBLE_DYNAMIC_SERVICE
698+
help
699+
Enable GATT caching
700+
config BT_NIMBLE_GATT_CACHING_MAX_CONNS
701+
int "Maximum connections to be cached"
702+
depends on BT_NIMBLE_GATT_CACHING
703+
default BT_NIMBLE_MAX_CONNECTIONS
704+
help
705+
Set this option to set the upper limit on number of connections to be cached.
706+
config BT_NIMBLE_GATT_CACHING_MAX_SVCS
707+
int "Maximum number of services per connection"
708+
depends on BT_NIMBLE_GATT_CACHING
709+
default 64
710+
help
711+
Set this option to set the upper limit on number of services per connection to be cached.
712+
config BT_NIMBLE_GATT_CACHING_MAX_CHRS
713+
int "Maximum number of characteristics per connection"
714+
depends on BT_NIMBLE_GATT_CACHING
715+
default 64
716+
help
717+
Set this option to set the upper limit on number of characteristics per connection to be cached.
718+
config BT_NIMBLE_GATT_CACHING_MAX_DSCS
719+
int "Maximum number of descriptors per connection"
720+
depends on BT_NIMBLE_GATT_CACHING
721+
default 64
722+
help
723+
Set this option to set the upper limit on number of descriptors per connection to be cached.
726724
config BT_NIMBLE_GATT_CACHING_DISABLE_AUTO
727725
bool "Do not start discovery procedure automatically upon receiving Out of Sync"
728726
depends on BT_NIMBLE_GATT_CACHING
@@ -934,6 +932,12 @@ menu "GAP Service"
934932
help
935933
Enable the LE GATT Security Level Characteristic
936934

935+
config BT_NIMBLE_SVC_GAP_RPA_ONLY
936+
bool "Resolvable Private Address Only characteristic"
937+
default n
938+
help
939+
Enable the Resolvable Private Address Only characteristic
940+
937941
endmenu
938942

939943
menu "BLE Services"
@@ -1060,7 +1064,8 @@ config BT_NIMBLE_HIGH_DUTY_ADV_ITVL
10601064

10611065
config BT_NIMBLE_HOST_ALLOW_CONNECT_WITH_SCAN
10621066
bool "Allow Connections with scanning in progress"
1063-
depends on BT_NIMBLE_ENABLED && (IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32S3)
1067+
depends on BT_NIMBLE_ENABLED
1068+
depends on (!SOC_ESP_NIMBLE_CONTROLLER || IDF_TARGET_ESP32C6 || IDF_TARGET_ESP32H2)
10641069
help
10651070
This enables support for user to initiate a new connection with scan in progress
10661071

components/bt/host/nimble/port/include/esp_nimble_cfg.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,6 +1818,11 @@
18181818
CONFIG_BT_NIMBLE_SVC_GAP_GATT_SECURITY_LEVEL
18191819
#endif
18201820

1821+
#ifndef MYNEWT_VAL_BLE_SVC_GAP_RPA_ONLY
1822+
#define MYNEWT_VAL_BLE_SVC_GAP_RPA_ONLY \
1823+
CONFIG_BT_NIMBLE_SVC_GAP_RPA_ONLY
1824+
#endif
1825+
18211826
/*** nimble/transport */
18221827
#ifndef MYNEWT_VAL_BLE_HCI_TRANSPORT_EMSPI
18231828
#define MYNEWT_VAL_BLE_HCI_TRANSPORT_EMSPI (0)

components/bt/include/esp32c6/include/esp_bt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ typedef struct {
276276
.ignore_wl_for_direct_adv = 0, \
277277
.enable_pcl = DEFAULT_BT_LE_POWER_CONTROL_ENABLED, \
278278
.csa2_select = DEFAULT_BT_LE_50_FEATURE_SUPPORT, \
279-
.enable_csr = 0, \
279+
.enable_csr = DEFAULT_BT_LE_SUBRATE_ENABLED, \
280280
.ble_aa_check = DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS, \
281281
.ble_llcp_disc_flag = BT_LE_CTRL_LLCP_DISC_FLAG, \
282282
.scan_backoff_upperlimitmax = BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \

components/driver/i2c/i2c.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -68,6 +68,7 @@ static const char *I2C_TAG = "i2c";
6868
#define I2C_CMD_USER_ALLOC_ERR_STR "i2c command link allocation error: the buffer provided is too small."
6969
#define I2C_TRANS_MODE_ERR_STR "i2c trans mode error"
7070
#define I2C_MODE_ERR_STR "i2c mode error"
71+
#define I2C_CLEAR_BUS_ERR_STR "clear bus error"
7172
#define I2C_SDA_IO_ERR_STR "sda gpio number error"
7273
#define I2C_SCL_IO_ERR_STR "scl gpio number error"
7374
#define I2C_SCL_SDA_EQUAL_ERR_STR "scl and sda gpio numbers are the same"
@@ -126,6 +127,8 @@ static const char *I2C_TAG = "i2c";
126127
#define I2C_RCC_ATOMIC()
127128
#endif
128129

130+
#define I2C_CLR_BUS_TIMEOUT_MS (50) // 50ms is sufficient for clearing the bus
131+
129132
/**
130133
* I2C bus are defined in the header files, let's check that the values are correct
131134
*/
@@ -657,6 +660,7 @@ esp_err_t i2c_get_data_mode(i2c_port_t i2c_num, i2c_trans_mode_t *tx_trans_mode,
657660
**/
658661
static esp_err_t i2c_master_clear_bus(i2c_port_t i2c_num)
659662
{
663+
esp_err_t ret = ESP_OK;
660664
#if !SOC_I2C_SUPPORT_HW_CLR_BUS
661665
const int scl_half_period = I2C_CLR_BUS_HALF_PERIOD_US; // use standard 100kHz data rate
662666
int i = 0;
@@ -685,11 +689,22 @@ static esp_err_t i2c_master_clear_bus(i2c_port_t i2c_num)
685689
i2c_set_pin(i2c_num, sda_io, scl_io, 1, 1, I2C_MODE_MASTER);
686690
#else
687691
i2c_ll_master_clr_bus(i2c_context[i2c_num].hal.dev, I2C_CLR_BUS_SCL_NUM, true);
692+
// If the i2c master clear bus state machine got disturbed when working, it would go into error state.
693+
// The solution here is to use freertos tick counter to set a timeout threshold. If it doesn't return on time,
694+
// return invalid state and turn off the state machine as its always wrong.
695+
TickType_t start_tick = xTaskGetTickCount();
696+
const TickType_t timeout_ticks = pdMS_TO_TICKS(I2C_CLR_BUS_TIMEOUT_MS);
688697
while (i2c_ll_master_is_bus_clear_done(i2c_context[i2c_num].hal.dev)) {
698+
if ((xTaskGetTickCount() - start_tick) > timeout_ticks) {
699+
ESP_LOGE(I2C_TAG, I2C_CLEAR_BUS_ERR_STR);
700+
i2c_ll_master_clr_bus(i2c_context[i2c_num].hal.dev, 0, false);
701+
ret = ESP_ERR_INVALID_STATE;
702+
break;
703+
}
689704
}
690705
i2c_ll_update(i2c_context[i2c_num].hal.dev);
691706
#endif
692-
return ESP_OK;
707+
return ret;
693708
}
694709

695710
/**if the power and SDA/SCL wires are in proper condition, everything works find with reading the slave.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
| Supported Targets | ESP32 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
2-
| ----------------- | ----- | -------- | -------- | -------- | --------- | -------- | -------- | -------- | -------- |
1+
| Supported Targets | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
2+
| ----------------- | ----- | -------- | -------- | --------- | -------- | -------- | -------- | -------- |

0 commit comments

Comments
 (0)