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

Panic from init (rtic 0.5.5) #361

Closed
HarryMakes opened this issue Sep 16, 2020 · 2 comments
Closed

Panic from init (rtic 0.5.5) #361

HarryMakes opened this issue Sep 16, 2020 · 2 comments

Comments

@HarryMakes
Copy link

Hi, I am working on a Cortex-M7-based project that has previously been functional before we update cortex-m-rtic from 0.5.3 to 0.5.5. I suspect that some changes have broken our RTIC implementation (link for reference).

Environment

  • CPU: STM32H743ZI
  • Cargo: 1.48.0-nightly (875e01232 2020-09-08)
  • Rustc: 1.48.0-nightly (6af1bdda5 2020-09-15)

Error

GDB backtrace:

#0  0x08020c90 in rust_begin_unwind (_info=<optimized out>)
#1  0x08017532 in core::panicking::panic_fmt () at library/core/src/panicking.rs:85
#2  0x0801f0d0 in core::option::expect_failed () at library/core/src/option.rs:1213
#3  0x08014674 in stabilizer::init (c=...)
    at /rustc/6af1bdda54abc9e919fc1137411dfc4311e05649/library/core/src/option.rs:370
#4  0x0801741c in stabilizer::APP::main () at src/main.rs:160

Using next in GDB, the program panics after:

...
halted: PC: 0x08000334
537	                *SCB_CPACR | SCB_CPACR_FPU_ENABLE | SCB_CPACR_FPU_USER,
(gdb) n
Info : halted: PC: 0x08000336
halted: PC: 0x08000336
Info : halted: PC: 0x0800033a
halted: PC: 0x0800033a
535	            core::ptr::write_volatile(
(gdb) n
Info : halted: PC: 0x0800033c
halted: PC: 0x0800033c
550	            trampoline()
(gdb) n
Info : halted: PC: 0x08020c88
halted: PC: 0x08020c88
^C
Program received signal SIGINT, Interrupt.
0x08020c96 in rust_begin_unwind (_info=<optimized out>)
@korken89
Copy link
Collaborator

Hi, I see the issue.

This line is undefined behavior and was fixed in the latest release: https://github.com/quartiq/stabilizer/blob/5d41fa0aa981c68372464c016e9e7a4b222dfc06/src/main.rs#L206

As you have the peripherals = true flag set you can find the peripherals in the context c.device.
Is explained more here: https://rtic.rs/0.5/book/en/by-example/app.html#init

Tell me if you experience more problems!

@HarryMakes
Copy link
Author

Thanks, it seems to be working now.

bors bot added a commit to quartiq/stabilizer that referenced this issue Sep 16, 2020
144: Fix syntax for taking core peripherals (required by cortex-m-rtic v0.5.5) r=jordens a=HarryMakes

This is to fix a panicking upon initialization problem that is caused by a now undefined behaviour in our code from the perspective of the latest release of the cortex-m-rtic crate. 

As per conversation in rtic-rs/rtic#361, `context.core` should now be used instead of `cortex_m::Peripherals::take()`, which would cause some unexpected behaviour.

On a side note, a similar symptom where the Ethernet PHY does not get reset, as discussed in #141, might have also arisen from this new version of rtic. However, the reset delay still seems a bit too short to me.

Co-authored-by: Harry Ho <hh@m-labs.hk>
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

2 participants