Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it easier to copy and paste example commands. #289

Merged
merged 1 commit into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/intro/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Install rustup by following the instructions at [https://rustup.rs](https://rust
**NOTE** Make sure you have a compiler version equal to or newer than `1.31`. `rustc
-V` should return a date newer than the one shown below.

``` console
``` text
$ rustc -V
rustc 1.31.1 (b6c32da9b 2018-12-18)
```
Expand All @@ -21,43 +21,43 @@ board used for the examples in this book, use the `thumbv7em-none-eabihf` target

Cortex-M0, M0+, and M1 (ARMv6-M architecture):
``` console
$ rustup target add thumbv6m-none-eabi
rustup target add thumbv6m-none-eabi
```

Cortex-M3 (ARMv7-M architecture):
``` console
$ rustup target add thumbv7m-none-eabi
rustup target add thumbv7m-none-eabi
```

Cortex-M4 and M7 without hardware floating point (ARMv7E-M architecture):
``` console
$ rustup target add thumbv7em-none-eabi
rustup target add thumbv7em-none-eabi
```

Cortex-M4F and M7F with hardware floating point (ARMv7E-M architecture):
``` console
$ rustup target add thumbv7em-none-eabihf
rustup target add thumbv7em-none-eabihf
```

Cortex-M23 (ARMv8-M architecture):
``` console
$ rustup target add thumbv8m.base-none-eabi
rustup target add thumbv8m.base-none-eabi
```

Cortex-M33 and M35P (ARMv8-M architecture):
``` console
$ rustup target add thumbv8m.main-none-eabi
rustup target add thumbv8m.main-none-eabi
```

Cortex-M33F and M35PF with hardware floating point (ARMv8-M architecture):
``` console
$ rustup target add thumbv8m.main-none-eabihf
rustup target add thumbv8m.main-none-eabihf
```


### `cargo-binutils`

``` console
``` text
$ cargo install cargo-binutils

$ rustup component add llvm-tools-preview
Expand All @@ -68,7 +68,7 @@ $ rustup component add llvm-tools-preview
We'll use this later to generate a project from a template.

``` console
$ cargo install cargo-generate
cargo install cargo-generate
```

### OS-Specific Instructions
Expand Down
2 changes: 1 addition & 1 deletion src/intro/install/macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All the tools can be install using [Homebrew]:

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

``` console
``` text
$ # GDB
$ brew install armmbed/formulae/arm-none-eabi-gcc

Expand Down
6 changes: 3 additions & 3 deletions src/intro/install/verify.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ST-LINK header is circled in red.
Now run the following command:

``` console
$ openocd -f interface/stlink.cfg -f target/stm32f3x.cfg
openocd -f interface/stlink.cfg -f target/stm32f3x.cfg
```

> **NOTE**: Old versions of openocd, including the 0.10.0 release from 2017, do
Expand Down Expand Up @@ -54,11 +54,11 @@ and move to the [next section].
If you didn't get the "breakpoints" line then try one of the following commands.

``` console
$ openocd -f interface/stlink-v2.cfg -f target/stm32f3x.cfg
openocd -f interface/stlink-v2.cfg -f target/stm32f3x.cfg
```

``` console
$ openocd -f interface/stlink-v2-1.cfg -f target/stm32f3x.cfg
openocd -f interface/stlink-v2-1.cfg -f target/stm32f3x.cfg
```

If one of those commands works it means you got an old hardware revision of the
Expand Down
4 changes: 2 additions & 2 deletions src/intro/install/windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARM provides `.exe` installers for Windows. Grab one from [here][gcc], and follo
Just before the installation process finishes tick/select the "Add path to environment variable"
option. Then verify that the tools are in your `%PATH%`:

``` console
``` text
$ arm-none-eabi-gdb -v
GNU gdb (GNU Tools for Arm Embedded Processors 7-2018-q2-update) 8.1.0.20180315-git
(..)
Expand All @@ -26,7 +26,7 @@ if you've been using the easy install)

Verify that OpenOCD is in your `%PATH%` with:

``` console
``` text
$ openocd -v
Open On-Chip Debugger 0.10.0
(..)
Expand Down
8 changes: 4 additions & 4 deletions src/start/exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ fn SysTick() {
```

``` console
$ tail -n5 Cargo.toml
tail -n5 Cargo.toml
```

``` toml
Expand All @@ -132,7 +132,7 @@ panic-halt = "0.2.0"
cortex-m-semihosting = "0.3.1"
```

``` console
``` text
$ cargo run --release
Running `qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb (..)
123456789
Expand Down Expand Up @@ -227,7 +227,7 @@ fn HardFault(ef: &ExceptionFrame) -> ! {
The `HardFault` handler prints the `ExceptionFrame` value. If you run this
you'll see something like this on the OpenOCD console.

``` console
``` text
$ openocd
(..)
ExceptionFrame {
Expand All @@ -248,7 +248,7 @@ and it points to the instruction that triggered the exception.
If you look at the disassembly of the program:


``` console
``` text
$ cargo objdump --bin app --release -- -d --no-show-raw-insn --print-imm-hex
(..)
ResetTrampoline:
Expand Down
26 changes: 13 additions & 13 deletions src/start/hardware.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ We'll start from scratch with a fresh template instance. Refer to the

[previous section on QEMU]: qemu.md

``` console
``` text
$ cargo generate --git https://github.com/rust-embedded/cortex-m-quickstart
Project Name: app
Creating project called `app`...
Done! New project created /tmp/app

$ cd app
$ cd app
```

Step number one is to set a default compilation target in `.cargo/config`.

``` console
$ tail -n5 .cargo/config
tail -n5 .cargo/config
```

``` toml
Expand All @@ -68,7 +68,7 @@ We'll use `thumbv7em-none-eabihf` as that covers the Cortex-M4F core.
The second step is to enter the memory region information into the `memory.x`
file.

``` console
``` text
$ cat memory.x
/* Linker script for the STM32F303VCT6 */
MEMORY
Expand Down Expand Up @@ -107,7 +107,7 @@ and inspect the binaries using `cargo-binutils` as you did before. The
as helpfully, pretty much all Cortex-M CPUs boot in the same fashion.

``` console
$ cargo build --example hello
cargo build --example hello
```

## Debugging
Expand All @@ -131,7 +131,7 @@ Run this command from the root of the template; `openocd` will pick up the
`openocd.cfg` file which indicates which interface file and target file to use.

``` console
$ cat openocd.cfg
cat openocd.cfg
```

``` text
Expand All @@ -153,7 +153,7 @@ source [find target/stm32f3x.cfg]
> board during the [verify] section then you should modify the `openocd.cfg`
> file at this point to use `interface/stlink-v2.cfg`.

``` console
``` text
$ openocd
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
Expand All @@ -175,7 +175,7 @@ Info : stm32f3x.cpu: hardware has 6 breakpoints, 4 watchpoints

On another terminal run GDB, also from the root of the template.

``` console
``` text
$ <gdb> -q target/thumbv7em-none-eabihf/debug/examples/hello
```

Expand Down Expand Up @@ -243,7 +243,7 @@ Advancing the program with `next` should produce the same results as before.
At this point you should see "Hello, world!" printed on the OpenOCD console,
among other stuff.

``` console
``` text
$ openocd
(..)
Info : halted: PC: 0x08000e6c
Expand All @@ -269,7 +269,7 @@ Program received signal SIGTRAP, Trace/breakpoint trap.

It also causes this to be printed to the OpenOCD console:

``` console
``` text
$ openocd
(..)
Info : halted: PC: 0x08001188
Expand All @@ -293,7 +293,7 @@ Debugging now requires a few more steps so we have packed all those steps into a
single GDB script named `openocd.gdb`. The file was created during the `cargo generate` step, and should work without any modifications. Let's have a peak:

``` console
$ cat openocd.gdb
cat openocd.gdb
```

``` text
Expand Down Expand Up @@ -323,7 +323,7 @@ Alternatively, you can turn `<gdb> -x openocd.gdb` into a custom runner to make
in `.cargo/config` but it's commented out.

``` console
$ head -n10 .cargo/config
head -n10 .cargo/config
```

``` toml
Expand All @@ -339,7 +339,7 @@ runner = "arm-none-eabi-gdb -x openocd.gdb"
# runner = "gdb -x openocd.gdb"
```

``` console
``` text
$ cargo run --example hello
(..)
Loading section .vector_table, size 0x400 lma 0x8000000
Expand Down
2 changes: 1 addition & 1 deletion src/start/panicking.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fn main() -> ! {
This example chose the `panic-semihosting` behavior which prints the panic
message to the host console using semihosting.

``` console
``` text
$ cargo run
Running `qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb (..)
panicked at 'index out of bounds: the len is 3 but the index is 4', src/main.rs:12:13
Expand Down
2 changes: 1 addition & 1 deletion src/start/qemu.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ To cross compile for the Cortex-M3 architecture we have to use
the Rust toolchain, it would now be a good time to add that target to the toolchain,
if you haven't done it yet:
``` console
$ rustup target add thumbv7m-none-eabi
rustup target add thumbv7m-none-eabi
```
Since the `thumbv7m-none-eabi` compilation target has been set as the default in
your `.cargo/config` file, the two commands below do the same:
Expand Down
8 changes: 4 additions & 4 deletions src/start/semihosting.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn main() -> ! {
If you run this program on hardware you'll see the "Hello, world!" message
within the OpenOCD logs.

``` console
``` text
$ openocd
(..)
Hello, world!
Expand All @@ -51,7 +51,7 @@ need to pass the `-semihosting-config` flag to QEMU to enable semihosting
support; these flags are already included in the `.cargo/config` file of the
template.

``` console
``` text
$ # this program will block the terminal
$ cargo run
Running `qemu-system-arm (..)
Expand Down Expand Up @@ -86,7 +86,7 @@ fn main() -> ! {
}
```

``` console
``` text
$ cargo run
Running `qemu-system-arm (..)

Expand Down Expand Up @@ -120,7 +120,7 @@ fn main() -> ! {
}
```

``` console
``` text
$ cargo run
Running `qemu-system-arm (..)
panicked at 'assertion failed: `(left == right)`
Expand Down
4 changes: 2 additions & 2 deletions src/unsorted/speed-vs-size.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ opt-level = "z" # +

Without the override:

``` console
``` text
$ cargo size --bin app -- -A
app :
section size addr
Expand All @@ -71,7 +71,7 @@ section size addr

With the override:

``` console
``` text
$ cargo size --bin app -- -A
app :
section size addr
Expand Down