-
Notifications
You must be signed in to change notification settings - Fork 231
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 during interrupt handling in esp32c3 timer_interrupt.rs example #196
Comments
Using this toolchain in the esp32c3-hal directory:
and then running from the esp32c3-hal directory:
it actually works!
|
Thanks for reporting this! I am a bit confused since the toolchain you added says Anyway, on nightlies there might be mis-compilations even for RV32 It's not really clear to me which rustc was used to create to faulty binary (i.e. what is the default toolchain or override) I double checked it with the esp-hal repository at commit |
I can't seem to reproduce this either. |
oh yeah, that's interesting. I don't remember why the target is I'm running One thing I did find though was I think this is somehow being caused by
And the esp-rs crate does not. So I removed the
seems to work. And again, running Thanks! |
Thanks for the update! The problem with opt-level "z" is really interesting. I'm a bit surprised to see those problems with the RV32 targets but something like that can happen on nightlies Regarding |
I've been looking into this a bit with @dougli1sqrd , and the panic seems to be limited to this shift operation: esp-hal/esp-hal-common/src/interrupt/riscv.rs Line 267 in 7889a99
I can reliably reproduce an underflow panic while shifting with this example:
The panic still only occurs with However, in So, this leads me to a pair of questions:
|
Thanks for the detailed analysis! Good job! The reason why I noticed you already opened an issue on rust-lang - thanks a lot! |
Looks like it's ultimately a LLVM bug: llvm/llvm-project#57988 I've got two ideas of varying quality:
It's your project, though, so I'll gladly defer to you on which maintenance burden you'd rather bear, if either! |
Thanks for the update! I'd personally vote for the second option especially since this problem might also get triggered in user-code. |
Ooh, good call about user code: I'll reworded the message to include some of that flavor and open a PR! Thanks for all your help and encouragement navigating the wild & woolly world of embedded rust, I appreciate it. |
I think the proof of concept looks okay. I'm not entirely convinced it should be behind a feature, and I think printing a warning and continuing is probably preferable to terminating. Based on my limited testing |
Oops, just saw your comment @jessebraham : unless you object, I'll move discussion over to the PR I just opened. |
I guess this is resolved now - reopen if you don't agree |
Hello, I've been using the esp-rs and esp32c3_hal crates to write code for an esp32c3 board. I'm trying out the timer_interrupt example here https://github.com/esp-rs/esp-hal/blob/main/esp32c3-hal/examples/timer_interrupt.rs.
Here's steps for a minimal example:
cargo generate
ed on the esp-rs template project, setting up a project for the esp32c3.(This was done this way because in my actual project (not this example) the 0.2.0 version had not been released yet, and had previously been depending on main, but that got updated significantly since the last time I was working on this, so I tied the revision to the latest at the time I was looking at this again)
mkdir examples
, andtouch timer_interrupts.rs
timer_interrupts
file in step 3.cargo build --example timer_interrupts && espflash target/riscv32imc-unknown-none-elf/debug/examples/timer_interrupts --monitor --format direct-boot
This should build and then flash the esp32 with the interrupt example, then monitor the output using the espflash tool
This is happening in https://github.com/esp-rs/esp-hal/blob/main/esp-hal-common/src/interrupt/riscv.rs#L267, at the left shift.
Has anyone experienced an issue like this? Is this a bug in esp-hal, or the compiler_builtins? Do I just need to configure something easy to fix it?
Here is the actual template project with the failing example: https://github.com/rustbox/esp32-examples
Let me know if you have any ideas, thanks!
The text was updated successfully, but these errors were encountered: