OpenOCD
esp32.c File Reference
Include dependency graph for esp32.c:

Go to the source code of this file.

Data Structures

struct  esp32_common
 

Macros

#define ESP32_DPORT_APPCPU_CLKGATE_EN   BIT(0)
 
#define ESP32_DPORT_APPCPU_CTRL_B_REG   (ESP32_DR_REG_DPORT_BASE + 0x030)
 
#define ESP32_DR_REG_DPORT_BASE   ESP32_DR_REG_LOW
 
#define ESP32_DR_REG_HIGH   0x3ff71000
 
#define ESP32_DR_REG_LOW   0x3ff00000
 
#define ESP32_RTC_CNTL_SW_CPU_STALL_DEF   0x0
 
#define ESP32_RTC_CNTL_SW_CPU_STALL_REG   (ESP32_RTCCNTL_BASE + 0xac)
 
#define ESP32_RTC_DATA_HIGH   0x50002000
 
#define ESP32_RTC_DATA_LOW   0x50000000
 
#define ESP32_RTC_SLOW_MEM_BASE   ESP32_RTC_DATA_LOW
 
#define ESP32_RTCCNTL_BASE   0x3ff48000
 
#define ESP32_RTCWDT_CFG   (ESP32_RTCCNTL_BASE + ESP32_RTCWDT_CFG_OFF)
 
#define ESP32_RTCWDT_CFG_OFF   0x8C
 
#define ESP32_RTCWDT_PROTECT   (ESP32_RTCCNTL_BASE + ESP32_RTCWDT_PROTECT_OFF)
 
#define ESP32_RTCWDT_PROTECT_OFF   0xA4
 
#define ESP32_SYS_RAM_HIGH   (ESP32_SYS_RAM_LOW + 0x20000000UL)
 
#define ESP32_SYS_RAM_LOW   0x60000000UL
 
#define ESP32_TIMG0_BASE   0x3ff5f000
 
#define ESP32_TIMG0WDT_CFG0   (ESP32_TIMG0_BASE + ESP32_TIMGWDT_CFG0_OFF)
 
#define ESP32_TIMG0WDT_PROTECT   (ESP32_TIMG0_BASE + ESP32_TIMGWDT_PROTECT_OFF)
 
#define ESP32_TIMG1_BASE   0x3ff60000
 
#define ESP32_TIMG1WDT_CFG0   (ESP32_TIMG1_BASE + ESP32_TIMGWDT_CFG0_OFF)
 
#define ESP32_TIMG1WDT_PROTECT   (ESP32_TIMG1_BASE + ESP32_TIMGWDT_PROTECT_OFF)
 
#define ESP32_TIMGWDT_CFG0_OFF   0x48
 
#define ESP32_TIMGWDT_PROTECT_OFF   0x64
 
#define ESP32_TRACEMEM_BLOCK_SZ   0x4000
 
#define ESP32_WDT_WKEY_VALUE   0x50d83aa1
 

Enumerations

enum  esp32_flash_bootstrap { FBS_DONTCARE = 0 , FBS_TMSLOW , FBS_TMSHIGH }
 

Functions

 COMMAND_HANDLER (esp32_cmd_flashbootstrap)
 
static COMMAND_HELPER (esp32_cmd_flashbootstrap_do, struct esp32_common *esp32)
 
static int esp32_arch_state (struct target *target)
 
static int esp32_disable_wdts (struct target *target)
 
static int esp32_on_halt (struct target *target)
 
static void esp32_queue_tdi_idle (struct target *target)
 
static int esp32_soc_reset (struct target *target)
 
static int esp32_target_create (struct target *target, Jim_Interp *interp)
 
static int esp32_target_init (struct command_context *cmd_ctx, struct target *target)
 
static int esp32_virt2phys (struct target *target, target_addr_t virtual, target_addr_t *physical)
 
static struct esp32_commontarget_to_esp32 (struct target *target)
 

Variables

static const struct command_registration esp32_any_command_handlers []
 
static const struct esp_xtensa_smp_chip_ops esp32_chip_ops
 
static const struct command_registration esp32_command_handlers []
 
static const struct xtensa_debug_ops esp32_dbg_ops
 
static const struct xtensa_power_ops esp32_pwr_ops
 
static const uint8_t esp32_reset_stub_code []
 
static const struct esp_semihost_ops esp32_semihost_ops
 
struct target_type esp32_target
 Holds methods for Xtensa targets. More...
 

Macro Definition Documentation

◆ ESP32_DPORT_APPCPU_CLKGATE_EN

#define ESP32_DPORT_APPCPU_CLKGATE_EN   BIT(0)

Definition at line 56 of file esp32.c.

◆ ESP32_DPORT_APPCPU_CTRL_B_REG

#define ESP32_DPORT_APPCPU_CTRL_B_REG   (ESP32_DR_REG_DPORT_BASE + 0x030)

Definition at line 55 of file esp32.c.

◆ ESP32_DR_REG_DPORT_BASE

#define ESP32_DR_REG_DPORT_BASE   ESP32_DR_REG_LOW

Definition at line 54 of file esp32.c.

◆ ESP32_DR_REG_HIGH

#define ESP32_DR_REG_HIGH   0x3ff71000

Definition at line 30 of file esp32.c.

◆ ESP32_DR_REG_LOW

#define ESP32_DR_REG_LOW   0x3ff00000

Definition at line 29 of file esp32.c.

◆ ESP32_RTC_CNTL_SW_CPU_STALL_DEF

#define ESP32_RTC_CNTL_SW_CPU_STALL_DEF   0x0

Definition at line 59 of file esp32.c.

◆ ESP32_RTC_CNTL_SW_CPU_STALL_REG

#define ESP32_RTC_CNTL_SW_CPU_STALL_REG   (ESP32_RTCCNTL_BASE + 0xac)

Definition at line 58 of file esp32.c.

◆ ESP32_RTC_DATA_HIGH

#define ESP32_RTC_DATA_HIGH   0x50002000

Definition at line 28 of file esp32.c.

◆ ESP32_RTC_DATA_LOW

#define ESP32_RTC_DATA_LOW   0x50000000

Definition at line 27 of file esp32.c.

◆ ESP32_RTC_SLOW_MEM_BASE

#define ESP32_RTC_SLOW_MEM_BASE   ESP32_RTC_DATA_LOW

Definition at line 33 of file esp32.c.

◆ ESP32_RTCCNTL_BASE

#define ESP32_RTCCNTL_BASE   0x3ff48000

Definition at line 45 of file esp32.c.

◆ ESP32_RTCWDT_CFG

#define ESP32_RTCWDT_CFG   (ESP32_RTCCNTL_BASE + ESP32_RTCWDT_CFG_OFF)

Definition at line 48 of file esp32.c.

◆ ESP32_RTCWDT_CFG_OFF

#define ESP32_RTCWDT_CFG_OFF   0x8C

Definition at line 46 of file esp32.c.

◆ ESP32_RTCWDT_PROTECT

#define ESP32_RTCWDT_PROTECT   (ESP32_RTCCNTL_BASE + ESP32_RTCWDT_PROTECT_OFF)

Definition at line 49 of file esp32.c.

◆ ESP32_RTCWDT_PROTECT_OFF

#define ESP32_RTCWDT_PROTECT_OFF   0xA4

Definition at line 47 of file esp32.c.

◆ ESP32_SYS_RAM_HIGH

#define ESP32_SYS_RAM_HIGH   (ESP32_SYS_RAM_LOW + 0x20000000UL)

Definition at line 32 of file esp32.c.

◆ ESP32_SYS_RAM_LOW

#define ESP32_SYS_RAM_LOW   0x60000000UL

Definition at line 31 of file esp32.c.

◆ ESP32_TIMG0_BASE

#define ESP32_TIMG0_BASE   0x3ff5f000

Definition at line 37 of file esp32.c.

◆ ESP32_TIMG0WDT_CFG0

#define ESP32_TIMG0WDT_CFG0   (ESP32_TIMG0_BASE + ESP32_TIMGWDT_CFG0_OFF)

Definition at line 41 of file esp32.c.

◆ ESP32_TIMG0WDT_PROTECT

#define ESP32_TIMG0WDT_PROTECT   (ESP32_TIMG0_BASE + ESP32_TIMGWDT_PROTECT_OFF)

Definition at line 43 of file esp32.c.

◆ ESP32_TIMG1_BASE

#define ESP32_TIMG1_BASE   0x3ff60000

Definition at line 38 of file esp32.c.

◆ ESP32_TIMG1WDT_CFG0

#define ESP32_TIMG1WDT_CFG0   (ESP32_TIMG1_BASE + ESP32_TIMGWDT_CFG0_OFF)

Definition at line 42 of file esp32.c.

◆ ESP32_TIMG1WDT_PROTECT

#define ESP32_TIMG1WDT_PROTECT   (ESP32_TIMG1_BASE + ESP32_TIMGWDT_PROTECT_OFF)

Definition at line 44 of file esp32.c.

◆ ESP32_TIMGWDT_CFG0_OFF

#define ESP32_TIMGWDT_CFG0_OFF   0x48

Definition at line 39 of file esp32.c.

◆ ESP32_TIMGWDT_PROTECT_OFF

#define ESP32_TIMGWDT_PROTECT_OFF   0x64

Definition at line 40 of file esp32.c.

◆ ESP32_TRACEMEM_BLOCK_SZ

#define ESP32_TRACEMEM_BLOCK_SZ   0x4000

Definition at line 51 of file esp32.c.

◆ ESP32_WDT_WKEY_VALUE

#define ESP32_WDT_WKEY_VALUE   0x50d83aa1

Definition at line 36 of file esp32.c.

Enumeration Type Documentation

◆ esp32_flash_bootstrap

Enumerator
FBS_DONTCARE 
FBS_TMSLOW 
FBS_TMSHIGH 

Definition at line 62 of file esp32.c.

Function Documentation

◆ COMMAND_HANDLER()

COMMAND_HANDLER ( esp32_cmd_flashbootstrap  )

Definition at line 398 of file esp32.c.

◆ COMMAND_HELPER()

static COMMAND_HELPER ( esp32_cmd_flashbootstrap_do  ,
struct esp32_common esp32 
)
static

◆ esp32_arch_state()

static int esp32_arch_state ( struct target target)
static

Definition at line 263 of file esp32.c.

References ERROR_OK.

◆ esp32_disable_wdts()

static int esp32_disable_wdts ( struct target target)
static

◆ esp32_on_halt()

static int esp32_on_halt ( struct target target)
static

Definition at line 255 of file esp32.c.

References ERROR_OK, esp32_disable_wdts(), and esp_xtensa_smp_on_halt().

◆ esp32_queue_tdi_idle()

static void esp32_queue_tdi_idle ( struct target target)
static

◆ esp32_soc_reset()

◆ esp32_target_create()

◆ esp32_target_init()

static int esp32_target_init ( struct command_context cmd_ctx,
struct target target 
)
static

Definition at line 303 of file esp32.c.

◆ esp32_virt2phys()

static int esp32_virt2phys ( struct target target,
target_addr_t  virtual,
target_addr_t physical 
)
static

Definition at line 268 of file esp32.c.

References ERROR_FAIL, and ERROR_OK.

◆ target_to_esp32()

static struct esp32_common* target_to_esp32 ( struct target target)
inlinestatic

Definition at line 73 of file esp32.c.

References target::arch_info, container_of, and esp32_common::esp_xtensa_smp.

Referenced by esp32_queue_tdi_idle().

Variable Documentation

◆ esp32_any_command_handlers

const struct command_registration esp32_any_command_handlers[]
static
Initial value:
= {
{
.name = "flashbootstrap",
.handler = esp32_cmd_flashbootstrap,
.mode = COMMAND_ANY,
.help =
"Set the idle state of the TMS pin, which at reset also is the voltage selector for the flash chip.",
.usage = "none|1.8|3.3|high|low",
},
}
#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

Definition at line 398 of file esp32.c.

◆ esp32_chip_ops

const struct esp_xtensa_smp_chip_ops esp32_chip_ops
static
Initial value:
= {
.reset = esp32_soc_reset,
.on_halt = esp32_on_halt
}
static int esp32_on_halt(struct target *target)
Definition: esp32.c:255
static int esp32_soc_reset(struct target *target)
Definition: esp32.c:96

Definition at line 303 of file esp32.c.

Referenced by esp32_target_create().

◆ esp32_command_handlers

const struct command_registration esp32_command_handlers[]
static
Initial value:
= {
{
},
{
.name = "esp",
.usage = "",
},
{
.name = "esp32",
.usage = "",
},
{
.name = "esp32",
.usage = "",
},
{
.name = "arm",
.mode = COMMAND_ANY,
.help = "ARM Command Group",
.usage = "",
},
}
static const struct command_registration esp32_any_command_handlers[]
Definition: esp32.c:418
const struct command_registration esp32_apptrace_command_handlers[]
const struct command_registration esp_xtensa_smp_command_handlers[]
const struct command_registration semihosting_common_handlers[]
const struct command_registration smp_command_handlers[]
Definition: smp.c:153
const char * name
Definition: command.h:235

Definition at line 398 of file esp32.c.

◆ esp32_dbg_ops

const struct xtensa_debug_ops esp32_dbg_ops
static
Initial value:
= {
.queue_enable = xtensa_dm_queue_enable,
.queue_reg_read = xtensa_dm_queue_reg_read,
.queue_reg_write = xtensa_dm_queue_reg_write
}
int xtensa_dm_queue_reg_read(struct xtensa_debug_module *dm, enum xtensa_dm_reg reg, uint8_t *value)
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)

Definition at line 303 of file esp32.c.

Referenced by esp32_target_create().

◆ esp32_pwr_ops

const struct xtensa_power_ops esp32_pwr_ops
static
Initial value:
= {
.queue_reg_read = xtensa_dm_queue_pwr_reg_read,
.queue_reg_write = xtensa_dm_queue_pwr_reg_write
}
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)

Definition at line 303 of file esp32.c.

Referenced by esp32_target_create().

◆ esp32_reset_stub_code

const uint8_t esp32_reset_stub_code[]
static
Initial value:
= {
}

Definition at line 92 of file esp32.c.

Referenced by esp32_soc_reset().

◆ esp32_semihost_ops

const struct esp_semihost_ops esp32_semihost_ops
static
Initial value:
= {
.prepare = esp32_disable_wdts
}
static int esp32_disable_wdts(struct target *target)
Definition: esp32.c:217

Definition at line 303 of file esp32.c.

Referenced by esp32_target_create().

◆ esp32_target

struct target_type esp32_target

Holds methods for Xtensa targets.

Definition at line 398 of file esp32.c.