eclipse-cdt-cloud / eclipse-cdt-cloud/vscode-peripheral-inspector

Incorrect inheritance of derivedFrom registers when peripheral also uses derivedFrom

Open
#124 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
9
Forks
17
Avg merge
4d 12h
Merged PRs (30d)
5

Description

Type: Bug Report

**Describe the bug**
- OS and Version: Microsoft Windows 11 pro
- VS Code Version: 1.127.0
- Extension Version: 1.9.2
- Target Device: MDR12065
- Other extensions you installed: Cortex-Debug, C/C++
- A clear and concise description of what the bug is.

Incorrect handling of the derivedFrom attribute for registers inside peripherals that also use derivedFrom.
Suppose we have a peripheral block PORTA with registers REG1 and REG2, where REG2 has the attribute derivedFrom="REG1". We also have a peripheral block PORTB declared with derivedFrom="PORTA". In this case, the extension processes the SVD file incorrectly: register REG2 in PORTB does not inherit the fields and properties of register REG1, as required by the CMSIS‑SVD specification.
In the attached test.svd file, the registers of peripherals PORTB, PORTC, and PORTD that use the derivedFrom attribute are handled incorrectly and are displayed as read‑only, even when this does not match their actual definition in the SVD file. Only PORTA registers are displayed correctly.

**To Reproduce**
Steps to reproduce the behavior:
1. Open a project that includes test.svd.
2. Start debugging with a configuration that uses test.svd.
3. Expand the PERIPHERALS view.
4. PORTB, PORTC, and PORTD are displayed incorrectly: the OE, ANALOG, and other registers with the derivedFrom attribute appear as read‑only and have no fields.

**Expected behavior**
Registers with the derivedFrom attribute inside peripherals that themselves use derivedFrom must inherit the fields, access types, and other properties of the base register in accordance with the CMSIS‑SVD specification.

**Code sample and logs**
- `test.svd` in [example.zip](https://github.com/user-attachments/files/29843615/example.zip)
- [registers.xml](https://github.com/user-attachments/files/29843684/registers.xml)

**Screenshots**
Image

Image

**Additional context**
This issue is likely caused by shallow inheritance in the SVD parser. Peripheral nodes that use derivedFrom are merged only at the top level, without properly expanding and linking their nested registers and fields. As a result, when a register with derivedFrom is inside a peripheral that also uses derivedFrom, the parser does not resolve the base register from the original peripheral context, and the derived register fails to inherit from the base register.

Contributor guide

Open the contributing guide

Research direction

Start by opening the attached test.svd and registers.xml, then reproduce the issue in the VS Code PERIPHERALS view with PORTA through PORTD. Trace how derivedFrom is resolved for peripherals and nested registers. Done means derived registers inherit the base register's fields, access types, and other properties and are displayed correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
devtools, embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.