-
Notifications
You must be signed in to change notification settings - Fork 151
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
Incorrect implementation of cortex_m::peripheral::scb::VectActive::from()
in stable release 0.7.7
#499
Comments
It looks like 0.7.7 does the right thing? https://github.com/rust-embedded/cortex-m/blob/v0.7.7/src/peripheral/scb.rs#L192 |
We can look by example, 303 line is cortex-m/src/peripheral/scb.rs Line 303 in bb4a782
So, it returns Interrupt with value irqn, while irqn is greater or equal to 16. In contrast, we have another function SCB::vect_active() which does the same (converting number to VectActive) and therefore should have the same implementation, but in fact it differs: cortex-m/src/peripheral/scb.rs Line 192 in bb4a782
|
It was fixed in this commit: together with replacing u8 with u16 |
Ugh, good spot. Why do we have the same code pasted twice? |
I guess so, but the only difference is that we'll need .unwrap() the Option, and it's better to keep guard |
Thanks for reporting this! I think we should backport the |
@adamgreig, Sure, I can do it. But how can we avoid using unwrap when we must cover all possible values in match? I guess it's ok to believe the register value we got from reading current vector register and assume correct arm target selected by user. |
I discovered this bug accidentally while working with SCB and exceptions.
cortex_m::peripheral::scb::VectActive::from()
function returns incorrect value, which is 16 higher than the expected value. (in case whenVectActive
isVectActive::Interrupt
.I know this was already fixed in #332, but it was really long time ago (2 years ago) and this change is not present in the current released version uploaded on crates.io.
https://github.com/rust-embedded/cortex-m/blob/bb4a78208323260a161e68b2498438867f971bc5/src/peripheral/scb.rs#L303C15-L303C15
Since the fix is already implemented in the master branch, I am curious about the timeline for the next release on crates.io. Alternatively, is it feasible to release a patch for version 0.7.7 specifically to address this bug?
The text was updated successfully, but these errors were encountered: