From fbc2f1072cc4724897699d3fe15e37b931f2cfb6 Mon Sep 17 00:00:00 2001 From: "Dennis Lambe Jr." Date: Fri, 28 Feb 2025 16:01:42 -0500 Subject: [PATCH 1/2] add specific error message for devices with no peripherals SEGGER's Ozone comes with some SVD files that don't define any peripherals. They're not useful for peripheral-viewer anyway, but maybe this will save someone else some time tracking down why what they're trying isn't working. --- src/svd-parser.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/svd-parser.ts b/src/svd-parser.ts index 7840db0..a987986 100644 --- a/src/svd-parser.ts +++ b/src/svd-parser.ts @@ -95,6 +95,9 @@ export class SVDParser { defaultOptions.accessType = accessTypeFromString(svdData.device.access[0]); } + if (!svdData.device.peripherals) { + throw new Error('Unable to parse SVD file: no peripherals defined'); + } svdData.device.peripherals[0].peripheral.forEach((element) => { const name = element.name[0]; peripheralMap[name] = element; From a13af7651234545dba2cc3f6560cad4a4423c42b Mon Sep 17 00:00:00 2001 From: "Dennis Lambe Jr." Date: Fri, 28 Feb 2025 16:09:32 -0500 Subject: [PATCH 2/2] add specific error message for register with no addressOffset SVD files produced by running tixml2svd on XML distributed with TI Code Creator Studio v20.0.2 for TI Hercules Cortex-R MCUs contain some registers that lack addressOffsets. I've submitted a PR to fix that bug, but I don't see the harm in also giving better guidance in the diagnostic message that peripheral-viewer produces. --- src/svd-parser.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/svd-parser.ts b/src/svd-parser.ts index a987986..9501229 100644 --- a/src/svd-parser.ts +++ b/src/svd-parser.ts @@ -349,6 +349,8 @@ export class SVDParser { registers.push(register); } } else { + if (!r.addressOffset) + throw new Error(`Unable to parse SVD file: register ${r.name[0]} has no addressOffset`); const description = this.cleanupDescription(r.description ? r.description[0] : ''); const register = new PeripheralRegisterNode(parent, { ...baseOptions,