From f5467acc83edd7278de9ffbecc3115935f4a7377 Mon Sep 17 00:00:00 2001 From: flip111 Date: Sun, 17 Feb 2019 01:01:14 +0000 Subject: [PATCH 1/2] Update no-std.md * There is no high level OS this means there are no primitives <-- this is wrong because there can be primitives without high level OS otherwise it wouldn't be a "primitive" * Using jargon "bare metal" without explaining it * By marking our code with `no_std` we indicate that our code is capable of running in such an environment. <-- this wording makes it so that using `no_std` is the only requirement of having runnable code. * Dynamic memory allocation can not be used --> not true, use crate (like described lower in the text) --- src/intro/no-std.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/intro/no-std.md b/src/intro/no-std.md index d72f593a..4c141173 100644 --- a/src/intro/no-std.md +++ b/src/intro/no-std.md @@ -18,12 +18,14 @@ You may also have some sort of sysroot and restrictions on RAM/ROM-usage, and pe special HW or I/Os. Overall it feels like coding on a special-purpose PC environment. ## Bare Metal Environments -In a bare metal environment there will be no high-level OS running and hosting our code. -This means there will be no primitives, which means there's also no standard library by default. -By marking our code with `no_std` we indicate that our code is capable of running in such an environment. -This means the rust [libstd](https://doc.rust-lang.org/std/) and dynamic memory allocation can't be used by such code. -However, such code can use [libcore](https://doc.rust-lang.org/core/), which can easily be made available -in any kind of environment by providing just a few symbols (for details see [libcore](https://doc.rust-lang.org/core/)). +In a bare metal environment no code has been loaded before your program. +Without the software provided by an OS we can not load the standard library. +Instead the program, along with the crates it uses, can only use the hardware (bare metal) to run. +To prevent rust from loading the standard library use `no_std`. +The platform-agnostic parts of the standard library are available through [libcore](https://doc.rust-lang.org/core/). +libcore also excludes things which are not always desirable in an embedded environment. +One of these things is a memory allocator for dynamic memory allocation. +If you require this or any other functionalities there are often crates which provide these. ### The libstd Runtime As mentioned before using [libstd](https://doc.rust-lang.org/std/) requires some sort of system integration, but this is not only because From 21712a35dbdb413c1b35d0ca4da0ca1283180686 Mon Sep 17 00:00:00 2001 From: flip111 Date: Sun, 17 Feb 2019 01:16:20 +0000 Subject: [PATCH 2/2] Update install.md `For bandwidth and disk usage concerns the default installation only supports native compilation.` I like what the default installation is doing, not downloading toolchains i don't need. Let's do the same for the book. At the same time, because the reader is just getting into embedded for rust, it's cool to see which toolchains for which CPU cores are already available. This gives a good feeling of control (which toolchain i can choose) and possibilities (many to choose from) --- src/intro/install.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/intro/install.md b/src/intro/install.md index 1b696969..a09cbd58 100644 --- a/src/intro/install.md +++ b/src/intro/install.md @@ -16,10 +16,27 @@ rustc 1.31.1 (b6c32da9b 2018-12-18) For bandwidth and disk usage concerns the default installation only supports native compilation. To add cross compilation support for the ARM Cortex-M -architecture install the following compilation targets. +architecture choose one of the following compilation targets. Use the last one +for the STM32F3DISCOVERY board and follow along with the book. +Cortex M0 M0+ ``` console -$ rustup target add thumbv6m-none-eabi thumbv7m-none-eabi thumbv7em-none-eabi thumbv7em-none-eabihf +$ rustup target add thumbv6m-none-eabi +``` + +Cortex M3 +``` console +$ rustup target add thumbv7m-none-eabi +``` + +Cortex M4 M7 without FPU +``` console +$ rustup target add thumbv7em-none-eabi +``` + +Cortex M4 M7 with FPU <-- STM32F3DISCOVERY +``` console +$ rustup target add thumbv7em-none-eabihf ``` ### `cargo-binutils`