Skip to content

Commit

Permalink
fix(dap): fix the debug clok of esp32/esp32c3 at low speed
Browse files Browse the repository at this point in the history
  • Loading branch information
windowsair committed Oct 29, 2022
1 parent ab95979 commit 9d3f7ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ python ./idf.py -p /dev/ttyS5 flash
The following example shows a possible way to build:

```bash
# Set build target
idf.py set-target esp32
# Build
idf.py build
# Flash
Expand Down
12 changes: 9 additions & 3 deletions components/DAP/source/DAP.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,16 @@ static uint32_t DAP_SWJ_Clock(const uint8_t *request, uint8_t *response) {
DAP_Data.fast_clock = 0U;
SWD_TransferSpeed = kTransfer_GPIO_normal;

////FIXME: esp32
#define CPU_CLOCK_FIXED 80000000

delay = ((CPU_CLOCK_FIXED/2U) + (clock - 1U)) / clock;
#ifdef CONFIG_IDF_TARGET_ESP8266
#define BUS_CLOCK_FIXED 80000000
#elif defined CONFIG_IDF_TARGET_ESP32
#define BUS_CLOCK_FIXED 100000000
#elif defined CONFIG_IDF_TARGET_ESP32C3
#define BUS_CLOCK_FIXED 80000000
#endif

delay = ((BUS_CLOCK_FIXED/2U) + (clock - 1U)) / clock;
if (delay > IO_PORT_WRITE_CYCLES) {
delay -= IO_PORT_WRITE_CYCLES;
delay = (delay + (DELAY_SLOW_CYCLES - 1U)) / DELAY_SLOW_CYCLES;
Expand Down

0 comments on commit 9d3f7ef

Please sign in to comment.