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_RTC_DATA_LOW 0x50000000
28 #define ESP32_RTC_DATA_HIGH 0x50002000
29 #define ESP32_DR_REG_LOW 0x3ff00000
30 #define ESP32_DR_REG_HIGH 0x3ff71000
31 #define ESP32_SYS_RAM_LOW 0x60000000UL
32 #define ESP32_SYS_RAM_HIGH (ESP32_SYS_RAM_LOW + 0x20000000UL)
33 #define ESP32_RTC_SLOW_MEM_BASE ESP32_RTC_DATA_LOW
34 
35 /* ESP32 WDT */
36 #define ESP32_WDT_WKEY_VALUE 0x50d83aa1
37 #define ESP32_TIMG0_BASE 0x3ff5f000
38 #define ESP32_TIMG1_BASE 0x3ff60000
39 #define ESP32_TIMGWDT_CFG0_OFF 0x48
40 #define ESP32_TIMGWDT_PROTECT_OFF 0x64
41 #define ESP32_TIMG0WDT_CFG0 (ESP32_TIMG0_BASE + ESP32_TIMGWDT_CFG0_OFF)
42 #define ESP32_TIMG1WDT_CFG0 (ESP32_TIMG1_BASE + ESP32_TIMGWDT_CFG0_OFF)
43 #define ESP32_TIMG0WDT_PROTECT (ESP32_TIMG0_BASE + ESP32_TIMGWDT_PROTECT_OFF)
44 #define ESP32_TIMG1WDT_PROTECT (ESP32_TIMG1_BASE + ESP32_TIMGWDT_PROTECT_OFF)
45 #define ESP32_RTCCNTL_BASE 0x3ff48000
46 #define ESP32_RTCWDT_CFG_OFF 0x8C
47 #define ESP32_RTCWDT_PROTECT_OFF 0xA4
48 #define ESP32_RTCWDT_CFG (ESP32_RTCCNTL_BASE + ESP32_RTCWDT_CFG_OFF)
49 #define ESP32_RTCWDT_PROTECT (ESP32_RTCCNTL_BASE + ESP32_RTCWDT_PROTECT_OFF)
50 
51 #define ESP32_TRACEMEM_BLOCK_SZ 0x4000
52 
53 /* ESP32 dport regs */
54 #define ESP32_DR_REG_DPORT_BASE ESP32_DR_REG_LOW
55 #define ESP32_DPORT_APPCPU_CTRL_B_REG (ESP32_DR_REG_DPORT_BASE + 0x030)
56 #define ESP32_DPORT_APPCPU_CLKGATE_EN BIT(0)
57 /* ESP32 RTC regs */
58 #define ESP32_RTC_CNTL_SW_CPU_STALL_REG (ESP32_RTCCNTL_BASE + 0xac)
59 #define ESP32_RTC_CNTL_SW_CPU_STALL_DEF 0x0
60 
61 /* 0 - don't care, 1 - TMS low, 2 - TMS high */
66 };
67 
68 struct esp32_common {
71 };
72 
73 static inline struct esp32_common *target_to_esp32(struct target *target)
74 {
76 }
77 
78 /* Reset ESP32 peripherals.
79  * Postconditions: all peripherals except RTC_CNTL are reset, CPU's PC is undefined, PRO CPU is halted,
80  * APP CPU is in reset
81  * How this works:
82  * 0. make sure target is halted; if not, try to halt it; if that fails, try to reset it (via OCD) and then halt
83  * 1. set CPU initial PC to 0x50000000 (ESP32_SMP_RTC_DATA_LOW) by clearing RTC_CNTL_{PRO,APP}CPU_STAT_VECTOR_SEL
84  * 2. load stub code into ESP32_SMP_RTC_DATA_LOW; once executed, stub code will disable watchdogs and
85  * make CPU spin in an idle loop.
86  * 3. trigger SoC reset using RTC_CNTL_SW_SYS_RST bit
87  * 4. wait for the OCD to be reset
88  * 5. halt the target and wait for it to be halted (at this point CPU is in the idle loop)
89  * 6. restore initial PC and the contents of ESP32_SMP_RTC_DATA_LOW
90  * TODO: some state of RTC_CNTL is not reset during SW_SYS_RST. Need to reset that manually. */
91 
92 static const uint8_t esp32_reset_stub_code[] = {
93 #include "../../../contrib/loaders/reset/espressif/esp32/cpu_reset_handler_code.inc"
94 };
95 
96 static int esp32_soc_reset(struct target *target)
97 {
98  int res;
99  struct target_list *head;
100  struct xtensa *xtensa;
101 
102  LOG_DEBUG("start");
103  /* In order to write to peripheral registers, target must be halted first */
104  if (target->state != TARGET_HALTED) {
105  LOG_DEBUG("Target not halted before SoC reset, trying to halt it first");
107  res = target_wait_state(target, TARGET_HALTED, 1000);
108  if (res != ERROR_OK) {
109  LOG_DEBUG("Couldn't halt target before SoC reset, trying to do reset-halt");
111  if (res != ERROR_OK) {
112  LOG_ERROR(
113  "Couldn't halt target before SoC reset! (xtensa_assert_reset returned %d)",
114  res);
115  return res;
116  }
117  alive_sleep(10);
119  bool reset_halt_save = target->reset_halt;
120  target->reset_halt = true;
122  target->reset_halt = reset_halt_save;
123  if (res != ERROR_OK) {
124  LOG_ERROR(
125  "Couldn't halt target before SoC reset! (xtensa_deassert_reset returned %d)",
126  res);
127  return res;
128  }
129  alive_sleep(10);
132  res = target_wait_state(target, TARGET_HALTED, 1000);
133  if (res != ERROR_OK) {
134  LOG_ERROR("Couldn't halt target before SoC reset");
135  return res;
136  }
137  }
138  }
139 
140  if (target->smp) {
142  xtensa = target_to_xtensa(head->target);
143  /* if any of the cores is stalled unstall them */
145  LOG_TARGET_DEBUG(head->target, "Unstall CPUs before SW reset!");
146  res = target_write_u32(target,
149  if (res != ERROR_OK) {
150  LOG_TARGET_ERROR(head->target, "Failed to unstall CPUs before SW reset!");
151  return res;
152  }
153  break; /* both cores are unstalled now, so exit the loop */
154  }
155  }
156  }
157 
158  LOG_DEBUG("Loading stub code into RTC RAM");
159  uint8_t slow_mem_save[sizeof(esp32_reset_stub_code)];
160 
161  /* Save contents of RTC_SLOW_MEM which we are about to overwrite */
162  res = target_read_buffer(target, ESP32_RTC_SLOW_MEM_BASE, sizeof(slow_mem_save), slow_mem_save);
163  if (res != ERROR_OK) {
164  LOG_ERROR("Failed to save contents of RTC_SLOW_MEM (%d)!", res);
165  return res;
166  }
167 
168  /* Write stub code into RTC_SLOW_MEM */
170  if (res != ERROR_OK) {
171  LOG_ERROR("Failed to write stub (%d)!", res);
172  return res;
173  }
174 
175  LOG_DEBUG("Resuming the target");
177  xtensa->suppress_dsr_errors = true;
178  res = xtensa_resume(target, false, ESP32_RTC_SLOW_MEM_BASE + 4, false,
179  false);
180  xtensa->suppress_dsr_errors = false;
181  if (res != ERROR_OK) {
182  LOG_ERROR("Failed to run stub (%d)!", res);
183  return res;
184  }
185  LOG_DEBUG("resume done, waiting for the target to come alive");
186 
187  /* Wait for SoC to reset */
188  alive_sleep(100);
189  int64_t timeout = timeval_ms() + 100;
190  bool get_timeout = false;
191  while (target->state != TARGET_RESET && target->state != TARGET_RUNNING) {
192  alive_sleep(10);
194  if (timeval_ms() >= timeout) {
195  LOG_TARGET_ERROR(target, "Timed out waiting for CPU to be reset, target state=%d",
196  target->state);
197  get_timeout = true;
198  break;
199  }
200  }
201 
202  /* Halt the CPU again */
203  LOG_DEBUG("halting the target");
205  res = target_wait_state(target, TARGET_HALTED, 1000);
206  if (res == ERROR_OK) {
207  LOG_DEBUG("restoring RTC_SLOW_MEM");
208  res = target_write_buffer(target, ESP32_RTC_SLOW_MEM_BASE, sizeof(slow_mem_save), slow_mem_save);
209  if (res != ERROR_OK)
210  LOG_TARGET_ERROR(target, "Failed to restore contents of RTC_SLOW_MEM (%d)!", res);
211  } else {
212  LOG_TARGET_ERROR(target, "Timed out waiting for CPU to be halted after SoC reset");
213  }
214 
215  return get_timeout ? ERROR_TARGET_TIMEOUT : res;
216 }
217 
218 static int esp32_disable_wdts(struct target *target)
219 {
220  /* TIMG1 WDT */
222  if (res != ERROR_OK) {
223  LOG_ERROR("Failed to write ESP32_TIMG0WDT_PROTECT (%d)!", res);
224  return res;
225  }
227  if (res != ERROR_OK) {
228  LOG_ERROR("Failed to write ESP32_TIMG0WDT_CFG0 (%d)!", res);
229  return res;
230  }
231  /* TIMG2 WDT */
233  if (res != ERROR_OK) {
234  LOG_ERROR("Failed to write ESP32_TIMG1WDT_PROTECT (%d)!", res);
235  return res;
236  }
238  if (res != ERROR_OK) {
239  LOG_ERROR("Failed to write ESP32_TIMG1WDT_CFG0 (%d)!", res);
240  return res;
241  }
242  /* RTC WDT */
244  if (res != ERROR_OK) {
245  LOG_ERROR("Failed to write ESP32_RTCWDT_PROTECT (%d)!", res);
246  return res;
247  }
249  if (res != ERROR_OK) {
250  LOG_ERROR("Failed to write ESP32_RTCWDT_CFG (%d)!", res);
251  return res;
252  }
253  return ERROR_OK;
254 }
255 
256 static int esp32_on_halt(struct target *target)
257 {
258  int ret = esp32_disable_wdts(target);
259  if (ret == ERROR_OK)
261  return ret;
262 }
263 
264 static int esp32_arch_state(struct target *target)
265 {
266  return ERROR_OK;
267 }
268 
269 static int esp32_virt2phys(struct target *target,
270  target_addr_t virtual, target_addr_t *physical)
271 {
272  if (physical) {
273  *physical = virtual;
274  return ERROR_OK;
275  }
276  return ERROR_FAIL;
277 }
278 
279 /* 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
280  * 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
281  * esp32 flashbootstrap command to set a level, and this routine will make sure the tdi line will return to
282  * that when the jtag port is idle. */
283 
284 static void esp32_queue_tdi_idle(struct target *target)
285 {
286  struct esp32_common *esp32 = target_to_esp32(target);
287  static uint32_t value;
288  uint8_t t[4] = { 0, 0, 0, 0 };
289 
290  if (esp32->flash_bootstrap == FBS_TMSLOW)
291  /* Make sure tdi is 0 at the exit of queue execution */
292  value = 0;
293  else if (esp32->flash_bootstrap == FBS_TMSHIGH)
294  /* Make sure tdi is 1 at the exit of queue execution */
295  value = 1;
296  else
297  return;
298 
299  /* Scan out 1 bit, do not move from IRPAUSE after we're done. */
300  buf_set_u32(t, 0, 1, value);
302 }
303 
304 static int esp32_target_init(struct command_context *cmd_ctx, struct target *target)
305 {
306  return esp_xtensa_smp_target_init(cmd_ctx, target);
307 }
308 
309 static const struct xtensa_debug_ops esp32_dbg_ops = {
311  .queue_reg_read = xtensa_dm_queue_reg_read,
312  .queue_reg_write = xtensa_dm_queue_reg_write
313 };
314 
315 static const struct xtensa_power_ops esp32_pwr_ops = {
317  .queue_reg_write = xtensa_dm_queue_pwr_reg_write
318 };
319 
320 static const struct esp_xtensa_smp_chip_ops esp32_chip_ops = {
322  .on_halt = esp32_on_halt
323 };
324 
325 static const struct esp_semihost_ops esp32_semihost_ops = {
327 };
328 
329 static int esp32_target_create(struct target *target, Jim_Interp *interp)
330 {
331  struct xtensa_debug_module_config esp32_dm_cfg = {
333  .pwr_ops = &esp32_pwr_ops,
334  .tap = target->tap,
335  .queue_tdi_idle = esp32_queue_tdi_idle,
336  .queue_tdi_idle_arg = target
337  };
338 
339  struct esp32_common *esp32 = calloc(1, sizeof(struct esp32_common));
340  if (!esp32) {
341  LOG_ERROR("Failed to alloc memory for arch info!");
342  return ERROR_FAIL;
343  }
344 
346  &esp32_dm_cfg, &esp32_chip_ops, &esp32_semihost_ops);
347  if (ret != ERROR_OK) {
348  LOG_ERROR("Failed to init arch info!");
349  free(esp32);
350  return ret;
351  }
352  esp32->flash_bootstrap = FBS_DONTCARE;
353 
354  /* Assume running target. If different, the first poll will fix this. */
357  return ERROR_OK;
358 }
359 
360 static COMMAND_HELPER(esp32_cmd_flashbootstrap_do, struct esp32_common *esp32)
361 {
362  int state = -1;
363 
364  if (CMD_ARGC < 1) {
365  const char *st;
366  state = esp32->flash_bootstrap;
367  if (state == FBS_DONTCARE)
368  st = "Don't care";
369  else if (state == FBS_TMSLOW)
370  st = "Low (3.3V)";
371  else if (state == FBS_TMSHIGH)
372  st = "High (1.8V)";
373  else
374  st = "None";
375  command_print(CMD, "Current idle tms state: %s", st);
376  return ERROR_OK;
377  }
378 
379  if (!strcasecmp(CMD_ARGV[0], "none"))
381  else if (!strcasecmp(CMD_ARGV[0], "1.8"))
382  state = FBS_TMSHIGH;
383  else if (!strcasecmp(CMD_ARGV[0], "3.3"))
384  state = FBS_TMSLOW;
385  else if (!strcasecmp(CMD_ARGV[0], "high"))
386  state = FBS_TMSHIGH;
387  else if (!strcasecmp(CMD_ARGV[0], "low"))
388  state = FBS_TMSLOW;
389 
390  if (state == -1) {
392  "Argument unknown. Please pick one of none, high, low, 1.8 or 3.3");
393  return ERROR_FAIL;
394  }
395  esp32->flash_bootstrap = state;
396  return ERROR_OK;
397 }
398 
399 COMMAND_HANDLER(esp32_cmd_flashbootstrap)
400 {
402 
403  if (target->smp) {
404  struct target_list *head;
405  struct target *curr;
407  curr = head->target;
408  int ret = CALL_COMMAND_HANDLER(esp32_cmd_flashbootstrap_do,
409  target_to_esp32(curr));
410  if (ret != ERROR_OK)
411  return ret;
412  }
413  return ERROR_OK;
414  }
415  return CALL_COMMAND_HANDLER(esp32_cmd_flashbootstrap_do,
417 }
418 
419 static const struct command_registration esp32_any_command_handlers[] = {
420  {
421  .name = "flashbootstrap",
422  .handler = esp32_cmd_flashbootstrap,
423  .mode = COMMAND_ANY,
424  .help =
425  "Set the idle state of the TMS pin, which at reset also is the voltage selector for the flash chip.",
426  .usage = "none|1.8|3.3|high|low",
427  },
429 };
430 
431 static const struct command_registration esp32_command_handlers[] = {
432  {
434  },
435  {
436  .name = "esp",
437  .usage = "",
439  },
440  {
441  .name = "esp32",
442  .usage = "",
443  .chain = smp_command_handlers,
444  },
445  {
446  .name = "esp32",
447  .usage = "",
449  },
450  {
451  .name = "arm",
452  .mode = COMMAND_ANY,
453  .help = "ARM Command Group",
454  .usage = "",
456  },
458 };
459 
461 struct target_type esp32_target = {
462  .name = "esp32",
463 
464  .poll = esp_xtensa_smp_poll,
465  .arch_state = esp32_arch_state,
466 
467  .halt = xtensa_halt,
468  .resume = esp_xtensa_smp_resume,
469  .step = esp_xtensa_smp_step,
470 
471  .assert_reset = esp_xtensa_smp_assert_reset,
472  .deassert_reset = esp_xtensa_smp_deassert_reset,
473  .soft_reset_halt = esp_xtensa_smp_soft_reset_halt,
474 
475  .virt2phys = esp32_virt2phys,
476  .mmu = xtensa_mmu_is_enabled,
477  .read_memory = xtensa_read_memory,
478  .write_memory = xtensa_write_memory,
479 
480  .read_buffer = xtensa_read_buffer,
481  .write_buffer = xtensa_write_buffer,
482 
483  .checksum_memory = xtensa_checksum_memory,
484 
485  .get_gdb_arch = xtensa_get_gdb_arch,
486  .get_gdb_reg_list = xtensa_get_gdb_reg_list,
487 
488  .run_algorithm = xtensa_run_algorithm,
489  .start_algorithm = xtensa_start_algorithm,
490  .wait_algorithm = xtensa_wait_algorithm,
491 
492  .add_breakpoint = esp_xtensa_breakpoint_add,
493  .remove_breakpoint = esp_xtensa_breakpoint_remove,
494 
495  .add_watchpoint = esp_xtensa_smp_watchpoint_add,
496  .remove_watchpoint = esp_xtensa_smp_watchpoint_remove,
497 
498  .target_create = esp32_target_create,
499  .init_target = esp32_target_init,
500  .examine = xtensa_examine,
501  .deinit_target = esp_xtensa_target_deinit,
502 
503  .commands = esp32_command_handlers,
504 };
static void buf_set_u32(uint8_t *_buffer, unsigned int first, unsigned int num, uint32_t value)
Sets num bits in _buffer, starting at the first bit, using the bits in value.
Definition: binarybuffer.h:34
void command_print(struct command_invocation *cmd, const char *format,...)
Definition: command.c:443
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
Definition: command.h:141
#define CALL_COMMAND_HANDLER(name, extra ...)
Use this to macro to call a command helper (or a nested handler).
Definition: command.h:118
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
Definition: command.h:156
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
Definition: command.h:151
#define CMD_CTX
Use this macro to access the context of the command being handled, rather than accessing the variable...
Definition: command.h:146
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:253
@ COMMAND_ANY
Definition: command.h:42
static const struct esp_xtensa_smp_chip_ops esp32_chip_ops
Definition: esp32.c:320
#define ESP32_TIMG0WDT_PROTECT
Definition: esp32.c:43
#define ESP32_TIMG0WDT_CFG0
Definition: esp32.c:41
static void esp32_queue_tdi_idle(struct target *target)
Definition: esp32.c:284
#define ESP32_TIMG1WDT_PROTECT
Definition: esp32.c:44
static const struct xtensa_debug_ops esp32_dbg_ops
Definition: esp32.c:309
static COMMAND_HELPER(esp32_cmd_flashbootstrap_do, struct esp32_common *esp32)
Definition: esp32.c:360
esp32_flash_bootstrap
Definition: esp32.c:62
@ FBS_TMSHIGH
Definition: esp32.c:65
@ FBS_TMSLOW
Definition: esp32.c:64
@ FBS_DONTCARE
Definition: esp32.c:63
static const struct command_registration esp32_any_command_handlers[]
Definition: esp32.c:419
static int esp32_virt2phys(struct target *target, target_addr_t virtual, target_addr_t *physical)
Definition: esp32.c:269
static int esp32_target_init(struct command_context *cmd_ctx, struct target *target)
Definition: esp32.c:304
static const struct command_registration esp32_command_handlers[]
Definition: esp32.c:431
static const struct esp_semihost_ops esp32_semihost_ops
Definition: esp32.c:325
#define ESP32_RTC_CNTL_SW_CPU_STALL_DEF
Definition: esp32.c:59
static const uint8_t esp32_reset_stub_code[]
Definition: esp32.c:92
#define ESP32_TIMG1WDT_CFG0
Definition: esp32.c:42
struct target_type esp32_target
Holds methods for Xtensa targets.
Definition: esp32.c:461
static int esp32_arch_state(struct target *target)
Definition: esp32.c:264
#define ESP32_WDT_WKEY_VALUE
Definition: esp32.c:36
#define ESP32_RTCWDT_CFG
Definition: esp32.c:48
static const struct xtensa_power_ops esp32_pwr_ops
Definition: esp32.c:315
static struct esp32_common * target_to_esp32(struct target *target)
Definition: esp32.c:73
static int esp32_on_halt(struct target *target)
Definition: esp32.c:256
#define ESP32_RTCWDT_PROTECT
Definition: esp32.c:49
static int esp32_disable_wdts(struct target *target)
Definition: esp32.c:218
static int esp32_soc_reset(struct target *target)
Definition: esp32.c:96
static int esp32_target_create(struct target *target, Jim_Interp *interp)
Definition: esp32.c:329
#define ESP32_RTC_SLOW_MEM_BASE
Definition: esp32.c:33
COMMAND_HANDLER(esp32_cmd_flashbootstrap)
Definition: esp32.c:399
#define ESP32_RTC_CNTL_SW_CPU_STALL_REG
Definition: esp32.c:58
const struct command_registration esp32_apptrace_command_handlers[]
void esp_xtensa_target_deinit(struct target *target)
Definition: esp_xtensa.c:87
int esp_xtensa_breakpoint_remove(struct target *target, struct breakpoint *breakpoint)
Definition: esp_xtensa.c:177
int esp_xtensa_breakpoint_add(struct target *target, struct breakpoint *breakpoint)
Definition: esp_xtensa.c:171
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_step(struct target *target, bool current, target_addr_t address, bool handle_breakpoints)
int esp_xtensa_smp_soft_reset_halt(struct target *target)
int esp_xtensa_smp_deassert_reset(struct target *target)
int esp_xtensa_smp_resume(struct target *target, bool current, target_addr_t address, bool handle_breakpoints, bool debug_execution)
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_on_halt(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)
void jtag_add_plain_ir_scan(int num_bits, const uint8_t *out_bits, uint8_t *in_bits, enum tap_state state)
Scan out the bits in ir scan mode.
Definition: jtag/core.c:398
@ TAP_IRPAUSE
Definition: jtag.h:52
void alive_sleep(uint64_t ms)
Definition: log.c:467
#define ERROR_FAIL
Definition: log.h:174
#define LOG_TARGET_ERROR(target, fmt_str,...)
Definition: log.h:162
#define LOG_TARGET_DEBUG(target, fmt_str,...)
Definition: log.h:150
#define LOG_ERROR(expr ...)
Definition: log.h:133
#define LOG_DEBUG(expr ...)
Definition: log.h:110
#define ERROR_OK
Definition: log.h:168
const struct command_registration semihosting_common_handlers[]
const struct command_registration smp_command_handlers[]
Definition: smp.c:153
#define foreach_smp_target(pos, head)
Definition: smp.h:15
const char * name
Definition: command.h:235
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:249
struct esp_xtensa_smp_common esp_xtensa_smp
Definition: esp32.c:69
enum esp32_flash_bootstrap flash_bootstrap
Definition: esp32.c:70
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:214
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:116
struct jtag_tap * tap
Definition: target.h:119
enum target_debug_reason debug_reason
Definition: target.h:154
enum target_state state
Definition: target.h:157
struct list_head * smp_targets
Definition: target.h:188
unsigned int smp
Definition: target.h:187
void * arch_info
Definition: target.h:164
bool reset_halt
Definition: target.h:144
Definition: psoc6.c:83
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:242
struct xtensa_debug_module dbg_mod
Definition: xtensa.h:246
bool suppress_dsr_errors
Definition: xtensa.h:272
int target_write_buffer(struct target *target, target_addr_t address, uint32_t size, const uint8_t *buffer)
Definition: target.c:2343
int target_read_buffer(struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
Definition: target.c:2408
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
Definition: target.c:2642
int target_wait_state(struct target *target, enum target_state state, unsigned int ms)
Definition: target.c:3215
struct target * get_current_target(struct command_context *cmd_ctx)
Definition: target.c:458
@ DBG_REASON_NOTHALTED
Definition: target.h:74
@ TARGET_RESET
Definition: target.h:57
@ TARGET_HALTED
Definition: target.h:56
@ TARGET_RUNNING
Definition: target.h:55
#define ERROR_TARGET_TIMEOUT
Definition: target.h:789
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(const struct target *target)
Definition: xtensa.c:3531
int xtensa_poll(struct target *target)
Definition: xtensa.c:2317
int xtensa_halt(struct target *target)
Definition: xtensa.c:1566
int xtensa_read_buffer(struct target *target, target_addr_t address, uint32_t count, uint8_t *buffer)
Definition: xtensa.c:2094
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:1489
int xtensa_checksum_memory(struct target *target, target_addr_t address, uint32_t count, uint32_t *checksum)
Definition: xtensa.c:2311
int xtensa_examine(struct target *target)
Definition: xtensa.c:886
int xtensa_start_algorithm(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, target_addr_t entry_point, target_addr_t exit_point, void *arch_info)
Definition: xtensa.c:2725
int xtensa_write_buffer(struct target *target, target_addr_t address, uint32_t count, const uint8_t *buffer)
Definition: xtensa.c:2305
int xtensa_write_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
Definition: xtensa.c:2100
int xtensa_mmu_is_enabled(struct target *target, int *enabled)
Definition: xtensa.c:1558
int xtensa_deassert_reset(struct target *target)
Definition: xtensa.c:1182
int xtensa_read_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
Definition: xtensa.c:2011
int xtensa_assert_reset(struct target *target)
Definition: xtensa.c:1161
int xtensa_run_algorithm(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, target_addr_t entry_point, target_addr_t exit_point, unsigned int timeout_ms, void *arch_info)
Definition: xtensa.c:2924
int xtensa_resume(struct target *target, bool current, target_addr_t address, bool handle_breakpoints, bool debug_execution)
Definition: xtensa.c:1673
int xtensa_wait_algorithm(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, target_addr_t exit_point, unsigned int timeout_ms, void *arch_info)
Waits for an algorithm in the target.
Definition: xtensa.c:2816
static struct xtensa * target_to_xtensa(struct target *target)
Definition: xtensa.h:291
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)