Comments (13)
@osterwood I would suggest reading through RTFM book and running the QEMU examples for now. You'll need to wait until svd2rust v0.14.0 is released and the device crates in the ecosystem catch up before you can run rtfm v0.4.0 on hardware.
@geomatsi v0.4.0 is using SCB.set_priority, which should do the right thing on ARMv6-M.
from rtic.
Maybe just trying to use edition 2015, i.e. remove this line in Cargo.toml:
edition = "2018"
from rtic.
That's better! Now down to two errors (once I changed device stm32f0::stm32f0x2
to device stm32f0x2
and made the end of init a () return (instead of returning the init::LateResources
struct).
error[E0308]: mismatched types
--> examples/rtfm-one.rs:28:1
|
28 | / app! {
29 | | device: stm32f0x2,
30 | |
31 | | // Here data resources are declared
... |
57 | | }
58 | | }
| |_^ expected struct `_initLateResources`, found ()
|
= note: expected type `for<'r> fn(init::Peripherals, _initResources<'r>) -> _initLateResources`
found type `for<'r> fn(init::Peripherals, _initResources<'r>) {init}`
error[E0308]: mismatched types
--> examples/rtfm-one.rs:28:1
|
28 | / app! {
29 | | device: stm32f0x2,
30 | |
31 | | // Here data resources are declared
... |
57 | | }
58 | | }
| |_^ expected u32, found u8
help: you can cast an `u8` to `u32`, which will zero-extend the source value
|
28 | app! {
29 | device: stm32f0x2,
30 |
31 | // Here data resources are declared
32 | //
33 | // Data resources are static variables that are safe to share across tasks
...
error: aborting due to 2 previous errors
from rtic.
init must return LateResources, that's tthe first error.
from rtic.
You'll aalso need the update branch of RTFM as commented in your Cargo.toml to use cortex-m 0.5
from rtic.
Thank so much for the help. I had pulled the init signature from an example which didn't use LateResources and neglected to change it when I added one.
I think I'm nearly there. Now have this error about SYS_TICK
error[E0599]: no variant named `SYS_TICK` found for type `hal::stm32::Interrupt` in the current scope
--> examples/rtfm-one.rs:27:1
|
27 | app! {
| ^ variant not found in `hal::stm32::Interrupt`
error: aborting due to previous error
I've looked through rtfm, stm32-rs, stm32f042-hal, stm32f103xx -- and I don't see where SYS_TICK is defined. stm32f103xx now only uses them in outdated examples. Should I revert to using a hardware timer?
from rtic.
now is SysTick
from rtic.
After changing this name it is possible to go a bit further. Next error looks like the following:
error[E0308]: mismatched types
--> examples/rtfm-one.rs:28:1
|
28 | app! {
| ^ expected u32, found u8
help: you can cast an `u8` to `u32`, which will zero-extend the source value
|
28 | a.into()pp! {
| ^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
On the first glance it looks like cortex-m-rtfm type issue for task priority: task priority is u8 while scb.shpr[] is [u32]. The following fix on top of PR#87 helps to go further:
diff --git a/macros/src/trans.rs b/macros/src/trans.rs
index 894abd7..08b8a90 100644
--- a/macros/src/trans.rs
+++ b/macros/src/trans.rs
@@ -366,7 +366,7 @@ fn init(app: &App, main: &mut Vec<TokenStream>, root: &mut Vec<TokenStream>) {
}
let nr = e.nr();
- let priority = task.priority;
+ let priority = task.priority as u32;
exceptions.push(quote! {
let prio_bits = #device::NVIC_PRIO_BITS;
let hw = ((1 << prio_bits) - #priority) << (8 - prio_bits);
However something is still wrong:
error: index out of bounds: the len is 2 but the index is 11
--> examples/rtfm-one.rs:28:1
|
28 | app! {
| ^
|
= note: #[deny(const_err)] on by default
error: aborting due to previous error
Build can be completed by adding #![allow(const_err)]
, but this hack is definitely wrong since that check exists somewhere in cortex-m-rtfm for reason.
from rtic.
Thanks so much for the additional comments and work here. I've forked ykomatsu's update branch and added your fix. I also ran into an error about a depreciated NVIC method, so changed that as well. https://github.com/osterwood/cortex-m-rtfm/tree/update
I've been trying to track down the source of the out of bounds error, and have isolated it to the use of LateResources. Defining tasks & resources builds without error. It's just when LateResources are introduced does the compile error appear.
from rtic.
Just for the record, all these issues pop up only when we try to use SysTick timer. I have several cortex-m-rtfm examples for stm32f030 and stm32f103 using TIM timers. Those examples work like a charm w/o any compilation issues with the same list of dependencies in Cargo.toml.
from rtic.
Finally, the root cause is as follows: cortex-m-rtfm calculates index for writing to scb.shpr[] in a way which is suitable for armv7, but not for armv6. The difference is clear from file src/peripheral/scb.rs from cortex-m source tree: see function set_priority
Quick hack (specific to armv6 only) which makes the app work on stm32f0 is as follows:
diff --git a/macros/src/trans.rs b/macros/src/trans.rs
index 894abd7..1f91a24 100644
--- a/macros/src/trans.rs
+++ b/macros/src/trans.rs
@@ -366,11 +366,11 @@ fn init(app: &App, main: &mut Vec<TokenStream>, root: &mut Vec<TokenStream>) {
}
let nr = e.nr();
- let priority = task.priority;
+ let priority = task.priority as u32;
exceptions.push(quote! {
let prio_bits = #device::NVIC_PRIO_BITS;
let hw = ((1 << prio_bits) - #priority) << (8 - prio_bits);
- scb.shpr[#nr - 4].write(hw);
+ scb.shpr[(#nr - 8) / 4].write(hw);
});
}
Kind::Interrupt { enabled } => {
@japaric , does it makes sense to work on a proper fix ? or this is a known issue and fix is somewhere on its way to cortex-m-rtfm/master ?
from rtic.
@japaric and @geomatsi Thanks for your help on this. Looks like v0.4.0 will be really nice to work with. In the meantime, I think I'll move to an armv7 MCU for my prototyping & testing.
from rtic.
I'm going to close this issue since it's about v0.3.x, which is no longer supported / maintained.
from rtic.
Related Issues (20)
- How to invoke code before RTIC main part. HOT 1
- Docs: Examples are broken and not showing HOT 3
- `atomic-polyfill` is deprecated
- rtic_monotonics 2.0 not in crates.io??? HOT 5
- Consider adding a hook to run code at the beginning of the entry point HOT 3
- SPI devices on shared bus (embedded-hal-bus) HOT 3
- Locked Status with Multiple Shared Resources HOT 2
- Software tasks and the stack HOT 2
- Support for embedded_alloc
- Call to SCB::sys_reset() results in locked up core. HOT 3
- rtic-monotonic on stm32 TIM20 or TIM17 HOT 1
- How to get the time stamp in a RTIC Rust Embedded application HOT 1
- Proplems while setting up rtic 2.1.1 HOT 2
- Multicore Support HOT 3
- How can I share the spawn handle? HOT 1
- rtic-monotonic panics HOT 9
- Cannot use higher priority tasks on STM32G030 with Embassy HAL
- Unit-Testing with RTIC v2
- rtic-monotonics v2.0.2 not compiling
- rtic::app macro "should be producing references to ::core::result::Result, not unqualified Result"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rtic.