27 #define ESP32_S3_RTC_DATA_LOW 0x50000000
28 #define ESP32_S3_RTC_DATA_HIGH 0x50002000
29 #define ESP32_S3_EXTRAM_DATA_LOW 0x3D000000
30 #define ESP32_S3_EXTRAM_DATA_HIGH 0x3E000000
31 #define ESP32_S3_SYS_RAM_LOW 0x60000000UL
32 #define ESP32_S3_SYS_RAM_HIGH (ESP32_S3_SYS_RAM_LOW + 0x10000000UL)
33 #define ESP32_S3_RTC_SLOW_MEM_BASE ESP32_S3_RTC_DATA_LOW
36 #define ESP32_S3_WDT_WKEY_VALUE 0x50D83AA1
37 #define ESP32_S3_TIMG0_BASE 0x6001F000
38 #define ESP32_S3_TIMG1_BASE 0x60020000
39 #define ESP32_S3_TIMGWDT_CFG0_OFF 0x48
40 #define ESP32_S3_TIMGWDT_PROTECT_OFF 0x64
41 #define ESP32_S3_TIMG0WDT_CFG0 (ESP32_S3_TIMG0_BASE + ESP32_S3_TIMGWDT_CFG0_OFF)
42 #define ESP32_S3_TIMG1WDT_CFG0 (ESP32_S3_TIMG1_BASE + ESP32_S3_TIMGWDT_CFG0_OFF)
43 #define ESP32_S3_TIMG0WDT_PROTECT (ESP32_S3_TIMG0_BASE + ESP32_S3_TIMGWDT_PROTECT_OFF)
44 #define ESP32_S3_TIMG1WDT_PROTECT (ESP32_S3_TIMG1_BASE + ESP32_S3_TIMGWDT_PROTECT_OFF)
45 #define ESP32_S3_RTCCNTL_BASE 0x60008000
46 #define ESP32_S3_RTCWDT_CFG_OFF 0x98
47 #define ESP32_S3_RTCWDT_PROTECT_OFF 0xB0
48 #define ESP32_S3_SWD_CONF_OFF 0xB0
49 #define ESP32_S3_SWD_WPROTECT_OFF 0xB4
50 #define ESP32_S3_RTCWDT_CFG (ESP32_S3_RTCCNTL_BASE + ESP32_S3_RTCWDT_CFG_OFF)
51 #define ESP32_S3_RTCWDT_PROTECT (ESP32_S3_RTCCNTL_BASE + ESP32_S3_RTCWDT_PROTECT_OFF)
52 #define ESP32_S3_SWD_CONF_REG (ESP32_S3_RTCCNTL_BASE + ESP32_S3_SWD_CONF_OFF)
53 #define ESP32_S3_SWD_WPROTECT_REG (ESP32_S3_RTCCNTL_BASE + ESP32_S3_SWD_WPROTECT_OFF)
54 #define ESP32_S3_SWD_AUTO_FEED_EN_M BIT(31)
55 #define ESP32_S3_SWD_WKEY_VALUE 0x8F1D312AU
57 #define ESP32_S3_TRACEMEM_BLOCK_SZ 0x4000
60 #define ESP32_S3_DR_REG_SYSTEM_BASE 0x600c0000
61 #define ESP32_S3_SYSTEM_CORE_1_CONTROL_0_REG (ESP32_S3_DR_REG_SYSTEM_BASE + 0x014)
62 #define ESP32_S3_SYSTEM_CONTROL_CORE_1_CLKGATE_EN BIT(1)
65 #define ESP32_S3_RTC_CNTL_SW_CPU_STALL_REG (ESP32_S3_RTCCNTL_BASE + 0xBC)
66 #define ESP32_S3_RTC_CNTL_SW_CPU_STALL_DEF 0x0
90 #include "../../../contrib/loaders/reset/espressif/esp32s3/cpu_reset_handler_code.inc"
102 LOG_DEBUG(
"Target not halted before SoC reset, trying to halt it first");
106 LOG_DEBUG(
"Couldn't halt target before SoC reset, trying to do reset-halt");
110 "Couldn't halt target before SoC reset! (xtensa_assert_reset returned %d)",
122 "Couldn't halt target before SoC reset! (xtensa_deassert_reset returned %d)",
131 LOG_ERROR(
"Couldn't halt target before SoC reset");
155 LOG_DEBUG(
"Loading stub code into RTC RAM");
161 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;
195 "Timed out waiting for CPU to be reset, target state=%d",
223 LOG_ERROR(
"Failed to write ESP32_S3_TIMG0WDT_PROTECT (%d)!", res);
228 LOG_ERROR(
"Failed to write ESP32_S3_TIMG0WDT_CFG0 (%d)!", res);
234 LOG_ERROR(
"Failed to write ESP32_S3_TIMG1WDT_PROTECT (%d)!", res);
239 LOG_ERROR(
"Failed to write ESP32_S3_TIMG1WDT_CFG0 (%d)!", res);
245 LOG_ERROR(
"Failed to write ESP32_S3_RTCWDT_PROTECT (%d)!", res);
250 LOG_ERROR(
"Failed to write ESP32_S3_RTCWDT_CFG (%d)!", res);
256 LOG_ERROR(
"Failed to write ESP32_S3_SWD_WPROTECT_REG (%d)!", res);
259 uint32_t swd_conf_reg = 0;
262 LOG_ERROR(
"Failed to read ESP32_S3_SWD_CONF_REG (%d)!", res);
268 LOG_ERROR(
"Failed to write ESP32_S3_SWD_CONF_REG (%d)!", res);
328 .queue_tdi_idle =
NULL,
329 .queue_tdi_idle_arg =
NULL
334 LOG_ERROR(
"Failed to alloc memory for arch info!");
373 .help =
"ARM Command Group",
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
const struct command_registration esp32_apptrace_command_handlers[]
static int esp32s3_target_init(struct command_context *cmd_ctx, struct target *target)
#define ESP32_S3_SWD_CONF_REG
struct target_type esp32s3_target
Holds methods for Xtensa targets.
static const struct esp_semihost_ops esp32s3_semihost_ops
static int esp32s3_soc_reset(struct target *target)
static const struct xtensa_debug_ops esp32s3_dbg_ops
#define ESP32_S3_SWD_AUTO_FEED_EN_M
static int esp32s3_target_create(struct target *target, Jim_Interp *interp)
#define ESP32_S3_WDT_WKEY_VALUE
#define ESP32_S3_RTC_CNTL_SW_CPU_STALL_DEF
static const struct xtensa_power_ops esp32s3_pwr_ops
#define ESP32_S3_SWD_WKEY_VALUE
#define ESP32_S3_RTC_CNTL_SW_CPU_STALL_REG
#define ESP32_S3_RTC_SLOW_MEM_BASE
#define ESP32_S3_SWD_WPROTECT_REG
static int esp32s3_virt2phys(struct target *target, target_addr_t virtual, target_addr_t *physical)
#define ESP32_S3_TIMG0WDT_PROTECT
static const struct command_registration esp32s3_command_handlers[]
#define ESP32_S3_RTCWDT_PROTECT
static const uint8_t esp32s3_reset_stub_code[]
static int esp32s3_disable_wdts(struct target *target)
#define ESP32_S3_TIMG1WDT_CFG0
#define ESP32_S3_RTCWDT_CFG
#define ESP32_S3_TIMG1WDT_PROTECT
static int esp32s3_on_halt(struct target *target)
#define ESP32_S3_TIMG0WDT_CFG0
static int esp32s3_arch_state(struct target *target)
static const struct esp_xtensa_smp_chip_ops esp32s3_chip_ops
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_profiling(struct target *target, uint32_t *samples, uint32_t max_num_samples, uint32_t *num_samples, uint32_t seconds)
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 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 char * usage
a string listing the options and arguments, required or optional
struct esp_xtensa_smp_common esp_xtensa_smp
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_read_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)
#define ERROR_TARGET_TIMEOUT
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)