mirror of
https://github.com/ferrous-systems/embedded-trainings-2020.git
synced 2024-05-03 17:19:12 +00:00
Merge pull request #191 from ferrous-systems/correct-logging
Correct logging
This commit is contained in:
commit
8e33ee685c
|
@ -12,18 +12,18 @@ usb2 = "0.0.1"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
consts = { path = "../common/consts" }
|
consts = { path = "../common/consts" }
|
||||||
cortex-m = "0.7.3"
|
cortex-m = "0.7.6"
|
||||||
cortex-m-rt = "0.7.1"
|
cortex-m-rt = "0.7.2"
|
||||||
cortex-m-rtic = "1.0.0"
|
cortex-m-rtic = "1.1.3"
|
||||||
defmt = "0.3.0"
|
defmt = "0.3.2"
|
||||||
defmt-rtt = "0.3.1"
|
defmt-rtt = "0.3.2"
|
||||||
dk = { path = "../../boards/dk", features = ["advanced"] }
|
dk = { path = "../../boards/dk", features = ["advanced"] }
|
||||||
panic-probe = { version = "0.3.0", features = ["print-defmt"] }
|
panic-probe = { version = "0.3.0", features = ["print-defmt"] }
|
||||||
usb = { path = "../common/usb" }
|
usb = { path = "../common/usb" }
|
||||||
usb2 = "0.0.1"
|
usb2 = "0.0.1"
|
||||||
|
|
||||||
[dependencies.heapless]
|
[dependencies.heapless]
|
||||||
version = "0.7.9"
|
version = "0.7.16"
|
||||||
features = ["defmt-impl"]
|
features = ["defmt-impl"]
|
||||||
|
|
||||||
# optimize code in both profiles
|
# optimize code in both profiles
|
||||||
|
|
|
@ -6,13 +6,13 @@ name = "apps"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cortex-m = "0.7.3"
|
cortex-m = {version = "0.7.6", features = ["critical-section-single-core"]}
|
||||||
cortex-m-rt = "0.7.1"
|
cortex-m-rt = "0.7.2"
|
||||||
dk = { path = "../../boards/dk", features = ["beginner"] }
|
dk = { path = "../../boards/dk", features = ["beginner"] }
|
||||||
heapless = "0.7.9"
|
heapless = "0.7.16"
|
||||||
panic-probe = { version = "0.3.0", features = ["print-defmt"] }
|
panic-probe = { version = "0.3.0", features = ["print-defmt"] }
|
||||||
defmt = "0.3.0"
|
defmt = "0.3.2"
|
||||||
defmt-rtt = "0.3.1"
|
defmt-rtt = "0.3.2"
|
||||||
|
|
||||||
# optimize code in both profiles
|
# optimize code in both profiles
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
|
@ -34,12 +34,11 @@ opt-level = 3
|
||||||
overflow-checks = false
|
overflow-checks = false
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# set defmt logging levels here
|
|
||||||
default = [
|
|
||||||
"defmt-default",
|
|
||||||
# "dependency-a/defmt-trace",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
default = [
|
||||||
|
"other-feature"
|
||||||
|
]
|
||||||
|
other-feature = []
|
||||||
# do NOT modify these features
|
# do NOT modify these features
|
||||||
defmt-default = []
|
defmt-default = []
|
||||||
defmt-trace = []
|
defmt-trace = []
|
||||||
|
|
|
@ -20,7 +20,7 @@ fn main() -> ! {
|
||||||
radio.set_channel(Channel::_25);
|
radio.set_channel(Channel::_25);
|
||||||
|
|
||||||
// capacity (128) should be large enough for the ASCII range
|
// 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();
|
let mut packet = Packet::new();
|
||||||
// TODO do the whole ASCII range [0, 127]
|
// TODO do the whole ASCII range [0, 127]
|
||||||
|
|
|
@ -6,23 +6,22 @@ name = "dk"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cortex-m = "0.7.3"
|
cortex-m = {version = "0.7.6", features = ["critical-section-single-core"]}
|
||||||
cortex-m-rt = "0.7.1"
|
cortex-m-rt = "0.7.2"
|
||||||
embedded-hal = "0.2.6"
|
embedded-hal = "0.2.7"
|
||||||
hal = { package = "nrf52840-hal", version = "0.14.0" }
|
hal = { package = "nrf52840-hal", version = "0.14.0" }
|
||||||
panic-probe = { version = "0.3.0", features = ["print-defmt"] }
|
panic-probe = { version = "0.3.0", features = ["print-defmt"] }
|
||||||
defmt = "0.3.0"
|
defmt = "0.3.2"
|
||||||
defmt-rtt = "0.3.1"
|
defmt-rtt = "0.3.2"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
advanced = []
|
advanced = []
|
||||||
beginner = []
|
beginner = []
|
||||||
|
|
||||||
# set defmt logging levels here
|
|
||||||
default = [
|
default = [
|
||||||
"defmt-info",
|
"other-feature"
|
||||||
# "dependency-a/defmt-trace",
|
|
||||||
]
|
]
|
||||||
|
other-feature = []
|
||||||
|
|
||||||
# do NOT modify these features
|
# do NOT modify these features
|
||||||
defmt-default = []
|
defmt-default = []
|
||||||
|
|
|
@ -6,16 +6,16 @@ name = "panic-log"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cortex-m = "0.6.4"
|
cortex-m = "0.7.6"
|
||||||
defmt = "0.2.1"
|
defmt = "0.3.2"
|
||||||
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# set defmt logging levels here
|
|
||||||
default = [
|
default = [
|
||||||
"defmt-debug",
|
"other-feature"
|
||||||
# "dependency-a/defmt-trace",
|
|
||||||
]
|
]
|
||||||
|
other-feature = []
|
||||||
|
|
||||||
# do NOT modify these features
|
# do NOT modify these features
|
||||||
defmt-default = []
|
defmt-default = []
|
||||||
|
|
|
@ -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:
|
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
|
``` rust
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn panic(info: &core::panic::PanicInfo) -> ! {
|
fn panic(info: &core::panic::PanicInfo) -> ! {
|
||||||
defmt::panic!("{}", info);
|
defmt::error!("{}", defmt::Debug2Format(info));
|
||||||
|
asm::udf();
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -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.
|
✅ 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:
|
🔎 If you want to see logs from Led API of the `dk` Hardware Abstraction Layer, flash the dk with the following environment variable:
|
||||||
|
|
||||||
```diff
|
```console
|
||||||
# set defmt logging levels here
|
$ DEFMT_LOG=trace cargo run --bin led
|
||||||
default = [
|
|
||||||
- "defmt-debug",
|
|
||||||
+ "defmt-trace",
|
|
||||||
# "dependency-a/defmt-trace",
|
|
||||||
]
|
|
||||||
```
|
```
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
Loading…
Reference in a new issue