start tutorial
This commit is contained in:
20
tutorial/04-embedded-no-std-hello/README.md
Normal file
20
tutorial/04-embedded-no-std-hello/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# 04 - Embedded no_std Hello (8 min)
|
||||
|
||||
## Goal
|
||||
|
||||
Erstes Bare-Metal-Programm mit `#![no_std]`, `#![no_main]` und RTT Logs.
|
||||
|
||||
## Run
|
||||
|
||||
- `bash scripts/run-step.sh 04 task`
|
||||
|
||||
## Tasks
|
||||
|
||||
1. Lies die Top-Level-Attribute in `task/src/main.rs`.
|
||||
2. Passe die Log-Ausgaben an.
|
||||
3. Flashe mit `cargo run --release`.
|
||||
|
||||
## Done when
|
||||
|
||||
1. Firmware läuft auf Bluepill.
|
||||
2. RTT zeigt zyklisch eine "alive"-Meldung.
|
||||
@@ -0,0 +1,12 @@
|
||||
[target.thumbv7m-none-eabi]
|
||||
runner = "probe-rs run --chip STM32F103C8"
|
||||
rustflags = [
|
||||
"-C", "link-arg=-Tlink.x",
|
||||
"-C", "link-arg=-Tdefmt.x",
|
||||
]
|
||||
|
||||
[build]
|
||||
target = "thumbv7m-none-eabi"
|
||||
|
||||
[env]
|
||||
DEFMT_LOG = "info"
|
||||
22
tutorial/04-embedded-no-std-hello/solution/Cargo.toml
Normal file
22
tutorial/04-embedded-no-std-hello/solution/Cargo.toml
Normal file
@@ -0,0 +1,22 @@
|
||||
[package]
|
||||
name = "step04_embedded_no_std_hello_solution"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
cortex-m = "0.7.7"
|
||||
cortex-m-rt = "0.7.5"
|
||||
defmt = "0.3.10"
|
||||
defmt-rtt = "0.4.2"
|
||||
panic-probe = { version = "0.3.2", features = ["print-defmt"] }
|
||||
nb = "1.1.0"
|
||||
|
||||
[dependencies.stm32f1xx-hal]
|
||||
version = "0.11.0"
|
||||
features = ["rt", "stm32f103", "medium"]
|
||||
|
||||
[profile.release]
|
||||
codegen-units = 1
|
||||
debug = 2
|
||||
lto = true
|
||||
opt-level = "z"
|
||||
5
tutorial/04-embedded-no-std-hello/solution/memory.x
Normal file
5
tutorial/04-embedded-no-std-hello/solution/memory.x
Normal file
@@ -0,0 +1,5 @@
|
||||
MEMORY
|
||||
{
|
||||
FLASH : ORIGIN = 0x08000000, LENGTH = 64K
|
||||
RAM : ORIGIN = 0x20000000, LENGTH = 20K
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
[toolchain]
|
||||
channel = "stable"
|
||||
components = ["rustfmt"]
|
||||
targets = ["thumbv7m-none-eabi"]
|
||||
17
tutorial/04-embedded-no-std-hello/solution/src/main.rs
Normal file
17
tutorial/04-embedded-no-std-hello/solution/src/main.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use cortex_m::asm;
|
||||
use cortex_m_rt::entry;
|
||||
use defmt::info;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
info!("step04: boot ok");
|
||||
|
||||
loop {
|
||||
asm::delay(8_000_000);
|
||||
info!("step04: alive");
|
||||
}
|
||||
}
|
||||
12
tutorial/04-embedded-no-std-hello/task/.cargo/config.toml
Normal file
12
tutorial/04-embedded-no-std-hello/task/.cargo/config.toml
Normal file
@@ -0,0 +1,12 @@
|
||||
[target.thumbv7m-none-eabi]
|
||||
runner = "probe-rs run --chip STM32F103C8"
|
||||
rustflags = [
|
||||
"-C", "link-arg=-Tlink.x",
|
||||
"-C", "link-arg=-Tdefmt.x",
|
||||
]
|
||||
|
||||
[build]
|
||||
target = "thumbv7m-none-eabi"
|
||||
|
||||
[env]
|
||||
DEFMT_LOG = "info"
|
||||
22
tutorial/04-embedded-no-std-hello/task/Cargo.toml
Normal file
22
tutorial/04-embedded-no-std-hello/task/Cargo.toml
Normal file
@@ -0,0 +1,22 @@
|
||||
[package]
|
||||
name = "step04_embedded_no_std_hello_task"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
cortex-m = "0.7.7"
|
||||
cortex-m-rt = "0.7.5"
|
||||
defmt = "0.3.10"
|
||||
defmt-rtt = "0.4.2"
|
||||
panic-probe = { version = "0.3.2", features = ["print-defmt"] }
|
||||
nb = "1.1.0"
|
||||
|
||||
[dependencies.stm32f1xx-hal]
|
||||
version = "0.11.0"
|
||||
features = ["rt", "stm32f103", "medium"]
|
||||
|
||||
[profile.release]
|
||||
codegen-units = 1
|
||||
debug = 2
|
||||
lto = true
|
||||
opt-level = "z"
|
||||
5
tutorial/04-embedded-no-std-hello/task/memory.x
Normal file
5
tutorial/04-embedded-no-std-hello/task/memory.x
Normal file
@@ -0,0 +1,5 @@
|
||||
MEMORY
|
||||
{
|
||||
FLASH : ORIGIN = 0x08000000, LENGTH = 64K
|
||||
RAM : ORIGIN = 0x20000000, LENGTH = 20K
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
[toolchain]
|
||||
channel = "stable"
|
||||
components = ["rustfmt"]
|
||||
targets = ["thumbv7m-none-eabi"]
|
||||
18
tutorial/04-embedded-no-std-hello/task/src/main.rs
Normal file
18
tutorial/04-embedded-no-std-hello/task/src/main.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use cortex_m::asm;
|
||||
use cortex_m_rt::entry;
|
||||
use defmt::info;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
// TODO: personalize these log lines.
|
||||
info!("step04: no_std hello on stm32f103c8");
|
||||
|
||||
loop {
|
||||
asm::delay(8_000_000);
|
||||
info!("step04: alive");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user