Skip to content

Commit 2436b4d

Browse files
committed
svdAddrGapThreshold added
1 parent cdd84a3 commit 2436b4d

File tree

8 files changed

+32
-8
lines changed

8 files changed

+32
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ New Features
99

1010
* 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.
1111
* 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`.
12+
* `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.
1213

1314
```
1415
"postRestartSessionCommands": [

debug_attributes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
| servertype | Common | GDB Server type - supported types are jlink, openocd, pyocd, pe, stlink, stutil, qemu and external
3434
| showDevDebugOutput | Common | Prints all GDB responses to the console
3535
| showDevDebugTimestamps | Common | Show timestamps when 'showDevDebugOutput' is true
36+
| svdAddrGapThreshold | Common | If the gap between registers is less than this threshold (multiple of 8), combine into a single read from device
3637
| 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.
3738
| swoConfig | Common | (unknown)
3839
| 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)

package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,14 @@
570570
"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.",
571571
"type": "string"
572572
},
573+
"svdAddrGapThreshold": {
574+
"default": 16,
575+
"type": "number",
576+
"multipleOf": 8,
577+
"minimum": 0,
578+
"maximum": 32,
579+
"description": "If the gap between registers is less than this threshold (multiple of 8), combine into a single read from device"
580+
},
573581
"rttConfig": {
574582
"type": "object",
575583
"description": "SEGGER's Real Time Trace (RTT) and supported by JLink, OpenOCD and perhaps others in the future",
@@ -1396,6 +1404,14 @@
13961404
"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.",
13971405
"type": "string"
13981406
},
1407+
"svdAddrGapThreshold": {
1408+
"default": 16,
1409+
"type": "number",
1410+
"multipleOf": 8,
1411+
"minimum": 0,
1412+
"maximum": 32,
1413+
"description": "If the gap between registers is less than this threshold (multiple of 8), combine into a single read from device"
1414+
},
13991415
"rttConfig": {
14001416
"type": "object",
14011417
"description": "SEGGER's Real Time Trace (RTT) and supported by JLink, OpenOCD and perhaps others in the future",

src/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ export interface ConfigurationArguments extends DebugProtocol.LaunchRequestArgum
184184
overrideGDBServerStartedRegex: string;
185185
doNotContinueAfterReset: boolean;
186186
svdFile: string;
187+
svdAddrGapThreshold: number;
187188
rttConfig: RTTConfiguration;
188189
swoConfig: SWOConfiguration;
189190
graphConfig: any[];

src/frontend/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ export class CortexDebugExtension {
496496
if (Object.keys(this.rttPortMap).length > 0) { this.initializeRTT(args); }
497497

498498
this.registerProvider.debugSessionStarted();
499-
this.peripheralProvider.debugSessionStarted(svdfile ? svdfile : null);
499+
this.peripheralProvider.debugSessionStarted(svdfile ? svdfile : null, args.svdAddrGapThreshold);
500500
this.cleanupRTTTerminals();
501501
}, (error) => {
502502
// TODO: Error handling for unable to get arguments

src/frontend/svd.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ const ACCESS_TYPE_MAP = {
2424
export class SVDParser {
2525
private static enumTypeValuesMap = {};
2626
private static peripheralRegisterMap = {};
27+
private static gapThreshold: number = 16;
2728

28-
public static parseSVD(path: string): Promise<PeripheralNode[]> {
29+
public static parseSVD(path: string, gapThreshold: number): Promise<PeripheralNode[]> {
30+
SVDParser.gapThreshold = gapThreshold;
2931
SVDParser.enumTypeValuesMap = {};
3032
SVDParser.peripheralRegisterMap = {};
3133
return new Promise((resolve, reject) => {
@@ -405,7 +407,7 @@ export class SVDParser {
405407
if (p.resetValue) { options.resetValue = parseInteger(p.resetValue[0]); }
406408
if (p.groupName) { options.groupName = p.groupName[0]; }
407409

408-
const peripheral = new PeripheralNode(options);
410+
const peripheral = new PeripheralNode(SVDParser.gapThreshold, options);
409411

410412
if (p.registers) {
411413
if (p.registers[0].register) {

src/frontend/views/nodes/peripheralnode.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class PeripheralNode extends PeripheralBaseNode {
3636

3737
private currentValue: number[];
3838

39-
constructor(options: PeripheralOptions) {
39+
constructor(public gapThreshold, options: PeripheralOptions) {
4040
super(null);
4141

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

165164
// OpenOCD has an issue where the max number of bytes readable are 8191 (instead of 8192)

src/frontend/views/peripheral.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export class PeripheralTreeProvider implements vscode.TreeDataProvider<Periphera
1818
private peripherials: PeripheralNode[] = [];
1919
private loaded: boolean = false;
2020
private svdFileName: string | null;
21+
private gapThreshold: number = 16;
2122

2223
constructor() {
2324

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

4748
this.svdFileName = SVDFile;
4849
try {
49-
return SVDParser.parseSVD(SVDFile).then((peripherals) => {
50+
return SVDParser.parseSVD(SVDFile, this.gapThreshold).then((peripherals) => {
5051
this.peripherials = peripherals;
5152
this.loaded = true;
5253
resolve(true);
@@ -98,11 +99,14 @@ export class PeripheralTreeProvider implements vscode.TreeDataProvider<Periphera
9899
}
99100
}
100101

101-
public debugSessionStarted(svdfile: string): Thenable<any> {
102+
public debugSessionStarted(svdfile: string, thresh: any): Thenable<any> {
102103
return new Promise<void>((resolve, reject) => {
103104
this.peripherials = [];
104105
this.loaded = false;
105106
this._onDidChangeTreeData.fire(undefined);
107+
108+
// Set the threshold between 0 and 32, with a default of 16 and a mukltiple of 8
109+
this.gapThreshold = ((((typeof thresh) === 'number') ? Math.max(0, Math.min(thresh, 32)) : 16) + 7) & ~0x7;
106110

107111
if (svdfile) {
108112
setTimeout(() => {

0 commit comments

Comments
 (0)