robertlipe / svdtoheaders

svdtoheaders parses CMSIS System View Description (SVD) file and writes C headers describing parts, written in style of Nuttx memorymap.h and various peripheral device register files.
BSD 2-Clause "Simplified" License
1 stars 1 forks source link

Error when using -r #1

Open eeucalyptus opened 8 months ago

eeucalyptus commented 8 months ago

Hi, when I try using the -r flag to generate the register header, I get an error

$ svdtoheaders -s AT32F403Axx_v2.svd -p "" -r AT32F403Axx_registers.h -o
Traceback (most recent call last):
  File "/home/eike/.local/bin/svdtoheaders", line 238, in <module>
    main()
  File "/home/eike/.local/bin/svdtoheaders", line 234, in main
    for r in (registers(doc)):
  File "/home/eike/.local/bin/svdtoheaders", line 118, in registers
    fields = register.get('fields', {}).get('field', [])
AttributeError: 'NoneType' object has no attribute 'get'
$ 

I'm using this SVD: https://raw.githubusercontent.com/vadrov/AT32F403ACGU7_display_spi_dma_st7789_ili9341/main/SVD/AT32F403Axx_v2.svd

robertlipe commented 8 months ago

There's something in that svd file we're not expecting. Please include it or a reduced case that repros the problem.

On Sat, Jan 13, 2024, 1:48 PM eeucalyptus @.***> wrote:

Hi, when I try using the -r flag to generate the register header, I get an error

$ svdtoheaders -s AT32F403Axx_v2.svd -p "" -r AT32F403Axx_registers.h -o Traceback (most recent call last): File "/home/eike/.local/bin/svdtoheaders", line 238, in main() File "/home/eike/.local/bin/svdtoheaders", line 234, in main for r in (registers(doc)): File "/home/eike/.local/bin/svdtoheaders", line 118, in registers fields = register.get('fields', {}).get('field', []) AttributeError: 'NoneType' object has no attribute 'get' $

— Reply to this email directly, view it on GitHub https://github.com/robertlipe/svdtoheaders/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCSD37SYFVI46TH2G4ENM3YOLQIJAVCNFSM6AAAAABBZQ75QGVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA4DANBUHE4DONI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

eeucalyptus commented 8 months ago

I'm not exacty sure what you mean. I was able to pinpoint the error to the register "PSR", which is defined as

        <register>
          <name>PSR</name>
          <displayName>PSR</displayName>
          <description>Performance selection register</description>
          <addressOffset>0x0</addressOffset>
          <size>0x20</size>
          <resetValue>0x00000030</resetValue>
          <fields>
          </fields>
        </register>

in contrast to all other registers, the "\<fields>" section is empty. I don't know about the svd standard, but in xml that's completely valid.

My suggestion would be to add a sanity check there. I can also add a pull request if that's of interest.

BTW my workaround was to add a field "reserved" which was 32 bit long

robertlipe commented 8 months ago

You didn't include that, so I don't know how I was supposed to guess that. I don't know what 'the "" section' means.

If you spot what makes that file unique, please submit a PR that works with your files. Since you're literally issue #1 with this problem since it was published, it's not like it's been exposed (to my knowledge) to thousands of SVDs and the rich, creative ways I'm sure that vendors have found to make them squirrely.

Thank you.

On Sat, Jan 13, 2024 at 3:30 PM eeucalyptus @.***> wrote:

I'm not exacty sure what you mean. I was able to pinpoint the error to the register "PSR", which is defined as

    <register>
      <name>PSR</name>
      <displayName>PSR</displayName>
      <description>Performance selection register</description>
      <addressOffset>0x0</addressOffset>
      <size>0x20</size>
      <resetValue>0x00000030</resetValue>
      <fields>
      </fields>
    </register>

in contrast to all other registers, the "" section is empty. I don't know about the svd standard, but in xml that's completely valid.

My suggestion would be to add a sanity check there. I can also add a pull request if that's of interest.

— Reply to this email directly, view it on GitHub https://github.com/robertlipe/svdtoheaders/issues/1#issuecomment-1890773692, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCSD33JDROB6JY5YY6JVITYOL4IXAVCNFSM6AAAAABBZQ75QGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJQG43TGNRZGI . You are receiving this because you commented.Message ID: @.***>

eeucalyptus commented 8 months ago

Alright I see where their initial miscommunication came from, I had to edit my description because I didn't escape the brackets in the first place and updates don't seem to be sent via email :D also the link to the svd file seems to be affected, hence the confusion

Okay I'll submit a PR when I find the time for a fix