Skip to content

Commit fb6de75

Browse files
committed
picoprog: use rtt and defmt for debug output
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
1 parent 2f35daf commit fb6de75

File tree

5 files changed

+9
-31
lines changed

5 files changed

+9
-31
lines changed

Cargo.lock

Lines changed: 2 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ embassy-stm32 = { version = "0.2.0" }
2020
embassy-sync = "0.6.2"
2121
embassy-time = "0.4.0"
2222
embassy-usb = { version = "0.4.0", features = ["max-handler-count-6", "max-interface-count-6"] }
23-
embassy-usb-logger = "0.4.0"
2423
embedded-hal = "1.0.0"
2524
embedded-hal-async = "1.0.0"
2625
futures = { version = "0.3.31", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] }
@@ -44,7 +43,6 @@ embassy-stm32 = { git = "https://github.com/embassy-rs/embassy", rev = "17301c00
4443
embassy-sync = { git = "https://github.com/embassy-rs/embassy", rev = "17301c00e986c5b8536435ea31ebf5aaf13aed17" }
4544
embassy-time = { git = "https://github.com/embassy-rs/embassy", rev = "17301c00e986c5b8536435ea31ebf5aaf13aed17" }
4645
embassy-usb = { git = "https://github.com/embassy-rs/embassy", rev = "17301c00e986c5b8536435ea31ebf5aaf13aed17" }
47-
embassy-usb-logger = { git = "https://github.com/embassy-rs/embassy", rev = "17301c00e986c5b8536435ea31ebf5aaf13aed17" }
4846

4947
[profile.release]
5048
debug = true

picoprog/Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@ authors = ["Marvin Drees <marvin.drees@9elements.com>"]
99
assign-resources.workspace = true
1010
cortex-m = { workspace = true, features = ["inline-asm", "critical-section"] }
1111
cortex-m-rt.workspace = true
12-
embassy-executor = { workspace = true, features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "nightly"] }
12+
embassy-executor = { workspace = true, features = ["arch-cortex-m", "executor-thread", "executor-interrupt", "nightly", "defmt"] }
1313
embassy-futures.workspace = true
1414
embedded-hal.workspace = true
1515
embedded-hal-async.workspace = true
1616
serprog.workspace = true
1717
embassy-rp = { workspace = true, features = ["unstable-pac", "time-driver", "critical-section-impl", "rom-func-cache", "rom-v2-intrinsics", "rp2040"] }
18-
embassy-sync.workspace = true
18+
embassy-sync = { workspace = true, features = ["defmt"] }
1919
embassy-time.workspace = true
20-
embassy-usb = { workspace = true, features = ["max-handler-count-6", "max-interface-count-6"] }
21-
embassy-usb-logger.workspace = true
20+
embassy-usb = { workspace = true, features = ["max-handler-count-6", "max-interface-count-6", "defmt"] }
2221
heapless = { workspace = true, features = ["portable-atomic-critical-section", "ufmt"] }
2322
log.workspace = true
2423
static_cell.workspace = true
2524
ufmt.workspace = true
25+
defmt.workspace = true
26+
defmt-rtt.workspace = true

picoprog/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@ fn main() {
3232
println!("cargo:rustc-link-arg-bins=--nmagic");
3333
println!("cargo:rustc-link-arg-bins=-Tlink.x");
3434
println!("cargo:rustc-link-arg-bins=-Tlink-rp.x");
35+
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
3536
}

picoprog/src/main.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use assign_resources::assign_resources;
99
use core::panic::PanicInfo;
1010
use cortex_m::peripheral::SCB;
11+
use defmt_rtt as _;
1112
use embassy_executor::Spawner;
1213
use embassy_rp::bind_interrupts;
1314
use embassy_rp::flash::{Async, Flash};
@@ -19,7 +20,6 @@ use embassy_rp::usb::{Driver, InterruptHandler as USBInterruptHandler};
1920
use embassy_usb::class::cdc_acm::{CdcAcmClass, State};
2021
use embassy_usb::driver::EndpointError;
2122
use embassy_usb::{Config as UsbConfig, UsbDevice};
22-
use embassy_usb_logger::with_class;
2323
use heapless::String;
2424
use static_cell::StaticCell;
2525
use ufmt::uwrite;
@@ -102,12 +102,6 @@ async fn main(spawner: Spawner) {
102102
builder
103103
};
104104

105-
let logger_class = {
106-
static STATE: StaticCell<State> = StaticCell::new();
107-
let state = STATE.init(State::new());
108-
CdcAcmClass::new(&mut builder, state, 64)
109-
};
110-
111105
let uart_class = {
112106
static STATE: StaticCell<State> = StaticCell::new();
113107
let state = STATE.init(State::new());
@@ -123,7 +117,6 @@ async fn main(spawner: Spawner) {
123117
let usb = builder.build();
124118
// We can't really recover here so just unwrap
125119
spawner.spawn(usb_task(usb)).unwrap();
126-
spawner.spawn(logger_task(logger_class)).unwrap();
127120
spawner.spawn(uart::uart_task(uart_class, r.uart)).unwrap();
128121
spawner.spawn(serprog_task(serprog_class, r.spi)).unwrap();
129122

@@ -151,11 +144,6 @@ async fn usb_task(mut usb: CustomUsbDevice) -> ! {
151144
usb.run().await
152145
}
153146

154-
#[embassy_executor::task]
155-
async fn logger_task(class: CdcAcmClass<'static, CustomUsbDriver>) {
156-
with_class!(1024, log::LevelFilter::Info, class).await
157-
}
158-
159147
#[embassy_executor::task]
160148
async fn serprog_task(class: CdcAcmClass<'static, CustomUsbDriver>, r: SpiResources) -> ! {
161149
let mut config = SpiConfig::default();

0 commit comments

Comments
 (0)