Skip to content

Commit b3ed878

Browse files
authored
Merge branch 'espressif:release/v5.5' into release/v5.5
2 parents d1eb487 + 4c3d086 commit b3ed878

File tree

219 files changed

+4093
-1342
lines changed

Some content is hidden

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

219 files changed

+4093
-1342
lines changed

.gitlab/ci/common.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ variables:
4040
GIT_FETCH_EXTRA_FLAGS: "--no-recurse-submodules --prune --prune-tags"
4141
# we're using .cache folder for caches
4242
GIT_CLEAN_FLAGS: -ffdx -e .cache/
43-
LATEST_GIT_TAG: v5.5-dev
43+
LATEST_GIT_TAG: v5.5-beta1
4444

4545
SUBMODULE_FETCH_TOOL: "tools/ci/ci_fetch_submodule.py"
4646
# by default we will fetch all submodules

.gitlab/ci/default-build-test-rules.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ extra_default_build_targets:
1414

1515
bypass_check_test_targets:
1616
- esp32h21
17+
- esp32c61
1718
- esp32h4
1819
- esp32c5
1920

.gitmodules

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@
5454
sbom-supplier = Person: Dave Gamble
5555
sbom-url = https://github.com/DaveGamble/cJSON
5656
sbom-description = Ultralightweight JSON parser in ANSI C
57-
sbom-hash = acc76239bee01d8e9c858ae2cab296704e52d916
57+
sbom-hash = 8f2beb57ddad1f94bed899790b00f46df893ccac
5858
sbom-cve-exclude-list = CVE-2024-31755 Resolved in v1.7.18
59+
sbom-cve-exclude-list = CVE-2023-26819 Resolved in commit a328d65ad490b64da8c87523cbbfe16050ba5bf6
5960

6061
[submodule "components/mbedtls/mbedtls"]
6162
path = components/mbedtls/mbedtls

components/app_trace/app_trace_membufs_proto.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0 OR MIT
55
*/
@@ -148,6 +148,18 @@ static esp_err_t esp_apptrace_membufs_swap_waitus(esp_apptrace_membufs_proto_dat
148148
if (res != ESP_OK) {
149149
break;
150150
}
151+
#if CONFIG_IDF_TARGET_ESP32S3
152+
/*
153+
* ESP32S3 has a serious data corruption issue with the transferred data to host.
154+
* This delay helps reduce the failure rate by temporarily reducing heavy memory writes
155+
* from RTOS-level tracing and giving OpenOCD more time to read trace memory before
156+
* the current thread continues execution. While this doesn't completely prevent
157+
* memory access from other threads/cores/ISRs, it has shown to significantly improve
158+
* reliability when combined with CRC checks in OpenOCD. In practice, this reduces the
159+
* number of retries needed to read an entire block without corruption.
160+
*/
161+
esp_rom_delay_us(100);
162+
#endif
151163
}
152164
return res;
153165
}
@@ -339,7 +351,7 @@ uint8_t *esp_apptrace_membufs_up_buffer_get(esp_apptrace_membufs_proto_data_t *p
339351
esp_err_t esp_apptrace_membufs_up_buffer_put(esp_apptrace_membufs_proto_data_t *proto, uint8_t *ptr, esp_apptrace_tmo_t *tmo)
340352
{
341353
esp_apptrace_membufs_pkt_end(ptr);
342-
// TODO: mark block as busy in order not to re-use it for other tracing calls until it is completely written
354+
// TODO: mark block as busy in order not to reuse it for other tracing calls until it is completely written
343355
// TODO: avoid potential situation when all memory is consumed by low prio tasks which can not complete writing due to
344356
// higher prio tasks and the latter can not allocate buffers at all
345357
// this is abnormal situation can be detected on host which will receive only uncompleted buffers

components/app_trace/port/xtensa/port.c

Lines changed: 29 additions & 10 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 OR MIT
55
*/
@@ -12,7 +12,7 @@
1212
// ======================
1313

1414
// Xtensa has useful feature: TRAX debug module. It allows recording program execution flow at run-time without disturbing CPU.
15-
// Exectution flow data are written to configurable Trace RAM block. Besides accessing Trace RAM itself TRAX module also allows to read/write
15+
// Execution flow data are written to configurable Trace RAM block. Besides accessing Trace RAM itself TRAX module also allows to read/write
1616
// trace memory via its registers by means of JTAG, APB or ERI transactions.
1717
// ESP32 has two Xtensa cores with separate TRAX modules on them and provides two special memory regions to be used as trace memory.
1818
// Chip allows muxing access to those trace memory blocks in such a way that while one block is accessed by CPUs another one can be accessed by host
@@ -47,17 +47,23 @@
4747
// 2. TRAX Registers layout
4848
// ========================
4949

50-
// This module uses two TRAX HW registers to communicate with host SW (OpenOCD).
50+
// This module uses two TRAX HW registers and one Performance Monitor register to communicate with host SW (OpenOCD).
5151
// - Control register uses TRAX_DELAYCNT as storage. Only lower 24 bits of TRAX_DELAYCNT are writable. Control register has the following bitfields:
5252
// | 31..XXXXXX..24 | 23 .(host_connect). 23| 22..(block_id)..15 | 14..(block_len)..0 |
5353
// 14..0 bits - actual length of user data in trace memory block. Target updates it every time it fills memory block and exposes it to host.
5454
// Host writes zero to this field when it finishes reading exposed block;
5555
// 21..15 bits - trace memory block transfer ID. Block counter. It can overflow. Updated by target, host should not modify it. Actually can be 2 bits;
5656
// 22 bit - 'host data present' flag. If set to one there is data from host, otherwise - no host data;
5757
// 23 bit - 'host connected' flag. If zero then host is not connected and tracing module works in post-mortem mode, otherwise in streaming mode;
58-
// - Status register uses TRAX_TRIGGERPC as storage. If this register is not zero then current CPU is changing TRAX registers and
59-
// this register holds address of the instruction which application will execute when it finishes with those registers modifications.
60-
// See 'Targets Connection' setion for details.
58+
// - Status register uses TRAX_TRIGGERPC as storage. If this register is not zero then current CPU is changing TRAX registers and
59+
// this register holds address of the instruction which application will execute when it finishes with those registers modifications.
60+
// See 'Targets Connection' section for details.
61+
// - CRC16 register uses ERI_PERFMON_PM1 as storage. This register is used to store CRC16 checksum of the exposed trace memory block.
62+
// The register has the following format:
63+
// | 31..16 (CRC indicator) | 15..0 (CRC16 value) |
64+
// CRC indicator (0xA55A) is used to distinguish valid CRC values from other data that might be in the register.
65+
// CRC16 is calculated over the entire exposed block and is updated every time a block is exposed to the host.
66+
// This allows the host to verify data integrity of the received trace data.
6167

6268
// 3. Modes of operation
6369
// =====================
@@ -127,7 +133,7 @@
127133

128134
// Access to internal module's data is synchronized with custom mutex. Mutex is a wrapper for portMUX_TYPE and uses almost the same sync mechanism as in
129135
// vPortCPUAcquireMutex/vPortCPUReleaseMutex. The mechanism uses S32C1I Xtensa instruction to implement exclusive access to module's data from tasks and
130-
// ISRs running on both cores. Also custom mutex allows specifying timeout for locking operation. Locking routine checks underlaying mutex in cycle until
136+
// ISRs running on both cores. Also custom mutex allows specifying timeout for locking operation. Locking routine checks underlying mutex in cycle until
131137
// it gets its ownership or timeout expires. The differences of application tracing module's mutex implementation from vPortCPUAcquireMutex/vPortCPUReleaseMutex are:
132138
// - Support for timeouts.
133139
// - Local IRQs for CPU which owns the mutex are disabled till the call to unlocking routine. This is made to avoid possible task's prio inversion.
@@ -142,9 +148,9 @@
142148

143149
// Timeout mechanism is based on xthal_get_ccount() routine and supports timeout values in microseconds.
144150
// There are two situations when task/ISR can be delayed by tracing API call. Timeout mechanism takes into account both conditions:
145-
// - Trace data are locked by another task/ISR. When wating on trace data lock.
151+
// - Trace data are locked by another task/ISR. When waiting on trace data lock.
146152
// - Current TRAX memory input block is full when working in streaming mode (host is connected). When waiting for host to complete previous block reading.
147-
// When wating for any of above conditions xthal_get_ccount() is called periodically to calculate time elapsed from trace API routine entry. When elapsed
153+
// When waiting for any of above conditions xthal_get_ccount() is called periodically to calculate time elapsed from trace API routine entry. When elapsed
148154
// time exceeds specified timeout value operation is canceled and ESP_ERR_TIMEOUT code is returned.
149155
#include "sdkconfig.h"
150156
#include "soc/soc.h"
@@ -159,11 +165,15 @@
159165
#include "esp_log.h"
160166
#include "esp_app_trace_membufs_proto.h"
161167
#include "esp_app_trace_port.h"
168+
#include "esp_rom_crc.h"
162169

163170
// TRAX is disabled, so we use its registers for our own purposes
164171
// | 31..XXXXXX..24 | 23 .(host_connect). 23 | 22 .(host_data). 22| 21..(block_id)..15 | 14..(block_len)..0 |
165172
#define ESP_APPTRACE_TRAX_CTRL_REG ERI_TRAX_DELAYCNT
166173
#define ESP_APPTRACE_TRAX_STAT_REG ERI_TRAX_TRIGGERPC
174+
#define ESP_APPTRACE_TRAX_CRC16_REG ERI_PERFMON_PM1
175+
176+
#define ESP_APPTRACE_CRC_INDICATOR (0xA55AU << 16)
167177

168178
#define ESP_APPTRACE_TRAX_BLOCK_LEN_MSK 0x7FFFUL
169179
#define ESP_APPTRACE_TRAX_BLOCK_LEN(_l_) ((_l_) & ESP_APPTRACE_TRAX_BLOCK_LEN_MSK)
@@ -498,7 +508,8 @@ static esp_err_t esp_apptrace_trax_buffer_swap_start(uint32_t curr_block_id)
498508
uint32_t acked_block = ESP_APPTRACE_TRAX_BLOCK_ID_GET(ctrl_reg);
499509
uint32_t host_to_read = ESP_APPTRACE_TRAX_BLOCK_LEN_GET(ctrl_reg);
500510
if (host_to_read != 0 || acked_block != (curr_block_id & ESP_APPTRACE_TRAX_BLOCK_ID_MSK)) {
501-
ESP_APPTRACE_LOGD("HC[%d]: Can not switch %" PRIx32 " %" PRIu32 " %" PRIx32 " %" PRIx32 "/%" PRIx32, esp_cpu_get_core_id(), ctrl_reg, host_to_read, acked_block,
511+
ESP_APPTRACE_LOGD("HC[%d]: Can not switch %" PRIx32 " %" PRIu32 " %" PRIx32 " %" PRIx32 "/%" PRIx32,
512+
esp_cpu_get_core_id(), ctrl_reg, host_to_read, acked_block,
502513
curr_block_id & ESP_APPTRACE_TRAX_BLOCK_ID_MSK, curr_block_id);
503514
res = ESP_ERR_NO_MEM;
504515
goto _on_err;
@@ -514,6 +525,14 @@ static esp_err_t esp_apptrace_trax_buffer_swap_end(uint32_t new_block_id, uint32
514525
{
515526
uint32_t ctrl_reg = eri_read(ESP_APPTRACE_TRAX_CTRL_REG);
516527
uint32_t host_connected = ESP_APPTRACE_TRAX_HOST_CONNECT & ctrl_reg;
528+
529+
/* calculate CRC16 of the already switched block */
530+
if (prev_block_len > 0) {
531+
const uint8_t *prev_block_start = s_trax_blocks[!((new_block_id % 2))];
532+
uint16_t crc16 = esp_rom_crc16_le(0, prev_block_start, prev_block_len);
533+
eri_write(ESP_APPTRACE_TRAX_CRC16_REG, crc16 | ESP_APPTRACE_CRC_INDICATOR);
534+
ESP_APPTRACE_LOGD("CRC16:%x %d @%x", crc16, prev_block_len, prev_block_start);
535+
}
517536
eri_write(ESP_APPTRACE_TRAX_CTRL_REG, ESP_APPTRACE_TRAX_BLOCK_ID(new_block_id) |
518537
host_connected | ESP_APPTRACE_TRAX_BLOCK_LEN(prev_block_len));
519538
esp_apptrace_trax_buffer_swap_unlock();

components/bootloader_support/private_include/bootloader_soc.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@ void bootloader_ana_super_wdt_reset_config(bool enable);
2525
void bootloader_ana_clock_glitch_reset_config(bool enable);
2626

2727
/**
28-
* @brief Configure analog power glitch reset & glitch reset dref
28+
* @brief Configure analog power glitch reset
2929
*
3030
* @param enable Boolean to enable or disable power glitch reset
31-
* @param dref voltage threshold
3231
*/
33-
void bootloader_power_glitch_reset_config(bool enable, uint8_t dref);
32+
void bootloader_power_glitch_reset_config(bool enable);
3433

3534
#ifdef __cplusplus
3635
}

components/bootloader_support/src/esp32c5/bootloader_esp32c5.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,7 @@ static inline void bootloader_ana_reset_config(void)
9494
{
9595
//Enable BOD reset (mode1)
9696
brownout_ll_ana_reset_enable(true);
97-
if (efuse_hal_chip_revision() == 0) {
98-
// decrease power glitch reset voltage to avoid start the glitch reset
99-
uint8_t power_glitch_dref = 0;
100-
bootloader_power_glitch_reset_config(true, power_glitch_dref);
101-
}
97+
bootloader_power_glitch_reset_config(true);
10298
}
10399

104100
esp_err_t bootloader_init(void)

components/bootloader_support/src/esp32c5/bootloader_soc.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ void bootloader_ana_clock_glitch_reset_config(bool enable)
1717
(void)enable;
1818
}
1919

20-
void bootloader_power_glitch_reset_config(bool enable, uint8_t dref)
20+
void bootloader_power_glitch_reset_config(bool enable)
2121
{
22-
assert(dref < 8);
23-
REG_SET_FIELD(LP_ANA_FIB_ENABLE_REG, LP_ANA_ANA_FIB_PWR_GLITCH_ENA, 0);
22+
//only detect VDDPST POWER GLITCH
23+
SET_PERI_REG_MASK(PMU_RF_PWC_REG, PMU_PERIF_I2C_RSTB);
24+
SET_PERI_REG_MASK(PMU_RF_PWC_REG, PMU_XPD_PERIF_I2C);
25+
REGI2C_WRITE_MASK(I2C_SAR_ADC, POWER_GLITCH_XPD_VDET_PERIF, 0);
26+
REGI2C_WRITE_MASK(I2C_SAR_ADC, POWER_GLITCH_XPD_VDET_XTAL, 0);
27+
REGI2C_WRITE_MASK(I2C_SAR_ADC, POWER_GLITCH_XPD_VDET_PLL, 0);
28+
29+
REG_SET_FIELD(LP_ANA_FIB_ENABLE_REG, LP_ANA_ANA_FIB_PWR_GLITCH_ENA, 0);//default val for chip from ECO1
2430
if (enable) {
25-
SET_PERI_REG_MASK(PMU_RF_PWC_REG, PMU_PERIF_I2C_RSTB);
26-
SET_PERI_REG_MASK(PMU_RF_PWC_REG, PMU_XPD_PERIF_I2C);
27-
REGI2C_WRITE_MASK(I2C_SAR_ADC, POWER_GLITCH_DREF_VDET_PERIF, dref);
28-
REGI2C_WRITE_MASK(I2C_SAR_ADC, POWER_GLITCH_DREF_VDET_VDDPST, dref);
29-
REGI2C_WRITE_MASK(I2C_SAR_ADC, POWER_GLITCH_DREF_VDET_XTAL, dref);
30-
REGI2C_WRITE_MASK(I2C_SAR_ADC, POWER_GLITCH_DREF_VDET_PLL, dref);
31-
REG_SET_FIELD(LP_ANA_POWER_GLITCH_CNTL_REG, LP_ANA_PWR_GLITCH_RESET_ENA, 0xf);
31+
REG_SET_FIELD(LP_ANA_POWER_GLITCH_CNTL_REG, LP_ANA_PWR_GLITCH_RESET_ENA, 0xf);//default val for chip from ECO1
3232
} else {
3333
REG_SET_FIELD(LP_ANA_POWER_GLITCH_CNTL_REG, LP_ANA_PWR_GLITCH_RESET_ENA, 0);
3434
}

components/bootloader_support/src/esp32c61/bootloader_esp32c61.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,7 @@ static inline void bootloader_ana_reset_config(void)
9595
{
9696
//Enable BOD reset (mode1)
9797
brownout_ll_ana_reset_enable(true);
98-
uint8_t power_glitch_dref = 0;
99-
bootloader_power_glitch_reset_config(true, power_glitch_dref);
98+
bootloader_power_glitch_reset_config(true);
10099
}
101100

102101
esp_err_t bootloader_init(void)

components/bootloader_support/src/esp32c61/bootloader_soc.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ void bootloader_ana_clock_glitch_reset_config(bool enable)
1717
(void)enable;
1818
}
1919

20-
void bootloader_power_glitch_reset_config(bool enable, uint8_t dref)
20+
void bootloader_power_glitch_reset_config(bool enable)
2121
{
22-
assert(dref < 8);
23-
REG_SET_FIELD(LP_ANA_FIB_ENABLE_REG, LP_ANA_ANA_FIB_PWR_GLITCH_ENA, 0);
22+
//only detect VDDPST POWER GLITCH
23+
SET_PERI_REG_MASK(PMU_RF_PWC_REG, PMU_PERIF_I2C_RSTB);
24+
SET_PERI_REG_MASK(PMU_RF_PWC_REG, PMU_XPD_PERIF_I2C);
25+
REGI2C_WRITE_MASK(I2C_SAR_ADC, POWER_GLITCH_XPD_VDET_PERIF, 0);
26+
REGI2C_WRITE_MASK(I2C_SAR_ADC, POWER_GLITCH_XPD_VDET_PLLBB, 0);
27+
REGI2C_WRITE_MASK(I2C_SAR_ADC, POWER_GLITCH_XPD_VDET_PLL, 0);
28+
29+
REG_SET_FIELD(LP_ANA_FIB_ENABLE_REG, LP_ANA_ANA_FIB_PWR_GLITCH_ENA, 0);//default val for chip from ECO2
2430
if (enable) {
25-
SET_PERI_REG_MASK(PMU_RF_PWC_REG, PMU_PERIF_I2C_RSTB);
26-
SET_PERI_REG_MASK(PMU_RF_PWC_REG, PMU_XPD_PERIF_I2C);
27-
REGI2C_WRITE_MASK(I2C_SAR_ADC, POWER_GLITCH_DREF_VDET_PERIF, dref);
28-
REGI2C_WRITE_MASK(I2C_SAR_ADC, POWER_GLITCH_DREF_VDET_VDDPST, dref);
29-
REGI2C_WRITE_MASK(I2C_SAR_ADC, POWER_GLITCH_DREF_VDET_PLLBB, dref);
30-
REGI2C_WRITE_MASK(I2C_SAR_ADC, POWER_GLITCH_DREF_VDET_PLL, dref);
31-
REG_SET_FIELD(LP_ANA_POWER_GLITCH_CNTL_REG, LP_ANA_POWER_GLITCH_RESET_ENA, 0xf);
31+
REG_SET_FIELD(LP_ANA_POWER_GLITCH_CNTL_REG, LP_ANA_POWER_GLITCH_RESET_ENA, 0xf);//default val for chip from ECO2
3232
} else {
3333
REG_SET_FIELD(LP_ANA_POWER_GLITCH_CNTL_REG, LP_ANA_POWER_GLITCH_RESET_ENA, 0);
3434
}

0 commit comments

Comments
 (0)