Skip to content

Commit c888eaa

Browse files
README: add setup instructions (#136)
* README: add setup instructions inspired by https://github.com/stm32-rs/stm32f1xx-hal/blob/master/README.md Co-authored-by: Daniel Egger <daniel@eggers-club.de>
1 parent e39a460 commit c888eaa

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,39 @@ crate by Jorge Aparicio.
4545
[stm32f103xx-hal]: https://github.com/japaric/stm32f103xx-hal
4646
[embedded-hal]: https://github.com/rust-embedded/embedded-hal
4747

48+
Setting up your project
49+
-------
50+
51+
Check if the BSP for your board exists in the
52+
[stm32-rs](https://github.com/stm32-rs) page.
53+
If it exists, the `stm32f4xx-hal` crate should be already included, so you can
54+
use the bsp as BSP for your project.
55+
56+
Otherwise, create a new Rust project as you usually do with `cargo init`. The
57+
"hello world" of embedded development is usually to blink a LED. The code to do
58+
so is available in [examples/delay-blinky.rs](examples/delay-blinky.rs).
59+
Copy that file to the `main.rs` of your project.
60+
61+
You also need to add some dependencies to your `Cargo.toml`:
62+
63+
```toml
64+
[dependencies]
65+
embedded-hal = "0.2.3"
66+
nb = "0.1.2"
67+
cortex-m = "0.6.2"
68+
cortex-m-rt = "0.6.11"
69+
# Panic behaviour, see https://crates.io/keywords/panic-impl for alternatives
70+
panic-halt = "0.2.0"
71+
72+
[dependencies.stm32f4xx-hal]
73+
version = "0.7"
74+
features = ["rt", "stm32f407"] # replace the model of your microcontroller here
75+
```
76+
77+
We also need to tell Rust how to link our executable and how to lay out the
78+
result in memory. To accomplish all this, copy [.cargo/config](.cargo/config)
79+
and [memory.x](memory.x) from the `stm32f4xx-hal` repository to your project and make sure the sizes match up with the datasheet. Also note that there might be different kinds of memory which are not equal; to be on the safe side only specify the size of the first block at the specified address.
80+
4881
License
4982
-------
5083

0 commit comments

Comments
 (0)