Skip to content

Commit

Permalink
svdAddrGapThreshold added
Browse files Browse the repository at this point in the history
  • Loading branch information
haneefdm committed Sep 10, 2021
1 parent cdd84a3 commit 2436b4d
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ New Features

* The only place we could put the `Reset` button was at the beginning. We would have rather put it closer to the end but there isn't an API to do that as far as we know. Note that the toolbar appears in docking and floating modes and it is the docking mode where this was not possible. Hopefully, it is not a hinderance.
* Some gdb-servers do not respond appropriately to being reset to be compatible with `gdb`. You will have to find out what set of gdb-server/gdb commands work for you and use appropriate options in the `launch.json`. For instance, just after 'reset halt' some versions of OpenOCD do not provide `gdb` the updated registers (SP, PC, LR, etc.). Some devices may have a more complicated, customized reset mechanism, boot-loaders, etc. To force a synchronization between `OpenOCD` and `gdb`, you can do the following in `launch.json`.
* `svdAddrGapThreshold` `launch.json` option. Normally adjacent register addresses with small gaps are combined to reduce the number of device memory reads. Default is 16 bytes. You can now control the number of bytes the gap can be including zero. Zero means strict reading of bytes but adjacent registers are still combined if there is no gap.

```
"postRestartSessionCommands": [
Expand Down
1 change: 1 addition & 0 deletions debug_attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
| servertype | Common | GDB Server type - supported types are jlink, openocd, pyocd, pe, stlink, stutil, qemu and external
| showDevDebugOutput | Common | Prints all GDB responses to the console
| showDevDebugTimestamps | Common | Show timestamps when 'showDevDebugOutput' is true
| svdAddrGapThreshold | Common | If the gap between registers is less than this threshold (multiple of 8), combine into a single read from device
| svdFile | Common | Path to an SVD file describing the peripherals of the microcontroller; if not supplied then one may be selected based upon the 'device' entered.
| swoConfig | Common | (unknown)
| targetId | Common | 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)
Expand Down
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,14 @@
"description": "Path to an SVD file describing the peripherals of the microcontroller; if not supplied then one may be selected based upon the 'device' entered.",
"type": "string"
},
"svdAddrGapThreshold": {
"default": 16,
"type": "number",
"multipleOf": 8,
"minimum": 0,
"maximum": 32,
"description": "If the gap between registers is less than this threshold (multiple of 8), combine into a single read from device"
},
"rttConfig": {
"type": "object",
"description": "SEGGER's Real Time Trace (RTT) and supported by JLink, OpenOCD and perhaps others in the future",
Expand Down Expand Up @@ -1396,6 +1404,14 @@
"description": "Path to an SVD file describing the peripherals of the microcontroller; if not supplied then one may be selected based upon the 'device' entered.",
"type": "string"
},
"svdAddrGapThreshold": {
"default": 16,
"type": "number",
"multipleOf": 8,
"minimum": 0,
"maximum": 32,
"description": "If the gap between registers is less than this threshold (multiple of 8), combine into a single read from device"
},
"rttConfig": {
"type": "object",
"description": "SEGGER's Real Time Trace (RTT) and supported by JLink, OpenOCD and perhaps others in the future",
Expand Down
1 change: 1 addition & 0 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export interface ConfigurationArguments extends DebugProtocol.LaunchRequestArgum
overrideGDBServerStartedRegex: string;
doNotContinueAfterReset: boolean;
svdFile: string;
svdAddrGapThreshold: number;
rttConfig: RTTConfiguration;
swoConfig: SWOConfiguration;
graphConfig: any[];
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ export class CortexDebugExtension {
if (Object.keys(this.rttPortMap).length > 0) { this.initializeRTT(args); }

this.registerProvider.debugSessionStarted();
this.peripheralProvider.debugSessionStarted(svdfile ? svdfile : null);
this.peripheralProvider.debugSessionStarted(svdfile ? svdfile : null, args.svdAddrGapThreshold);
this.cleanupRTTTerminals();
}, (error) => {
// TODO: Error handling for unable to get arguments
Expand Down
6 changes: 4 additions & 2 deletions src/frontend/svd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ const ACCESS_TYPE_MAP = {
export class SVDParser {
private static enumTypeValuesMap = {};
private static peripheralRegisterMap = {};
private static gapThreshold: number = 16;

public static parseSVD(path: string): Promise<PeripheralNode[]> {
public static parseSVD(path: string, gapThreshold: number): Promise<PeripheralNode[]> {
SVDParser.gapThreshold = gapThreshold;
SVDParser.enumTypeValuesMap = {};
SVDParser.peripheralRegisterMap = {};
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -405,7 +407,7 @@ export class SVDParser {
if (p.resetValue) { options.resetValue = parseInteger(p.resetValue[0]); }
if (p.groupName) { options.groupName = p.groupName[0]; }

const peripheral = new PeripheralNode(options);
const peripheral = new PeripheralNode(SVDParser.gapThreshold, options);

if (p.registers) {
if (p.registers[0].register) {
Expand Down
5 changes: 2 additions & 3 deletions src/frontend/views/nodes/peripheralnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class PeripheralNode extends PeripheralBaseNode {

private currentValue: number[];

constructor(options: PeripheralOptions) {
constructor(public gapThreshold, options: PeripheralOptions) {
super(null);

this.name = options.name;
Expand Down Expand Up @@ -156,10 +156,9 @@ export class PeripheralNode extends PeripheralBaseNode {
if (skipAddressGaps) {
// Split the entire range into a set of smaller ranges. Some svd files specify
// a very large address space but may use very little of it.
const gapThreshold = 16; // Merge gaps less than this many bytes, avoid too many gdb requests
const addresses = new AddressRangesInUse(this.totalLength);
this.children.map((child) => child.markAddresses(addresses));
ranges = addresses.getAddressRangesOptimized(this.baseAddress, false, gapThreshold);
ranges = addresses.getAddressRangesOptimized(this.baseAddress, false, this.gapThreshold);
}

// OpenOCD has an issue where the max number of bytes readable are 8191 (instead of 8192)
Expand Down
8 changes: 6 additions & 2 deletions src/frontend/views/peripheral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class PeripheralTreeProvider implements vscode.TreeDataProvider<Periphera
private peripherials: PeripheralNode[] = [];
private loaded: boolean = false;
private svdFileName: string | null;
private gapThreshold: number = 16;

constructor() {

Expand Down Expand Up @@ -46,7 +47,7 @@ export class PeripheralTreeProvider implements vscode.TreeDataProvider<Periphera

this.svdFileName = SVDFile;
try {
return SVDParser.parseSVD(SVDFile).then((peripherals) => {
return SVDParser.parseSVD(SVDFile, this.gapThreshold).then((peripherals) => {
this.peripherials = peripherals;
this.loaded = true;
resolve(true);
Expand Down Expand Up @@ -98,11 +99,14 @@ export class PeripheralTreeProvider implements vscode.TreeDataProvider<Periphera
}
}

public debugSessionStarted(svdfile: string): Thenable<any> {
public debugSessionStarted(svdfile: string, thresh: any): Thenable<any> {
return new Promise<void>((resolve, reject) => {
this.peripherials = [];
this.loaded = false;
this._onDidChangeTreeData.fire(undefined);

// Set the threshold between 0 and 32, with a default of 16 and a mukltiple of 8
this.gapThreshold = ((((typeof thresh) === 'number') ? Math.max(0, Math.min(thresh, 32)) : 16) + 7) & ~0x7;

if (svdfile) {
setTimeout(() => {
Expand Down

0 comments on commit 2436b4d

Please sign in to comment.