Skip to content

Commit dd69b78

Browse files
authored
Merge pull request #1204 from sobuch/esp-riscv-cfg-fix
Fix esp RISC-V configs
2 parents 88fe568 + fb16cb5 commit dd69b78

File tree

5 files changed

+30
-23
lines changed

5 files changed

+30
-23
lines changed

tcl/target/esp32c2.cfg

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
source [find target/esp_common.cfg]
66

77
# Target specific global variables
8-
set _CHIPNAME "riscv"
8+
set _CHIPNAME "esp32c2"
99
set _CPUTAPID 0x0000cc25
1010
set _ESP_ARCH "riscv"
1111
set _ONLYCPU 1
@@ -14,7 +14,7 @@ set _ESP_SMP_BREAK 0
1414
set _ESP_EFUSE_MAC_ADDR_REG 0x60008840
1515

1616
# Target specific functions should be implemented for each riscv chips.
17-
proc riscv_wdt_disable { } {
17+
proc esp32c2_wdt_disable { } {
1818
# Halt event can occur during config phase (before "init" is done).
1919
# Ignore it since mww commands don't work at that time.
2020
if { [string compare [command mode] config] == 0 } {
@@ -32,7 +32,7 @@ proc riscv_wdt_disable { } {
3232
mww 0x600080A0 0x84B00000
3333
}
3434

35-
proc riscv_soc_reset { } {
35+
proc esp32c2_soc_reset { } {
3636
global _RISCV_DMCONTROL
3737

3838
# This procedure does "digital system reset", i.e. resets
@@ -52,7 +52,7 @@ proc riscv_soc_reset { } {
5252
sleep 10
5353
poll
5454
# Disable the watchdogs again
55-
riscv_wdt_disable
55+
esp32c2_wdt_disable
5656

5757
# Here debugger reads allresumeack and allhalted bits as set (0x330a2)
5858
# We will clean allhalted state by resuming the core.
@@ -62,7 +62,7 @@ proc riscv_soc_reset { } {
6262
riscv dmi_write $_RISCV_DMCONTROL 0x80000003
6363
}
6464

65-
proc riscv_memprot_is_enabled { } {
65+
proc esp32c2_memprot_is_enabled { } {
6666
global _RISCV_ABS_CMD _RISCV_ABS_DATA0
6767

6868
# PMPADDR 0-1 covers entire valid IRAM range and PMPADDR 2-3 covers entire DRAM region

tcl/target/esp32c3.cfg

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
source [find target/esp_common.cfg]
66

77
# Target specific global variables
8-
set _CHIPNAME "riscv"
8+
set _CHIPNAME "esp32c3"
99
set _CPUTAPID 0x00005c25
1010
set _ESP_ARCH "riscv"
1111
set _ONLYCPU 1
@@ -14,7 +14,7 @@ set _ESP_SMP_BREAK 0
1414
set _ESP_EFUSE_MAC_ADDR_REG 0x60008844
1515

1616
# Target specific functions should be implemented for each riscv chips.
17-
proc riscv_wdt_disable { } {
17+
proc esp32c3_wdt_disable { } {
1818
# Halt event can occur during config phase (before "init" is done).
1919
# Ignore it since mww commands don't work at that time.
2020
if { [string compare [command mode] config] == 0 } {
@@ -36,7 +36,7 @@ proc riscv_wdt_disable { } {
3636

3737
# This is almost identical with the esp32c2_soc_reset.
3838
# Will be refactored with the other common settings.
39-
proc riscv_soc_reset { } {
39+
proc esp32c3_soc_reset { } {
4040
global _RISCV_DMCONTROL
4141

4242
# This procedure does "digital system reset", i.e. resets
@@ -56,7 +56,7 @@ proc riscv_soc_reset { } {
5656
sleep 10
5757
poll
5858
# Disable the watchdogs again
59-
riscv_wdt_disable
59+
esp32c3_wdt_disable
6060

6161
# Here debugger reads allresumeack and allhalted bits as set (0x330a2)
6262
# We will clean allhalted state by resuming the core.
@@ -66,7 +66,7 @@ proc riscv_soc_reset { } {
6666
riscv dmi_write $_RISCV_DMCONTROL 0x80000003
6767
}
6868

69-
proc riscv_memprot_is_enabled { } {
69+
proc esp32c3_memprot_is_enabled { } {
7070
# IRAM0 PMS lock, SENSITIVE_CORE_X_IRAM0_PMS_CONSTRAIN_0_REG
7171
if { [get_mmr_bit 0x600C10A8 0] != 0 } {
7272
return 1

tcl/target/esp32c6.cfg

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
source [find target/esp_common.cfg]
66

77
# Target specific global variables
8-
set _CHIPNAME "riscv"
8+
set _CHIPNAME "esp32c6"
99
set _CPUTAPID 0x0000dc25
1010
set _ESP_ARCH "riscv"
1111
set _ONLYCPU 1
@@ -14,7 +14,7 @@ set _ESP_SMP_BREAK 0
1414
set _ESP_EFUSE_MAC_ADDR_REG 0x600B0844
1515

1616
# Target specific functions should be implemented for each riscv chips.
17-
proc riscv_wdt_disable { } {
17+
proc esp32c6_wdt_disable { } {
1818
# Halt event can occur during config phase (before "init" is done).
1919
# Ignore it since mww commands don't work at that time.
2020
if { [string compare [command mode] config] == 0 } {
@@ -34,7 +34,7 @@ proc riscv_wdt_disable { } {
3434
mww 0x600b1c1c 0x40000000
3535
}
3636

37-
proc riscv_soc_reset { } {
37+
proc esp32c6_soc_reset { } {
3838
global _RISCV_DMCONTROL _RISCV_SB_CS _RISCV_SB_ADDR0 _RISCV_SB_DATA0
3939

4040
riscv dmi_write $_RISCV_DMCONTROL 0x80000001
@@ -59,7 +59,7 @@ proc riscv_soc_reset { } {
5959
# Here debugger reads dmstatus as 0x3a2
6060

6161
# Disable the watchdogs again
62-
riscv_wdt_disable
62+
esp32c6_wdt_disable
6363

6464
# Here debugger reads anyhalted and allhalted bits as set (0x3a2)
6565
# We will clean allhalted state by resuming the core.
@@ -69,7 +69,7 @@ proc riscv_soc_reset { } {
6969
riscv dmi_write $_RISCV_DMCONTROL 0x80000003
7070
}
7171

72-
proc riscv_memprot_is_enabled { } {
72+
proc esp32c6_memprot_is_enabled { } {
7373
global _RISCV_ABS_CMD _RISCV_ABS_DATA0
7474

7575
# If IRAM/DRAM split is enabled TOR address match mode is used.

tcl/target/esp32h2.cfg

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
source [find target/esp_common.cfg]
66

77
# Target specific global variables
8-
set _CHIPNAME "riscv"
8+
set _CHIPNAME "esp32h2"
99
set _CPUTAPID 0x00010c25
1010
set _ESP_ARCH "riscv"
1111
set _ONLYCPU 1
@@ -14,7 +14,7 @@ set _ESP_SMP_BREAK 0
1414
set _ESP_EFUSE_MAC_ADDR_REG 0x600B0844
1515

1616
# Target specific functions should be implemented for each riscv chips.
17-
proc riscv_wdt_disable { } {
17+
proc esp32h2_wdt_disable { } {
1818
# Halt event can occur during config phase (before "init" is done).
1919
# Ignore it since mww commands don't work at that time.
2020
if { [string compare [command mode] config] == 0 } {
@@ -34,7 +34,7 @@ proc riscv_wdt_disable { } {
3434
#mww 0x600b1c1c 0x84B00000
3535
}
3636

37-
proc riscv_soc_reset { } {
37+
proc esp32h2_soc_reset { } {
3838
global _RISCV_DMCONTROL _RISCV_SB_CS _RISCV_SB_ADDR0 _RISCV_SB_DATA0
3939

4040
riscv dmi_write $_RISCV_DMCONTROL 0x80000001
@@ -59,7 +59,7 @@ proc riscv_soc_reset { } {
5959
# Here debugger reads dmstatus as 0x3a2
6060

6161
# Disable the watchdogs again
62-
riscv_wdt_disable
62+
esp32h2_wdt_disable
6363

6464
# Here debugger reads anyhalted and allhalted bits as set (0x3a2)
6565
# We will clean allhalted state by resuming the core.
@@ -69,7 +69,7 @@ proc riscv_soc_reset { } {
6969
riscv dmi_write $_RISCV_DMCONTROL 0x80000003
7070
}
7171

72-
proc riscv_memprot_is_enabled { } {
72+
proc esp32h2_memprot_is_enabled { } {
7373
global _RISCV_ABS_CMD _RISCV_ABS_DATA0
7474
# If IRAM/DRAM split is enabled, PMPADDR 5-6 will cover valid IRAM region and PMPADDR 7 will cover valid DRAM region
7575
# Only TOR mode is used for IRAM and DRAM protections.

tcl/target/esp_common.cfg

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ proc set_esp_common_variables { } {
3333
global _CHIPNAME _ONLYCPU _ESP_SMP_TARGET
3434
global _CPUNAME_0 _CPUNAME_1 _TARGETNAME_0 _TARGETNAME_1 _TAPNAME_0 _TAPNAME_1
3535
global _ESP_WDT_DISABLE _ESP_SOC_RESET _ESP_MEMPROT_IS_ENABLED
36+
global _TARGET_TYPE _ESP_ARCH
3637

3738
# For now we support dual core at most.
3839
if { $_ONLYCPU == 1 && $_ESP_SMP_TARGET == 0} {
@@ -51,6 +52,12 @@ proc set_esp_common_variables { } {
5152
set _ESP_WDT_DISABLE "${_CHIPNAME}_wdt_disable"
5253
set _ESP_SOC_RESET "${_CHIPNAME}_soc_reset"
5354
set _ESP_MEMPROT_IS_ENABLED "${_CHIPNAME}_memprot_is_enabled"
55+
56+
if {$_ESP_ARCH == "riscv"} {
57+
set _TARGET_TYPE $_ESP_ARCH
58+
} else {
59+
set _TARGET_TYPE $_CHIPNAME
60+
}
5461
}
5562

5663
proc create_esp_jtag { } {
@@ -64,11 +71,11 @@ proc create_esp_jtag { } {
6471
}
6572

6673
proc create_openocd_targets { } {
67-
global _TARGETNAME_0 _TARGETNAME_1 _TAPNAME_0 _TAPNAME_1 _RTOS _CHIPNAME _ONLYCPU
74+
global _TARGETNAME_0 _TARGETNAME_1 _TAPNAME_0 _TAPNAME_1 _RTOS _CHIPNAME _ONLYCPU _TARGET_TYPE
6875

69-
target create $_TARGETNAME_0 $_CHIPNAME -chain-position $_TAPNAME_0 -coreid 0 -rtos $_RTOS
76+
target create $_TARGETNAME_0 $_TARGET_TYPE -chain-position $_TAPNAME_0 -coreid 0 -rtos $_RTOS
7077
if { $_ONLYCPU != 1 } {
71-
target create $_TARGETNAME_1 $_CHIPNAME -chain-position $_TAPNAME_1 -coreid 1 -rtos $_RTOS
78+
target create $_TARGETNAME_1 $_TARGET_TYPE -chain-position $_TAPNAME_1 -coreid 1 -rtos $_RTOS
7279
target smp $_TARGETNAME_0 $_TARGETNAME_1
7380
}
7481
}

0 commit comments

Comments
 (0)