Skip to content

Commit

Permalink
feat: add SWO support for BMP
Browse files Browse the repository at this point in the history
  • Loading branch information
ssimek committed Oct 12, 2024
1 parent 8b38bad commit 9ff7e3a
Show file tree
Hide file tree
Showing 10 changed files with 299 additions and 21 deletions.
55 changes: 54 additions & 1 deletion binary_modules/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion binary_modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"electron-rebuild": "^3.2.8"
},
"dependencies": {
"serialport": "^10.4.0"
"serialport": "^10.4.0",
"usb": "^2.14.0"
}
}
4 changes: 2 additions & 2 deletions debug_attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ If the type is marked as `{...}` it means that it is a complex item can have mul
| swoConfig<br>.enabled | boolean | Both | Enable SWO decoding. |
| 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. |
| swoConfig<br>.swoFrequency | number | Both | SWO frequency in Hz. |
| swoConfig<br>.swoPath | string | Both | Path name when source is "file" or "serial". Typically a /path-name or a serial-port-name |
| swoConfig<br>.swoPort | string | Both | When server is "external" && source is "socket", port to connect to. Format [host:]port |
| 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 |
| 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. |
| 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 |
| 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) |
| targetProcessor | number | Both | The processor you want to debug. Zero based integer index. Must be less than 'numberOfProcessors' |
Expand Down
51 changes: 51 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2493,12 +2493,12 @@
"swoPath": {
"type": "string",
"default": "",
"description": "Path name when source is \"file\" or \"serial\". Typically a /path-name or a serial-port-name"
"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"
},
"swoPort": {
"type": "string",
"default": "",
"description": "When server is \"external\" && source is \"socket\", port to connect to. Format [host:]port"
"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."
},
"decoders": {
"description": "SWO Decoder Configuration",
Expand Down Expand Up @@ -3009,6 +3009,7 @@
"stream-json": "^1.7.3",
"tmp": "^0.2.1",
"universal-analytics": "^0.5.3",
"usb": "^2.14.0",
"uuid": "^8.3.2",
"vscode-jsonrpc": "^6.0.0"
},
Expand Down
27 changes: 20 additions & 7 deletions src/bmp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ export class BMPServerController extends EventEmitter implements GDBServerContro
);

commands.push(this.args.swoConfig.profile ? 'EnablePCSample' : 'DisablePCSample');

if (this.args.swoConfig.source === 'probe') {
commands.push('monitor traceswo');
}

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

public serverLaunchStarted(): void {}
public serverLaunchCompleted(): void {
if (this.args.swoConfig.enabled && this.args.swoConfig.source !== 'probe') {
this.emit('event', new SWOConfigureEvent({
type: 'serial',
args: this.args,
device: this.args.swoConfig.source,
baudRate: this.args.swoConfig.swoFrequency
}));
if (this.args.swoConfig.enabled) {
if (this.args.swoConfig.source === 'probe') {
this.emit('event', new SWOConfigureEvent({
type: 'usb',
args: this.args,
device: this.args.swoConfig.swoPath || 'Black Magic Probe',
port: this.args.swoConfig.swoPort || 'Black Magic Trace Capture'
}));
} else {
this.emit('event', new SWOConfigureEvent({
type: 'serial',
args: this.args,
device: this.args.swoConfig.source,
baudRate: this.args.swoConfig.swoFrequency
}));
}
}
}

Expand Down
6 changes: 0 additions & 6 deletions src/frontend/configprovider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,12 +622,6 @@ export class CortexDebugConfigurationProvider implements vscode.DebugConfigurati
return 'The Black Magic Probe GDB Server does not have support for the rtos option.';
}

if (config.swoConfig.enabled && config.swoConfig.source === 'probe') {
vscode.window.showWarningMessage('SWO support is not available from the probe when using the BMP GDB server. Disabling SWO.');
config.swoConfig = { enabled: false, ports: [], cpuFrequency: 0, swoFrequency: 0 };
config.graphConfig = [];
}

return null;
}

Expand Down
5 changes: 5 additions & 0 deletions src/frontend/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { JLinkSocketRTTSource, SocketRTTSource, SocketSWOSource, PeMicroSocketSo
import { FifoSWOSource } from './swo/sources/fifo';
import { FileSWOSource } from './swo/sources/file';
import { SerialSWOSource } from './swo/sources/serial';
import { UsbSWOSource } from './swo/sources/usb';
import { SymbolInformation, SymbolScope } from '../symbols';
import { RTTTerminal } from './rtt_terminal';
import { GDBServerConsole } from './server_console';
Expand Down Expand Up @@ -763,6 +764,10 @@ export class CortexDebugExtension {
mySession.swoSource = new SerialSWOSource(e.body.device, e.body.baudRate);
Reporting.sendEvent('SWO', 'Source', 'Serial');
}
else if (e.body.type === 'usb') {
mySession.swoSource = new UsbSWOSource(e.body.device, e.body.port);
Reporting.sendEvent('SWO', 'Source', 'USB');
}

this.initializeSWO(e.session, e.body.args);
}
Expand Down
Loading

0 comments on commit 9ff7e3a

Please sign in to comment.