Skip to content

Commit

Permalink
Merge pull request ferrous-systems#191 from ferrous-systems/correct-l…
Browse files Browse the repository at this point in the history
…ogging

Correct logging
  • Loading branch information
Mirabellensaft authored Dec 7, 2022
2 parents 1449e1a + 6370eae commit 8e33ee6
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 40 deletions.
12 changes: 6 additions & 6 deletions advanced/firmware/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ usb2 = "0.0.1"

[dependencies]
consts = { path = "../common/consts" }
cortex-m = "0.7.3"
cortex-m-rt = "0.7.1"
cortex-m-rtic = "1.0.0"
defmt = "0.3.0"
defmt-rtt = "0.3.1"
cortex-m = "0.7.6"
cortex-m-rt = "0.7.2"
cortex-m-rtic = "1.1.3"
defmt = "0.3.2"
defmt-rtt = "0.3.2"
dk = { path = "../../boards/dk", features = ["advanced"] }
panic-probe = { version = "0.3.0", features = ["print-defmt"] }
usb = { path = "../common/usb" }
usb2 = "0.0.1"

[dependencies.heapless]
version = "0.7.9"
version = "0.7.16"
features = ["defmt-impl"]

# optimize code in both profiles
Expand Down
17 changes: 8 additions & 9 deletions beginner/apps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ name = "apps"
version = "0.0.0"

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

# optimize code in both profiles
[profile.dev]
Expand All @@ -34,12 +34,11 @@ opt-level = 3
overflow-checks = false

[features]
# set defmt logging levels here

default = [
"defmt-default",
# "dependency-a/defmt-trace",
"other-feature"
]

other-feature = []
# do NOT modify these features
defmt-default = []
defmt-trace = []
Expand Down
2 changes: 1 addition & 1 deletion beginner/apps/src/bin/radio-puzzle-3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn main() -> ! {
radio.set_channel(Channel::_25);

// capacity (128) should be large enough for the ASCII range
let mut dict = LinearMap::<u8, u8, 128>::new();
let dict = LinearMap::<u8, u8, 128>::new();

let mut packet = Packet::new();
// TODO do the whole ASCII range [0, 127]
Expand Down
15 changes: 7 additions & 8 deletions boards/dk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,22 @@ name = "dk"
version = "0.0.0"

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

[features]
advanced = []
beginner = []

# set defmt logging levels here
default = [
"defmt-info",
# "dependency-a/defmt-trace",
"other-feature"
]
other-feature = []

# do NOT modify these features
defmt-default = []
Expand Down
10 changes: 5 additions & 5 deletions common/panic-log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ name = "panic-log"
version = "0.0.0"

[dependencies]
cortex-m = "0.6.4"
defmt = "0.2.1"
cortex-m = "0.7.6"
defmt = "0.3.2"


[features]
# set defmt logging levels here

default = [
"defmt-debug",
# "dependency-a/defmt-trace",
"other-feature"
]
other-feature = []

# do NOT modify these features
defmt-default = []
Expand Down
5 changes: 3 additions & 2 deletions embedded-workshop-book/src/panicking.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ stack backtrace:

In `no_std` programs the behavior of panic is defined using the `#[panic_handler]` attribute. In the example, the *panic handler* is defined in the `panic_log` crate but we can also implement it manually:

✅ Comment out the `panic_probe` import and add the following function to the example:
✅ Comment out the `use apps as _;` import and add the following function to the example:

``` rust
#[panic_handler]
fn panic(info: &core::panic::PanicInfo) -> ! {
defmt::panic!("{}", info);
defmt::error!("{}", defmt::Debug2Format(info));
asm::udf();
}
```

Expand Down
13 changes: 4 additions & 9 deletions embedded-workshop-book/src/using-hal.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,10 @@ $ cargo doc -p dk --open

✅ Check the API docs of the `Led` abstraction. Change the `led` program, so that the bottom two LEDs are turned on, and the top two are turned off.

🔎 If you want to see logs from Led API of the `dk` Hardware Abstraction Layer, go to `boards/dk/Cargo.toml` and change the log level of the `dk` crate:

```diff
# set defmt logging levels here
default = [
- "defmt-debug",
+ "defmt-trace",
# "dependency-a/defmt-trace",
]
🔎 If you want to see logs from Led API of the `dk` Hardware Abstraction Layer, flash the dk with the following environment variable:

```console
$ DEFMT_LOG=trace cargo run --bin led
```

Among the logs you'll find the line "I/O pins have been configured for digital output". At this point the electrical pins of the nRF52840 microcontroller have been configured to drive the 4 LEDs on the board.
Expand Down

0 comments on commit 8e33ee6

Please sign in to comment.