Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Fix: println without colors not printing #53

Merged
merged 3 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 31 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ jobs:
check-riscv:
name: Check RISC-V
runs-on: ubuntu-latest
env:
RUSTFLAGS: -Dwarnings
strategy:
fail-fast: false
matrix:
chip: [esp32c2, esp32c3, esp32c6, esp32h2, esp32p4]
printer: ["esp-println/uart"]
colors: ["colors"]
method: ["println"]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@v1
Expand All @@ -28,21 +31,45 @@ jobs:
toolchain: nightly
components: rust-src
- uses: Swatinem/rust-cache@v2
- run: cargo check -Zbuild-std=core --target=riscv32imc-unknown-none-elf --features=${{ matrix.chip }},panic-handler,exception-handler,println,${{ matrix.printer }}
- run: cargo check -Zbuild-std=core --target=riscv32imc-unknown-none-elf --no-default-features --features=esp-println/uart,${{ matrix.chip }},panic-handler,exception-handler,${{ matrix.method }},${{ matrix.colors }}

check-xtensa:
name: Check Xtensa
runs-on: ubuntu-latest
env:
RUSTFLAGS: -Dwarnings
strategy:
fail-fast: false
matrix:
chip: [esp32, esp32s2, esp32s3]
printer: ["esp-println/uart"]
colors: ["colors"]
method: ["println"]
steps:
- uses: actions/checkout@v3
- uses: esp-rs/xtensa-toolchain@v1.5
with:
default: true
ldproxy: false
- uses: Swatinem/rust-cache@v2
- run: cargo check -Zbuild-std=core --target=xtensa-${{ matrix.chip }}-none-elf --features=${{ matrix.chip }},panic-handler,exception-handler,println,${{ matrix.printer }}
- run: cargo check -Zbuild-std=core --target=xtensa-${{ matrix.chip }}-none-elf --no-default-features --features=esp-println/uart,${{ matrix.chip }},panic-handler,exception-handler,${{ matrix.method }},${{ matrix.colors }}

check-features:
name: Check unusual feature combinations
runs-on: ubuntu-latest
env:
RUSTFLAGS: -Dwarnings
strategy:
fail-fast: false
matrix:
chip: [esp32c3]
colors: ["colors", ""]
method: ["println","defmt"]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@v1
with:
target: riscv32imc-unknown-none-elf
toolchain: nightly
components: rust-src
- uses: Swatinem/rust-cache@v2
- run: cargo check -Zbuild-std=core --target=riscv32imc-unknown-none-elf --no-default-features --features=esp-println/uart,${{ matrix.chip }},panic-handler,exception-handler,${{ matrix.method }},${{ matrix.colors }}
12 changes: 10 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ fn panic_handler(info: &core::panic::PanicInfo) -> ! {
#[cfg(nightly)]
{
if let Some(message) = info.message() {
#[cfg(not(feature = "defmt"))]
println!("{}", message);

#[cfg(feature = "defmt")]
println!("{}", defmt::Display2Format(message));
}
}

Expand All @@ -95,7 +99,7 @@ fn panic_handler(info: &core::panic::PanicInfo) -> ! {
#[cfg(all(feature = "colors", feature = "println"))]
println!("{}0x{:x}", RED, addr - crate::arch::RA_OFFSET);

#[cfg(not(any(feature = "colors", feature = "println")))]
#[cfg(not(all(feature = "colors", feature = "println")))]
println!("0x{:x}", addr - crate::arch::RA_OFFSET);
}
}
Expand Down Expand Up @@ -192,7 +196,11 @@ fn exception_handler(context: &arch::TrapFrame) -> ! {
}
for e in backtrace {
if let Some(addr) = e {
println!("0x{:x}", addr);
#[cfg(all(feature = "colors", feature = "println"))]
println!("{}0x{:x}", RED, addr - crate::arch::RA_OFFSET);

#[cfg(not(all(feature = "colors", feature = "println")))]
println!("0x{:x}", addr - crate::arch::RA_OFFSET);
}
}
}
Expand Down