Skip to content

Commit c486c54

Browse files
committed
add "the path towards stable" announcement
1 parent 697648c commit c486c54

File tree

1 file changed

+195
-0
lines changed

1 file changed

+195
-0
lines changed
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
# Cortex-M library development now possible on beta and the path towards stable embedded Rust
2+
3+
> 2018-05-12
4+
5+
We are happy to announce that *library* development for the Cortex-M targets is now possible on the
6+
beta channel! :tada:
7+
8+
For example, to cross compile a library crate for the Cortex-M3 you would run these commands:
9+
10+
``` console
11+
$ # switch to the beta channel
12+
$ rustup default beta
13+
14+
$ # install the rust-std component (pre-compiled core) for the target
15+
$ rustup target add thumbv7m-none-eabi
16+
17+
$ # get some source to build
18+
$ cargo clone cortex-m --vers 0.5.0 && cd cortex-m
19+
20+
$ # then It Just Works
21+
$ cargo build --target thumbv7m-none-eabi
22+
```
23+
24+
What about embedded *application* development? There is just a single unstable feature that prevents
25+
us from building a `no_std` binary on stable: the `panic_fmt` lang item. This unstable feature will
26+
soon be removed in favor of the `#[panic_implementation]` feature ([implementation PR]), which is
27+
slated for stabilization in time for the edition release (we are hoping to stabilize it as early as
28+
1.28 but we'll see).
29+
30+
[implementation PR]: https://github.com/rust-lang/rust/pull/50338
31+
32+
## Making the Cortex-M ecosystem work on stable
33+
34+
"`no_std` binaries are *possible* on stable" is very different from "*my* embedded application
35+
builds on stable". The later requires all the dependencies to also compile on stable. So we are
36+
starting to migrate the Cortex-M ecosystem to work on stable. All the crates listed below are now
37+
compiling on the beta channel.
38+
39+
Legend: `crate-name` - link to CHANGELOG - link to stabilization PR - ~removed unstable features~
40+
41+
- [`cortex-m-quickstart`][c0] - [CHANGELOG][ch0] - [PR][p0]
42+
43+
[c0]: https://docs.rs/cortex-m-quickstart/~0.3
44+
[ch0]: https://github.com/japaric/cortex-m-quickstart/blob/master/CHANGELOG.md#v030---2018-05-12
45+
[p0]: https://github.com/japaric/cortex-m-quickstart/pull/29
46+
47+
- [`cortex-m-rt`][c1] - [CHANGELOG][ch1] - [PR][p1] - ~asm!~ ~core_intrinsics~ ~global_asm!~
48+
~lang_items~ ~linkage~ ~naked_functions~ ~used~
49+
50+
[c1]: https://crates.io/crates/cortex-m-rt/0.4.0
51+
[ch1]: https://github.com/japaric/cortex-m-rt/blob/master/CHANGELOG.md#v050---2018-05-12
52+
[p1]: https://github.com/japaric/cortex-m-rt/pull/69
53+
54+
- [`cortex-m-semihosting`][c2] - [CHANGELOG][ch2] - [PR][p2]
55+
56+
[c2]: https://crates.io/crates/cortex-m-semihosting/0.3.0
57+
[ch2]: https://github.com/japaric/cortex-m-semihosting/blob/master/CHANGELOG.md#v030---2018-05-10
58+
[p2]: https://github.com/japaric/cortex-m-semihosting/pull/16
59+
60+
- [`cortex-m`][c3] - [CHANGELOG][ch3] - [PR][p3] - ~asm!~ ~const_fn~
61+
62+
[c3]: https://crates.io/crates/cortex-m/0.5.0
63+
[ch3]: https://github.com/japaric/cortex-m/blob/master/CHANGELOG.md#v050---2018-05-11
64+
[p3]: https://github.com/japaric/cortex-m/pull/88
65+
66+
- [`embedded-hal`][c4] - [CHANGELOG][ch4] - [PR][p4] - ~never_type~
67+
68+
[c4]: https://crates.io/crates/embedded-hal/0.2.0
69+
[ch4]: https://github.com/japaric/embedded-hal/blob/master/CHANGELOG.md#v020---2018-05-11
70+
[p4]: https://github.com/japaric/embedded-hal/pull/80
71+
72+
- [`f3`][c5] - [CHANGELOG][ch5] - [PR][p5]
73+
74+
[c5]: https://crates.io/crates/f3/0.6.0
75+
[ch5]: https://github.com/japaric/f3/blob/master/CHANGELOG.md#v060---2018-05-12
76+
[p5]: https://github.com/japaric/f3/pull/XXX
77+
78+
- [`l3gd20`][c6] - [CHANGELOG][ch6] - [PR][p6] - ~Unsized~
79+
80+
[c6]: https://crates.io/crates/l3gd20/0.2.0
81+
[ch6]: https://github.com/japaric/l3gd20/blob/master/CHANGELOG.md#v020---2018-05-12
82+
[p6]: https://github.com/japaric/l3gd20/pull/4
83+
84+
- [`lsm303dlhc`][c7] - [CHANGELOG][ch7] - [PR][p7] - ~Unsized~
85+
86+
[c7]: https://crates.io/crates/lsm303dlhc/0.2.0
87+
[ch7]: https://github.com/japaric/lsm303dlhc/blob/master/CHANGELOG.md#v020---2018-05-12
88+
[p7]: https://github.com/japaric/lsm303dlhc/pull/4
89+
90+
- [`stm32f103xx`][c8] - [CHANGELOG][ch8] - [PR][p8] - ~const_fn~ ~global_asm!~ ~try_from~
91+
~use_extern_macros~ ~used~
92+
93+
[c8]: https://crates.io/crates/stm32f103xx/0.10.0
94+
[ch8]: https://github.com/japaric/stm32f103xx/blob/master/CHANGELOG.md#v0100---2018-05-12
95+
[p8]: https://github.com/japaric/stm32f103xx/pull/24
96+
97+
- [`stm32f30x-hal`][c9] - [CHANGELOG][ch9] - [PR][p9] - ~never_type~
98+
99+
[c9]: https://crates.io/crates/stm32f30x-hal/0.2.0
100+
[ch9]: https://github.com/japaric/stm32f30x-hal/blob/master/CHANGELOG.md#XXX
101+
[p9]: https://github.com/japaric/stm32f30x-hal/pull/XXX
102+
103+
- [`stm32f30x`][c10] - [CHANGELOG][ch10] - [PR][p10] - ~const_fn~ ~global_asm!~ ~try_from~
104+
~use_extern_macros~ ~used~
105+
106+
[c10]: https://crates.io/crates/stm32f30x/0.7.0
107+
[ch10]: https://github.com/japaric/stm32f30x/blob/master/CHANGELOG.md#XXX
108+
[p10]: https://github.com/japaric/stm32f30x/pull/XXX
109+
110+
- [`svd2rust`][c11] - [CHANGELOG][ch11] - [PR][p11]
111+
112+
[c11]: https://crates.io/crates/svd2rust/0.13.0
113+
[ch11]: https://github.com/japaric/svd2rust/blob/master/CHANGELOG.md#XXX
114+
[p11]: https://github.com/japaric/svd2rust/pull/203
115+
116+
There's a lot of breaking changes there but the most visible one is `cortex-m-rt` because it changes
117+
how applications are structured. Check the [`cortex-m-quickstart`][c0] template for instructions on
118+
how to set up an embedded application using the latest versions of everything.
119+
120+
There are still a lot of crates that will need to be updated to work on beta. Among the more general
121+
purpose ones we have [`heapless`] and [`cortex-m-rtfm`], which needs to be update to work with
122+
`cortex-m-rt` v0.5.0.
123+
124+
[`heapless`]: https://crates.io/crates/heapless
125+
[`cortex-m-rtfm`]: https://crates.io/crates/cortex-m-rtfm
126+
127+
### How you can help us
128+
129+
Try to compile your Cortex-M crate using the beta channel! If your crate is an application the build
130+
will certainly fail, but check if all the dependencies, excluding the [panic handler crate][phc],
131+
compile on beta. If any dependency doesn't compile on the beta channel let the author know, but
132+
first check if there's a new version of the crate that already compiles on the beta channel. And if
133+
you feel up to the task you could even send a PR to the dependency to make it compile on beta -- the
134+
list of stabilization PRs in the previous section may give you a clue on how to move the crate to
135+
beta.
136+
137+
If you are the author of a Cortex-M device crate, a crate generated using `svd2rust`, moving it to
138+
stable only requires regenerating it using `svd2rust` v0.13.0. Do note that the generation process
139+
[has changed] for the Cortex-M target, and make sure you bump the minor version when you publish a
140+
new version.
141+
142+
[has changed]: https://docs.rs/svd2rust/0.13.0/svd2rust/#usage
143+
144+
If you are the author of a driver crate or a HAL implementation, please update your crate to use
145+
v0.2.0 of `embedded-hal` and test that it builds on beta. Make sure you bump the minor version when
146+
you publish a new version of your crate -- bumping the version of the `embedded-hal` dependency is a
147+
breaking change (drivers that depend on `embedded-hal` v0.1.0 can't be used with HAL implementation
148+
crates that depend on `embedded-hal` v0.2.0).
149+
150+
## What does this all mean for you?
151+
152+
To those of you who have been doing embedded development on nightly: things will get *much easier*
153+
from now on. We have reduced the number of unstable features in core crates of the Cortex-M
154+
ecosystem to **zero**. Although you will have to continue to use nightly for application development
155+
you can expect zero breakage from these crates when updating the nightly compiler. There is one
156+
expected breakage coming soon though: `panic_fmt` will be removed as announced above. This will
157+
break the [panic handler crates][phc]; however, the breakage will be isolated to those crates and
158+
the fix will consist of simply updating the dependency version.
159+
160+
[phc]: https://crates.io/keywords/panic-impl
161+
162+
To those of you who have been meaning to dive into embedded Rust development: we'll soon be done
163+
with our "embedded Rust on stable" tasks and we'll move our focus to documenting the embedded
164+
development process, tooling and ecosystem. The [embedded Rust book][book] will become the resource
165+
to get started on embedded Rust, but it doesn't quite exist right now.
166+
167+
[book]: https://github.com/rust-lang-nursery/embedded-wg/blob/master/books/embedded-rust-book/README.md
168+
169+
## What about architectures other than ARM Cortex-M?
170+
171+
The path carved for ARM Cortex-M can be followed by the other architectures (ARM Cortex-R, AVR,
172+
MSP430, RISCV, etc.). Each architecture presents its own extra set of challenges though:
173+
174+
- MSP430 being the second oldest embedded / `no_std` target is the closest one to make it to stable
175+
(as a tier 2 target) by the edition release. The main blocker is that `extern "msp430-interrupt"`
176+
is not available on stable but I think that may be possible to work around using external C /
177+
assembly files + FFI.
178+
179+
- Both AVR and RISCV are blocked from being included in the Rust compiler due to either the
180+
immaturity of the LLVM backend or LLVM backend bugs. Not many (embedded) Rust developers can also
181+
hack LLVM backends so we are short handed on the AVR front; OTOH, the RISCV is being actively
182+
developed by third parties so it's probably just a matter of time before we add it to rustc.
183+
184+
- ARM Cortex-R LLVM backend is probably in good shape due to the similarities between its
185+
instruction set and the ARM Cortex-M instruction set, so adding the target to the compiler should
186+
be straightforward. However, the crate ecosystem is nonexistent at this point so there's a lot of
187+
work to be done on that front.
188+
189+
---
190+
191+
This work is part of the [embedded WG][ewg] effort towards [making embedded development possible on
192+
the stable channel][stable]. (We are almost done! :tada:)
193+
194+
[ewg]: https://github.com/rust-lang-nursery/embedded-wg
195+
[stable]: https://github.com/rust-lang-nursery/embedded-wg

0 commit comments

Comments
 (0)