27 #define ESP32_S3_IRAM_LOW 0x40370000
28 #define ESP32_S3_IRAM_HIGH 0x403E0000
29 #define ESP32_S3_IROM_MASK_LOW 0x40000000
30 #define ESP32_S3_IROM_MASK_HIGH 0x40060000
31 #define ESP32_S3_DRAM_LOW 0x3FC88000
32 #define ESP32_S3_DRAM_HIGH 0x3FD00000
33 #define ESP32_S3_RTC_IRAM_LOW 0x600FE000
34 #define ESP32_S3_RTC_IRAM_HIGH 0x60100000
35 #define ESP32_S3_RTC_DRAM_LOW 0x600FE000
36 #define ESP32_S3_RTC_DRAM_HIGH 0x60100000
37 #define ESP32_S3_RTC_DATA_LOW 0x50000000
38 #define ESP32_S3_RTC_DATA_HIGH 0x50002000
39 #define ESP32_S3_EXTRAM_DATA_LOW 0x3D000000
40 #define ESP32_S3_EXTRAM_DATA_HIGH 0x3E000000
41 #define ESP32_S3_SYS_RAM_LOW 0x60000000UL
42 #define ESP32_S3_SYS_RAM_HIGH (ESP32_S3_SYS_RAM_LOW + 0x10000000UL)
43 #define ESP32_S3_RTC_SLOW_MEM_BASE ESP32_S3_RTC_DATA_LOW
46 #define ESP32_S3_WDT_WKEY_VALUE 0x50D83AA1
47 #define ESP32_S3_TIMG0_BASE 0x6001F000
48 #define ESP32_S3_TIMG1_BASE 0x60020000
49 #define ESP32_S3_TIMGWDT_CFG0_OFF 0x48
50 #define ESP32_S3_TIMGWDT_PROTECT_OFF 0x64
51 #define ESP32_S3_TIMG0WDT_CFG0 (ESP32_S3_TIMG0_BASE + ESP32_S3_TIMGWDT_CFG0_OFF)
52 #define ESP32_S3_TIMG1WDT_CFG0 (ESP32_S3_TIMG1_BASE + ESP32_S3_TIMGWDT_CFG0_OFF)
53 #define ESP32_S3_TIMG0WDT_PROTECT (ESP32_S3_TIMG0_BASE + ESP32_S3_TIMGWDT_PROTECT_OFF)
54 #define ESP32_S3_TIMG1WDT_PROTECT (ESP32_S3_TIMG1_BASE + ESP32_S3_TIMGWDT_PROTECT_OFF)
55 #define ESP32_S3_RTCCNTL_BASE 0x60008000
56 #define ESP32_S3_RTCWDT_CFG_OFF 0x98
57 #define ESP32_S3_RTCWDT_PROTECT_OFF 0xB0
58 #define ESP32_S3_SWD_CONF_OFF 0xB0
59 #define ESP32_S3_SWD_WPROTECT_OFF 0xB4
60 #define ESP32_S3_RTCWDT_CFG (ESP32_S3_RTCCNTL_BASE + ESP32_S3_RTCWDT_CFG_OFF)
61 #define ESP32_S3_RTCWDT_PROTECT (ESP32_S3_RTCCNTL_BASE + ESP32_S3_RTCWDT_PROTECT_OFF)
62 #define ESP32_S3_SWD_CONF_REG (ESP32_S3_RTCCNTL_BASE + ESP32_S3_SWD_CONF_OFF)
63 #define ESP32_S3_SWD_WPROTECT_REG (ESP32_S3_RTCCNTL_BASE + ESP32_S3_SWD_WPROTECT_OFF)
64 #define ESP32_S3_SWD_AUTO_FEED_EN_M BIT(31)
65 #define ESP32_S3_SWD_WKEY_VALUE 0x8F1D312AU
67 #define ESP32_S3_TRACEMEM_BLOCK_SZ 0x4000
70 #define ESP32_S3_DR_REG_SYSTEM_BASE 0x600c0000
71 #define ESP32_S3_SYSTEM_CORE_1_CONTROL_0_REG (ESP32_S3_DR_REG_SYSTEM_BASE + 0x014)
72 #define ESP32_S3_SYSTEM_CONTROL_CORE_1_CLKGATE_EN BIT(1)
75 #define ESP32_S3_RTC_CNTL_SW_CPU_STALL_REG (ESP32_S3_RTCCNTL_BASE + 0xBC)
76 #define ESP32_S3_RTC_CNTL_SW_CPU_STALL_DEF 0x0
100 #include "../../../contrib/loaders/reset/espressif/esp32s3/cpu_reset_handler_code.inc"
112 LOG_DEBUG(
"Target not halted before SoC reset, trying to halt it first");
116 LOG_DEBUG(
"Couldn't halt target before SoC reset, trying to do reset-halt");
120 "Couldn't halt target before SoC reset! (xtensa_assert_reset returned %d)",
132 "Couldn't halt target before SoC reset! (xtensa_deassert_reset returned %d)",
141 LOG_ERROR(
"Couldn't halt target before SoC reset");
165 LOG_DEBUG(
"Loading stub code into RTC RAM");
171 LOG_ERROR(
"Failed to save contents of RTC_SLOW_MEM (%d)!", res);
181 LOG_ERROR(
"Failed to write stub (%d)!", res);
191 LOG_ERROR(
"Failed to run stub (%d)!", res);
194 LOG_DEBUG(
"resume done, waiting for the target to come alive");
199 bool get_timeout =
false;
205 "Timed out waiting for CPU to be reset, target state=%d",
233 LOG_ERROR(
"Failed to write ESP32_S3_TIMG0WDT_PROTECT (%d)!", res);
238 LOG_ERROR(
"Failed to write ESP32_S3_TIMG0WDT_CFG0 (%d)!", res);
244 LOG_ERROR(
"Failed to write ESP32_S3_TIMG1WDT_PROTECT (%d)!", res);
249 LOG_ERROR(
"Failed to write ESP32_S3_TIMG1WDT_CFG0 (%d)!", res);
255 LOG_ERROR(
"Failed to write ESP32_S3_RTCWDT_PROTECT (%d)!", res);
260 LOG_ERROR(
"Failed to write ESP32_S3_RTCWDT_CFG (%d)!", res);
266 LOG_ERROR(
"Failed to write ESP32_S3_SWD_WPROTECT_REG (%d)!", res);
269 uint32_t swd_conf_reg = 0;
272 LOG_ERROR(
"Failed to read ESP32_S3_SWD_CONF_REG (%d)!", res);
278 LOG_ERROR(
"Failed to write ESP32_S3_SWD_CONF_REG (%d)!", res);
335 .queue_tdi_idle =
NULL,
336 .queue_tdi_idle_arg =
NULL
341 LOG_ERROR(
"Failed to alloc memory for arch info!");
375 .help =
"ARM Command Group",
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
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_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 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, int ms)
#define ERROR_TARGET_TIMEOUT
const char * xtensa_get_gdb_arch(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_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)
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)