Skip to content

Commit 9ff7e3a

Browse files
committed
feat: add SWO support for BMP
1 parent 8b38bad commit 9ff7e3a

File tree

10 files changed

+299
-21
lines changed

10 files changed

+299
-21
lines changed

Diff for: binary_modules/package-lock.json

+54-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: binary_modules/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"electron-rebuild": "^3.2.8"
1212
},
1313
"dependencies": {
14-
"serialport": "^10.4.0"
14+
"serialport": "^10.4.0",
15+
"usb": "^2.14.0"
1516
}
1617
}

Diff for: debug_attributes.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ If the type is marked as `{...}` it means that it is a complex item can have mul
8888
| swoConfig<br>.enabled | boolean | Both | Enable SWO decoding. |
8989
| swoConfig<br>.source | string | Both | Source for SWO data. Can either be "probe" to get directly from debug probe, or a serial port device to use a serial port external to the debug probe. |
9090
| swoConfig<br>.swoFrequency | number | Both | SWO frequency in Hz. |
91-
| swoConfig<br>.swoPath | string | Both | Path name when source is "file" or "serial". Typically a /path-name or a serial-port-name |
92-
| swoConfig<br>.swoPort | string | Both | When server is "external" && source is "socket", port to connect to. Format [host:]port |
91+
| swoConfig<br>.swoPath | string | Both | Path name when source is "file" or "serial", device name regex match when source is "probe" for BMP. Typically a /path-name or a serial-port-name |
92+
| swoConfig<br>.swoPort | string | Both | When server is "external" && source is "socket", port to connect to. Format [host:]port. For BMP, specifies the regex match of the USB interface contianing raw SWO data. |
9393
| symbolFiles | object[] | Both | Array of ELF files to load symbols from instead of the executable file. Each item in the array cab be a string or an object. Program information is ignored (see `loadFiles`). Can be an empty list to specify none. If this property does not exist, then the executable is used for symbols |
9494
| targetId | string &#124; number | Both | On BMP this is the ID number that should be passed to the attach command (defaults to 1); for PyOCD this is the target identifier (only needed for custom hardware) |
9595
| targetProcessor | number | Both | The processor you want to debug. Zero based integer index. Must be less than 'numberOfProcessors' |

Diff for: package-lock.json

+51
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -2493,12 +2493,12 @@
24932493
"swoPath": {
24942494
"type": "string",
24952495
"default": "",
2496-
"description": "Path name when source is \"file\" or \"serial\". Typically a /path-name or a serial-port-name"
2496+
"description": "Path name when source is \"file\" or \"serial\", device name regex match when source is \"probe\" for BMP. Typically a /path-name or a serial-port-name"
24972497
},
24982498
"swoPort": {
24992499
"type": "string",
25002500
"default": "",
2501-
"description": "When server is \"external\" && source is \"socket\", port to connect to. Format [host:]port"
2501+
"description": "When server is \"external\" && source is \"socket\", port to connect to. Format [host:]port. For BMP, specifies the regex match of the USB interface contianing raw SWO data."
25022502
},
25032503
"decoders": {
25042504
"description": "SWO Decoder Configuration",
@@ -3009,6 +3009,7 @@
30093009
"stream-json": "^1.7.3",
30103010
"tmp": "^0.2.1",
30113011
"universal-analytics": "^0.5.3",
3012+
"usb": "^2.14.0",
30123013
"uuid": "^8.3.2",
30133014
"vscode-jsonrpc": "^6.0.0"
30143015
},

Diff for: src/bmp.ts

+20-7
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ export class BMPServerController extends EventEmitter implements GDBServerContro
109109
);
110110

111111
commands.push(this.args.swoConfig.profile ? 'EnablePCSample' : 'DisablePCSample');
112+
113+
if (this.args.swoConfig.source === 'probe') {
114+
commands.push('monitor traceswo');
115+
}
112116

113117
return commands.map((c) => `interpreter-exec console "${c}"`);
114118
}
@@ -131,13 +135,22 @@ export class BMPServerController extends EventEmitter implements GDBServerContro
131135

132136
public serverLaunchStarted(): void {}
133137
public serverLaunchCompleted(): void {
134-
if (this.args.swoConfig.enabled && this.args.swoConfig.source !== 'probe') {
135-
this.emit('event', new SWOConfigureEvent({
136-
type: 'serial',
137-
args: this.args,
138-
device: this.args.swoConfig.source,
139-
baudRate: this.args.swoConfig.swoFrequency
140-
}));
138+
if (this.args.swoConfig.enabled) {
139+
if (this.args.swoConfig.source === 'probe') {
140+
this.emit('event', new SWOConfigureEvent({
141+
type: 'usb',
142+
args: this.args,
143+
device: this.args.swoConfig.swoPath || 'Black Magic Probe',
144+
port: this.args.swoConfig.swoPort || 'Black Magic Trace Capture'
145+
}));
146+
} else {
147+
this.emit('event', new SWOConfigureEvent({
148+
type: 'serial',
149+
args: this.args,
150+
device: this.args.swoConfig.source,
151+
baudRate: this.args.swoConfig.swoFrequency
152+
}));
153+
}
141154
}
142155
}
143156

Diff for: src/frontend/configprovider.ts

-6
Original file line numberDiff line numberDiff line change
@@ -622,12 +622,6 @@ export class CortexDebugConfigurationProvider implements vscode.DebugConfigurati
622622
return 'The Black Magic Probe GDB Server does not have support for the rtos option.';
623623
}
624624

625-
if (config.swoConfig.enabled && config.swoConfig.source === 'probe') {
626-
vscode.window.showWarningMessage('SWO support is not available from the probe when using the BMP GDB server. Disabling SWO.');
627-
config.swoConfig = { enabled: false, ports: [], cpuFrequency: 0, swoFrequency: 0 };
628-
config.graphConfig = [];
629-
}
630-
631625
return null;
632626
}
633627

Diff for: src/frontend/extension.ts

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { JLinkSocketRTTSource, SocketRTTSource, SocketSWOSource, PeMicroSocketSo
1616
import { FifoSWOSource } from './swo/sources/fifo';
1717
import { FileSWOSource } from './swo/sources/file';
1818
import { SerialSWOSource } from './swo/sources/serial';
19+
import { UsbSWOSource } from './swo/sources/usb';
1920
import { SymbolInformation, SymbolScope } from '../symbols';
2021
import { RTTTerminal } from './rtt_terminal';
2122
import { GDBServerConsole } from './server_console';
@@ -763,6 +764,10 @@ export class CortexDebugExtension {
763764
mySession.swoSource = new SerialSWOSource(e.body.device, e.body.baudRate);
764765
Reporting.sendEvent('SWO', 'Source', 'Serial');
765766
}
767+
else if (e.body.type === 'usb') {
768+
mySession.swoSource = new UsbSWOSource(e.body.device, e.body.port);
769+
Reporting.sendEvent('SWO', 'Source', 'USB');
770+
}
766771

767772
this.initializeSWO(e.session, e.body.args);
768773
}

0 commit comments

Comments
 (0)