Skip to content
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

Build Errors in Code Generated from Renesas RA6M3 SVD #852

Open
AddisonH opened this issue Jun 18, 2024 · 3 comments
Open

Build Errors in Code Generated from Renesas RA6M3 SVD #852

AddisonH opened this issue Jun 18, 2024 · 3 comments

Comments

@AddisonH
Copy link

AddisonH commented Jun 18, 2024

Hello, I am seeing many errors when attempting to build a PAC from a Renesas RA6M3 SVD file. I've already fixed some errors that I found in the Renesas provided file. I've attached the modified file below.

R7FA6M3AH.svd.txt

Here is a sample of the errors that I'm seeing:

Error E0412

error[E0412]: cannot find type `P40pfs` in this scope
    --> src\pfs.rs:68:15
     |
68   |     p400pfs: [P40pfs; 10],
     |               ^^^^^^ help: a type alias with a similar name exists: `P400pfs`
...
2702 | pub type P100pfs = crate::Reg<p100pfs::P100pfsSpec>;
     | ---------------------------------------------------- similarly named type alias `P400pfs` defined here

Error E0592

error[E0592]: duplicate definitions with name `offset`
   --> src\generic.rs:223:5
    |
223 |     pub const fn offset(&self) -> u8 {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ duplicate definitions for `offset`
    |
   ::: src\glcdc\tcon_tim.rs:28:5
    |
28  |     pub fn offset(self) -> &'a mut crate::W<REG> {
    |     -------------------------------------------- other definition for `offset`

Error E0599

error[E0599]: the method `variant` exists for struct `FieldWriter<'a, REG, 11, Fh, Safe>`, but its trait bounds were not satisfied
   --> src\glcdc\bg_peri.rs:29:14
    |
7   | pub struct Fh(u16);
    | ------------- doesn't satisfy `Fh: generic::IsEnum`
...
29  |         self.variant(Fh::Fh)
    |              ^^^^^^^ method cannot be called on `FieldWriter<'a, REG, 11, Fh, Safe>` due to unsatisfied trait bounds
    |
   ::: src\generic\raw.rs:44:1
    |
44  | pub struct FieldWriter<'a, REG, const WI: u8, FI = u8, Safety = Unsafe>
    | ----------------------------------------------------------------------- method `variant` not found for this struct
    |
note: trait bound `Fh: generic::IsEnum` was not satisfied
   --> src\generic.rs:312:9
    |
309 | impl<'a, REG, const WI: u8, FI, Safety> FieldWriter<'a, REG, WI, FI, Safety>
    |                                         ------------------------------------
...
312 |     FI: IsEnum,
    |         ^^^^^^ unsatisfied trait bound introduced here
note: the trait `generic::IsEnum` must be implemented
   --> src\generic.rs:54:1
    |
54  | pub trait IsEnum: FieldSpec {}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^

Here is the full log:
cargo_check.txt

I've tested this SVD file with several versions of svd2rust. I found that version 0.30.x works without error, but I begin to have trouble starting with version 0.31.x and up. These error logs are from the latest tagged version, v 0.33.4.

Here is my PAC that I'm working on:
ra6m3-pac.zip

Please let me know if I can offer up any more detail or assist with debugging. Thanks.

@burrbull
Copy link
Member

It looks like 2 main issues here:

1st was introduced in #692. Looks like:

error[E0592]: duplicate definitions with name `p400pfs`
    --> src/pfs.rs:1050:5
     |
1045 |     pub const fn p400pfs(&self, n: usize) -> &P400PFS {
     |     ------------------------------------------------- other definition for `p400pfs`
...
1050 |     pub const fn p400pfs(&self) -> &P400PFS {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ duplicate definitions for `p400pfs`

There should be pub const fn p40pfs(&self, n: usize) -> &P40PFS on 1045. Register description:

                <register derivedFrom="P100PFS">
                    <dim>10</dim>
                    <dimIncrement>0x4</dimIncrement>
                    <dimIndex>0-9</dimIndex>
                    <name>P40%sPFS</name>
                    <description>P40%s Pin Function Control Register</description>
                    <addressOffset>0x100</addressOffset>
                    <size>32</size>
                    <access>read-write</access>
                    <resetValue>0x00000000</resetValue>
                    <resetMask>0xFFFFFFFD</resetMask>
                </register>

2nd is related to special case not covered in #767.
EnumeratedValues with only one isDefault value.

                        <field>
                            <name>GAIN01</name>
                            <description>Gain value of area 1Unsigned 11-bit fixed point</description>
                            <lsb>0</lsb>
                            <msb>10</msb>
                            <access>read-write</access>
                            <enumeratedValues>
                                <enumeratedValue>
                                    <name>GAIN01</name>
                                    <description>GAIN01/1024</description>
                                    <isDefault>true</isDefault>
                                </enumeratedValue>
                            </enumeratedValues>
                        </field>

@burrbull
Copy link
Member

cc @n8tlarsen

@9names
Copy link

9names commented Aug 3, 2024

as per ra-rs/ra#6 n8tlarsen isn't active with ra-rs any more.
cc @elrafoon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants