Skip to content

Parsing fails if the "enumeratedValues derivedFrom" field of the SVD is described by a forward reference #513

@tekitounix

Description

@tekitounix

Hi, cortex-debug is very nice and I am grateful to the committers.

I'm working on a C ++ STM32 project and when I try to use the SVD used by svd2rust, it fails to load.

I used stm32f401.svd.patched, the error message is:

Unable to parse SVD file: Error: Invalid derivedFrom = HSIRDYR for enumeratedValues of field PLLI2SRDY

This SVD contains a enumeratedValues field that ST's SVD does not have.
I thought that the cause of the error was probably that enumeratedValues deriveFrom was a forward reference, so I changed the order of the SVD description so that the definition of enumeratedValues comes first, and now it can be loaded.

↓This is the error location in the SVD file and cannot be loaded.↓

<field>
  <name>HSERDY</name>
  ...
<enumeratedValues derivedFrom="HSIRDYR"/>
</field>
<field>
  <name>HSIRDY</name>
  ...
<enumeratedValues><name>HSIRDYR</name><usage>read</usage><enumeratedValue><name>NotReady</name><description>Clock not ready</description><value>0</value></enumeratedValue><enumeratedValue><name>Ready</name><description>Clock ready</description><value>1</value></enumeratedValue></enumeratedValues>
</field>

But when I changed the order of the definitions of "HSIRDYR", it worked.

<field>
  <name>HSERDY</name>
  ...
<enumeratedValues><name>HSIRDYR</name><usage>read</usage><enumeratedValue><name>NotReady</name><description>Clock not ready</description><value>0</value></enumeratedValue><enumeratedValue><name>Ready</name><description>Clock ready</description><value>1</value></enumeratedValue></enumeratedValues>
</field>
<field>
  <name>HSIRDY</name>
  ...
<enumeratedValues derivedFrom="HSIRDYR"/>
</field>

There were a lot of points that were similarly forward-referenced, and all had to be reordered.

However, since svd2rust already has some similar SVDs, it would be nice to be able to handle them without changing the SVD.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions