rust-embedded / rust-embedded/svd2rust

Disjoint array handling issue with Microchip SAM L21

Open
#713 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
857
Forks
164
PR merge metrics
No merged PRs in 30d

Description

Greetings,

I have run into an issue while upgrading my SAM L21 crates. With the SVD file ATSAML21G16B.svd, svd2rust v0.27.2 was successful while v0.28.0 (and current master) lead to the following compilation error:

error[E0412]: cannot find type `PMUX1_0` in this scope
   --> src\port.rs:58:19
    |
58  |     pub pmux1_0: [PMUX1_0; 16],
    |                   ^^^^^^^ help: a type alias with a similar name exists: `PMUX1_`
...
111 | pub type PMUX0_ = crate::Reg<pmux0_::PMUX0__SPEC>;
    | -------------------------------------------------- similarly named type alias `PMUX1_` defined here

error[E0412]: cannot find type `PINCFG1_0` in this scope
   --> src\port.rs:60:21
    |
60  |     pub pincfg1_0: [PINCFG1_0; 32],
    |                     ^^^^^^^^^ help: a type alias with a similar name exists: `PINCFG1_`
...
117 | pub type PINCFG0_ = crate::Reg<pincfg0_::PINCFG0__SPEC>;
    | -------------------------------------------------------- similarly named type alias `PINCFG1_` defined here

For more information about this error, try `rustc --explain E0412`.
error: could not compile `atsaml21g16b` due to 2 previous errors

In the generated file port.rs, the block:

#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
    // [...]
    #[doc = "0xb0..0xc0 - Peripheral Multiplexing n - Group 1"]
    pub pmux1_: [PMUX1_; 16],
    #[doc = "0xc0..0xe0 - Pin Configuration n - Group 1"]
    pub pincfg1_: [PINCFG1_; 32],
}

has changed to:

#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
    // [...]
    #[doc = "0xb0..0xc0 - Peripheral Multiplexing n - Group 1"]
    pub pmux1_0: [PMUX1_0; 16],
    #[doc = "0xc0..0xe0 - Pin Configuration n - Group 1"]
    pub pincfg1_0: [PINCFG1_0; 32],
}

A git bisect pointed me to 874f7df2b634e7fe85388b6416c1370e84802a3f. Is this a regression in svd2rust or an error in the SVD file?

Thanks in advance!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ATSAML21G16B.svd and the generated port.rs, then inspect the change introduced by commit 874f7df2b634e7fe85388b6416c1370e84802a3f. Compare svd2rust v0.27.2 with v0.28.0 for the PMUX and PINCFG array types; done means determining whether the regression is in svd2rust or the SVD and documenting or fixing the cause.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
embedded-iot, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.