Skip to content

Commit

Permalink
Merge pull request #1073 from minuteos/feat/bmp-usb-swo
Browse files Browse the repository at this point in the history
BMP SWO support final touches
  • Loading branch information
haneefdm authored Jan 15, 2025
2 parents fb96ac6 + 5c9a24d commit 9c1ab68
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
* It is not clear what (should) happens when you use the `Restart` button when multiple debuggers are active at the same time. For instance in a multi-core session. It may work, but we have not tested it.
* This is the reason why we implemented the `Reset` button a while ago because VSCode `Restart` meant different (undocumented) behaviors at different times.
* As a result, all the Restart related launch.json properties no longer apply. But, for compatibility reasons, they still exist and used by the `Reset` functionality when a `Reset` specific property does not exist. This is what used to happen in the previous releases.
* Native external dependencies have been integrated into the extension once again (`serialport` and `usb` packages),
so the extension no longer depends on other extensions to provide related functionality.
* Black Magic Probe now supports SWO via the dedicated USB endpoint.
* ST-LINK GDB server (*not* st-util) now supports SWO functionality, using standard configuration options.

# V1.12.1
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
Debugging support for ARM Cortex-M Microcontrollers with the following features:

* Highly configurable. See https://github.com/Marus/cortex-debug/blob/master/debug_attributes.md
* Support J-Link, OpenOCD GDB Server, STMicroelectronic's ST-LINK GDB server, pyOCD
* Initial support for the Black Magic Probe (This has not been as heavily tested; SWO can only be captured via a serial port)
* Support J-Link, OpenOCD GDB Server, STMicroelectronic's ST-LINK GDB server, pyOCD and the Black Magic Probe
* Partial support textane/stlink (st-util) GDB Servers (SWO can only be captured via a serial port)
* Multi-core and multi-session debugging. See https://github.com/Marus/cortex-debug/wiki/Multi-core-debugging
* Disassembly of source code available along with instruction level breakpoints and stepping. The actual disassembly window is provided and managed by VSCode. See https://github.com/Marus/cortex-debug/wiki/Disassembly-Debugging
Expand Down
1 change: 1 addition & 0 deletions debug_attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ If the type is marked as `{...}` it means that it is a complex item can have mul
| swoConfig<br>.decoders | {object} | Both | SWO Decoder Configuration |
| 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>.swoEncoding | string | Both | BMP only: SWO encoding data used at the line level. Depends on the probe hardware, native (the original one) supports only Manchester (self-clocked, but slower rates) while most other platforms (e.g. ST-LINK with BMP firmware) support only UART (frequency/baud rate has to match to within ~2%). |
| swoConfig<br>.swoFrequency | number | Both | SWO frequency in Hz. |
| 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. |
Expand Down
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,15 @@
"default": 0,
"description": "SWO frequency in Hz; 0 will attempt to automatically calculate.",
"type": "number"
},
"swoEncoding": {
"default": "uart",
"description": "BMP only: SWO encoding data used at the line level. Depends on the probe hardware, native (the original one) supports only Manchester (self-clocked, but slower rates) while most other platforms (e.g. ST-LINK with BMP firmware) support only UART (frequency/baud rate has to match to within ~2%).",
"type": "string",
"enum": [
"uart",
"manchester"
]
}
},
"required": [],
Expand Down Expand Up @@ -2683,6 +2692,15 @@
"default": 0,
"description": "SWO frequency in Hz.",
"type": "number"
},
"swoEncoding": {
"default": "uart",
"description": "BMP only: SWO encoding data used at the line level. Depends on the probe hardware, native (the original one) supports only Manchester (self-clocked, but slower rates) while most other platforms (e.g. ST-LINK with BMP firmware) support only UART (frequency/baud rate has to match to within ~2%).",
"type": "string",
"enum": [
"uart",
"manchester"
]
}
},
"required": [],
Expand Down
4 changes: 2 additions & 2 deletions src/bmp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class BMPServerController extends EventEmitter implements GDBServerContro
const cpuFrequency = this.args.swoConfig.cpuFrequency;

const ratio = Math.floor(cpuFrequency / swoFrequency) - 1;
const encoding = this.args.swoConfig.source === 'probe' ? 1 : 2;
const encoding = this.args.swoConfig.swoEncoding === 'manchester' ? 1 : 2;

const commands: string[] = [];

Expand All @@ -112,7 +112,7 @@ 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');
commands.push(encoding === 2 ? `monitor traceswo ${swoFrequency}` : 'monitor traceswo');
}

return commands.map((c) => `interpreter-exec console "${c}"`);
Expand Down
1 change: 1 addition & 0 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export interface SWOConfiguration {
enabled: boolean;
cpuFrequency: number;
swoFrequency: number;
swoEncoding: 'manchester' | 'uart';
decoders: any[];
profile: boolean;
source: string;
Expand Down

0 comments on commit 9c1ab68

Please sign in to comment.