From 51845ac40322157bc5baf0ffdfaf2db99b153c68 Mon Sep 17 00:00:00 2001 From: Stefan Eicher Date: Mon, 3 Jun 2019 10:42:25 +0200 Subject: [PATCH 1/5] Update headings to get the the following TOC # QEMU ## Creating a non standard Rust program ### Using `cargo-generate` ### Using `git` ### Using neither ## Cross compiling ## Inspecting ## Running ## Debugging pull request is related to https://github.com/rust-embedded/book/issues/186 --- src/start/qemu.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/start/qemu.md b/src/start/qemu.md index 239ea24b..3cb4a5fa 100644 --- a/src/start/qemu.md +++ b/src/start/qemu.md @@ -14,7 +14,7 @@ project from it. [`cortex-m-quickstart`]: https://github.com/rust-embedded/cortex-m-quickstart -- Using `cargo-generate` +### Using `cargo-generate` ```console cargo generate --git https://github.com/rust-embedded/cortex-m-quickstart @@ -30,7 +30,7 @@ cargo generate --git https://github.com/rust-embedded/cortex-m-quickstart cd app ``` -- Using `git` +### Using `git` Clone the repository @@ -56,7 +56,7 @@ test = false bench = false ``` -- Using neither +### Using neither Grab the latest snapshot of the `cortex-m-quickstart` template and extract it. @@ -74,7 +74,7 @@ download" button and then click "Download ZIP". Then fill in the placeholders in the `Cargo.toml` file as done in the second part of the "Using `git`" version. - +___ **IMPORTANT** We'll use the name "app" for the project name in this tutorial. Whenever you see the word "app" you should replace it with the name you selected for your project. Or, you could also name your project "app" and avoid the @@ -125,7 +125,7 @@ that'd be `#[entry]`. hardware so we don't want it to end! We use a [divergent function](https://doc.rust-lang.org/rust-by-example/fn/diverging.html) (the `-> !` bit in the function signature) to ensure at compile time that'll be the case. -### Cross compiling +## Cross compiling The next step is to *cross* compile the program for the Cortex-M3 architecture. That's as simple as running `cargo build --target $TRIPLE` if you know what the @@ -154,7 +154,7 @@ cargo build --target thumbv7m-none-eabi cargo build ``` -### Inspecting +## Inspecting Now we have a non-native ELF binary in `target/thumbv7m-none-eabi/debug/app`. We can inspect it using `cargo-binutils`. @@ -293,7 +293,7 @@ HardFault: 663: ``` -### Running +## Running Next, let's see how to run an embedded program on QEMU! This time we'll use the `hello` example which actually does something. @@ -414,7 +414,7 @@ cargo run --example hello --release Hello, world! ``` -### Debugging +## Debugging Debugging is critical to embedded development. Let's see how it's done. From 753d71acb9e498076a912808e5ff0c5008034a69 Mon Sep 17 00:00:00 2001 From: Stefan Eicher Date: Mon, 3 Jun 2019 10:47:33 +0200 Subject: [PATCH 2/5] add comment to run "cargo install cargo-generate" first --- src/start/qemu.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/start/qemu.md b/src/start/qemu.md index 3cb4a5fa..3414ae38 100644 --- a/src/start/qemu.md +++ b/src/start/qemu.md @@ -15,7 +15,11 @@ project from it. [`cortex-m-quickstart`]: https://github.com/rust-embedded/cortex-m-quickstart ### Using `cargo-generate` - +First install cargo-generate +```console +cargo install cargo-generate +``` +Then generate a new project ```console cargo generate --git https://github.com/rust-embedded/cortex-m-quickstart ``` From c0f7b63c306d62eae89c2c20ba134610f238ad5e Mon Sep 17 00:00:00 2001 From: Stefan Eicher Date: Mon, 3 Jun 2019 10:49:04 +0200 Subject: [PATCH 3/5] delete "Using the command line:" to make the documentation style consistent to the previous command line blocks --- src/start/qemu.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/start/qemu.md b/src/start/qemu.md index 3414ae38..f92b8d28 100644 --- a/src/start/qemu.md +++ b/src/start/qemu.md @@ -64,8 +64,6 @@ bench = false Grab the latest snapshot of the `cortex-m-quickstart` template and extract it. -Using the command line: - ```console curl -LO https://github.com/rust-embedded/cortex-m-quickstart/archive/master.zip unzip master.zip From a9e976af033910215dcedf389ea7fbc4df08b5a5 Mon Sep 17 00:00:00 2001 From: Stefan Eicher Date: Mon, 3 Jun 2019 10:56:25 +0200 Subject: [PATCH 4/5] move "**IMPORTANT** We'll use the name "app" for the project name" since the term app is already used before --- src/start/qemu.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/start/qemu.md b/src/start/qemu.md index f92b8d28..ff4048bd 100644 --- a/src/start/qemu.md +++ b/src/start/qemu.md @@ -7,6 +7,12 @@ the tooling and the development process. [LM3S6965]: http://www.ti.com/product/LM3S6965 +**IMPORTANT** +We'll use the name "app" for the project name in this tutorial. +Whenever you see the word "app" you should replace it with the name you selected +for your project. Or, you could also name your project "app" and avoid the +substitutions. + ## Creating a non standard Rust program We'll use the [`cortex-m-quickstart`] project template to generate a new @@ -76,11 +82,6 @@ download" button and then click "Download ZIP". Then fill in the placeholders in the `Cargo.toml` file as done in the second part of the "Using `git`" version. -___ -**IMPORTANT** We'll use the name "app" for the project name in this tutorial. -Whenever you see the word "app" you should replace it with the name you selected -for your project. Or, you could also name your project "app" and avoid the -substitutions. For convenience here are the most important parts of the source code in `src/main.rs`: From b003f33afa135f2fa6286a0b62b29a9e956ef945 Mon Sep 17 00:00:00 2001 From: Stefan Eicher Date: Mon, 3 Jun 2019 10:57:45 +0200 Subject: [PATCH 5/5] create section ## Program Overview to make obvious that this is no part of those sections ### Using `cargo-generate` ### Using `git` ### Using neither --- src/start/qemu.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/start/qemu.md b/src/start/qemu.md index ff4048bd..e92e6aed 100644 --- a/src/start/qemu.md +++ b/src/start/qemu.md @@ -83,6 +83,8 @@ download" button and then click "Download ZIP". Then fill in the placeholders in the `Cargo.toml` file as done in the second part of the "Using `git`" version. +## Program Overview + For convenience here are the most important parts of the source code in `src/main.rs`: ```rust,ignore