-
Notifications
You must be signed in to change notification settings - Fork 38
Description
Hi,
I am using the Python version of svdtools to patch some GigaDevice GD32F303 SVD files.
In these files, the SVD does not even comply with CMSIS-SVD.xsd because I have some fields with read or write access:
<field>
<name>IRC48MSTBIC</name>
<description>Internal 48 MHz RC oscillator Stabilization Interrupt Clear</description>
<bitOffset>22</bitOffset>
<bitWidth>1</bitWidth>
<access>write</access>
</field>In the YAML, I have some rules to change this:
_svd: ../svd/gd32f303.svd
RCU:
ADDINT:
_modify:
IRC48MSTBIC:
access: write-only
RTC:
PSC[LH]:
_modify:
PSC:
access: write-only
_modify:
DIV[LH]:
access: read-only
ALRM[LH]:
access: write-only
USART0:
STAT1:
_modify:
EBF:
access: write-only
RTF:
access: write-onlyI have tried the Rust version of svdtools to see the difference but I cannot even run it, I have this error:
$ svdtools patch devices/gd32f303.yaml svd/gd32f303.svd.patched.rust
[2025-05-29T13:39:58Z ERROR svdtools::cli] by svdtools (0.5.0)
Caused by:
0: In device `GD32F30x_XD`
1: In peripheral `RCU`
2: In register `ADDINT`
3: In field `IRC48MSTBIC`
4: Parsing unknown access at 25442:15
5: unknown access variant 'write' found
I have ran a debugger on it and this is this line of svd-parser that fails: https://github.com/rust-embedded/svd/blob/60a3b6019a4375e683e9bc3ffbe9ad6aeebb6828/svd-parser/src/field.rs#L32 called from this line in svdtools:
Line 134 in 6ebab74
| let mut dev = svd_parser::parse_with_config(&contents, &parser_config)?; |
I understand that svd-parser should only load valid SVD file.
But svdtools is made to fix buggy SVD files but cannot be used on a SVD file not following the spec.
For now, I can keep using the more permissive Python version. But I wanted to let you know of this issue.
I can also do a two-step process with a first pass with the Python version and only the YAML provided above and then a second pass with the Rust version on the Python patched SVD :)
One of the faulty SVD for reference: https://github.com/gd32-rust/gd32-rs/blob/2e4796265091558e922c5d69d0a31ffd641548b2/svd/vendor/GD32F30x_XD.svd