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 generated using the parameter -r #3

Open i-tesetd-it-no-problem opened 1 month ago

i-tesetd-it-no-problem commented 1 month ago

Hello,

When I use the parameter -r with this script, I encounter the following error. Attached is the SVD file I am using. Additionally, I also experience an error when using the parameter -m.

$ python svdtoheaders -s GD32F30x_XD.svd -r test_reg.h Traceback (most recent call last): File "D:\Tool\svdtoheaders\svdtoheaders", line 238, in main() File "D:\Tool\svdtoheaders\svdtoheaders", line 234, in main for r in (registers(doc)): ^^^^^^^^^^^^^^ File "D:\Tool\svdtoheaders\svdtoheaders", line 149, in registers for original_name, original_value in pperiphs[d_name].items():


KeyError: 'GPIOB'
-------------------------------------------------------------------------------------
$ python svdtoheaders -s GD32F30x_XD.svd -m test_map.h
Traceback (most recent call last):
  File "D:\Tool\svdtoheaders\svdtoheaders", line 238, in <module>
    main()
  File "D:\Tool\svdtoheaders\svdtoheaders", line 226, in main
    for p in (peripherals(doc)):
              ^^^^^^^^^^^^^^^^
  File "D:\Tool\svdtoheaders\svdtoheaders", line 55, in peripherals
    size = int(address_block.get('size', "0"), 0)
               ^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'get'
-------------------------------------------------------------------------------------
[GD32F30x_XD.zip](https://github.com/user-attachments/files/16408910/GD32F30x_XD.zip)
robertlipe commented 1 month ago

That's a bummer. I developed it on the WCH SVD files and honestly have no idea how diverse SVD files can be in the wild. Your best bet will be to look at the SVDs that you have, compare them to the structure (not contents) of the checked-in SVD files and make the Python more robust in whatever is missing/extra different.

My guess is that there's a GPIOB block that's defined in the overall map that's missing a region size, which is necessary to build the mask.

You might also add a test to see if it's just one or two blocks that's being goofy to just test for that case and continue the relevant loops, skipping that peripheral set. If the SVD is malformed or just nto formed in a way we can recognize it, it might be that ONLY GPIOB is bad (or all GPIOS after A or something) are bad and you can still generate the rest of the peripherals. That's not awesome, but it might be a way forward.

SVDheaders is pretty self-serve at this point. I think you're like the second user, so we don't have a great pool of python/svd expertise at our disposal, I'm afraid.

Unless someone else is lurking. In that case, Step Right Up! :-)

On Mon, Jul 29, 2024 at 2:18 AM I_tested_it_no_problem < @.***> wrote:

Hello, When I use the parameter -r with this script, I encounter the following error. Attached is the SVD file I am using. Additionally, I also experience an error when using the parameter -m. $ python svdtoheaders -s GD32F30x_XD.svd -r test_reg.h Traceback (most recent call last): File "D:\Tool\svdtoheaders\svdtoheaders", line 238, in main() File "D:\Tool\svdtoheaders\svdtoheaders", line 234, in main for r in (registers(doc)): ^^^^^^^^^^^^^^ File "D:\Tool\svdtoheaders\svdtoheaders", line 149, in registers for original_name, original_value in pperiphs[d_name].items():


KeyError: 'GPIOB' $ python svdtoheaders -s GD32F30x_XD.svd -m test_map.h
Traceback (most recent call last):
File "D:\Tool\svdtoheaders\svdtoheaders", line 238, in
main()
File "D:\Tool\svdtoheaders\svdtoheaders", line 226, in main
for p in (peripherals(doc)):
^^^^^^^^^^^^^^^^
File "D:\Tool\svdtoheaders\svdtoheaders", line 55, in peripherals
size = int(address_block.get('size', "0"), 0)
^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'get'

GD32F30x_XD.zip
<https://github.com/user-attachments/files/16408910/GD32F30x_XD.zip>

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