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
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)
51 #define ESP32_TRACEMEM_BLOCK_SZ 0x4000
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)
58 #define ESP32_RTC_CNTL_SW_CPU_STALL_REG (ESP32_RTCCNTL_BASE + 0xac)
59 #define ESP32_RTC_CNTL_SW_CPU_STALL_DEF 0x0
93 #include "../../../contrib/loaders/reset/espressif/esp32/cpu_reset_handler_code.inc"
105 LOG_DEBUG(
"Target not halted before SoC reset, trying to halt it first");
109 LOG_DEBUG(
"Couldn't halt target before SoC reset, trying to do reset-halt");
113 "Couldn't halt target before SoC reset! (xtensa_assert_reset returned %d)",
125 "Couldn't halt target before SoC reset! (xtensa_deassert_reset returned %d)",
134 LOG_ERROR(
"Couldn't halt target before SoC reset");
158 LOG_DEBUG(
"Loading stub code into RTC RAM");
164 LOG_ERROR(
"Failed to save contents of RTC_SLOW_MEM (%d)!", res);
171 LOG_ERROR(
"Failed to write stub (%d)!", res);
181 LOG_ERROR(
"Failed to run stub (%d)!", res);
184 LOG_DEBUG(
"resume done, waiting for the target to come alive");
189 bool get_timeout =
false;
222 LOG_ERROR(
"Failed to write ESP32_TIMG0WDT_PROTECT (%d)!", res);
227 LOG_ERROR(
"Failed to write ESP32_TIMG0WDT_CFG0 (%d)!", res);
233 LOG_ERROR(
"Failed to write ESP32_TIMG1WDT_PROTECT (%d)!", res);
238 LOG_ERROR(
"Failed to write ESP32_TIMG1WDT_CFG0 (%d)!", res);
244 LOG_ERROR(
"Failed to write ESP32_RTCWDT_PROTECT (%d)!", res);
249 LOG_ERROR(
"Failed to write ESP32_RTCWDT_CFG (%d)!", res);
286 static uint32_t value;
287 uint8_t t[4] = { 0, 0, 0, 0 };
335 .queue_tdi_idle_arg =
target
340 LOG_ERROR(
"Failed to alloc memory for arch info!");
378 if (!strcasecmp(
CMD_ARGV[0],
"none"))
380 else if (!strcasecmp(
CMD_ARGV[0],
"1.8"))
382 else if (!strcasecmp(
CMD_ARGV[0],
"3.3"))
384 else if (!strcasecmp(
CMD_ARGV[0],
"high"))
386 else if (!strcasecmp(
CMD_ARGV[0],
"low"))
391 "Argument unknown. Please pick one of none, high, low, 1.8 or 3.3");
420 .
name =
"flashbootstrap",
421 .handler = esp32_cmd_flashbootstrap,
424 "Set the idle state of the TMS pin, which at reset also is the voltage selector for the flash chip.",
425 .usage =
"none|1.8|3.3|high|low",
452 .help =
"ARM Command Group",
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.
void command_print(struct command_invocation *cmd, const char *format,...)
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
#define CALL_COMMAND_HANDLER(name, extra ...)
Use this to macro to call a command helper (or a nested handler).
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
#define CMD_CTX
Use this macro to access the context of the command being handled, rather than accessing the variable...
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
static const struct esp_xtensa_smp_chip_ops esp32_chip_ops
#define ESP32_TIMG0WDT_PROTECT
#define ESP32_TIMG0WDT_CFG0
static void esp32_queue_tdi_idle(struct target *target)
#define ESP32_TIMG1WDT_PROTECT
static const struct xtensa_debug_ops esp32_dbg_ops
static COMMAND_HELPER(esp32_cmd_flashbootstrap_do, struct esp32_common *esp32)
static const struct command_registration esp32_any_command_handlers[]
static int esp32_virt2phys(struct target *target, target_addr_t virtual, target_addr_t *physical)
static int esp32_target_init(struct command_context *cmd_ctx, struct target *target)
static const struct command_registration esp32_command_handlers[]
static const struct esp_semihost_ops esp32_semihost_ops
#define ESP32_RTC_CNTL_SW_CPU_STALL_DEF
static const uint8_t esp32_reset_stub_code[]
#define ESP32_TIMG1WDT_CFG0
struct target_type esp32_target
Holds methods for Xtensa targets.
static int esp32_arch_state(struct target *target)
#define ESP32_WDT_WKEY_VALUE
static const struct xtensa_power_ops esp32_pwr_ops
static struct esp32_common * target_to_esp32(struct target *target)
static int esp32_on_halt(struct target *target)
#define ESP32_RTCWDT_PROTECT
static int esp32_disable_wdts(struct target *target)
static int esp32_soc_reset(struct target *target)
static int esp32_target_create(struct target *target, Jim_Interp *interp)
#define ESP32_RTC_SLOW_MEM_BASE
COMMAND_HANDLER(esp32_cmd_flashbootstrap)
#define ESP32_RTC_CNTL_SW_CPU_STALL_REG
const struct command_registration esp32_apptrace_command_handlers[]
void esp_xtensa_target_deinit(struct target *target)
int esp_xtensa_breakpoint_remove(struct target *target, struct breakpoint *breakpoint)
int esp_xtensa_breakpoint_add(struct target *target, struct breakpoint *breakpoint)
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_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)
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.
void alive_sleep(uint64_t ms)
#define LOG_TARGET_ERROR(target, fmt_str,...)
#define LOG_TARGET_DEBUG(target, fmt_str,...)
#define LOG_ERROR(expr ...)
#define LOG_DEBUG(expr ...)
const struct command_registration semihosting_common_handlers[]
const struct command_registration smp_command_handlers[]
#define foreach_smp_target(pos, head)
const struct command_registration * chain
If non-NULL, the commands in chain will be registered in the same context and scope of this registrat...
struct esp_xtensa_smp_common esp_xtensa_smp
enum esp32_flash_bootstrap flash_bootstrap
Semihost calls handling operations.
int(* prepare)(struct target *target)
Callback called before handling semihost call.
int(* reset)(struct target *target)
This holds methods shared between all instances of a given target type.
const char * name
Name of this type of target.
enum target_debug_reason debug_reason
struct list_head * smp_targets
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.
struct xtensa_debug_module dbg_mod
int target_write_buffer(struct target *target, target_addr_t address, uint32_t size, const uint8_t *buffer)
int target_read_buffer(struct target *target, target_addr_t address, uint32_t size, uint8_t *buffer)
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
int target_wait_state(struct target *target, enum target_state state, unsigned int ms)
struct target * get_current_target(struct command_context *cmd_ctx)
#define ERROR_TARGET_TIMEOUT
#define container_of(ptr, type, member)
Cast a member of a structure out to the containing structure.
const char * xtensa_get_gdb_arch(const struct target *target)
int xtensa_poll(struct target *target)
int xtensa_halt(struct target *target)
int xtensa_read_buffer(struct target *target, target_addr_t address, uint32_t count, uint8_t *buffer)
int xtensa_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class)
int xtensa_checksum_memory(struct target *target, target_addr_t address, uint32_t count, uint32_t *checksum)
int xtensa_examine(struct target *target)
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)
int xtensa_resume(struct target *target, int current, target_addr_t address, int handle_breakpoints, int debug_execution)
int xtensa_write_buffer(struct target *target, target_addr_t address, uint32_t count, const uint8_t *buffer)
int xtensa_write_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
int xtensa_mmu_is_enabled(struct target *target, int *enabled)
int xtensa_deassert_reset(struct target *target)
int xtensa_read_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
int xtensa_assert_reset(struct target *target)
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)
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.
static struct xtensa * target_to_xtensa(struct target *target)
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)