Skip to content

Commit 9d3f7ef

Browse files
committed
fix(dap): fix the debug clok of esp32/esp32c3 at low speed
1 parent ab95979 commit 9d3f7ef

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ python ./idf.py -p /dev/ttyS5 flash
261261
The following example shows a possible way to build:
262262

263263
```bash
264+
# Set build target
265+
idf.py set-target esp32
264266
# Build
265267
idf.py build
266268
# Flash

components/DAP/source/DAP.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,16 @@ static uint32_t DAP_SWJ_Clock(const uint8_t *request, uint8_t *response) {
412412
DAP_Data.fast_clock = 0U;
413413
SWD_TransferSpeed = kTransfer_GPIO_normal;
414414

415-
////FIXME: esp32
416-
#define CPU_CLOCK_FIXED 80000000
417415

418-
delay = ((CPU_CLOCK_FIXED/2U) + (clock - 1U)) / clock;
416+
#ifdef CONFIG_IDF_TARGET_ESP8266
417+
#define BUS_CLOCK_FIXED 80000000
418+
#elif defined CONFIG_IDF_TARGET_ESP32
419+
#define BUS_CLOCK_FIXED 100000000
420+
#elif defined CONFIG_IDF_TARGET_ESP32C3
421+
#define BUS_CLOCK_FIXED 80000000
422+
#endif
423+
424+
delay = ((BUS_CLOCK_FIXED/2U) + (clock - 1U)) / clock;
419425
if (delay > IO_PORT_WRITE_CYCLES) {
420426
delay -= IO_PORT_WRITE_CYCLES;
421427
delay = (delay + (DELAY_SLOW_CYCLES - 1U)) / DELAY_SLOW_CYCLES;

0 commit comments

Comments
 (0)