Skip to content

Commit 9fb01a6

Browse files
committed
Prevent deprecated messages from openocd for port settings
1 parent 07b3099 commit 9fb01a6

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"instrs",
3636
"jlink",
3737
"jtag",
38+
"llength",
3839
"Logpoints",
3940
"nuttx",
4041
"Prio",

src/openocd.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ export class OpenOCDServerController extends EventEmitter implements GDBServerCo
210210
public serverArguments(): string[] {
211211
let serverargs: string[] = [];
212212

213+
// This should come before anything else so that gdb/tcl/telnet ports can be used in OpenoCD V12
214+
// without a warning and older versions will work fine as well
215+
serverargs.push('-f', `${this.args.extensionPath}/support/openocd-helpers.tcl`);
216+
213217
// Regardless of the target processor, we will only supply the processor '0's port#
214218
// OpenOcd will increment and assign the right port-numer to the right processor
215219
serverargs.push('-c', `gdb_port ${this.ports['gdbPort']}`);
@@ -228,7 +232,6 @@ export class OpenOCDServerController extends EventEmitter implements GDBServerCo
228232
serverargs.push('-c', cmd);
229233
}
230234

231-
serverargs.push('-f', `${this.args.extensionPath}/support/openocd-helpers.tcl`);
232235
this.args.configFiles.forEach((cf, idx) => {
233236
serverargs.push('-f', cf);
234237
});

support/openocd-helpers.tcl

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
# Note that this file simply defines a function for use later when it is time to configure
77
# for SWO.
88
#
9+
# This file must be loaded before the `init` command is called and before gdb/tcl/telnet ports are set
10+
# as it contains overrides for those commands to keep compatibility with older versions of OpenOCD
11+
#
912
set USE_SWO 0
10-
proc CDSWOConfigure { CDCPUFreqHz CDSWOFreqHz CDSWOOutput } {
13+
proc CDSWOConfigure { CDCPUFreqHz CDSWOFreqHz CDSWOOutput } {
1114
# We don't create/configure the entire TPIU which requires advanced knowledge of the device
1215
# like which DAP/AP ports to use, what their bases addresses are, etc. That should already
1316
# be done by the config files from the Silicon Vendor
@@ -64,3 +67,26 @@ proc CDLiveWatchSetup {} {
6467
puts stderr "[info script]: Error: Failed to increase gdb-max-connections for current target. Live variables will not work"
6568
}
6669
}
70+
71+
# In version 12 of openocd they deprecated the gdb_port command. So, we create the old command and
72+
# use it from the command-line so that we keep compatibility with older versions of openocd
73+
if { [llength [info commands "gdb"] ] != 0 } {
74+
proc gdb_port { port } {
75+
puts "[info script]: Setting gdb port to $port"
76+
gdb port $port
77+
}
78+
}
79+
80+
if { [llength [info commands "tcl"] ] != 0 } {
81+
proc tcl_port { port } {
82+
puts "[info script]: Setting tcl port to $port"
83+
tcl port $port
84+
}
85+
}
86+
87+
if { [llength [info commands "telnet"] ] != 0 } {
88+
proc telnet_port { port } {
89+
puts "[info script]: Setting telnet port to $port"
90+
telnet port $port
91+
}
92+
}

0 commit comments

Comments
 (0)