Skip to content

Commit dca6a29

Browse files
authored
Merge pull request syntacore#4 from syntacore/en-sc/use-scr-info
Support Syntacore platforms
2 parents 36c24d2 + e5c8327 commit dca6a29

File tree

2 files changed

+39
-7
lines changed

2 files changed

+39
-7
lines changed

tcl/target/syntacore_target.cfg

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ set __sc_target_defaults(chipname) riscv
5353
set __sc_target_defaults(expose_csrs) ""
5454
set __sc_target_defaults(disable_EQ_triggers) 1
5555
set __sc_target_defaults(disable_ebreak) 0
56+
set __sc_target_defaults(platform_extension) ""
5657

5758
set __sc_target_defaults(smp_configuration) 0
5859
set __sc_target_defaults(gdb_report_data_abort) 1
@@ -75,6 +76,13 @@ proc proc_exists p {
7576
# return uplevel 1 [expr {[llength [info procs $p]] > 0}]
7677
}
7778

79+
proc check_and_call {msg proc_name args} {
80+
if {![proc_exists $proc_name]} {
81+
error $msg
82+
}
83+
tailcall $proc_name {*}$args
84+
}
85+
7886
proc sc_pre_tap_hook {} {
7987
}
8088

@@ -274,6 +282,14 @@ proc init_targets {} {
274282
jtag newtap [dict get $tap_item prefix] [dict get $tap_item suffix] -irlen [dict get $tap_item irlen]
275283
}
276284

285+
set _PLATFORM_EXT [sc_target_config_get platform_extension]
286+
set _EXPOSED_REGISTERS ""
287+
if {$_PLATFORM_EXT ne "" } {
288+
set errmsg "incorrect version of scr_info platform extension plugin"
289+
set platform_name [check_and_call $errmsg ::scr_info::type_name $_PLATFORM_EXT]
290+
set _EXPOSED_REGISTERS [check_and_call $errmsg ::scr_info::expose_custom_string ${platform_name}]
291+
sc_target_config_log "new registers from scr_info platform: $_EXPOSED_REGISTERS"
292+
}
277293
foreach tgt_item [lindex $tapmap 1] {
278294
if {[sc_target_config_get no_ocd_targets] == 1} {
279295
continue
@@ -303,6 +319,10 @@ proc init_targets {} {
303319
$_TARGETNAME riscv hide_csrs $HIDE_CSRS
304320
}
305321

322+
if {$_EXPOSED_REGISTERS ne ""} {
323+
$_TARGETNAME riscv expose_csrs $_EXPOSED_REGISTERS
324+
}
325+
306326
if {[sc_target_config_get expose_csrs] ne ""} {
307327
$_TARGETNAME riscv expose_csrs [sc_target_config_get expose_csrs]
308328
}

tools/syntacore/openocd_run.exp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ set COMMAND_LINE_OPTIONS [dict create \
5252
--log-session "value:log_path. Path to session log" \
5353
--no-extra-scripts "flag. avoid loading of extra scripts (common routines to help with debugging)" \
5454
--no-targets "devel:flag. create only TAP, do not create OpenOCD targets" \
55+
--platform "value:name. The name of the platform. Performs platform-specific initialization if appropriate plugin is available" \
5556
--reset-adapter "flag. enforce reset of debug adapter before use" \
5657
--run-command "value:command. extra TCL command to run. Can be specified multiple times. The command is run after init phase" \
5758
--run-script "value:file. additional TCL script to run. Can be specified multiple times. The script is run after init phase" \
@@ -101,6 +102,7 @@ set SETTINGS(load_extra_scripts) 1
101102
set SETTINGS(extra_run_commands) []
102103
set SETTINGS(extra_spike_args) []
103104
set SETTINGS(no_openocd_targets) 0
105+
set SETTINGS(platform) ""
104106
set SETTINGS(reset_adapter) 0
105107

106108
set DEBUG_ADAPTER_INFO(adapter_string) ""
@@ -266,6 +268,8 @@ for { set i 0 } { $i < $argc } { incr i } {
266268
set SETTINGS(stand_db) $optarg
267269
} elseif { $option == $COMMAND_LINE_ARG(--no-targets) } {
268270
set SETTINGS(no_openocd_targets) 1
271+
} elseif { $option == $COMMAND_LINE_ARG(--platform) } {
272+
set SETTINGS(platform) $optarg
269273
} elseif { $option == $COMMAND_LINE_ARG(--reset-adapter) } {
270274
set SETTINGS(reset_adapter) 1
271275
} elseif { $option == $COMMAND_LINE_ARG(--help) } {
@@ -731,16 +735,19 @@ proc buildOpenOCDCommandLine {DebugInterfaceCfg AdapterSerial JtagTopologyString
731735
-c "sc_target_config jtag_topology ${JtagTopologyString}"]
732736
}
733737

738+
set ExtraLibraries [list]
734739
if {$SETTINGS(load_extra_scripts) == 1} {
735-
set ExtraLibraries [list]
736740
lappend ExtraLibraries "[getOpenOCDRootDir]/share/openocd/scripts/syntacore/sc_fpga_lib.tcl"
737-
foreach Lib $ExtraLibraries {
738-
if {![file exists "$Lib"]} {
739-
fatalError "unable to locate extra library: $Lib"
740-
}
741-
lappend OpenOCDArgs -f
742-
lappend OpenOCDArgs "$Lib"
741+
}
742+
if {$SETTINGS(platform) ne ""} {
743+
lappend ExtraLibraries "[getOpenOCDRootDir]/share/openocd/scripts/syntacore/scr_info.tcl"
744+
}
745+
foreach Lib $ExtraLibraries {
746+
if {![file exists "$Lib"]} {
747+
fatalError "unable to locate extra library: $Lib"
743748
}
749+
lappend OpenOCDArgs -f
750+
lappend OpenOCDArgs "$Lib"
744751
}
745752

746753
if {$SETTINGS(ide_mode) == 1} {
@@ -783,6 +790,11 @@ proc buildOpenOCDCommandLine {DebugInterfaceCfg AdapterSerial JtagTopologyString
783790
lappend OpenOCDArgs -c
784791
lappend OpenOCDArgs "sc_target_config target_type $SETTINGS(target_type)"
785792

793+
if {$SETTINGS(platform) ne ""} {
794+
lappend OpenOCDArgs -c
795+
lappend OpenOCDArgs "sc_target_config platform_extension $SETTINGS(platform)"
796+
}
797+
786798
lappend OpenOCDArgs [deriveDesiredVerbosityOption]
787799

788800
# Apparently, depending on the presence -c "init" command OpenOCD behaves

0 commit comments

Comments
 (0)