OpenOCD
esp32.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /***************************************************************************
4  * ESP32 target API for OpenOCD *
5  * Copyright (C) 2016-2019 Espressif Systems Ltd. *
6  ***************************************************************************/
7 
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif
11 
12 #include <helper/time_support.h>
13 #include <target/target.h>
14 #include <target/target_type.h>
15 #include <target/smp.h>
17 #include "assert.h"
18 #include "esp_xtensa_smp.h"
19 
20 /*
21 This is a JTAG driver for the ESP32, the are two Tensilica cores inside
22 the ESP32 chip. For more information please have a look into ESP32 target
23 implementation.
24 */
25 
26 /* ESP32 memory map */
27 #define ESP32_DRAM_LOW 0x3ffae000
28 #define ESP32_DRAM_HIGH 0x40000000
29 #define ESP32_IROM_MASK_LOW 0x40000000
30 #define ESP32_IROM_MASK_HIGH 0x40064f00
31 #define ESP32_IRAM_LOW 0x40070000
32 #define ESP32_IRAM_HIGH 0x400a0000
33 #define ESP32_RTC_IRAM_LOW 0x400c0000
34 #define ESP32_RTC_IRAM_HIGH 0x400c2000
35 #define ESP32_RTC_DRAM_LOW 0x3ff80000
36 #define ESP32_RTC_DRAM_HIGH 0x3ff82000
37 #define ESP32_RTC_DATA_LOW 0x50000000
38 #define ESP32_RTC_DATA_HIGH 0x50002000
39 #define ESP32_EXTRAM_DATA_LOW 0x3f800000
40 #define ESP32_EXTRAM_DATA_HIGH 0x3fc00000
41 #define ESP32_DR_REG_LOW 0x3ff00000
42 #define ESP32_DR_REG_HIGH 0x3ff71000
43 #define ESP32_SYS_RAM_LOW 0x60000000UL
44 #define ESP32_SYS_RAM_HIGH (ESP32_SYS_RAM_LOW + 0x20000000UL)
45 #define ESP32_RTC_SLOW_MEM_BASE ESP32_RTC_DATA_LOW
46 
47 /* ESP32 WDT */
48 #define ESP32_WDT_WKEY_VALUE 0x50d83aa1
49 #define ESP32_TIMG0_BASE 0x3ff5f000
50 #define ESP32_TIMG1_BASE 0x3ff60000
51 #define ESP32_TIMGWDT_CFG0_OFF 0x48
52 #define ESP32_TIMGWDT_PROTECT_OFF 0x64
53 #define ESP32_TIMG0WDT_CFG0 (ESP32_TIMG0_BASE + ESP32_TIMGWDT_CFG0_OFF)
54 #define ESP32_TIMG1WDT_CFG0 (ESP32_TIMG1_BASE + ESP32_TIMGWDT_CFG0_OFF)
55 #define ESP32_TIMG0WDT_PROTECT (ESP32_TIMG0_BASE + ESP32_TIMGWDT_PROTECT_OFF)
56 #define ESP32_TIMG1WDT_PROTECT (ESP32_TIMG1_BASE + ESP32_TIMGWDT_PROTECT_OFF)
57 #define ESP32_RTCCNTL_BASE 0x3ff48000
58 #define ESP32_RTCWDT_CFG_OFF 0x8C
59 #define ESP32_RTCWDT_PROTECT_OFF 0xA4
60 #define ESP32_RTCWDT_CFG (ESP32_RTCCNTL_BASE + ESP32_RTCWDT_CFG_OFF)
61 #define ESP32_RTCWDT_PROTECT (ESP32_RTCCNTL_BASE + ESP32_RTCWDT_PROTECT_OFF)
62 
63 #define ESP32_TRACEMEM_BLOCK_SZ 0x4000
64 
65 /* ESP32 dport regs */
66 #define ESP32_DR_REG_DPORT_BASE ESP32_DR_REG_LOW
67 #define ESP32_DPORT_APPCPU_CTRL_B_REG (ESP32_DR_REG_DPORT_BASE + 0x030)
68 #define ESP32_DPORT_APPCPU_CLKGATE_EN BIT(0)
69 /* ESP32 RTC regs */
70 #define ESP32_RTC_CNTL_SW_CPU_STALL_REG (ESP32_RTCCNTL_BASE + 0xac)
71 #define ESP32_RTC_CNTL_SW_CPU_STALL_DEF 0x0
72 
73 /* 0 - don't care, 1 - TMS low, 2 - TMS high */
78 };
79 
80 struct esp32_common {
83 };
84 
85 static inline struct esp32_common *target_to_esp32(struct target *target)
86 {
88 }
89 
90 /* Reset ESP32 peripherals.
91  * Postconditions: all peripherals except RTC_CNTL are reset, CPU's PC is undefined, PRO CPU is halted,
92  * APP CPU is in reset
93  * How this works:
94  * 0. make sure target is halted; if not, try to halt it; if that fails, try to reset it (via OCD) and then halt
95  * 1. set CPU initial PC to 0x50000000 (ESP32_SMP_RTC_DATA_LOW) by clearing RTC_CNTL_{PRO,APP}CPU_STAT_VECTOR_SEL
96  * 2. load stub code into ESP32_SMP_RTC_DATA_LOW; once executed, stub code will disable watchdogs and
97  * make CPU spin in an idle loop.
98  * 3. trigger SoC reset using RTC_CNTL_SW_SYS_RST bit
99  * 4. wait for the OCD to be reset
100  * 5. halt the target and wait for it to be halted (at this point CPU is in the idle loop)
101  * 6. restore initial PC and the contents of ESP32_SMP_RTC_DATA_LOW
102  * TODO: some state of RTC_CNTL is not reset during SW_SYS_RST. Need to reset that manually. */
103 
104 static const uint8_t esp32_reset_stub_code[] = {
105 #include "../../../contrib/loaders/reset/espressif/esp32/cpu_reset_handler_code.inc"
106 };
107 
108 static int esp32_soc_reset(struct target *target)
109 {
110  int res;
111  struct target_list *head;
112  struct xtensa *xtensa;
113 
114  LOG_DEBUG("start");
115  /* In order to write to peripheral registers, target must be halted first */
116  if (target->state != TARGET_HALTED) {
117  LOG_DEBUG("Target not halted before SoC reset, trying to halt it first");
119  res = target_wait_state(target, TARGET_HALTED, 1000);
120  if (res != ERROR_OK) {
121  LOG_DEBUG("Couldn't halt target before SoC reset, trying to do reset-halt");
123  if (res != ERROR_OK) {
124  LOG_ERROR(
125  "Couldn't halt target before SoC reset! (xtensa_assert_reset returned %d)",
126  res);
127  return res;
128  }
129  alive_sleep(10);
131  bool reset_halt_save = target->reset_halt;
132  target->reset_halt = true;
134  target->reset_halt = reset_halt_save;
135  if (res != ERROR_OK) {
136  LOG_ERROR(
137  "Couldn't halt target before SoC reset! (xtensa_deassert_reset returned %d)",
138  res);
139  return res;
140  }
141  alive_sleep(10);
144  res = target_wait_state(target, TARGET_HALTED, 1000);
145  if (res != ERROR_OK) {
146  LOG_ERROR("Couldn't halt target before SoC reset");
147  return res;
148  }
149  }
150  }
151 
152  if (target->smp) {
154  xtensa = target_to_xtensa(head->target);
155  /* if any of the cores is stalled unstall them */
157  LOG_TARGET_DEBUG(head->target, "Unstall CPUs before SW reset!");
158  res = target_write_u32(target,
161  if (res != ERROR_OK) {
162  LOG_TARGET_ERROR(head->target, "Failed to unstall CPUs before SW reset!");
163  return res;
164  }
165  break; /* both cores are unstalled now, so exit the loop */
166  }
167  }
168  }
169 
170  LOG_DEBUG("Loading stub code into RTC RAM");
171  uint8_t slow_mem_save[sizeof(esp32_reset_stub_code)];
172 
173  /* Save contents of RTC_SLOW_MEM which we are about to overwrite */
174  res = target_read_buffer(target, ESP32_RTC_SLOW_MEM_BASE, sizeof(slow_mem_save), slow_mem_save);
175  if (res != ERROR_OK) {
176  LOG_ERROR("Failed to save contents of RTC_SLOW_MEM (%d)!", res);
177  return res;
178  }
179 
180  /* Write stub code into RTC_SLOW_MEM */
182  if (res != ERROR_OK) {
183  LOG_ERROR("Failed to write stub (%d)!", res);
184  return res;
185  }
186 
187  LOG_DEBUG("Resuming the target");
189  xtensa->suppress_dsr_errors = true;
190  res = xtensa_resume(target, 0, ESP32_RTC_SLOW_MEM_BASE + 4, 0, 0);
191  xtensa->suppress_dsr_errors = false;
192  if (res != ERROR_OK) {
193  LOG_ERROR("Failed to run stub (%d)!", res);
194  return res;
195  }
196  LOG_DEBUG("resume done, waiting for the target to come alive");
197 
198  /* Wait for SoC to reset */
199  alive_sleep(100);
200  int64_t timeout = timeval_ms() + 100;
201  bool get_timeout = false;
202  while (target->state != TARGET_RESET && target->state != TARGET_RUNNING) {
203  alive_sleep(10);
205  if (timeval_ms() >= timeout) {
206  LOG_TARGET_ERROR(target, "Timed out waiting for CPU to be reset, target state=%d",
207  target->state);
208  get_timeout = true;
209  break;
210  }
211  }
212 
213  /* Halt the CPU again */
214  LOG_DEBUG("halting the target");
216  res = target_wait_state(target, TARGET_HALTED, 1000);
217  if (res == ERROR_OK) {
218  LOG_DEBUG("restoring RTC_SLOW_MEM");
219  res = target_write_buffer(target, ESP32_RTC_SLOW_MEM_BASE, sizeof(slow_mem_save), slow_mem_save);
220  if (res != ERROR_OK)
221  LOG_TARGET_ERROR(target, "Failed to restore contents of RTC_SLOW_MEM (%d)!", res);
222  } else {
223  LOG_TARGET_ERROR(target, "Timed out waiting for CPU to be halted after SoC reset");
224  }
225 
226  return get_timeout ? ERROR_TARGET_TIMEOUT : res;
227 }
228 
229 static int esp32_disable_wdts(struct target *target)
230 {
231  /* TIMG1 WDT */
233  if (res != ERROR_OK) {
234  LOG_ERROR("Failed to write ESP32_TIMG0WDT_PROTECT (%d)!", res);
235  return res;
236  }
238  if (res != ERROR_OK) {
239  LOG_ERROR("Failed to write ESP32_TIMG0WDT_CFG0 (%d)!", res);
240  return res;
241  }
242  /* TIMG2 WDT */
244  if (res != ERROR_OK) {
245  LOG_ERROR("Failed to write ESP32_TIMG1WDT_PROTECT (%d)!", res);
246  return res;
247  }
249  if (res != ERROR_OK) {
250  LOG_ERROR("Failed to write ESP32_TIMG1WDT_CFG0 (%d)!", res);
251  return res;
252  }
253  /* RTC WDT */
255  if (res != ERROR_OK) {
256  LOG_ERROR("Failed to write ESP32_RTCWDT_PROTECT (%d)!", res);
257  return res;
258  }
260  if (res != ERROR_OK) {
261  LOG_ERROR("Failed to write ESP32_RTCWDT_CFG (%d)!", res);
262  return res;
263  }
264  return ERROR_OK;
265 }
266 
267 static int esp32_on_halt(struct target *target)
268 {
269  return esp32_disable_wdts(target);
270 }
271 
272 static int esp32_arch_state(struct target *target)
273 {
274  return ERROR_OK;
275 }
276 
277 static int esp32_virt2phys(struct target *target,
278  target_addr_t virtual, target_addr_t *physical)
279 {
280  if (physical) {
281  *physical = virtual;
282  return ERROR_OK;
283  }
284  return ERROR_FAIL;
285 }
286 
287 /* The TDI pin is also used as a flash Vcc bootstrap pin. If we reset the CPU externally, the last state of the TDI pin
288  * can allow the power to an 1.8V flash chip to be raised to 3.3V, or the other way around. Users can use the
289  * esp32 flashbootstrap command to set a level, and this routine will make sure the tdi line will return to
290  * that when the jtag port is idle. */
291 
292 static void esp32_queue_tdi_idle(struct target *target)
293 {
294  struct esp32_common *esp32 = target_to_esp32(target);
295  static uint32_t value;
296  uint8_t t[4] = { 0, 0, 0, 0 };
297 
298  if (esp32->flash_bootstrap == FBS_TMSLOW)
299  /* Make sure tdi is 0 at the exit of queue execution */
300  value = 0;
301  else if (esp32->flash_bootstrap == FBS_TMSHIGH)
302  /* Make sure tdi is 1 at the exit of queue execution */
303  value = 1;
304  else
305  return;
306 
307  /* Scan out 1 bit, do not move from IRPAUSE after we're done. */
308  buf_set_u32(t, 0, 1, value);
310 }
311 
312 static int esp32_target_init(struct command_context *cmd_ctx, struct target *target)
313 {
314  return esp_xtensa_smp_target_init(cmd_ctx, target);
315 }
316 
317 static const struct xtensa_debug_ops esp32_dbg_ops = {
319  .queue_reg_read = xtensa_dm_queue_reg_read,
320  .queue_reg_write = xtensa_dm_queue_reg_write
321 };
322 
323 static const struct xtensa_power_ops esp32_pwr_ops = {
325  .queue_reg_write = xtensa_dm_queue_pwr_reg_write
326 };
327 
328 static const struct esp_xtensa_smp_chip_ops esp32_chip_ops = {
330  .on_halt = esp32_on_halt
331 };
332 
333 static const struct esp_semihost_ops esp32_semihost_ops = {
335 };
336 
337 static int esp32_target_create(struct target *target, Jim_Interp *interp)
338 {
339  struct xtensa_debug_module_config esp32_dm_cfg = {
341  .pwr_ops = &esp32_pwr_ops,
342  .tap = target->tap,
343  .queue_tdi_idle = esp32_queue_tdi_idle,
344  .queue_tdi_idle_arg = target
345  };
346 
347  struct esp32_common *esp32 = calloc(1, sizeof(struct esp32_common));
348  if (!esp32) {
349  LOG_ERROR("Failed to alloc memory for arch info!");
350  return ERROR_FAIL;
351  }
352 
354  &esp32_dm_cfg, &esp32_chip_ops, &esp32_semihost_ops);
355  if (ret != ERROR_OK) {
356  LOG_ERROR("Failed to init arch info!");
357  free(esp32);
358  return ret;
359  }
360  esp32->flash_bootstrap = FBS_DONTCARE;
361 
362  /* Assume running target. If different, the first poll will fix this. */
365  return ERROR_OK;
366 }
367 
368 static COMMAND_HELPER(esp32_cmd_flashbootstrap_do, struct esp32_common *esp32)
369 {
370  int state = -1;
371 
372  if (CMD_ARGC < 1) {
373  const char *st;
374  state = esp32->flash_bootstrap;
375  if (state == FBS_DONTCARE)
376  st = "Don't care";
377  else if (state == FBS_TMSLOW)
378  st = "Low (3.3V)";
379  else if (state == FBS_TMSHIGH)
380  st = "High (1.8V)";
381  else
382  st = "None";
383  command_print(CMD, "Current idle tms state: %s", st);
384  return ERROR_OK;
385  }
386 
387  if (!strcasecmp(CMD_ARGV[0], "none"))
389  else if (!strcasecmp(CMD_ARGV[0], "1.8"))
390  state = FBS_TMSHIGH;
391  else if (!strcasecmp(CMD_ARGV[0], "3.3"))
392  state = FBS_TMSLOW;
393  else if (!strcasecmp(CMD_ARGV[0], "high"))
394  state = FBS_TMSHIGH;
395  else if (!strcasecmp(CMD_ARGV[0], "low"))
396  state = FBS_TMSLOW;
397 
398  if (state == -1) {
400  "Argument unknown. Please pick one of none, high, low, 1.8 or 3.3");
401  return ERROR_FAIL;
402  }
403  esp32->flash_bootstrap = state;
404  return ERROR_OK;
405 }
406 
407 COMMAND_HANDLER(esp32_cmd_flashbootstrap)
408 {
410 
411  if (target->smp) {
412  struct target_list *head;
413  struct target *curr;
415  curr = head->target;
416  int ret = CALL_COMMAND_HANDLER(esp32_cmd_flashbootstrap_do,
417  target_to_esp32(curr));
418  if (ret != ERROR_OK)
419  return ret;
420  }
421  return ERROR_OK;
422  }
423  return CALL_COMMAND_HANDLER(esp32_cmd_flashbootstrap_do,
425 }
426 
427 static const struct command_registration esp32_any_command_handlers[] = {
428  {
429  .name = "flashbootstrap",
430  .handler = esp32_cmd_flashbootstrap,
431  .mode = COMMAND_ANY,
432  .help =
433  "Set the idle state of the TMS pin, which at reset also is the voltage selector for the flash chip.",
434  .usage = "none|1.8|3.3|high|low",
435  },
437 };
438 
439 static const struct command_registration esp32_command_handlers[] = {
440  {
442  },
443  {
444  .name = "esp32",
445  .usage = "",
446  .chain = smp_command_handlers,
447  },
448  {
449  .name = "esp32",
450  .usage = "",
452  },
453  {
454  .name = "arm",
455  .mode = COMMAND_ANY,
456  .help = "ARM Command Group",
457  .usage = "",
459  },
461 };
462 
464 struct target_type esp32_target = {
465  .name = "esp32",
466 
467  .poll = esp_xtensa_smp_poll,
468  .arch_state = esp32_arch_state,
469 
470  .halt = xtensa_halt,
471  .resume = esp_xtensa_smp_resume,
472  .step = esp_xtensa_smp_step,
473 
474  .assert_reset = esp_xtensa_smp_assert_reset,
475  .deassert_reset = esp_xtensa_smp_deassert_reset,
476  .soft_reset_halt = esp_xtensa_smp_soft_reset_halt,
477 
478  .virt2phys = esp32_virt2phys,
479  .mmu = xtensa_mmu_is_enabled,
480  .read_memory = xtensa_read_memory,
481  .write_memory = xtensa_write_memory,
482 
483  .read_buffer = xtensa_read_buffer,
484  .write_buffer = xtensa_write_buffer,
485 
486  .checksum_memory = xtensa_checksum_memory,
487 
488  .get_gdb_arch = xtensa_get_gdb_arch,
489  .get_gdb_reg_list = xtensa_get_gdb_reg_list,
490 
491  .add_breakpoint = esp_xtensa_breakpoint_add,
492  .remove_breakpoint = esp_xtensa_breakpoint_remove,
493 
494  .add_watchpoint = esp_xtensa_smp_watchpoint_add,
495  .remove_watchpoint = esp_xtensa_smp_watchpoint_remove,
496 
497  .target_create = esp32_target_create,
498  .init_target = esp32_target_init,
499  .examine = xtensa_examine,
500  .deinit_target = esp_xtensa_target_deinit,
501 
502  .commands = esp32_command_handlers,
503 };
static void buf_set_u32(uint8_t *_buffer, unsigned first, unsigned num, uint32_t value)
Sets num bits in _buffer, starting at the first bit, using the bits in value.
Definition: binarybuffer.h:30
void command_print(struct command_invocation *cmd, const char *format,...)
Definition: command.c:473
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
Definition: command.h:140
#define CALL_COMMAND_HANDLER(name, extra ...)
Use this to macro to call a command helper (or a nested handler).
Definition: command.h:117
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
Definition: command.h:155
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
Definition: command.h:150
#define CMD_CTX
Use this macro to access the context of the command being handled, rather than accessing the variable...
Definition: command.h:145
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:247
@ COMMAND_ANY
Definition: command.h:42
static const struct esp_xtensa_smp_chip_ops esp32_chip_ops
Definition: esp32.c:328
#define ESP32_TIMG0WDT_PROTECT
Definition: esp32.c:55
#define ESP32_TIMG0WDT_CFG0
Definition: esp32.c:53
static void esp32_queue_tdi_idle(struct target *target)
Definition: esp32.c:292
#define ESP32_TIMG1WDT_PROTECT
Definition: esp32.c:56
static const struct xtensa_debug_ops esp32_dbg_ops
Definition: esp32.c:317
static COMMAND_HELPER(esp32_cmd_flashbootstrap_do, struct esp32_common *esp32)
Definition: esp32.c:368
esp32_flash_bootstrap
Definition: esp32.c:74
@ FBS_TMSHIGH
Definition: esp32.c:77
@ FBS_TMSLOW
Definition: esp32.c:76
@ FBS_DONTCARE
Definition: esp32.c:75
static const struct command_registration esp32_any_command_handlers[]
Definition: esp32.c:427
static int esp32_virt2phys(struct target *target, target_addr_t virtual, target_addr_t *physical)
Definition: esp32.c:277
static int esp32_target_init(struct command_context *cmd_ctx, struct target *target)
Definition: esp32.c:312
static const struct command_registration esp32_command_handlers[]
Definition: esp32.c:439
static const struct esp_semihost_ops esp32_semihost_ops
Definition: esp32.c:333
#define ESP32_RTC_CNTL_SW_CPU_STALL_DEF
Definition: esp32.c:71
static const uint8_t esp32_reset_stub_code[]
Definition: esp32.c:104
#define ESP32_TIMG1WDT_CFG0
Definition: esp32.c:54
struct target_type esp32_target
Holds methods for Xtensa targets.
Definition: esp32.c:464
static int esp32_arch_state(struct target *target)
Definition: esp32.c:272
#define ESP32_WDT_WKEY_VALUE
Definition: esp32.c:48
#define ESP32_RTCWDT_CFG
Definition: esp32.c:60
static const struct xtensa_power_ops esp32_pwr_ops
Definition: esp32.c:323
static struct esp32_common * target_to_esp32(struct target *target)
Definition: esp32.c:85
static int esp32_on_halt(struct target *target)
Definition: esp32.c:267
#define ESP32_RTCWDT_PROTECT
Definition: esp32.c:61
static int esp32_disable_wdts(struct target *target)
Definition: esp32.c:229
static int esp32_soc_reset(struct target *target)
Definition: esp32.c:108
static int esp32_target_create(struct target *target, Jim_Interp *interp)
Definition: esp32.c:337
#define ESP32_RTC_SLOW_MEM_BASE
Definition: esp32.c:45
COMMAND_HANDLER(esp32_cmd_flashbootstrap)
Definition: esp32.c:407
#define ESP32_RTC_CNTL_SW_CPU_STALL_REG
Definition: esp32.c:70
void esp_xtensa_target_deinit(struct target *target)
Definition: esp_xtensa.c:36
int esp_xtensa_breakpoint_remove(struct target *target, struct breakpoint *breakpoint)
Definition: esp_xtensa.c:60
int esp_xtensa_breakpoint_add(struct target *target, struct breakpoint *breakpoint)
Definition: esp_xtensa.c:54
int esp_xtensa_smp_init_arch_info(struct target *target, struct esp_xtensa_smp_common *esp_xtensa_smp, struct xtensa_debug_module_config *dm_cfg, const struct esp_xtensa_smp_chip_ops *chip_ops, const struct esp_semihost_ops *semihost_ops)
const struct command_registration esp_xtensa_smp_command_handlers[]
int esp_xtensa_smp_soft_reset_halt(struct target *target)
int esp_xtensa_smp_deassert_reset(struct target *target)
int esp_xtensa_smp_step(struct target *target, int current, target_addr_t address, int handle_breakpoints)
int esp_xtensa_smp_watchpoint_remove(struct target *target, struct watchpoint *watchpoint)
int esp_xtensa_smp_target_init(struct command_context *cmd_ctx, struct target *target)
int esp_xtensa_smp_watchpoint_add(struct target *target, struct watchpoint *watchpoint)
int esp_xtensa_smp_assert_reset(struct target *target)
int esp_xtensa_smp_poll(struct target *target)
int esp_xtensa_smp_resume(struct target *target, int current, target_addr_t address, int handle_breakpoints, int debug_execution)
void jtag_add_plain_ir_scan(int num_bits, const uint8_t *out_bits, uint8_t *in_bits, tap_state_t state)
Scan out the bits in ir scan mode.
Definition: jtag/core.c:392
@ TAP_IRPAUSE
Definition: jtag.h:51
void alive_sleep(uint64_t ms)
Definition: log.c:460
#define ERROR_FAIL
Definition: log.h:161
#define LOG_TARGET_ERROR(target, fmt_str,...)
Definition: log.h:149
#define LOG_TARGET_DEBUG(target, fmt_str,...)
Definition: log.h:140
#define LOG_ERROR(expr ...)
Definition: log.h:123
#define LOG_DEBUG(expr ...)
Definition: log.h:109
#define ERROR_OK
Definition: log.h:155
const struct command_registration semihosting_common_handlers[]
const struct command_registration smp_command_handlers[]
Definition: smp.c:150
#define foreach_smp_target(pos, head)
Definition: smp.h:15
const char * name
Definition: command.h:229
const struct command_registration * chain
If non-NULL, the commands in chain will be registered in the same context and scope of this registrat...
Definition: command.h:243
struct esp_xtensa_smp_common esp_xtensa_smp
Definition: esp32.c:81
enum esp32_flash_bootstrap flash_bootstrap
Definition: esp32.c:82
Semihost calls handling operations.
int(* prepare)(struct target *target)
Callback called before handling semihost call.
int(* reset)(struct target *target)
struct target * target
Definition: target.h:215
This holds methods shared between all instances of a given target type.
Definition: target_type.h:26
const char * name
Name of this type of target.
Definition: target_type.h:31
Definition: target.h:120
int smp
Definition: target.h:192
struct jtag_tap * tap
Definition: target.h:124
enum target_debug_reason debug_reason
Definition: target.h:159
enum target_state state
Definition: target.h:162
struct list_head * smp_targets
Definition: target.h:193
void * arch_info
Definition: target.h:169
bool reset_halt
Definition: target.h:149
Definition: psoc6.c:84
const struct xtensa_debug_ops * dbg_ops
int(* queue_enable)(struct xtensa_debug_module *dm)
enable operation
int(* queue_reg_read)(struct xtensa_debug_module *dm, enum xtensa_dm_pwr_reg reg, uint8_t *data, uint32_t clear)
register read.
Represents a generic Xtensa core.
Definition: xtensa.h:192
struct xtensa_debug_module dbg_mod
Definition: xtensa.h:196
bool suppress_dsr_errors
Definition: xtensa.h:222
int target_write_buffer(struct target *target, target_addr_t address, uint32_t size, const uint8_t *buffer)
Definition: target.c:2408
int target_read_buffer(struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
Definition: target.c:2473
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
Definition: target.c:2707
struct target * get_current_target(struct command_context *cmd_ctx)
Definition: target.c:536
int target_wait_state(struct target *target, enum target_state state, int ms)
Definition: target.c:3270
@ DBG_REASON_NOTHALTED
Definition: target.h:78
@ TARGET_RESET
Definition: target.h:56
@ TARGET_HALTED
Definition: target.h:55
@ TARGET_RUNNING
Definition: target.h:54
#define ERROR_TARGET_TIMEOUT
Definition: target.h:791
int64_t timeval_ms(void)
uint64_t target_addr_t
Definition: types.h:335
#define container_of(ptr, type, member)
Cast a member of a structure out to the containing structure.
Definition: types.h:68
#define NULL
Definition: usb.h:16
uint8_t state[4]
Definition: vdebug.c:21
const char * xtensa_get_gdb_arch(struct target *target)
Definition: xtensa.c:2994
int xtensa_poll(struct target *target)
Definition: xtensa.c:2022
int xtensa_halt(struct target *target)
Definition: xtensa.c:1302
int xtensa_read_buffer(struct target *target, target_addr_t address, uint32_t count, uint8_t *buffer)
Definition: xtensa.c:1805
int xtensa_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class)
Definition: xtensa.c:1225
int xtensa_checksum_memory(struct target *target, target_addr_t address, uint32_t count, uint32_t *checksum)
Definition: xtensa.c:2016
int xtensa_examine(struct target *target)
Definition: xtensa.c:780
int xtensa_resume(struct target *target, int current, target_addr_t address, int handle_breakpoints, int debug_execution)
Definition: xtensa.c:1404
int xtensa_write_buffer(struct target *target, target_addr_t address, uint32_t count, const uint8_t *buffer)
Definition: xtensa.c:2010
int xtensa_write_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
Definition: xtensa.c:1811
int xtensa_mmu_is_enabled(struct target *target, int *enabled)
Definition: xtensa.c:1294
int xtensa_deassert_reset(struct target *target)
Definition: xtensa.c:979
int xtensa_read_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
Definition: xtensa.c:1722
int xtensa_assert_reset(struct target *target)
Definition: xtensa.c:958
static struct xtensa * target_to_xtensa(struct target *target)
Definition: xtensa.h:239
int xtensa_dm_queue_reg_read(struct xtensa_debug_module *dm, enum xtensa_dm_reg reg, uint8_t *value)
int xtensa_dm_queue_pwr_reg_write(struct xtensa_debug_module *dm, enum xtensa_dm_pwr_reg reg, uint32_t data)
int xtensa_dm_queue_pwr_reg_read(struct xtensa_debug_module *dm, enum xtensa_dm_pwr_reg reg, uint8_t *data, uint32_t clear)
int xtensa_dm_queue_reg_write(struct xtensa_debug_module *dm, enum xtensa_dm_reg reg, uint32_t value)
int xtensa_dm_queue_enable(struct xtensa_debug_module *dm)
static bool xtensa_dm_core_is_stalled(struct xtensa_debug_module *dm)