-
Notifications
You must be signed in to change notification settings - Fork 36
improve derive for registers (breaking) #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit enables two features (F): F1. We're permitted to rename a peripheral that has a derivedFrom attribute. F2. When we rename a peripheral that has derivations, svd patch will automatically update all derivations to use the new name. These behaviors support renames of peripheral hierarchies. Suppose a chip has two USB peripherals: USB_OTG1 and USB_OTG2. USB_OTG2 derives from USB_OTG1. Before this commit, renaming these peripherals to USB1 and USB2 looks like this: _modify: # Step 1: Rename the base peripheral USB_OTG1 => USB1. _peripherals: USB_OTG1: name: USB1 _delete: # Step 2: Delete USB_OTG2, because it can't be renamed. - USB_OTG2 _add: # Step 3: Add USB2, derived from USB1, with values from the SVD. USB2: derivedFrom: USB1 baseAddress: 0x4042C000 addressBlock: # Re-define address block interrupts: # Re-define interrupts Step 2 is required because modifications don't apply to derivedFrom peripherals (line 180 in README.md). Step 3 means we duplicate SVD information which was otherwise correct. This could be cumbersome when trying to rename many instances. (I wasn't able to figure out any other way to achieve this rename. Let me know if this is already supported using other svdtool directives.) F1 makes it easier to achieve the rename. There's no need for steps 2 and 3. When combined with F2, we write _modify: _peripherals: USB_OTG1: name: USB1 USB_OTG2: name: USB2 F2 is a convenience. Without it, it's possible to use _derive directives to fix the names. (You can't use _rebase though; _rebase needs both peripherals to exist.) But _derive seems to focus on collapsing independently-defined peripherals, which is not what we're doing when changing peripheral names.
@mciantyre Could you test both Python and Rust |
svd2rust now supports register deriving, but svdtools doesn't |
self.get_register(rderive) | ||
.ok_or_else(|| anyhow!("register {} not found", rderive))?; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also 1 question. Should we do this check?
It doesn't support cross-peripheral deriving.
Looks good for my purposes. See 0faef6f's message to understand original and new approaches. Python
Rust
|
A UI nitpick I noticed while testing rust-embedded#118. The Rust-based svdtools patch help output suggests that the user provides an SVD file: $ svdtools patch --help svdtools-patch Patches an SVD file as specified by a YAML file USAGE: svdtools patch <SVD_FILE> ARGS: <SVD_FILE> Path to input SVD file OPTIONS: -h, --help Print help information If we actually provide an SVD file, the tool errors. $ svdtools patch ../ral/svd/imxrt1176_cm7.svd [2022-08-19T12:47:48Z ERROR svdtools::cli] mapping values are not allowed in this context at line 11 column 24 Compare this with the Python documentation, which suggests that the user provides a YAML file, not an SVD file. svd patch --help Usage: svd patch [OPTIONS] YAML_FILE Patches an SVD file as specified by a YAML file Options: --help Show this message and exit.
This looks good to me. I propose we merge this first, then fix conflicts in #89 and merge that too, then release a new svdtools (despite the stm32-rs and rp2040 tests failing at that point) and get PRs merged in those repos as soon as possible afterwards to use the new version. Does that sound OK? |
OK |
Closes #73, #116