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

New embedded assignment #195

Draft
wants to merge 112 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
eaab435
new book pages
Mirabellensaft Feb 14, 2023
e98ddd2
new code examples for new exercise
Mirabellensaft Feb 14, 2023
028a850
add notes to bsc exercise
Mirabellensaft Feb 14, 2023
3f56cd6
mark expected exercise solution
Mirabellensaft Feb 17, 2023
a9293e6
Cleaned up lib
Mirabellensaft Feb 20, 2023
923b850
rn file to lib_solution
Mirabellensaft Feb 20, 2023
9e46b57
add template with gaps to fill
Mirabellensaft Feb 20, 2023
c4cc515
rename folder
Mirabellensaft Feb 20, 2023
aa907e9
correct crate name
Mirabellensaft Feb 21, 2023
6529d50
rename hal to nrf-hal for clarity
Mirabellensaft Feb 21, 2023
5f8e4b1
correct dir name
Mirabellensaft Feb 21, 2023
f21124a
change setup
Mirabellensaft Feb 21, 2023
8b31518
rm dead code, correct comments
Mirabellensaft Feb 21, 2023
fd51794
rm deny warnings
Mirabellensaft Feb 21, 2023
ad7f9db
rm duplicate line
Mirabellensaft Feb 21, 2023
1891f17
rm deprecated lines
Mirabellensaft Feb 21, 2023
25cd0fa
Merge pull request #197 from ferrous-systems/minor_fixes
Mirabellensaft Feb 21, 2023
14d76fb
add pages to book
Mirabellensaft Feb 21, 2023
3afc29c
add step by step solution
Mirabellensaft Feb 21, 2023
c1825d1
add exercise intro draft
Mirabellensaft Feb 21, 2023
bf87279
add uarte draft
Mirabellensaft Feb 21, 2023
dffa5d4
add learning goals
Mirabellensaft Feb 22, 2023
453eb95
add most of exercise text
Mirabellensaft Feb 22, 2023
a142d15
finish draft of uarte implementation
Mirabellensaft Feb 27, 2023
16fbd1c
rm button from example
Mirabellensaft Feb 27, 2023
1665506
correct uarte peripheral
Mirabellensaft Feb 27, 2023
cd345aa
mark code
Mirabellensaft Mar 7, 2023
373e791
clean text
Mirabellensaft Mar 7, 2023
a1e990b
Intro to testing
Mirabellensaft Mar 7, 2023
b2adf4a
add todo
Mirabellensaft Mar 7, 2023
3465441
add comments and solution file
Mirabellensaft Mar 7, 2023
71ad8b0
clarification
Mirabellensaft Mar 7, 2023
59a08c6
correct message
Mirabellensaft Mar 7, 2023
37930c3
add uarte tasks
Mirabellensaft Mar 7, 2023
5b11a4d
add generate docs instruction
Mirabellensaft Mar 7, 2023
38c963e
clarifications after test
Mirabellensaft Mar 10, 2023
3b72b1b
address issues from testing
Mirabellensaft Mar 13, 2023
9a354f2
last formatting and adding code snippets
Mirabellensaft Mar 14, 2023
30fe350
polish
Mirabellensaft Mar 17, 2023
bfcb572
Update down-the-stack/dk_bsc/src/lib_solution.rs
Mirabellensaft Mar 20, 2023
ab2d908
Update down-the-stack/dk_bsc/src/lib_solution.rs
Mirabellensaft Mar 20, 2023
5f079cd
Update down-the-stack/dk_bsc/src/lib_solution.rs
Mirabellensaft Mar 20, 2023
2505e00
Update down-the-stack/dk_bsc/src/lib_solution.rs
Mirabellensaft Mar 20, 2023
e7eef7a
Update down-the-stack/dk_bsc/src/lib_solution.rs
Mirabellensaft Mar 20, 2023
f0bf2ec
Update embedded-workshop-book/src/uarte-implementation.md
Mirabellensaft Mar 20, 2023
5fc64c5
Update embedded-workshop-book/src/uarte-implementation.md
Mirabellensaft Mar 20, 2023
b5c3480
Update down-the-stack/dk_bsc/src/lib_solution.rs
Mirabellensaft Mar 20, 2023
a3f653d
Update down-the-stack/dk_bsc/src/lib_solution.rs
Mirabellensaft Mar 20, 2023
89ee72e
Update down-the-stack/dk_bsc/src/lib_solution.rs
Mirabellensaft Mar 20, 2023
274767b
Update down-the-stack/dk_bsc/src/lib_solution.rs
Mirabellensaft Mar 20, 2023
d647036
Update down-the-stack/dk_bsc/src/lib_solution.rs
Mirabellensaft Mar 20, 2023
dc9232f
Update down-the-stack/dk_bsc/src/lib_solution.rs
Mirabellensaft Mar 20, 2023
81b6657
Update down-the-stack/dk_bsc/src/lib_solution.rs
Mirabellensaft Mar 20, 2023
4fb7415
Update down-the-stack/dk_bsc/src/lib_solution.rs
Mirabellensaft Mar 20, 2023
8de826d
Update down-the-stack/dk_bsc/src/lib_solution.rs
Mirabellensaft Mar 20, 2023
1db5935
Update down-the-stack/dk_bsc/src/lib_solution.rs
Mirabellensaft Mar 20, 2023
08654a5
Update down-the-stack/dk_bsc/src/lib_solution.rs
Mirabellensaft Mar 20, 2023
ee29b74
Update embedded-workshop-book/src/bsc-exercise.md
Mirabellensaft Mar 20, 2023
f981189
Update embedded-workshop-book/src/uarte-implementation.md
Mirabellensaft Mar 20, 2023
debd765
rm led color comment
Mirabellensaft Mar 20, 2023
7701ae8
Update embedded-workshop-book/src/uarte-implementation.md
Mirabellensaft Mar 20, 2023
5e5ccb5
Update embedded-workshop-book/src/uarte-implementation.md
Mirabellensaft Mar 20, 2023
b09dd73
Update embedded-workshop-book/src/uarte-implementation.md
Mirabellensaft Mar 20, 2023
ee0f7b1
add links to html doc
Mirabellensaft Mar 20, 2023
70ce745
Merge pull request #196 from ferrous-systems/add_bsc_exercise_text
Mirabellensaft Mar 20, 2023
e55713f
code to enable uarte0
Mirabellensaft Mar 10, 2023
7a8e94e
cargo.toml for pac
Mirabellensaft Mar 10, 2023
11bd35e
nrf svd with writeonce -> writeOnce
Mirabellensaft Mar 10, 2023
6606472
pac
Mirabellensaft Mar 10, 2023
8518686
unsafe and safe enable/disable
Mirabellensaft Mar 10, 2023
eda4261
set flag
Mirabellensaft Mar 10, 2023
53a7c72
draft of exercise text
Mirabellensaft Mar 10, 2023
bb86aed
add explanations
Mirabellensaft Mar 13, 2023
1424c7d
adding text to md book
Mirabellensaft Mar 13, 2023
ed973e7
split exercise into several pages
Mirabellensaft Mar 13, 2023
b4de9b3
add solution and template for uarte_enable
Mirabellensaft Mar 13, 2023
b8f34e4
formatting and polishing
Mirabellensaft Mar 13, 2023
13b90e1
move uarte solution to its own folder
Mirabellensaft Mar 14, 2023
4eb0ac3
Clean up for testing (rm generated pac)
Mirabellensaft Mar 14, 2023
2c2358a
corrections
Mirabellensaft Mar 14, 2023
3e1dca1
address review issues
Mirabellensaft Mar 14, 2023
c097fcf
add pyserial to book
Mirabellensaft Mar 21, 2023
15302d1
add pyserial installation to installation chapter
Mirabellensaft Mar 21, 2023
55b40e8
change uarte setup
Mirabellensaft Mar 21, 2023
3e62747
add readme
Mirabellensaft Mar 21, 2023
da3ef09
rename package
Mirabellensaft Mar 21, 2023
14247f5
add warning
Mirabellensaft Mar 21, 2023
747edc5
Update down-the-stack/solutions/src/bin/uarte_enable.rs
Mirabellensaft Mar 21, 2023
ab0e106
Update embedded-workshop-book/src/enabling-uarte.md
Mirabellensaft Mar 21, 2023
baa572a
Update embedded-workshop-book/src/enabling-uarte.md
Mirabellensaft Mar 21, 2023
8b58405
Update embedded-workshop-book/src/enabling-uarte.md
Mirabellensaft Mar 21, 2023
c7576cf
Update embedded-workshop-book/src/enabling-uarte.md
Mirabellensaft Mar 21, 2023
00c20e6
Update embedded-workshop-book/src/enabling-uarte.md
Mirabellensaft Mar 21, 2023
f93eb74
Update embedded-workshop-book/src/enabling-uarte.md
Mirabellensaft Mar 21, 2023
7e9bf1b
Update embedded-workshop-book/src/enabling-uarte.md
Mirabellensaft Mar 21, 2023
2355def
Update embedded-workshop-book/src/enabling-uarte.md
Mirabellensaft Mar 21, 2023
a80583f
Update embedded-workshop-book/src/enabling-uarte.md
Mirabellensaft Mar 21, 2023
6c513bd
Update embedded-workshop-book/src/generating-pac.md
Mirabellensaft Mar 21, 2023
d84cc58
Update embedded-workshop-book/src/generating-pac.md
Mirabellensaft Mar 21, 2023
19cf5c2
Update embedded-workshop-book/src/generating-pac.md
Mirabellensaft Mar 21, 2023
de261dc
Update embedded-workshop-book/src/generating-pac.md
Mirabellensaft Mar 21, 2023
a74ae1a
Update embedded-workshop-book/src/generating-pac.md
Mirabellensaft Mar 21, 2023
aa93c99
Update embedded-workshop-book/src/pac-docs.md
Mirabellensaft Mar 21, 2023
e85a98b
Update embedded-workshop-book/src/pac-docs.md
Mirabellensaft Mar 21, 2023
8900ace
Update embedded-workshop-book/src/pac-exercise.md
Mirabellensaft Mar 21, 2023
ef6f61c
Update embedded-workshop-book/src/pac-docs.md
Mirabellensaft Mar 21, 2023
3689d0d
Update embedded-workshop-book/src/pac-docs.md
Mirabellensaft Mar 21, 2023
a5f4ebe
address issues
Mirabellensaft Mar 21, 2023
3a4acd3
Merge pull request #201 from ferrous-systems/fix_serial_term
Mirabellensaft Mar 21, 2023
fbda1d9
fixing issue with form, rm download link
Mirabellensaft Mar 21, 2023
971ec39
add troubleshooting
Mirabellensaft Mar 21, 2023
9ec556b
Merge pull request #200 from ferrous-systems/svd2rust_clean
Mirabellensaft Mar 23, 2023
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
22 changes: 22 additions & 0 deletions down-the-stack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Down the Stack

This folder contains all relevant exercise templates, demo code and solutions for the exercises in the `Down the Stack` session.

## `apps` package
* `button.rs` - demo code for the BSC exercise
* `hello.rs` - for testing as described in the BSC exercise
* `uarte_print.rs` - demo code for the BSC exercise
* `uarte_enable.rs` - exercise template for PAC exercise

## `dk_bsc` package
* `lib.rs` - exercise template for the BSC exercise
* `lib_solution.rs` - solution code to the BSC exercise

## `dk_pac` package
* `Cargo.toml` - a `Cargo.toml` file for the to be generated PAC
* `nrf52.svd` - an SVD file for generating the PAC

You will generate the remaining files during the training

## `solutions` package
* `uarte_enable.rs` - contains the solution for the PAC exercise
19 changes: 19 additions & 0 deletions down-the-stack/apps/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# (..)
rustflags = [
"-C", "linker=flip-link", # adds stack overflow protection
"-C", "link-arg=-Tdefmt.x", # defmt support
# (..)
]

[target.thumbv7em-none-eabihf]
# set custom cargo runner to flash & run on embedded target when we call `cargo run`
# for more information, check out https://github.com/knurling-rs/probe-run
runner = "probe-run --chip nRF52840_xxAA"
rustflags = [
"-C", "link-arg=-Tlink.x",
]

[build]
# cross-compile to this target
target = "thumbv7em-none-eabihf" # = ARM Cortex-M4
49 changes: 49 additions & 0 deletions down-the-stack/apps/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[package]
authors = ["Tanks Transfeld <[email protected]>"]
edition = "2018"
license = "MIT OR Apache-2.0"
name = "apps"
version = "0.0.0"

[dependencies]
cortex-m = {version = "0.7.6", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7.2"
dk_bsc = { path = "../dk_bsc" }
heapless = "0.7.16"
panic-probe = { version = "0.3.0", features = ["print-defmt"] }
defmt = "0.3.2"
defmt-rtt = "0.3.2"

# optimize code in both profiles
[profile.dev]
codegen-units = 1
debug = 2
debug-assertions = true # !
incremental = false
lto = "fat"
opt-level = 'z' # !
overflow-checks = false

[profile.release]
codegen-units = 1
debug = 1
debug-assertions = false
incremental = false
lto = "fat"
opt-level = 3
overflow-checks = false

[features]


default = [
"other-feature"
]
other-feature = []
# do NOT modify these features
defmt-default = []
defmt-trace = []
defmt-debug = []
defmt-info = []
defmt-warn = []
defmt-error = []
31 changes: 31 additions & 0 deletions down-the-stack/apps/src/bin/button.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#![no_main]
#![no_std]


use cortex_m_rt::entry;

// this imports `down-the-stack/apps/lib.rs` to retrieve our global logger + panicking-behavior
use apps as _;

// ⚠️ ⚠️ ⚠️ Don't change this file! ⚠️ ⚠️ ⚠️

#[entry]
fn main() -> ! {
// to enable more verbose logs, go to your `Cargo.toml` and set defmt logging levels
// to `defmt-trace` by changing the `default = []` entry in `[features]`

let board = dk_bsc::init().unwrap();

let mut led = board.leds;
let button_1 = board.buttons.b_1;

loop {
if button_1.is_pushed() {
led.led_1.on();
} else {
led.led_1.off();
}
}

// this program does not `exit`; use Ctrl+C to terminate it
}
28 changes: 28 additions & 0 deletions down-the-stack/apps/src/bin/hello.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// this program does not use the standard library to avoid heap allocations.
// only the `core` library functions are available.
#![no_std]
// this program uses a custom entry point instead of `fn main()`
#![no_main]

use cortex_m::asm;
use cortex_m_rt::entry;
// this imports `beginner/apps/lib.rs` to retrieve our global logger + panicking-behavior
use apps as _;

// the custom entry point
// vvvvv
#[entry]
fn main() -> ! {
// ˆˆˆ
// ! is the 'never' type: this function never returns

// initializes the peripherals
dk_bsc::init().unwrap();

defmt::println!("Hello, world!"); // :wave:

loop {
// breakpoint: halts the program's execution
asm::bkpt();
}
}
28 changes: 28 additions & 0 deletions down-the-stack/apps/src/bin/uarte_enable.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#![no_main]
#![no_std]

use cortex_m::asm;
use cortex_m_rt::entry;

// ^^^^ import the PAC here

// this imports `down-the-stack/apps/lib.rs` to retrieve our global logger + panicking-behavior
use apps as _;
use defmt;
use defmt_rtt as _; // global logger

#[entry]
fn main() -> ! {
// to enable more verbose logs, go to your `Cargo.toml` and set defmt logging levels
// to `defmt-trace` by changing the `default = []` entry in `[features]`

// Your code goes here...


// this program does not `exit`; use Ctrl+C to terminate it
loop {
asm::nop();
}
}

// The helper function goes here...
28 changes: 28 additions & 0 deletions down-the-stack/apps/src/bin/uarte_print.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#![no_main]
#![no_std]

use cortex_m::asm;
use cortex_m_rt::entry;
use core::fmt::Write;

// this imports `down-the-stack/apps/lib.rs` to retrieve our global logger + panicking-behavior
use apps as _;

// ⚠️ ⚠️ ⚠️ Don't change this file! ⚠️ ⚠️ ⚠️

#[entry]
fn main() -> ! {
// to enable more verbose logs, go to your `Cargo.toml` and set defmt logging levels
// to `defmt-trace` by changing the `default = []` entry in `[features]`

let board = dk_bsc::init().unwrap();
let mut uarte = board.uarte;

let tx_buffer = "Hello, World!\n";
uarte.write_str(tx_buffer).unwrap();

// this program does not `exit`; use Ctrl+C to terminate it
loop {
asm::nop();
}
}
10 changes: 10 additions & 0 deletions down-the-stack/apps/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#![no_std]
// ⚠️ ⚠️ ⚠️ Don't change this file! ⚠️ ⚠️ ⚠️
use panic_probe as _;

// same panicking *behavior* as `panic-probe` but doesn't print a panic message
// this prevents the panic message being printed *twice* when `defmt::panic` is invoked
#[defmt::panic_handler]
fn panic() -> ! {
cortex_m::asm::udf()
}
24 changes: 24 additions & 0 deletions down-the-stack/dk_bsc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
authors = ["Jorge Aparicio <[email protected]>", "Tanks Transfeld <[email protected]"]
edition = "2018"
license = "MIT OR Apache-2.0"
name = "dk_bsc"
version = "0.0.0"

[dependencies]
cortex-m = {version = "0.7.6", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7.2"
embedded-hal = "0.2.7"
nrf52840-hal = "0.14.0"
panic-probe = { version = "0.3.0", features = ["print-defmt"] }
defmt = "0.3.2"
defmt-rtt = "0.3.2"

[features]
advanced = []
beginner = []

default = [
"other-feature"
]
other-feature = []
7 changes: 7 additions & 0 deletions down-the-stack/dk_bsc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# `dk`

Board Support Crate for the nRF52840 Development Kit (DK)

## Getting familiar with the hardware

TODO
12 changes: 12 additions & 0 deletions down-the-stack/dk_bsc/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use std::{env, error::Error, fs, path::PathBuf};

fn main() -> Result<(), Box<dyn Error>> {
let out_dir = PathBuf::from(env::var("OUT_DIR")?);

// put memory layout (linker script) in the linker search path
fs::copy("memory.x", out_dir.join("memory.x"))?;

println!("cargo:rustc-link-search={}", out_dir.display());

Ok(())
}
5 changes: 5 additions & 0 deletions down-the-stack/dk_bsc/memory.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MEMORY
{
FLASH : ORIGIN = 0x00000000, LENGTH = 1024K
RAM : ORIGIN = 0x20000000, LENGTH = 256K
}
Loading