Skip to content

Commit 3746885

Browse files
authored
Merge branch 'master' into rustconf-dump
2 parents b3b5732 + daeb4b0 commit 3746885

22 files changed

+1454
-213
lines changed

src/SUMMARY.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ more information and coordination
1818
- [Tooling](./intro/tooling.md)
1919
- [Hardware](./intro/hardware.md)
2020
- [`no_std`](./intro/no-std.md)
21-
- [Blinking your first LED](./blinky/blinky.md)
21+
- [Getting started](./start.md)
22+
- [QEMU](./start/qemu.md)
23+
- [Hardware](./start/hardware.md)
24+
- [Panics](./start/panics.md)
25+
- [Exceptions](./start/exceptions.md)
26+
- [IO](./start/io.md)
2227
- [Peripherals](./peripherals/peripherals.md)
2328
- [A first attempt in Rust](./peripherals/a-first-attempt.md)
2429
- [The Borrow Checker](./peripherals/borrowck.md)

src/assets/verify.jpeg

152 KB
Loading

src/blinky/blinky.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/c-tips/c-tips.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Tips for embedded C developers
22

3-
> ❌: This section has not yet been written. Please refer to [embedded-wg#126](https://github.com/rust-lang-nursery/embedded-wg/issues/126) for discussion of this section.
3+
> ❌: This section has not yet been written. Please refer to [rust-embedded/book#9](https://github.com/rust-embedded/book/issues/9) for discussion of this section.

src/concurrency/concurrency.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Concurrency
22

3-
> ❌: This section has not yet been written. Please refer to [embedded-wg#124](https://github.com/rust-lang-nursery/embedded-wg/issues/124) for discussion of this section.
3+
> ❌: This section has not yet been written. Please refer to [rust-embedded/book#7](https://github.com/rust-embedded/book/issues/7) for discussion of this section.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Interoperability
22

3-
> ❌: This section has not yet been written. Please refer to [embedded-wg#48](https://github.com/rust-lang-nursery/embedded-wg/issues/48) for discussion of this section.
3+
> ❌: This section has not yet been written. Please refer to [rust-embedded/book#1](https://github.com/rust-embedded/book/issues/1) for discussion of this section.

src/intro/hardware.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1-
> **⚠️: This section contains exports from [Japaric's Discovery] book.**
2-
>
3-
> Contents should be reviewed for consistency in the context
4-
> of this book before "publishing"
5-
6-
[Japaric's Discovery]: https://japaric.github.io/discovery/
7-
81
# Meet your hardware
92

103
Let's get familiar with the hardware we'll be working with.
114

125
## STM32F3DISCOVERY (the "F3")
136

147
<p align="center">
15-
<img title="F3" src="/book/assets/f3.jpg">
8+
<img title="F3" src="/assets/f3.jpg">
169
</p>
1710

1811
We'll refer to this board as "F3" throughout this book.

src/intro/install.md

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,90 @@
1-
> **⚠️: This section contains exports from [Japaric's Discovery] book.**
2-
>
3-
> Contents should be reviewed for consistency in the context
4-
> of this book before "publishing"
5-
6-
[Japaric's Discovery]: https://japaric.github.io/discovery/
7-
8-
> **⚠️: This section still references `nightly` Rust**
1+
> **⚠️: This section still references `beta` Rust**
92
>
103
> Contents should be updated to work on `stable` Rust when possible
114
12-
> **⚠️: This section has not been checked as of 2018-07-29**
13-
>
14-
> Contents should be checked to still be working with current `nightly`
15-
> or `stable` Rust
5+
> **⚠️: This section was last checked on 2018-09-13**
166
177
# Setting up a development environment
188

199
Dealing with microcontrollers involves several tools as we'll be dealing with an architecture
20-
different than your laptop's and we'll have to run and debug programs on a "remote" device.
10+
different than your laptop's and we'll have to run and debug programs on a *remote* device.
11+
12+
<!-- NOTE(japaric) I'm not sure we are going to need the user to download *all* -->
13+
<!-- these docs so I'm going to comment out this section. If it turns out we do -->
14+
<!-- need some doc I think it would be best to link it from the section where -->
15+
<!-- it's needed -->
2116

22-
## Documentation
17+
<!-- ## Documentation -->
2318

24-
Tooling is not everything though. Without documentation is pretty much impossible to work with microcontrollers.
19+
<!-- Tooling is not everything though. Without documentation is pretty much impossible to work with microcontrollers. -->
2520

26-
We'll be referring to all these documents throughout this book:
21+
<!-- We'll be referring to all these documents throughout this book: -->
2722

28-
*HEADS UP* All these links point to PDF files and some of them are hundreds of pages long and
29-
several MBs in size.
23+
<!-- *HEADS UP* All these links point to PDF files and some of them are hundreds of pages long and -->
24+
<!-- several MBs in size. -->
3025

31-
- [STM32F3DISCOVERY User Manual][um]
32-
- [STM32F303VC Datasheet][ds]
33-
- [STM32F303VC Reference Manual][rm]
34-
- [LSM303DLHC]
35-
- [L3GD20]
26+
<!-- - [STM32F3DISCOVERY User Manual][um] -->
27+
<!-- - [STM32F303VC Datasheet][ds] -->
28+
<!-- - [STM32F303VC Reference Manual][rm] -->
29+
<!-- - [LSM303DLHC] -->
30+
<!-- - [L3GD20] -->
3631

37-
[L3GD20]: http://www.st.com/resource/en/datasheet/l3gd20.pdf
38-
[LSM303DLHC]: http://www.st.com/resource/en/datasheet/lsm303dlhc.pdf
39-
[ds]: http://www.st.com/resource/en/datasheet/stm32f303vc.pdf
40-
[rm]: http://www.st.com/resource/en/reference_manual/dm00043574.pdf
41-
[um]: http://www.st.com/resource/en/user_manual/dm00063382.pdf
32+
<!-- [L3GD20]: http://www.st.com/resource/en/datasheet/l3gd20.pdf -->
33+
<!-- [LSM303DLHC]: http://www.st.com/resource/en/datasheet/lsm303dlhc.pdf -->
34+
<!-- [ds]: http://www.st.com/resource/en/datasheet/stm32f303vc.pdf -->
35+
<!-- [rm]: http://www.st.com/resource/en/reference_manual/dm00043574.pdf -->
36+
<!-- [um]: http://www.st.com/resource/en/user_manual/dm00063382.pdf -->
4237

4338
## Tools
4439

4540
We'll use all the tools listed below. Where a minimum version is not specified, any recent version should work but we have listed the version we have tested.
4641

47-
- Cargo & `rustc` >= nightly-2018-06-04
48-
- [`itmdump`] v0.2.1
42+
- Rust 1.30, 1.30-beta, nightly-2018-09-13, or a newer toolchain PLUS ARM
43+
Cortex-M compilation support.
44+
- [`cargo-binutils`](https://github.com/rust-embedded/cargo-binutils) ~0.1.4
45+
- [`qemu-system-arm`](https://www.qemu.org/). Tested versions: 3.0.0
4946
- OpenOCD >=0.8. Tested versions: v0.9.0 and v0.10.0
50-
- `arm-none-eabi-gcc`. Tested version: ?.??
51-
- `arm-none-eabi-binutils`
52-
- `arm-none-eabi-ld`. Tested version: 2.30
53-
- `arm-none-eabi-gdb`. Version 7.12 or newer highly recommended. Tested versions: 7.10, 7.11,
54-
7.12 and 8.1
55-
- `minicom` on Linux and macOS. Tested version: 2.7. Readers report that `picocom` also works but
56-
we'll use `minicom` in this text.
57-
58-
- `PuTTY` on Windows.
59-
60-
[`itmdump`]: https://crates.io/crates/itm
47+
- GDB with ARM support. Version 7.12 or newer highly recommended. Tested
48+
versions: 7.10, 7.11, 7.12 and 8.1
49+
- [OPTIONAL] `git` OR
50+
[`cargo-generate`](https://github.com/ashleygwilliams/cargo-generate). If you
51+
have neither installed then don't worry about installing either.
6152

6253
Next, follow OS-agnostic installation instructions for a few of the tools:
6354

64-
### `rustc` & Cargo
55+
### Rust toolchain
6556

6657
Install rustup by following the instructions at [https://rustup.rs](https://rustup.rs).
6758

68-
Then, install or switch to the nightly channel.
59+
Then switch to the beta channel.
6960

7061
``` console
71-
$ rustup default nightly
62+
$ rustup default beta
7263
```
7364

74-
**NOTE** Make sure you have a nightly newer than `nightly-2018-06-04`. `rustc -V` should return a
75-
date newer than the one shown below:
65+
**NOTE** Make sure you have a beta equal to or newer than `1.30-beta`. `rustc
66+
-V` should return a date newer than the one shown below. If `1.30-beta` is not
67+
out yet then use the nightly channel for the time being.
7668

7769
``` console
7870
$ rustc -V
79-
rustc 1.28.0-nightly (29f48ccf3 2018-06-03)
71+
rustc 1.30.0-beta (????????? 2018-09-1?)
72+
```
73+
74+
For bandwidth and disk usage reasons the default installation only supports
75+
native compilation. To add cross compilation support for the ARM Cortex-M
76+
architecture install the following compilation targets.
77+
78+
``` console
79+
$ rustup target add thumbv6m-none-eabi thumbv7m-none-eabi thumbv7em-none-eabi thumbv7em-none-eabihf
8080
```
8181

82-
### `itmdump`
82+
### `cargo-binutils`
8383

8484
``` console
85-
$ cargo install itm --vers 0.2.1
85+
$ cargo install cargo-binutils
86+
87+
$ rustup component add llvm-tools-preview
8688
```
8789

8890
### OS specific instructions

src/intro/install/linux.md

Lines changed: 72 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,127 @@
1-
> **⚠️: This section contains exports from [Japaric's Discovery] book.**
2-
>
3-
> Contents should be reviewed for consistency in the context
4-
> of this book before "publishing"
5-
6-
[Japaric's Discovery]: https://japaric.github.io/discovery/
7-
8-
> **⚠️: This section has not been checked as of 2018-07-29**
9-
>
10-
> Contents should be checked to still be working with current `nightly`
11-
> or `stable` Rust
1+
> **⚠️: This section was last checked on 2018-09-13
122
133
# Linux
144

155
Here are the installation commands for a few Linux distributions.
166

17-
## REQUIRED packages
7+
## Packages
8+
9+
- Ubuntu 18.04 or newer / Debian stretch or newer
10+
11+
> **NOTE** `gdb-multiarch` is the GDB command you'll use to debug your ARM
12+
> Cortex-M programs
13+
14+
<!-- Debian stretch -->
15+
<!-- GDB 7.12 -->
16+
<!-- OpenOCD 0.9.0 -->
17+
<!-- QEMU 2.8.1 -->
1818

19-
- Ubuntu 16.04 or newer / Debian Jessie or newer
19+
<!-- Ubuntu 18.04 -->
20+
<!-- GDB 8.1 -->
21+
<!-- OpenOCD 0.10.0 -->
22+
<!-- QEMU 2.11.1 -->
23+
24+
``` console
25+
$ sudo apt-get install \
26+
gdb-multiarch \
27+
openocd \
28+
qemu-system-arm
29+
```
30+
31+
- Ubuntu 14.04 and 16.04
32+
33+
> **NOTE** `arm-none-eabi-gdb` is the GDB command you'll use to debug your ARM
34+
> Cortex-M programs
35+
36+
<!-- Ubuntu 14.04 -->
37+
<!-- GDB 7.6 (!) -->
38+
<!-- OpenOCD 0.7.0 (?) -->
39+
<!-- QEMU 2.0.0 (?) -->
2040

2141
``` console
2242
$ sudo apt-get install \
23-
binutils-arm-none-eabi \
2443
gdb-arm-none-eabi \
25-
minicom \
26-
openocd
44+
openocd \
45+
qemu-system-arm
2746
```
2847

29-
- Fedora 23 or newer
48+
- Fedora 27 or newer
49+
50+
> **NOTE** `arm-none-eabi-gdb` is the GDB command you'll use to debug your ARM
51+
> Cortex-M programs
52+
53+
<!-- Fedora 27 -->
54+
<!-- GDB 7.6 (!) -->
55+
<!-- OpenOCD 0.10.0 -->
56+
<!-- QEMU 2.10.2 -->
3057

3158
``` console
3259
$ sudo dnf install \
33-
arm-none-eabi-gcc-cs \
3460
arm-none-eabi-gdb \
35-
minicom \
36-
openocd
61+
openocd \
62+
qemu-system-arm
3763
```
3864

3965
- Arch Linux
4066

67+
> **NOTE** `arm-none-eabi-gdb` is the GDB command you'll use to debug ARM
68+
> Cortex-M programs
69+
4170
``` console
4271
$ sudo pacman -S \
43-
arm-none-eabi-gcc \
4472
arm-none-eabi-gdb \
45-
arm-none-eabi-gcc \
46-
minicom
73+
qemu-system-arm
4774

48-
$ yaourt -S openocd
75+
$ # install openocd from the AUR -- https://aur.archlinux.org/packages/openocd/
4976
```
5077

5178
## udev rules
5279

53-
These rules let you use USB devices like the F3 and the Serial module without root privilege, i.e.
54-
`sudo`.
80+
This rule lets you use OpenOCD with the Discovery board without root privilege.
5581

56-
Create these two files in `/etc/udev/rules.d` with the contents shown below.
82+
Create this file in `/etc/udev/rules.d` with the contents shown below.
5783

5884
``` console
59-
$ cat /etc/udev/rules.d/99-ftdi.rules
60-
```
61-
62-
``` text
63-
# FT232 - USB <-> Serial Converter
64-
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", GROUP="uucp"
65-
```
66-
67-
``` console
68-
$ cat /etc/udev/rules.d/99-openocd.rules
85+
$ cat /etc/udev/rules.d/99-st-link.rules
6986
```
7087

7188
``` text
7289
# STM32F3DISCOVERY rev A/B - ST-LINK/V2
73-
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", GROUP="uucp"
90+
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", MODE:="0666"
7491
7592
# STM32F3DISCOVERY rev C+ - ST-LINK/V2-1
76-
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", GROUP="uucp"
93+
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", MODE:="0666"
7794
```
7895

79-
Then reload the udev rules with:
96+
Then reload all the udev rules with:
8097

8198
``` console
8299
$ sudo udevadm control --reload-rules
83100
```
84101

85-
If you had any board plugged to your laptop, unplug them and then plug them in again.
86-
87-
Finally, check if you are in the `uucp` group.
88-
89-
``` console
90-
$ groups $(id -nu)
91-
(..) uucp (..)
92-
$ # ^^^^
93-
```
94-
95-
(`$(id -nu)` returns your user name. In my case it's `japaric`.)
96-
97-
If `uucp` appears in the output. You are all set! Go to the [next section]. Otherwise, keep reading:
98-
99-
[next section]: /intro/install/verify.html
102+
If you had the board plugged to your laptop, unplug it and then plug it again.
100103

101-
- Add yourself to the `uucp` group.
104+
You can check the permissions by running these commands:
102105

103106
``` console
104-
$ sudo usermod -a -G uucp $(id -u -n)
107+
$ lsusb
108+
(..)
109+
Bus 001 Device 018: ID 0483:374b STMicroelectronics ST-LINK/V2.1
110+
(..)
105111
```
106112

107-
- Check again the output of `groups`. `uucp` should be there this time!
113+
Take note of the bus and device numbers. Use those numbers in the following
114+
command:
108115

109116
``` console
110-
$ groups $(id -nu)
111-
(..) uucp (..)
112-
$ # ^^^^
117+
$ # the format of the path is /dev/bus/usb/<bus>/<device>
118+
$ ls -l /dev/bus/usb/001/018
119+
crw-rw-rw- 1 root root 189, 17 Sep 13 12:34 /dev/bus/usb/001/018
113120
```
114121

115-
You'll have to re-log for these changes to take effect. You have two options:
116-
117-
You can reboot or log out from your current session and then log in; this will close all the
118-
programs you have open right now.
119-
120-
The other option is to use the command below:
121-
122-
``` console
123-
$ su - $(id -nu)
124-
```
125-
126-
to re-log *only in the current shell* and get access to `uucp` devices *only on that shell*. Other
127-
shells *won't* have access to `uucp` devices unless you manually re-log on them with the same `su`
128-
command.
122+
The permissions should be `crw-rw-rw-`; this indicates that all users can make
123+
use of this device.
129124

130125
Now, go to the [next section].
126+
127+
[next section]: /intro/install/verify.html

0 commit comments

Comments
 (0)