From bc91e3b4a62a71e33e4dcc83edcc95499bd240f5 Mon Sep 17 00:00:00 2001 From: Berthier Lemieux Date: Sun, 14 Jun 2020 09:06:52 +0300 Subject: [PATCH 1/4] Updates --- src/start/hardware.md | 8 ++++---- src/start/registers.md | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/start/hardware.md b/src/start/hardware.md index ba339479..d8b23076 100644 --- a/src/start/hardware.md +++ b/src/start/hardware.md @@ -135,7 +135,7 @@ $ cat openocd.cfg # interfaces. At any time only one interface should be commented out. # Revision C (newer revision) -source [find interface/stlink-v2-1.cfg] +source [find interface/stlink.cfg] # Revision A and B (older revisions) # source [find interface/stlink-v2.cfg] @@ -284,14 +284,14 @@ You can now exit GDB using the `quit` command. ``` Debugging now requires a few more steps so we have packed all those steps into a -single GDB script named `openocd.gdb`. +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 ``` ``` text -target remote :3333 +target extended-remote :3333 # print demangled symbols set print asm-demangle on @@ -309,7 +309,7 @@ load stepi ``` -Now running ` -x openocd.gdb $program` will immediately connect GDB to +Now running ` -x openocd.gdb target/thumbv7em-none-eabihf/debug/examples/hello` will immediately connect GDB to OpenOCD, enable semihosting, load the program and start the process. Alternatively, you can turn ` -x openocd.gdb` into a custom runner to make diff --git a/src/start/registers.md b/src/start/registers.md index 9ab16b64..63c892b9 100644 --- a/src/start/registers.md +++ b/src/start/registers.md @@ -22,12 +22,15 @@ You may well find that the code you need to access the peripherals in your micro Let's look at the SysTick peripheral that's common to all Cortex-M based micro-controllers. We can find a pretty low-level API in the [cortex-m] crate, and we can use it like this: ```rust,ignore +#![no_std] +#![no_main] use cortex_m::peripheral::{syst, Peripherals}; use cortex_m_rt::entry; +extern crate panic_halt; #[entry] fn main() -> ! { - let mut peripherals = Peripherals::take().unwrap(); + let peripherals = Peripherals::take().unwrap(); let mut systick = peripherals.SYST; systick.set_clock_source(syst::SystClkSource::Core); systick.set_reload(1_000); @@ -41,7 +44,7 @@ fn main() -> ! { } ``` -The functions on the `SYST` struct map pretty closely to the functionality defined by the ARM Technical Reference Manual for this peripheral. There's nothing in this API about 'delaying for X milliseconds' - we have to crudely implement that ourselves using a `while` loop. Note that we can't access our `SYST` struct until we have called `Peripherals::take()` - this is a special routine that guarantees that there is only one `SYST` structure in our entire program. For more on that, see the [Peripherals] section. +The code above will wait for 1000 milliseconds. The functions on the `SYST` struct map pretty closely to the functionality defined by the ARM Technical Reference Manual for this peripheral. There's nothing in this API about 'delaying for X milliseconds' - we have to crudely implement that ourselves using a `while` loop. Note that we can't access our `SYST` struct until we have called `Peripherals::take()` - this is a special routine that guarantees that there is only one `SYST` structure in our entire program. For more on that, see the [Peripherals] section. [Peripherals]: ../peripherals/index.md From 4a0b1022540962a80e695a83ff42f7d67a3a011f Mon Sep 17 00:00:00 2001 From: Berthier Lemieux Date: Sun, 14 Jun 2020 10:10:27 +0300 Subject: [PATCH 2/4] Board crates --- src/assets/crates.png | Bin 0 -> 11522 bytes src/start/registers.md | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 src/assets/crates.png diff --git a/src/assets/crates.png b/src/assets/crates.png new file mode 100644 index 0000000000000000000000000000000000000000..d5898301de7bf69a9ad75a311f5a2cbb0c17bb95 GIT binary patch literal 11522 zcmd6Nc|6qZ_xH4#cB8bYWF`t($Jj!e)mXDF=Ojyxz6=fIRzj<(!$k?%3!mkHs1Twm@HR@*M>MnB{`%VYU2gX*TH4u zDbpNfqH17*x3cD_>SGxm-b%768)JMq-n5M|RGPo56OI2=2@kgOOK-58>n}|?WCeXZ zTFqFOZo$N&om8EaFtQuNRjoa!j>;@HK^Le@AUlx#tmu|HF4klNJsl+nGlqhNfweDE z)s*37K{RJudvpB3FlVMUn}S1|1u9Y`_YJ}^i%Mqx{$C`W0s+- zs<*!pp6l=INx+&K80gVShIk!+yt${fzcQ2QZs6<3Lg}+mdPE;J1(XhsOfm8BG((v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ines common to the processor core your microcontroller is using, as well as any peripherals that are common to all micro-controllers that use that particular type of processor core. For example the [cortex-m] crate gives you functions to enable and disable interrupts, which are the same for all Cortex-M based micro-controllers. It also gives you access to the 'SysTick' peripheral included with all Cortex-M based micro-controllers. * Peripheral Access Crate (PAC) - This sort of crate is a thin wrapper over the various memory-wrapper registers defined for your particular part-number of micro-controller you are using. For example, [tm4c123x] for the Texas Instruments Tiva-C TM4C123 series, or [stm32f30x] for the ST-Micro STM32F30x series. Here, you'll be interacting with the registers directly, following each peripheral's operating instructions given in your micro-controller's Technical Reference Manual. @@ -15,9 +18,17 @@ You may well find that the code you need to access the peripherals in your micro [embedded-hal]: https://crates.io/crates/embedded-hal [Portability]: ../portability/index.md [F3]: https://crates.io/crates/f3 +[Discovery]: https://rust-embedded.github.io/discovery/ +## Board Crate -## Starting at the bottom +A board crate is the perfect starting point, if you're new to embedded Rust. They nicely abstracts the HW details that might be overwelming when starting studying this subject, and makes standard tasks easy, like turning a LED on or off. The functionality they exposes varies a lot between boards. Since this book aims at staying hardware agnostic, the board crates won't be covered by this book. + +If you want to experiment with the STM32F3DISCOVERY board, it is highly recommmand to take a look at the [F3] board crate, which provides functionality to blink the board LEDs, access its compass, bluetooth and more. The [Discovery] book offers a great introduction to the [F3] board crate. + +But if you're working on a system that doesn't yet have dedicated board crate, or you need functionality not provided by existing crates, read on as we start from the bottom, with the micro-architecture crates. + +## Micro-architecture crate Let's look at the SysTick peripheral that's common to all Cortex-M based micro-controllers. We can find a pretty low-level API in the [cortex-m] crate, and we can use it like this: @@ -43,8 +54,7 @@ fn main() -> ! { loop {} } ``` - -The code above will wait for 1000 milliseconds. The functions on the `SYST` struct map pretty closely to the functionality defined by the ARM Technical Reference Manual for this peripheral. There's nothing in this API about 'delaying for X milliseconds' - we have to crudely implement that ourselves using a `while` loop. Note that we can't access our `SYST` struct until we have called `Peripherals::take()` - this is a special routine that guarantees that there is only one `SYST` structure in our entire program. For more on that, see the [Peripherals] section. +The functions on the `SYST` struct map pretty closely to the functionality defined by the ARM Technical Reference Manual for this peripheral. There's nothing in this API about 'delaying for X milliseconds' - we have to crudely implement that ourselves using a `while` loop. Note that we can't access our `SYST` struct until we have called `Peripherals::take()` - this is a special routine that guarantees that there is only one `SYST` structure in our entire program. For more on that, see the [Peripherals] section. [Peripherals]: ../peripherals/index.md From 95559087c442d9ed0f945898f827be4a3a93fcb4 Mon Sep 17 00:00:00 2001 From: Berthier Lemieux Date: Mon, 15 Jun 2020 22:20:07 +0300 Subject: [PATCH 3/4] Fixed comments from review --- src/start/registers.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/start/registers.md b/src/start/registers.md index ef1a104b..1bb80daf 100644 --- a/src/start/registers.md +++ b/src/start/registers.md @@ -10,21 +10,21 @@ You may well find that the code you need to access the peripherals in your micro * Micro-architecture Crate - This sort of crate handles any useful routines common to the processor core your microcontroller is using, as well as any peripherals that are common to all micro-controllers that use that particular type of processor core. For example the [cortex-m] crate gives you functions to enable and disable interrupts, which are the same for all Cortex-M based micro-controllers. It also gives you access to the 'SysTick' peripheral included with all Cortex-M based micro-controllers. * Peripheral Access Crate (PAC) - This sort of crate is a thin wrapper over the various memory-wrapper registers defined for your particular part-number of micro-controller you are using. For example, [tm4c123x] for the Texas Instruments Tiva-C TM4C123 series, or [stm32f30x] for the ST-Micro STM32F30x series. Here, you'll be interacting with the registers directly, following each peripheral's operating instructions given in your micro-controller's Technical Reference Manual. * HAL Crate - These crates offer a more user-friendly API for your particular processor, often by implementing some common traits defined in [embedded-hal]. For example, this crate might offer a `Serial` struct, with a constructor that takes an appropriate set of GPIO pins and a baud rate, and offers some sort of `write_byte` function for sending data. See the chapter on [Portability] for more information on [embedded-hal]. -* Board Crate - These crates go one step further than a HAL Crate by pre-configuring various peripherals and GPIO pins to suit the specific developer kit or board you are using, such as [F3] for the STM32F3DISCOVERY board. +* Board Crate - These crates go one step further than a HAL Crate by pre-configuring various peripherals and GPIO pins to suit the specific developer kit or board you are using, such as [stm32f3-discovery] for the STM32F3DISCOVERY board. [cortex-m]: https://crates.io/crates/cortex-m [tm4c123x]: https://crates.io/crates/tm4c123x [stm32f30x]: https://crates.io/crates/stm32f30x [embedded-hal]: https://crates.io/crates/embedded-hal [Portability]: ../portability/index.md -[F3]: https://crates.io/crates/f3 +[stm32f3-discovery]: https://crates.io/crates/stm32f3-discovery [Discovery]: https://rust-embedded.github.io/discovery/ ## Board Crate A board crate is the perfect starting point, if you're new to embedded Rust. They nicely abstracts the HW details that might be overwelming when starting studying this subject, and makes standard tasks easy, like turning a LED on or off. The functionality they exposes varies a lot between boards. Since this book aims at staying hardware agnostic, the board crates won't be covered by this book. -If you want to experiment with the STM32F3DISCOVERY board, it is highly recommmand to take a look at the [F3] board crate, which provides functionality to blink the board LEDs, access its compass, bluetooth and more. The [Discovery] book offers a great introduction to the [F3] board crate. +If you want to experiment with the STM32F3DISCOVERY board, it is highly recommmand to take a look at the [stm32f3-discovery] board crate, which provides functionality to blink the board LEDs, access its compass, bluetooth and more. The [Discovery] book offers a great introduction to the use of a board crate. But if you're working on a system that doesn't yet have dedicated board crate, or you need functionality not provided by existing crates, read on as we start from the bottom, with the micro-architecture crates. @@ -37,7 +37,7 @@ Let's look at the SysTick peripheral that's common to all Cortex-M based micro-c #![no_main] use cortex_m::peripheral::{syst, Peripherals}; use cortex_m_rt::entry; -extern crate panic_halt; +use panic_halt as _; #[entry] fn main() -> ! { @@ -66,7 +66,7 @@ We won't get very far with our embedded software development if we restrict ours #![no_std] #![no_main] -extern crate panic_halt; // panic handler +use panic_halt as _; use cortex_m_rt::entry; use tm4c123x; @@ -142,7 +142,7 @@ Let's see an example: #![no_std] #![no_main] -extern crate panic_halt; // panic handler +use panic_halt as _; use cortex_m_rt::entry; use tm4c123x_hal as hal; From 4920c17ebd9196990ac3695c9036de0044343587 Mon Sep 17 00:00:00 2001 From: Berthier Lemieux Date: Tue, 16 Jun 2020 08:41:45 +0300 Subject: [PATCH 4/4] Removed surperflous newline. --- src/start/registers.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/start/registers.md b/src/start/registers.md index b43b36fa..7540e60b 100644 --- a/src/start/registers.md +++ b/src/start/registers.md @@ -66,7 +66,6 @@ We won't get very far with our embedded software development if we restrict ours #![no_std] #![no_main] - use panic_halt as _; // panic handler use cortex_m_rt::entry;