Skip to content

Commit 8ea5d2c

Browse files
Merge #304
304: Update-03-setting-up-a-dev-env r=adamgreig a=winksaville Update `*.md` files so that copy-to-clipboard button in code blocks works so that commands can be copied and pasted into terminal windows. Some reorganization of the text for clarity. Co-authored-by: Wink Saville <wink@saville.com>
2 parents d074114 + 53b0081 commit 8ea5d2c

File tree

5 files changed

+151
-74
lines changed

5 files changed

+151
-74
lines changed

src/03-setup/README.md

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ should work but we have listed the version we have tested.
3838

3939
- Rust 1.31 or a newer toolchain.
4040

41-
- [`itmdump`] v0.3.1 (`cargo install itm`)
41+
- [`itmdump`] >=0.3.1 (`cargo install itm`). Tested versions: 0.3.1.
4242

4343
- OpenOCD >=0.8. Tested versions: v0.9.0 and v0.10.0
4444

@@ -84,37 +84,70 @@ rustc 1.31.0 (abe02cefd 2018-12-04)
8484

8585
### `itmdump`
8686

87+
8788
``` console
88-
$ cargo install itm --vers 0.3.1
89+
cargo install itm
90+
```
8991

92+
Verify the version is >=0.3.1
93+
```
9094
$ itmdump -V
9195
itmdump 0.3.1
9296
```
9397

9498
### `cargo-binutils`
9599

100+
Install `llvm-tools-preview`
101+
96102
``` console
97-
$ rustup component add llvm-tools-preview
103+
rustup component add llvm-tools-preview
104+
```
105+
106+
Install `cargo-binutils`
107+
```
108+
cargo install cargo-binutils
109+
```
110+
111+
#### Verify tools are installed
98112

99-
$ cargo install cargo-binutils
113+
Run the following commands at your terminal
114+
``` console
115+
cargo new test-size
116+
```
117+
```
118+
cd test-size
119+
```
120+
```
121+
cargo run
122+
```
123+
```
124+
cargo size -- -version
125+
```
100126

127+
The results should be something like:
128+
```
129+
~
101130
$ cargo new test-size
102131
Created binary (application) `test-size` package
103132
133+
~
104134
$ cd test-size
105135
136+
~/test-size (main)
106137
$ cargo run
107-
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
108-
Running `target\debug\test-size.exe`
138+
Compiling test-size v0.1.0 (~/test-size)
139+
Finished dev [unoptimized + debuginfo] target(s) in 0.26s
140+
Running `target/debug/test-size`
109141
Hello, world!
110142
143+
~/test-size (main)
111144
$ cargo size -- -version
112-
Finished dev [unoptimized + debuginfo] target(s) in 0.50s
145+
Finished dev [unoptimized + debuginfo] target(s) in 0.00s
113146
LLVM (http://llvm.org/):
114-
LLVM version 11.0.0-rust-1.49.0-stable
147+
LLVM version 11.0.0-rust-1.50.0-stable
115148
Optimized build.
116-
Default target: x86_64-pc-windows-msvc
117-
Host CPU: skylake
149+
Default target: x86_64-unknown-linux-gnu
150+
Host CPU: znver2
118151
```
119152

120153
### OS specific instructions

src/03-setup/linux.md

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Here are the installation commands for a few Linux distributions.
1818
<!-- OpenOCD 0.10.0 -->
1919

2020
``` console
21-
$ sudo apt-get install \
21+
sudo apt-get install \
2222
gdb-multiarch \
2323
minicom \
2424
openocd
@@ -34,7 +34,7 @@ $ sudo apt-get install \
3434
<!-- OpenOCD 0.7.0 -->
3535

3636
``` console
37-
$ sudo apt-get install \
37+
sudo apt-get install \
3838
gdb-arm-none-eabi \
3939
minicom \
4040
openocd
@@ -46,7 +46,7 @@ $ sudo apt-get install \
4646
> Cortex-M programs
4747
4848
``` console
49-
$ sudo dnf install \
49+
sudo dnf install \
5050
arm-none-eabi-gdb \
5151
minicom \
5252
openocd
@@ -58,7 +58,7 @@ $ sudo dnf install \
5858
> Cortex-M programs
5959
6060
``` console
61-
$ sudo pacman -S \
61+
sudo pacman -S \
6262
arm-none-eabi-gdb \
6363
minicom \
6464
openocd
@@ -75,39 +75,41 @@ download the "Linux 64-bit" file and put its `bin` directory on your path.
7575
Here's one way to do it:
7676

7777
``` console
78-
$ mkdir -p ~/local && cd ~/local
79-
$ tar xjf /path/to/downloaded/file/gcc-arm-none-eabi-7-2017-q4-major-linux.tar.bz2.tbz
78+
mkdir -p ~/local && cd ~/local
79+
```
80+
``` console
81+
tar xjf /path/to/downloaded/file/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2
8082
```
8183

8284
Then, use your editor of choice to append to your `PATH` in the appropriate
8385
shell init file (e.g. `~/.zshrc` or `~/.bashrc`):
8486

8587
```
86-
PATH=$PATH:$HOME/local/gcc-arm-none-eabi-7-2017-q4-major/bin
88+
PATH=$PATH:$HOME/local/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux/bin
8789
```
8890

8991
## Optional packages
9092

9193
### Ubuntu / Debian
9294

9395
``` console
94-
$ sudo apt-get install \
96+
sudo apt-get install \
9597
bluez \
9698
rfkill
9799
```
98100

99101
### Fedora
100102

101103
``` console
102-
$ sudo dnf install \
104+
sudo dnf install \
103105
bluez \
104106
rfkill
105107
```
106108

107109
### Arch Linux
108110

109111
``` console
110-
$ sudo pacman -S \
112+
sudo pacman -S \
111113
bluez \
112114
bluez-utils \
113115
rfkill
@@ -118,35 +120,49 @@ $ sudo pacman -S \
118120
These rules let you use USB devices like the F3 and the Serial module without root privilege, i.e.
119121
`sudo`.
120122

121-
Create these two files in `/etc/udev/rules.d` with the contents shown below.
123+
Create `99-openocd.rules` in `/etc/udev/rules.d` using the `idVendor` and `idProduct`
124+
from the `lsusb` output.
122125

126+
For example, connect the STM32F3DISCOVERY to your computer using a USB cable.
127+
Be sure to connect the cable to the "USB ST-LINK" port, the USB port in the
128+
center of the edge of the board.
129+
130+
Execute `lsusb`:
123131
``` console
124-
$ cat /etc/udev/rules.d/99-ftdi.rules
132+
lsusb | grep ST-LINK
133+
```
134+
It should result in something like:
125135
```
136+
$ lsusb | grep ST-LINK
137+
Bus 003 Device 003: ID 0483:374b STMicroelectronics ST-LINK/V2.1
138+
```
139+
So the `idProduct` is `0483` and `idVendor` is `374b`.
126140

141+
### Create `/etc/udev/rules.d/99-openocd.rules`:
142+
``` console
143+
sudo vi /etc/udev/rules.d/99-openocd.rules
144+
```
145+
With the contents:
127146
``` text
128-
# FT232 - USB <-> Serial Converter
129-
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE:="0666"
147+
# STM32F3DISCOVERY - ST-LINK/V2.1
148+
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", MODE:="0666"
130149
```
150+
#### For older devices with OPTIONAL USB <-> FT232 based Serial Module
131151

132-
If you have a different USB <-> Serial converter, get its vendor and product ids from `lsusb` output.
133-
152+
Create `/etc/udev/rules.d/99-ftdi.rules`:
134153
``` console
135-
$ cat /etc/udev/rules.d/99-openocd.rules
154+
sudo vi /etc/udev/rules.d/99-openocd.rules
136155
```
137-
156+
With the contents:
138157
``` text
139-
# STM32F3DISCOVERY rev A/B - ST-LINK/V2
140-
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", MODE:="0666"
141-
142-
# STM32F3DISCOVERY rev C+ - ST-LINK/V2-1
143-
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", MODE:="0666"
158+
# FT232 - USB <-> Serial Converter
159+
ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", MODE:="0666"
144160
```
145161

146-
Then reload the udev rules with:
162+
### Reload the udev rules with:
147163

148164
``` console
149-
$ sudo udevadm control --reload-rules
165+
sudo udevadm control --reload-rules
150166
```
151167

152168
If you had any board plugged to your computer, unplug them and then plug them in again.

src/03-setup/macos.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ All the tools can be install using [Homebrew]:
44

55
[Homebrew]: http://brew.sh/
66

7+
Install ArmMbed
78
``` console
8-
$ # Arm GCC toolchain
9-
$ brew tap ArmMbed/homebrew-formulae
10-
$ brew install arm-none-eabi-gcc
11-
12-
$ # Minicom and OpenOCD
13-
$ brew install minicom openocd
9+
brew tap ArmMbed/homebrew-formulae
10+
```
11+
Install the ARM GCC toolchain
12+
``` console
13+
brew install arm-none-eabi-gcc
14+
```
15+
Install minicom and OpenOCD
16+
``` console
17+
brew install minicom openocd
1418
```
1519

1620
That's all! Go to the [next section].

src/03-setup/verify.md

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,27 @@ Let's verify that all the tools were installed correctly.
66

77
### Verify permissions
88

9-
Connect the F3 to your computer using an USB cable. Be sure to connect the cable to the "USB ST-LINK"
9+
Connect the STM32F3DISCOVERY to your computer using an USB cable. Be sure to connect the cable to the "USB ST-LINK"
1010
port, the USB port in the center of the edge of the board.
1111

12-
The F3 should now appear as a USB device (file) in `/dev/bus/usb`. Let's find out how it got
12+
The STM32F3DISCOVERY should now appear as a USB device (file) in `/dev/bus/usb`. Let's find out how it got
1313
enumerated:
1414

15+
``` console
16+
lsusb | grep -i stm
17+
```
18+
This should result in:
1519
``` console
1620
$ lsusb | grep -i stm
1721
Bus 003 Device 004: ID 0483:374b STMicroelectronics ST-LINK/V2.1
1822
$ # ^^^ ^^^
1923
```
2024

21-
In my case, the F3 got connected to the bus #3 and got enumerated as the device #4. This means the
22-
file `/dev/bus/usb/003/004` *is* the F3. Let's check its permissions:
23-
25+
In my case, the STM32F3DISCOVERY got connected to the bus #3 and got enumerated as the device #4. This means the
26+
file `/dev/bus/usb/003/004` *is* the STM32F3DISCOVERY. Let's check its permissions:
2427
``` console
25-
$ ls -l /dev/bus/usb/003/004
26-
crw-rw-rw- 1 root root 189, 20 Sep 13 00:00 /dev/bus/usb/003/004
28+
$ ls -la /dev/bus/usb/003/004
29+
crw-rw-rw-+ 1 root root 189, 259 Feb 28 13:32 /dev/bus/usb/003/00
2730
```
2831

2932
The permissions should be `crw-rw-rw-`. If it's not ... then check your [udev
@@ -32,12 +35,12 @@ rules] and try re-loading them with:
3235
[udev rules]: linux.md#udev-rules
3336

3437
``` console
35-
$ sudo udevadm control --reload-rules
38+
sudo udevadm control --reload-rules
3639
```
3740

38-
Now let's repeat the procedure for the Serial module.
41+
#### For older devices with OPTIONAL USB <-> FT232 based Serial Module
3942

40-
Unplug the F3 and plug the Serial module. Now, figure out what's its associated file:
43+
Unplug the STM32F3DISCOVERY and plug the Serial module. Now, figure out what's its associated file:
4144

4245
``` console
4346
$ lsusb | grep -i ft232
@@ -53,36 +56,51 @@ crw-rw-rw- 1 root root 189, 21 Sep 13 00:00 /dev/bus/usb/003/005
5356

5457
As before, the permissions should be `crw-rw-rw-`.
5558

56-
## All
59+
## Verify OpenOCD connection
5760

58-
### First OpenOCD connection
59-
60-
First, connect the F3 to your computer using an USB cable. Connect the cable to the USB port in the
61+
Connect the STM32F3DISCOVERY using the USB cable to the USB port in the
6162
center of edge of the board, the one that's labeled "USB ST-LINK".
6263

6364
Two *red* LEDs should turn on right after connecting the USB cable to the board.
6465

65-
Next, run this command:
66+
> **IMPORTANT** There is more than one hardware revision of the STM32F3DISCOVERY board. For older
67+
> revisions, you'll need to change the "interface" argument to `-f interface/stlink-v2.cfg` (note:
68+
> no `-1` at the end). Alternatively, older revisions can use `-f board/stm32f3discovery.cfg`
69+
> instead of `-f interface/stlink-v2-1.cfg -f target/stm32f3x.cfg`.
70+
71+
### *Nix
72+
73+
> **FYI:** The `interface` directory is typically located in `/usr/share/openocd/scripts/`,
74+
> which is the default location OpenOCD expects these files. If you've installed them
75+
> somewhere else use the `-s /path/to/scripts/` option to specify your install directory.
6676
6777
``` console
68-
$ # *nix
69-
$ openocd -f interface/stlink-v2-1.cfg -f target/stm32f3x.cfg
78+
openocd -f interface/stlink-v2-1.cfg -f target/stm32f3x.cfg
79+
```
7080

71-
$ # Windows
72-
$ # NOTE cygwin users have reported problems with the -s flag. If you run into
73-
$ # that you can call openocd from the `C:\OpenOCD\share\scripts` directory
74-
$ openocd -s C:\OpenOCD\share\scripts -f interface/stlink-v2-1.cfg -f target/stm32f3x.cfg
81+
### Windows
82+
83+
Below the references to `C:\OpenOCD` is the directory where OpenOCD is installed.
84+
85+
``` console
86+
openocd -s C:\OpenOCD\share\scripts -f interface/stlink-v2-1.cfg -f target/stm32f3x.cfg
7587
```
7688

77-
> **NOTE** Windows users: `C:\OpenOCD` is the directory where you installed OpenOCD to.
89+
> **NOTE** cygwin users have reported problems with the -s flag. If you run into
90+
> that problem you can add `C:\OpenOCD\share\scripts\` directory to the parameters.
7891
79-
> **IMPORTANT** There is more than one hardware revision of the STM32F3DISCOVERY board. For older
80-
> revisions, you'll need to change the "interface" argument to `-f interface/stlink-v2.cfg` (note:
81-
> no `-1` at the end). Alternatively, older revisions can use `-f board/stm32f3discovery.cfg`
82-
> instead of `-f interface/stlink-v2-1.cfg -f target/stm32f3x.cfg`.
92+
cygwin users:
93+
``` console
94+
openocd -f C:\OpenOCD\share\scripts\interface\stlink-v2-1.cfg -f C:\OpenOCD\share\scripts\target\stm32f3x.cfg
95+
```
8396

84-
You should see output like this:
97+
### All
8598

99+
OpenOCD is a service which forwards debug information from the ITM channel
100+
to a file, `itm.txt`, as such it runs forever and does **not** return to the
101+
terminal prompt.
102+
103+
The initial output of OpenOCD is something like:
86104
``` console
87105
Open On-Chip Debugger 0.10.0
88106
Licensed under GNU GPL v2
@@ -106,9 +124,7 @@ Info : stm32f3x.cpu: hardware has 6 breakpoints, 4 watchpoints
106124

107125
[general troubleshooting]: ../appendix/1-general-troubleshooting/index.html
108126

109-
`openocd` will block the terminal. That's fine.
110-
111127
Also, one of the red LEDs, the one closest to the USB port, should start oscillating between red
112128
light and green light.
113129

114-
That's it! It works. You can now close/kill `openocd`.
130+
That's it! It works. You can now use `Ctrl-c` to stop OpenOCD or close/kill the terminal.

0 commit comments

Comments
 (0)