@@ -44,8 +44,10 @@ function get_ST_DIR(): string {
4444}
4545
4646// Path of the top-level STM32CubeIDE installation directory, os-dependant
47+ /*
4748const ST_DIR = get_ST_DIR();
4849const ST_CLT_ISTALL_DIR = get_CLT_INSTALL_DIR();
50+ */
4951const SERVER_EXECUTABLE_NAME = os . platform ( ) === 'win32' ? 'ST-LINK_gdbserver.exe' : 'ST-LINK_gdbserver' ;
5052
5153const STMCUBEIDE_REGEX = / ^ S T M 3 2 C u b e I D E _ ( .+ ) $ / i;
@@ -92,26 +94,27 @@ export class STLinkServerController extends EventEmitter implements GDBServerCon
9294 public readonly name : string = 'ST-LINK' ;
9395 // STLink uses 4 ports per core. Not sure what 3rd and 4th are for but reserve them anyways
9496 public readonly portsNeeded : string [ ] = [ 'gdbPort' , 'swoPort' , 'gap1' , 'gap2' ] ;
95-
97+ public readonly ST_DIR = get_ST_DIR ( ) ;
98+ public readonly ST_CLT_ISTALL_DIR = get_CLT_INSTALL_DIR ( ) ;
9699 private args : ConfigurationArguments ;
97100 private ports : { [ name : string ] : number } ;
98101 private targetProcessor : number = 0 ;
99102
100- public static getSTMCubeIdeDir ( ) : string {
103+ public getSTMCubeIdeDir ( ) : string {
101104 switch ( os . platform ( ) ) {
102105 case 'darwin' :
103- return ST_DIR ;
106+ return this . ST_DIR ;
104107 case 'linux' :
105- return resolveCubePath ( [ ST_DIR ] , STMCUBEIDE_REGEX , '' ) ;
108+ return resolveCubePath ( [ this . ST_DIR ] , STMCUBEIDE_REGEX , '' ) ;
106109 default :
107- return resolveCubePath ( [ ST_DIR ] , STMCUBEIDE_REGEX , 'STM32CubeIDE' ) ;
110+ return resolveCubePath ( [ this . ST_DIR ] , STMCUBEIDE_REGEX , 'STM32CubeIDE' ) ;
108111 }
109112 }
110113
111- public static getArmToolchainPath ( ) : string {
114+ public getArmToolchainPath ( ) : string {
112115 // Try to resolve gcc location
113- if ( ST_CLT_ISTALL_DIR ) {
114- const p = path . join ( ST_CLT_ISTALL_DIR , 'GNU-tools-for-STM32' , 'bin' ) ;
116+ if ( this . ST_CLT_ISTALL_DIR ) {
117+ const p = path . join ( this . ST_CLT_ISTALL_DIR , 'GNU-tools-for-STM32' , 'bin' ) ;
115118 if ( fs . existsSync ( p ) ) {
116119 return p ;
117120 }
@@ -202,14 +205,14 @@ export class STLinkServerController extends EventEmitter implements GDBServerCon
202205 if ( this . args . serverpath ) {
203206 return this . args . serverpath ;
204207 } else {
205- if ( ST_CLT_ISTALL_DIR ) {
206- const p = path . join ( ST_CLT_ISTALL_DIR , 'STLink-gdb-server' , 'bin' , SERVER_EXECUTABLE_NAME ) ;
208+ if ( this . ST_CLT_ISTALL_DIR ) {
209+ const p = path . join ( this . ST_CLT_ISTALL_DIR , 'STLink-gdb-server' , 'bin' , SERVER_EXECUTABLE_NAME ) ;
207210 if ( fs . existsSync ( p ) ) {
208211 this . args . serverpath = p ;
209212 return p ;
210213 }
211214 }
212- return resolveCubePath ( [ STLinkServerController . getSTMCubeIdeDir ( ) , 'plugins' ] , GDB_SERVER_REGEX , 'tools/bin' , SERVER_EXECUTABLE_NAME ) ;
215+ return resolveCubePath ( [ this . getSTMCubeIdeDir ( ) , 'plugins' ] , GDB_SERVER_REGEX , 'tools/bin' , SERVER_EXECUTABLE_NAME ) ;
213216 }
214217 }
215218
@@ -227,14 +230,14 @@ export class STLinkServerController extends EventEmitter implements GDBServerCon
227230 if ( stm32cubeprogrammer ) {
228231 serverargs . push ( '-cp' , stm32cubeprogrammer ) ;
229232 } else {
230- if ( ST_CLT_ISTALL_DIR ) {
231- const p = path . join ( ST_CLT_ISTALL_DIR , 'STM32CubeProgrammer' , 'bin' ) ;
233+ if ( this . ST_CLT_ISTALL_DIR ) {
234+ const p = path . join ( this . ST_CLT_ISTALL_DIR , 'STM32CubeProgrammer' , 'bin' ) ;
232235 if ( fs . existsSync ( p ) ) {
233236 stm32cubeprogrammer = p ;
234237 }
235238 }
236239 if ( ! stm32cubeprogrammer ) {
237- stm32cubeprogrammer = resolveCubePath ( [ STLinkServerController . getSTMCubeIdeDir ( ) , 'plugins' ] , PROG_REGEX , 'tools/bin' ) ;
240+ stm32cubeprogrammer = resolveCubePath ( [ this . getSTMCubeIdeDir ( ) , 'plugins' ] , PROG_REGEX , 'tools/bin' ) ;
238241 // Fallback to standalone programmer if no STMCube32IDE is installed:
239242 if ( ! stm32cubeprogrammer ) {
240243 if ( os . platform ( ) === 'win32' ) {
0 commit comments