You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How can dynamically sized Vec<T> be using on STM32? #335
When evaluating using Rust for an embedded project at work, not having dynamic containers was a big drawback at the time compared with C++11/14 where the gcc-arm-embedded toolchain had versions of std::string and std::vector<T>. (C++ has it's own set of drawbacks, like exception-based error handling APIs, but in this one, fundamental case, it had a leg up).
Is there a way (even it's nightly) to use Vec<T> on something like the STM32F3DISCOVERY? It was a hard sell to recommend Rust over C++ without being able to safely use the heap.
Edit: We used heapless in some tutorials but we wanted to have true heap access available like is available for C++11/14 and the gcc-arm-embedded toolchain.
@therealprof Thanks, yeah I had seen heapless and I changed the title to be more clear that we'd like to actually use the heap for true dynamically sized containers. heapless requires a fixed size up front.
changed the title [-]How can dynamically resizable Vec<T> be using on STM32?[/-][+]How can dynamically sized Vec<T> be using on STM32?[/+]on Mar 19, 2019
I think this would be more appropriate for the book and/or the embeddonomicon with a reference in the discovery book. Any contributions in that directions would certainly be welcome.
Activity
therealprof commentedon Mar 19, 2019
https://crates.io/crates/heapless
[-]How can Vec<T> be using on STM32?[/-][+]How can dynamically resizable Vec<T> be using on STM32?[/+]johnthagen commentedon Mar 19, 2019
@therealprof Thanks, yeah I had seen
heaplessand I changed the title to be more clear that we'd like to actually use the heap for true dynamically sized containers.heaplessrequires a fixed size up front.[-]How can dynamically resizable Vec<T> be using on STM32?[/-][+]How can dynamically sized Vec<T> be using on STM32?[/+]therealprof commentedon Mar 19, 2019
You can use alloc-cortex-m to create a heap and combine it with heapless.
japaric commentedon Mar 19, 2019
@johnthagen what @therealprof said. The quickstart template has an example: https://github.com/rust-embedded/cortex-m-quickstart/blob/master/examples/allocator.rs
japaric commentedon Mar 19, 2019
(you don't need to specifically use alloc-cortex-m; any global_allocator will do)
johnthagen commentedon Mar 19, 2019
@japaric Is this mentioned in the Discovery Book? And if not, would you accept a PR to add it? I think this would be a really great addition!
johnthagen commentedon Mar 19, 2019
(For anyone else finding this issue in the future, the embedded book has some discussion on this as well.)
therealprof commentedon Mar 19, 2019
I think this would be more appropriate for the book and/or the embeddonomicon with a reference in the discovery book. Any contributions in that directions would certainly be welcome.
jamesmunns commentedon Mar 19, 2019
I think we should also note (last time I checked) that
alloc-cortex-mrequires nightly rust to operate.johnthagen commentedon Mar 19, 2019
Correct, this RFC is currently being discussed to potentially stabilize
alloc: rust-lang/rfcs#2480johnthagen commentedon Apr 22, 2019
allocis on track to stabilize for Rust 1.36.0: rust-lang/rust#59675marcoieni commentedon Jun 14, 2020
So:
alloccrate.I think that no action is required here anymore and this issue could be closed.
jonas-schievink commentedon Jun 14, 2020
Yup, closing then. Thanks!