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

svd2rust does not handle aliased enumeratedValues #194

Closed
jscarrott opened this issue Mar 19, 2018 · 4 comments
Closed

svd2rust does not handle aliased enumeratedValues #194

jscarrott opened this issue Mar 19, 2018 · 4 comments
Labels
bad svd robustness this issue is caused by not handling svds that are not fully to specification

Comments

@jscarrott
Copy link

When using svd2rust on the nRF52840.svd file the generated code contains an unreachable pattern and won't build without adding allow(unreachable_patterns) to the library.

error: unreachable pattern --> /home/jscarrott/Git/nrf52840/src/lib.rs:29983:21 | 29983 | 216 => TXPOWERR::NEG40DBM, | ^^^ | note: lint level defined here --> /home/jscarrott/Git/nrf52840/src/lib.rs:1:487
I've ended up just adding the allow for now and using it anyway.

@jamesmunns
Copy link
Member

jamesmunns commented Mar 19, 2018

Hey @jscarrott - I think that this is because they have an old aliased name in the SVD. I had a similar problem with my bindings for the nrf52832: nrf-rs/nrf52832-pac@f27102a

My approach was to modify the SVD file, since it is not possible to have the two match statements resolve bidirectionally.

Let me know if that is an acceptable workaround for you.

@jamesmunns jamesmunns added individual chip problem This issue describes an issue with a particular chip bad svd robustness this issue is caused by not handling svds that are not fully to specification labels Mar 19, 2018
@jscarrott
Copy link
Author

Yeah, I'm sure that's fine. I'm just tinkering around with the board for fun and to teach myself about embedded rust and with the very vague goal of getting it to transmit some MQTT stuff over Bluetooth.

I'm going to take the opportunity to thank you for the great documentation on embedded rust with svd2rust. It's been a real learning curve getting some LEDs to turn on over the weekend but with the documentation on svd2rust and @japaric's blog, the answers were never too far away. The next thing to work out though is why the LEDs only turn on after I reset the board and not when my code runs....

@jamesmunns
Copy link
Member

I can't take any credit for the docs, but if you want to chat about Rust, the nRF family, and misc IoT stuff, feel free to email me (its in my profile), or catch up with us on #rust-embedded at irc.mozilla.org!

I'm going to change the title to be a little more broad, we may still decide to "gracefully" handle this issue in the future.

@jamesmunns jamesmunns changed the title Generated rust file contains an unreachable pattern svd2rust does not handle aliased enumeratedValues Mar 19, 2018
@jamesmunns jamesmunns removed the individual chip problem This issue describes an issue with a particular chip label Mar 19, 2018
@burrbull burrbull mentioned this issue Jul 25, 2019
@adamgreig
Copy link
Member

I believe this is fixed by new svd-parser in #317, please re-open if the issue persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bad svd robustness this issue is caused by not handling svds that are not fully to specification
Projects
None yet
Development

No branches or pull requests

3 participants