Skip to content

Commit

Permalink
Update defmt project with esp-backtrace changes (#36)
Browse files Browse the repository at this point in the history
* feat: Update defmt project with esp-backtrace changes

* build: Remove patch

* build: Update deps
  • Loading branch information
SergioGasquez authored Feb 12, 2024
1 parent 182cd99 commit 1ffbab8
Show file tree
Hide file tree
Showing 18 changed files with 637 additions and 434 deletions.
7 changes: 5 additions & 2 deletions book/src/03_6_defmt.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ In this chapter, we will cover [`defmt`][defmt], a highly efficient logging fram
- `espflash` requires framming bytes as when using `defmt` it also needs to print non-`defmt` messages, like the bootloader prints.
- It's important to note that other `defmt`-enabled tools like `probe-rs` won't be able to parse these messages due to the extra framing bytes.
- Uses [rzcobs encoding](https://github.com/Dirbaio/rzcobs)
- Both `esp-println` and `esp-backtrace` have a `defmt-espflash` feature, which adds framming bytes so `espflash` knows that is a `defmt` message.
- `esp-println` has a `defmt-espflash` feature, which adds framming bytes so `espflash` knows that is a `defmt` message.
- `esp-backtrace` has a `defmt` feature that uses `defmt` logging to print panic and exception handler messages.


[esp-println]: https://github.com/esp-rs/esp-println
Expand All @@ -33,7 +34,9 @@ cargo run --release --example defmt

## Exercise

✅ Make sure the `defmt-espflash` feature of `esp-println` and `esp-backtrace` are enabled.
✅ Make sure the `defmt-espflash` feature of `esp-println` is enabled.

✅ Make sure the `defmt` feature of `esp-backtrace` is enabled.

✅ Update the [linking process](https://defmt.ferrous-systems.com/setup#linker-script) in the `.cargo/config.toml`.

Expand Down
16 changes: 0 additions & 16 deletions intro/blinky/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@ rustflags = [
# Required to obtain backtraces (e.g. when using the "esp-backtrace" crate.)
# NOTE: May negatively impact performance of produced code
"-C", "force-frame-pointers",

# comment the cfgs below if you do _not_ wish to emulate atomics.
# enable the atomic codegen option for RISCV
"-C", "target-feature=+a",
# tell the core library have atomics even though it's not specified in the target definition
"--cfg", "target_has_atomic_load_store",
"--cfg", 'target_has_atomic_load_store="8"',
"--cfg", 'target_has_atomic_load_store="16"',
"--cfg", 'target_has_atomic_load_store="32"',
"--cfg", 'target_has_atomic_load_store="ptr"',
# enable cas
"--cfg", "target_has_atomic",
"--cfg", 'target_has_atomic="8"',
"--cfg", 'target_has_atomic="16"',
"--cfg", 'target_has_atomic="32"',
"--cfg", 'target_has_atomic="ptr"',
]

target = "riscv32imc-unknown-none-elf"
Expand Down
6 changes: 3 additions & 3 deletions intro/blinky/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ edition = "2021"
license = "MIT OR Apache-2.0"

[dependencies]
hal = { package = "esp32c3-hal", version = "0.13.0" }
esp-backtrace = { version = "0.9.0", features = ["esp32c3", "panic-handler", "exception-handler", "print-uart"] }
esp-println = { version = "0.7.1", features = ["esp32c3"] }
hal = { package = "esp32c3-hal", version = "0.15.0" }
esp-backtrace = { version = "0.11.0", features = ["esp32c3", "panic-handler", "exception-handler", "println"] }
esp-println = { version = "0.9.0", features = ["esp32c3"] }
16 changes: 0 additions & 16 deletions intro/button-interrupt/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@ rustflags = [
# Required to obtain backtraces (e.g. when using the "esp-backtrace" crate.)
# NOTE: May negatively impact performance of produced code
"-C", "force-frame-pointers",

# comment the cfgs below if you do _not_ wish to emulate atomics.
# enable the atomic codegen option for RISCV
"-C", "target-feature=+a",
# tell the core library have atomics even though it's not specified in the target definition
"--cfg", "target_has_atomic_load_store",
"--cfg", 'target_has_atomic_load_store="8"',
"--cfg", 'target_has_atomic_load_store="16"',
"--cfg", 'target_has_atomic_load_store="32"',
"--cfg", 'target_has_atomic_load_store="ptr"',
# enable cas
"--cfg", "target_has_atomic",
"--cfg", 'target_has_atomic="8"',
"--cfg", 'target_has_atomic="16"',
"--cfg", 'target_has_atomic="32"',
"--cfg", 'target_has_atomic="ptr"',
]

target = "riscv32imc-unknown-none-elf"
Expand Down
6 changes: 3 additions & 3 deletions intro/button-interrupt/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
license = "MIT OR Apache-2.0"

[dependencies]
hal = { package = "esp32c3-hal", version = "0.13.0" }
esp-backtrace = { version = "0.9.0", features = ["esp32c3", "panic-handler", "exception-handler", "print-uart"] }
esp-println = { version = "0.7.1", features = ["esp32c3"] }
hal = { package = "esp32c3-hal", version = "0.15.0" }
esp-backtrace = { version = "0.11.0", features = ["esp32c3", "panic-handler", "exception-handler", "println"] }
esp-println = { version = "0.9.0", features = ["esp32c3"] }
critical-section = "1.1.2"
16 changes: 0 additions & 16 deletions intro/button/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,6 @@ rustflags = [
# Required to obtain backtraces (e.g. when using the "esp-backtrace" crate.)
# NOTE: May negatively impact performance of produced code
"-C", "force-frame-pointers",

# comment the cfgs below if you do _not_ wish to emulate atomics.
# enable the atomic codegen option for RISCV
"-C", "target-feature=+a",
# tell the core library have atomics even though it's not specified in the target definition
"--cfg", "target_has_atomic_load_store",
"--cfg", 'target_has_atomic_load_store="8"',
"--cfg", 'target_has_atomic_load_store="16"',
"--cfg", 'target_has_atomic_load_store="32"',
"--cfg", 'target_has_atomic_load_store="ptr"',
# enable cas
"--cfg", "target_has_atomic",
"--cfg", 'target_has_atomic="8"',
"--cfg", 'target_has_atomic="16"',
"--cfg", 'target_has_atomic="32"',
"--cfg", 'target_has_atomic="ptr"',
]

target = "riscv32imc-unknown-none-elf"
Expand Down
6 changes: 3 additions & 3 deletions intro/button/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ edition = "2021"
license = "MIT OR Apache-2.0"

[dependencies]
hal = { package = "esp32c3-hal", version = "0.13.0" }
esp-backtrace = { version = "0.9.0", features = ["esp32c3", "panic-handler", "exception-handler", "print-uart"] }
esp-println = { version = "0.7.1", features = ["esp32c3"] }
hal = { package = "esp32c3-hal", version = "0.15.0" }
esp-backtrace = { version = "0.11.0", features = ["esp32c3", "panic-handler", "exception-handler", "println"] }
esp-println = { version = "0.9.0", features = ["esp32c3"] }
Loading

0 comments on commit 1ffbab8

Please sign in to comment.