Skip to content

Commit

Permalink
feat(bmp): make SWO encoding (Manchester/UART) configurable
Browse files Browse the repository at this point in the history
Refs: bmp enhancements; swo support #20
  • Loading branch information
ssimek committed Jan 14, 2025
1 parent 790df01 commit 5c9a24d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
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 5c9a24d

Please sign in to comment.