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
You will also need a debug probe, for example an [stlink v3
20
+
mini](https://www.st.com/en/development-tools/stlink-v3mini.html) for programming and debugging.
21
+
(There are many different STLink probes out there, all of them _should_ work fine with this instructions given here, other JTAG or SWD debug probes will work as well but will need different software or configuration).
22
+
23
+
### Installing software
24
+
25
+
To program your microcontroller, you need to install:
26
+
-[openocd](http://openocd.org/)
27
+
-`arm-none-eabi-gdb`
28
+
29
+
Finally, you need to install arm target support for the Rust compiler. To do
30
+
so, run
31
+
```
32
+
rustup target install thumbv7m-none-eabi
33
+
```
34
+
35
+
36
+
### Setting up your project
37
+
38
+
Create a new Rust project as you usually do with `cargo init`. The hello world
39
+
of embedded development is usually to blink an LED and code to do so is
40
+
available in [examples/blinky.rs](examples/blinky.rs). Copy that file to the
41
+
`main.rs` of your project.
42
+
43
+
You also need to add some dependencies to your `Cargo.toml`:
44
+
45
+
```toml
46
+
[dependencies]
47
+
embedded-hal = "0.2.3"
48
+
nb = "0.1.2"
49
+
cortex-m = "0.6.2"
50
+
cortex-m-rt = "0.6.11"
51
+
# Panic behaviour, see https://crates.io/keywords/panic-impl for alternatives
52
+
panic-halt = "0.2.0"
53
+
54
+
[dependencies.stm32f1xx-hal]
55
+
version = "0.5.2"
56
+
features = ["rt", "stm32f103"]
57
+
```
58
+
59
+
If you build your project now, you should get a single error: `error: language
60
+
item required, but not found: eh_personality`. This unhelpful error message
61
+
is fixed by compiling for the right target.
62
+
63
+
We also need to tell Rust how to link our executable, and how to lay out the
64
+
result in memory. To accomplish all this, copy [.cargo/config](.cargo/config) and
65
+
[memory.x](memory.x) from the stm32f1xx-hal repo to your project.
66
+
67
+
```bash
68
+
cargo build
69
+
```
70
+
71
+
If everything went well, your project should have built without errors.
72
+
73
+
74
+
### Programming the microcontroller
75
+
76
+
It is now time to actually run the code on the hardware. To do so plug your
77
+
debug probe into the blue pill and start `openocd` using
0 commit comments