Skip to content

support <access>read-writeOnce</access> #91

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

Closed
japaric opened this issue May 22, 2017 · 4 comments
Closed

support <access>read-writeOnce</access> #91

japaric opened this issue May 22, 2017 · 4 comments
Milestone

Comments

@japaric
Copy link
Member

japaric commented May 22, 2017

The code generated from the file STM32L063x.svd doesn't compile. Because the read-writeOnce access mode is not supported by svd2rust the DAC_SR register has no access methods:

# [ doc = "Digital-to-analog converter" ]
pub mod dac {
    // ..
    # [ doc = "status register" ]
    pub struct Sr {
        register: VolatileCell<u32>,
    }
    # [ doc = "status register" ]
    pub mod sr {
        impl super::Sr {}
    }
}

And you run into an unused field warning which becomes an error because of #![deny(warnings)].

@kjetilkjeka
Copy link
Contributor

I will contribute to this issue instead of making a new since I suspect these issues are the same.

When using svd2rust on NXP S32K144 svd file i get:

svd2rust -i ~/Nedlastinger/S32K144.svd | rustfmt | tee src/s32k144.rs
thread 'main' panicked at 'unknown access variant: writeonce', 
/home/kjeka/.cargo/registry/src/github.com-1ecc6299db9ec823/svd-parser-0.5.1/src/lib.rs:286
note: Run with `RUST_BACKTRACE=1` for a backtrace.

and with RUST_BACKTRACE=1

RUST_BACKTRACE=1 svd2rust -i ~/Nedlastinger/S32K144.svd | rustfmt | tee src/s32k144.rs
thread 'main' panicked at 'unknown access variant: writeonce',         
/home/kjeka/.cargo/registry/src/github.com-1ecc6299db9ec823/svd-parser-0.5.1/src/lib.rs:286
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:60
             at /checkout/src/libstd/panicking.rs:355
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:371
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:549
   5: std::panicking::begin_panic
             at /checkout/src/libstd/panicking.rs:511
   6: std::panicking::begin_panic_fmt
             at /checkout/src/libstd/panicking.rs:495
   7: <core::option::Option<T>>::map
   8: <core::iter::FilterMap<I, F> as core::iter::iterator::Iterator>::next
   9: svd_parser::Device::parse
  10: svd_parser::parse
  11: svd2rust::main
  12: __rust_maybe_catch_panic
             at /checkout/src/libpanic_unwind/lib.rs:98
  13: std::rt::lang_start
             at /checkout/src/libstd/panicking.rs:433
             at /checkout/src/libstd/panic.rs:361
             at /checkout/src/libstd/rt.rs:56
  14: __libc_start_main
  15: _start

I will attach the file in case you would like to test for yourself.
S32K144.svd.zip

@Emilgardis
Copy link
Member

@kjetilkjeka Your error is not related, it comes from a miswritten svd file, the variant is called writeOnce, not writeonce. We could fix this in svd-parser, but I think we should strive to follow the SVD 1.0/1.1 schema as close as possible.

To fix your error and generate some code simply patch your svd to change all the writeonce into writeOnce.

@kjetilkjeka
Copy link
Contributor

@Emilgardis You are of course right. It worked when replacing writeonce with writeOnce, thanks.

And for what it's worth I do agree with your view on forcing the svd to be up to spec rather than accepting badly written svd files.

@japaric japaric added this to the cmsis-svd milestone May 25, 2017
@burrbull burrbull mentioned this issue Jul 25, 2019
@adamgreig
Copy link
Member

Implemented by #322.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants