-
Notifications
You must be signed in to change notification settings - Fork 269
Added an example for using alloc-cortex-m #306
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
Conversation
We build all examples as part of CI - this example would need to be somehow not built if the compiler is not nightly. |
One way to do it could be this:
(For this to work, the With this, |
That could work.
We also don't specify a stack size. It's "whatever is left" after static allocations. The base address is defined in the cortex-m-rt linker script, so you could calculate the limit yourself - assuming you know how large you want the stack to be. |
Hi @umgefahren! Are you still interested in this pull request? The good news is: It's now possible to implement this on stable rust. So we no longer need to think about nightly rust. As a proof of concept, I successfully applied your changes to the rp-hal-boards repo: rp-rs/rp-hal-boards@main...jannic-dev-forks:rp-hal-boards:pr306 (There are still some rough edges, clippy complains and some formatting is wrong.) But then, I wonder if this really should be a rp-pico example. The alloc feature is by no means board specific. So it might be better to have an example in rp2040-hal/examples. That would require some minor changes as no BSP would be available. The easiest way would probably be to start from https://github.com/rp-rs/rp-hal/blob/main/rp2040-hal/examples/blinky.rs. Your pull request is more than a year old, so I wouldn't be surprised if you were no longer interested. In that case, I'd try to find some time to adapt the example myself. But I don't want to "steal" your idea, in case you still want to work on it. |
Quite honestly I didn't remember I did this PR until this very email. I would have to get back into it, so it would be great if you could make the time. |
59006c5
to
81b78e5
Compare
Ok, I moved the example to It looks like I was a little bit too quick with my statement about compatibility with stable rust: Therefore I'll label the PR as a breaking change, to be merged shortly before releasing v0.10.0 |
Updated to rp2040-hal 0.9 by @jannic Co-authored-by: Jan Niehusmann <[email protected]>
81b78e5
to
fccfdbe
Compare
I rebased the pull request to current |
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.
Hey there, alloc-cortex-m only supports single core and is deprecated in favor of embedded-alloc.
Good point! Fortunately, porting was trivial, it's basically the same crate under a different name. |
I found it interesting how using an allocator with the rp-pico would work, so i build this little example, which is derived from the blinking led example.
I couldn't find any constant indicating a possible heap size in the hal, but i may have overlooked it.
I was mainly inspired by this repository: alloc-cortex-m
Feedback is appreciated :)