-
Notifications
You must be signed in to change notification settings - Fork 910
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
RP time driver alternatively using mtimer, timer0, timer1, or aot #3873
base: main
Are you sure you want to change the base?
RP time driver alternatively using mtimer, timer0, timer1, or aot #3873
Conversation
Why are you closing a PR, and reopening a new one with the same thing? |
I am not familiar with GitHub PRs (Just plain old GitLab.) I did not think a PR that issued error message to me is of any relevance and therefore I closed them. Is the better way to "elongate" the PR by committing something to the fork and then do (what ?) ? Anyway. Even though it now actually seems to I suppose the problem is due to the cfg Here I am not sure if I did it correctly. IMHO for the 235x the default should be the
I think,. the system tick should be somehow automatically be 1_000_000 with timer0, timer1 and mtimer, but 1_000 with aot. BTW: I can't compile the cloned repository due to |
If you commit to the same branch, the PR will be updated, and CI will run on it. However, closing and creating a new PR will send 2 messages to the matrix chat for 1700 people to see. |
Ooops :( So just committing tho the forked is enough to have you be aware of the changes (even if the pipeline fails) ? |
Should we refacture this moving the code for each hardware alternative to a dedicated module ? |
Could you fix CI?
|
@@ -28,6 +28,10 @@ features = ["defmt", "unstable-pac", "time-driver", "rp2040"] | |||
default = [ "rt" ] | |||
## Enable the rt feature of [`rp-pac`](https://docs.rs/rp-pac). This brings in the [`cortex-m-rt`](https://docs.rs/cortex-m-rt) crate, which adds startup code and minimal runtime initialization. | |||
rt = [ "rp-pac/rt" ] | |||
time-driver-timer1 = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add documentation for the features? Use ##
just like the existing comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did the modification in the toml file not as a suggestion but just to allow the pipeline to do the build.
Supposedly, in the end these features should not be allowed in the project, but in the embassy-time
dependency section. But I have no idea how this should be done.
@@ -28,6 +28,10 @@ features = ["defmt", "unstable-pac", "time-driver", "rp2040"] | |||
default = [ "rt" ] | |||
## Enable the rt feature of [`rp-pac`](https://docs.rs/rp-pac). This brings in the [`cortex-m-rt`](https://docs.rs/cortex-m-rt) crate, which adds startup code and minimal runtime initialization. | |||
rt = [ "rp-pac/rt" ] | |||
time-driver-timer1 = [] | |||
time-driver-aot = [] | |||
time-driver-mtime = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Cargo features would make more sense if we did the following changes
- Remove the
time-driver
feature. Instead, the time driver is automatically enabled if any of thetime-driver-*
features is enabled.- To do this you could rename the
time-driver
feature to_time-driver
so that it's "private", and make thetime-driver-*
features enable it.
- To do this you could rename the
- Add a
time-driver-timer0
feature instead of making it the default if no other time driver is enabled.
To make examples compile you'll have to edit their Cargo.toml.
Also, please add to ci.sh
lines that test compiling embassy-rp
with the 4 different time drivers, so CI checks they all compile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. As I am not at all experienced in doing cargo instructions, I think it would be good if you could do the decisions and the (suggestions for) implementation.
My idea was as such:
- if there is
"integrated-timers"
in theembassy-executor
section, the time driver is used. - if there are no additional instructions in the
embassy-time
section :- if its a RP2040, the
#[cfg
s use the"TIMER"
(already in place) - if its a RP235x, the
#[cfg
s use the RISC V System timer inpac::SIO
(currently in place:TIMER0
.)
- if its a RP2040, the
- if there is a feature
"time-driver-timer0"
,"time-driver-timer1"
, or"time-driver-aot"
in theembassy-time
section, the#[cfg
s use the appropriate timer:TIMER0
,TIMER1
, or the timer inpac::POWMAN
. - if the feature
"time-driver-aot"
is given in theembassy-time
section, the feature"tick-hz-1_000"
is automatically set to prohibit any ambiguity (while otherwise the feature"tick-hz-1_000_000"
is set (as it seemingly is right now, as trying a different setting when"integrated-timers"
is enabled fails to compile.
Can such be implemented ?
Or is some other implementation (with no "default" setting) more appropriate ?
I suggest the RISK V system timer as a default, as
- it's provided exactly for this "system" purpose by the hardware design.
- the user might want to use the more versatile timers "0" and "1" for dedicated purposes
- it counts 64 bits, the alarm checks all 64 bits. Hence no 32 Bit / 72 hours considerations necessary.
- I feel the RISK V system timer is slightly more "secure" as the interrupt simply is managed by the alarm register content and stays active until same is lower than the count register. No additional conditions.
- The RISK V system timer is in the
"Secure SIO"
. This might be advantageous - and works with the examples, but it also might be a problem in certain situations ?!?!?!
BTW: the tick generator is set up for driving TIMER0
with 1_000_000 Hz in embassy-rp-0.3.1/src/clocks.rs:529 ff
. This seems not appropriate when TIMER0
is not used. Maybe it makes sense just to set just the constants appropriately so that clocks::clk_ref_freq()
can be used in the timer driver to configure the appropriate clock to drive the timer to be enabled (as shown in the suggested driver code ).
adding potential features in cargo.toml