| 64 | } |
| 65 | |
| 66 | export class STLinkServerController extends EventEmitter implements GDBServerController { |
| 67 | public readonly name: string = 'ST-LINK'; |
| 68 | // STLink uses 4 ports per core. Not sure what 3rd and 4th are for but reserve them anyways |
| 69 | public readonly portsNeeded: string[] = ['gdbPort', 'swoPort', 'gap1', 'gap2']; |
| 70 | |
| 71 | private args: ConfigurationArguments; |
| 72 | private ports: { [name: string]: number }; |
| 73 | |
| 74 | public static getSTMCubeIdeDir(): string { |
| 75 | switch (os.platform()) { |
| 76 | case 'darwin': |
| 77 | return ST_DIR; |
| 78 | case 'linux': |
| 79 | return resolveCubePath([ST_DIR], STMCUBEIDE_REGEX, ''); |
| 80 | default: |
| 81 | return resolveCubePath([ST_DIR], STMCUBEIDE_REGEX, 'STM32CubeIDE'); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | public static getArmToolchainPath(): string { |
| 86 | // Try to resolve gcc location |
| 87 | return resolveCubePath([this.getSTMCubeIdeDir(), 'plugins'], GCC_REGEX, 'tools/bin'); |
| 88 | } |
| 89 | |
| 90 | constructor() { |
| 91 | super(); |
| 92 | } |
| 93 | |
| 94 | public setPorts(ports: { [name: string]: number }): void { |
| 95 | this.ports = ports; |
| 96 | } |
| 97 | |
| 98 | public setArguments(args: ConfigurationArguments): void { |
| 99 | this.args = args; |
| 100 | } |
| 101 | |
| 102 | public customRequest(command: string, response: DebugProtocol.Response, args: any): boolean { |
| 103 | return false; |
| 104 | } |
| 105 | |
| 106 | public initCommands(): string[] { |
| 107 | const gdbport = this.ports[createPortName(this.args.targetProcessor)]; |
| 108 | return [ |
| 109 | `target-select extended-remote localhost:${gdbport}` |
| 110 | ]; |
| 111 | } |
| 112 | |
| 113 | public launchCommands(): string[] { |
| 114 | const commands = [ |
| 115 | // 'interpreter-exec console "monitor halt"', // Not needed because of -halt, not supported in older versions, still not documented |
| 116 | ...genDownloadCommands(this.args, ['interpreter-exec console "monitor reset"']), |
| 117 | 'interpreter-exec console "monitor reset"', |
| 118 | 'interpreter-exec console "monitor halt"' |
| 119 | ]; |
| 120 | return commands; |
| 121 | } |
| 122 | |
| 123 | public attachCommands(): string[] { |
nothing calls this directly
no outgoing calls
no test coverage detected