svd2rust icon indicating copy to clipboard operation
svd2rust copied to clipboard

svd2rust crashes with some SVDs

Open maximevince opened this issue 8 years ago • 7 comments

When trying "svd2rust -i BlueNRG1.svd" it crashes in: thread 'main' panicked at 'svd-parser-0.5.2/src/lib.rs:411 tree.get_child("bitWidth")', src/libcore/option.rs:819:4

BlueNRG1.svd can be found as part of "STMicroelectronics BlueNRG-1 Series Device Support" here: https://www.keil.com/dd2/pack/

maximevince avatar Sep 18 '17 20:09 maximevince

I'm having similar issue with SVD's in http://www.st.com/resource/en/svd/stm32l0_svd.zip

$ svd2rust -i STM32L0x3.svd
tree.get_child("mpuPresent")', /checkout/src/libcore/option.rs:839:4

Detegr avatar Sep 19 '17 09:09 Detegr

svd parser doesn't have a proper error handling, so it just panics when SVD file is incorrect. See https://github.com/japaric/svd2rust/issues/136

pftbest avatar Sep 19 '17 18:09 pftbest

@maximevince Hmm, that may be a bug in the SVD parser since the SVD spec says that <bitWidth> is optional. in bit ranges.

@Detegr <mpuPresent> is a mandatory subfield of <cpu>. Your SVD file doesn't adhere to the standard so you'll have to fix it.

japaric avatar Sep 19 '17 20:09 japaric

BlueNRG1.svd has derivedFrom attributes on MFT1_TIMER_B, which is why svd-parser crashes as the <bitWidth> information comes from MFT1_TIMER_A Related japaric/svd#21

Emilgardis avatar Mar 02 '18 03:03 Emilgardis

I'm having the same issue with the BlueNRG2.svd file. Is there anything I can edit manually to get this file parsed?

robinvalk avatar Apr 30 '19 06:04 robinvalk

Allright, I manually mapped all the bitWidth fields and fixed some issues in the SVD itself. File is now parsed.

I see that the derivedFrom attribute parsing is not yet implemented on the Field element. When I find the time I might create a PR to implement this.

robinvalk avatar Apr 30 '19 07:04 robinvalk

Unfortunately, I'm not going to find the time...

robinvalk avatar May 06 '19 18:05 robinvalk

Should be fixed. Reopen if it is not.

burrbull avatar Nov 07 '22 19:11 burrbull