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

Patched SVD files do not meet the requirements through svdconv tool #825

Open
KamilDuljas opened this issue Mar 31, 2023 · 23 comments
Open

Comments

@KamilDuljas
Copy link

Example:
svdconv.exe stm32f7x6.svd
return

Found 0 Error(s) and 1 Warning(s).

svdconv.exe stm32f7x6.svd.patched
return
Found 1060 Error(s) and 292 Warning(s).

The patches schould be compatible with CMSIS tools and Vendors architecture manners.

@KamilDuljas
Copy link
Author

In relation to the comment:
Open-CMSIS-Pack/devtools#814 (comment)

forward reference is not supported and this restriction will be added to CMSIS documentation

@burrbull
Copy link
Contributor

I've made fast fix. Could you try stm32f7x6.svd.patched.new.zip ?

bors bot added a commit to rust-embedded/svdtools that referenced this issue Mar 31, 2023
145: add field name in enumeratedValues derive path r=adamgreig a=burrbull

for better compatibility with CMSIS specification

related to stm32-rs/stm32-rs#825

Co-authored-by: Andrey Zgarbul <zgarbul.andrey@gmail.com>
@KamilDuljas
Copy link
Author

Still the same. The solution is guaranting the ordering derivedFrom entry against to reference to type as I shown in
Open-CMSIS-Pack/devtools#814
For example: First declare USART1 and then use derivedFrom="USART1". The svdFile still use forward reference

@burrbull
Copy link
Contributor

where can I load svdconv for linux?

highly prefered by direct link for ci

@KamilDuljas
Copy link
Author

Compile source only
https://github.com/Open-CMSIS-Pack/devtools

@burrbull
Copy link
Contributor

it is awful

@KamilDuljas
Copy link
Author

@burrbull
Copy link
Contributor

I've added field name to derivedFrom which was the real issue. Then I reordered fields to place derived first, but svdconv still not happy:
изображение


*** ERROR M206: Z:/home/burrbull/tests/stm32f7x6.patched.supernew.svd (Line 9422) 
  DerivedFrom not found: 'PUPDR0.PUPDR0'

*** INFO M211: Z:/home/burrbull/tests/stm32f7x6.patched.supernew.svd (Line 9422) 
  Ignoring DerivedFrom  (see previous message)

*** INFO M211: Z:/home/burrbull/tests/stm32f7x6.patched.supernew.svd (Line 9422) 
  Ignoring EnumeratedValues  (see previous message)

*** ERROR M206: Z:/home/burrbull/tests/stm32f7x6.patched.supernew.svd (Line 9429) 
  DerivedFrom not found: 'PUPDR0.PUPDR0'

stm32f7x6.patched.supernew.svd.zip

@KamilDuljas
Copy link
Author

Hmm, You need read deeper CMSIS schema :p

            <field derivedFrom="PUPDR0">
              <name>PUPDR1</name>
              <description>Port x configuration bits (y =               0..15)</description>
              <bitOffset>2</bitOffset>
              <bitWidth>2</bitWidth>
            </field>

Above example works fine. Look also on USART. It uses "derviedFrom" as attribute of pheripherial node:

 <peripheral derivedFrom="USART1">
      <name>USART6</name>
      <baseAddress>0x40011400</baseAddress>
      <interrupt>
        <name>USART6</name>
        <description>USART6 global interrupt</description>
        <value>71</value>
      </interrupt>
    </peripheral>

@KamilDuljas
Copy link
Author

<xs:complexType name="fieldType">
    <xs:sequence>
      <xs:group    ref="dimElementGroup" minOccurs="0"/>
      <!-- name specifies a field's name. The System Viewer and the device header file will
           use the name of the field as identifier -->
      <xs:element name="name" type="dimableIdentifierType"/>
      <!-- description contains reference manual level information about the function and
           options of a field -->
      <xs:element name="description" type="stringType" minOccurs="0"/>
      <!-- alternative specifications of the bit position of the field within the register -->
      <xs:choice minOccurs="1" maxOccurs="1">
        <!-- bit field described by lsb followed by msb tag -->
        <xs:group ref="bitRangeLsbMsbStyle"/>
        <!-- bit field described by bit offset relative to Bit0 + bit width of field -->
        <xs:group ref="bitRangeOffsetWidthStyle"/>
        <!-- bit field described by [<msb>:<lsb>] -->
        <xs:element name="bitRange" type="bitRangeType"/>
      </xs:choice>
      <!-- access describes the predefined permissions for the field. -->
      <xs:element name="access" type="accessType" minOccurs="0"/>
      <!-- predefined description of write side effects -->
      <xs:element name="modifiedWriteValues" type="modifiedWriteValuesType" minOccurs="0"/>
      <!-- writeContstraint specifies the subrange of allowed values -->
      <xs:element name="writeConstraint" type="writeConstraintType" minOccurs="0"/>
      <!-- readAction specifies the read side effects. -->
      <xs:element name="readAction" type="readActionType" minOccurs="0"/>
      <!-- enumeratedValues derivedFrom=<identifierType> -->
      <xs:element name="enumeratedValues" type="enumerationType" minOccurs="0" maxOccurs="2">
      </xs:element>
    </xs:sequence>
    <xs:attribute name="derivedFrom" type="dimableIdentifierType" use="optional"/>
  </xs:complexType>

As above part of CMSIS schema I see that derivedFrom is attribute of field, not enumeratedValues

@burrbull
Copy link
Contributor

burrbull commented Apr 1, 2023

Hmm, You need read deeper CMSIS schema :p

            <field derivedFrom="PUPDR0">
              <name>PUPDR1</name>
              <description>Port x configuration bits (y =               0..15)</description>
              <bitOffset>2</bitOffset>
              <bitWidth>2</bitWidth>
            </field>

Deriving of whole field is independent question. You are right saying that this is better in this particular case.
But this doesn't give answer why svdconv can't find enumeratedValue. It doesn't say "whole field should be derived here", it says "DerivedFrom not found"

@KamilDuljas
Copy link
Author

KamilDuljas commented Apr 1, 2023

As I said above. Not found because enumerated value has not "derivedFrom" attribute in schema

@burrbull
Copy link
Contributor

burrbull commented Apr 1, 2023

enumeratedValues has https://www.keil.com/pack/doc/CMSIS/SVD/html/elem_registers.html#elem_enumeratedValues

Oh. @adamgreig could you comment this?

This file is modified from version 1.3.6 for the stm32-rs project:
https://github.com/stm32-rs/stm32-rs
stm32-rs changes:
- enumerationType now has enumeratedValue minOccurs=0, as otherwise
a derivedFrom enumerationType does not validate
Version 1.3.6:

@KamilDuljas
Copy link
Author

Ah, ok. My mistake.

Perhaps you should extend naming such as
peripheral + register + field?

@KamilDuljas
Copy link
Author

Ok I found some solution:
The name of enumeratedValues must be different than field name:

<field>
              <name>PUPDR0</name>
              <description>Port x configuration bits (y =               0..15)</description>
              <bitOffset>0</bitOffset>
              <bitWidth>2</bitWidth>
              <enumeratedValues>
                <name>PUPDR0A</name>
                <usage>read-write</usage>

and derivedFrom must be full "namespace":

<enumeratedValues derivedFrom="GPIOD.PUPDR.PUPDR0.PUPDR0A"/>

Otherwise It does not work. Maybe It is bug in svdconv or the next idocumentation issue and implicit assuming that the names must be different :)

@KamilDuljas
Copy link
Author

KamilDuljas commented Apr 1, 2023

I think that I open next issue on svdconv

@burrbull
Copy link
Contributor

burrbull commented Apr 1, 2023

Thanks.

The name of enumeratedValues must be different than field name:

This should be easy to fix

and derivedFrom must be full "namespace":

but this could be problematic, especially during patching. The shorter the path, the less conflicts.

@KamilDuljas
Copy link
Author

I know, full namespace sounds like bug... Or feature
:D

@burrbull
Copy link
Contributor

burrbull commented Apr 1, 2023

I know, full namespace sounds like bug... Or feature :D

It is feature if we have ready unbugged SVD.
But if we need to change it, or even more copy parts from one to another then it's not funny anymore.

@KamilDuljas
Copy link
Author

To tracking:
Open-CMSIS-Pack/devtools#815

@KamilDuljas
Copy link
Author

@burrbull please refer to the proposed solution in Open-CMSIS-Pack/devtools#815

@thorstendb-ARM
Copy link

thorstendb-ARM commented Apr 6, 2023

Hi, some comments:

  • SVDConv is available as compiled for Windows, Linux, Mac, and as source distribution. See https://github.com/Open-CMSIS-Pack/devtools
  • regarding derivedFrom:
    if field name and enumeratedValues container name are the same, it falls into a "this" trap, which fails afterwards, because the types do not match. See SvdItem.cpp, FindChildFromItem().
  • regarding forward references:
    currently SVDConv does not support forward references. This is because derivedFrom can be executed to an object or it's children that have already been derived from another object, a dimed object, or both. SVDConv model stores and links original data and references to other objects (derivedFrom and dim), but currently forward references (which means, that derivedFrom is executed after reading the whole model) are not supported.

Regarding derivedFrom="PUPDR0.PUPDR0": The derive mechanism uses either:

  • specify the name from current position going "down" the tree
  • specify the full name from top of tree (peripherals container)
    If the object cannot be found on the current level, it is searched on top level (peripherals). Currently it is not possible to specify a path that goes up some levels and then down again.

If we would have no clusters (group of registers or other clusters) this would be easy (go up the number of dots). But as we have clusters with an unknown depth (clusters in clusters...) e.g. a path to a register can have an unknown depth from the current position. Consider:
ClusterA, containing RegisterA
Register B derivedFrom="ClusterA.RegisterA"

@burrbull
Copy link
Contributor

burrbull commented Oct 15, 2023

@KamilDuljas with rust-embedded/svdtools#173 and #320 I've got

stm32f7x6.svd.patched.zip

svdconv shows:

Found 4 Error(s) and 295 Warning(s).

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