Skip to content
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
21 changes: 21 additions & 0 deletions debug-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,29 @@
#![allow(clippy::indexing_slicing)]
#![allow(clippy::unwrap_used)]

// This module has a hard dependency on defmt, which doesn't work on desktop.
// This means that the entire workspace's tests won't compile if this module is enabled.
//
// On Linux, we sort-of get away with it - as far as I can tell, the linker on Linux is more aggressive
// with pruning unused code, so as long as there's no test that calls into anything that eventually calls
// into defmt, we at least compile on Linux.
//
// However, on Windows, it looks like the linker is erroring out because it can't find defmt-related symbols before
// it does the analysis to determine that those symbols aren't reachable anyway, so we have to disable this module
// entirely to be able to compile the workspace's tests at all on Windows.
//
// If we ever want to run tests for this module on Windows, we'll need some way to either break the dependency
// on defmt or provide dummy implementations of the defmt symbols for test builds on Windows. Until then,
// we need to gate everything on #[cfg(not(test))].

#[cfg(not(test))]
mod debug_service;

#[cfg(not(test))]
mod defmt_ring_logger;

#[cfg(not(test))]
pub mod task;

#[cfg(not(test))]
pub use debug_service::*;
11 changes: 3 additions & 8 deletions espi-service/src/espi_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ impl Service<'_> {
})?;
// Last byte is PEC, ignore for now
let packet = &packet[..packet.len() - 1];
#[cfg(feature = "defmt")]
trace!("Sending MCTP response: {:?}", packet);

self.write_to_hw(espi, packet).map_err(|e| {
Expand Down Expand Up @@ -228,7 +227,7 @@ pub(crate) async fn process_controller_event(
with_pec[src_slice.len()] = 0;
let with_pec = &with_pec[..=src_slice.len()];

#[cfg(feature = "defmt")]
#[cfg(feature = "defmt")] // Required because without defmt, there is no implementation of UpperHex for [u8]
debug!("OOB message: {:02X}", &src_slice[0..]);

let mut assembly_access = espi_service
Expand All @@ -240,13 +239,11 @@ pub(crate) async fn process_controller_event(

match mctp_ctx.deserialize_packet(with_pec) {
Ok(Some(message)) => {
#[cfg(feature = "defmt")]
trace!("MCTP packet successfully deserialized");

match message.parse_as::<HostRequest>() {
Ok((header, body)) => {
let target_endpoint = header.service.get_endpoint_id();
#[cfg(feature = "defmt")]
trace!(
"Host Request: Service {:?}, Command {:?}",
target_endpoint, header.message_id,
Expand All @@ -261,9 +258,8 @@ pub(crate) async fn process_controller_event(
.expect("result error type is infallible");
info!("MCTP packet forwarded to service: {:?}", target_endpoint);
}
Err(_e) => {
#[cfg(feature = "defmt")]
error!("MCTP ODP type malformed: {}", _e);
Err(e) => {
error!("MCTP ODP type malformed: {:?}", e);

espi.complete_port(port_event.port);

Expand All @@ -282,7 +278,6 @@ pub(crate) async fn process_controller_event(
// Handle protocol or medium error
error!("MCTP packet malformed");

#[cfg(feature = "defmt")]
error!("error code: {:?}", _e);
espi.complete_port(OOB_PORT_ID);

Expand Down
21 changes: 21 additions & 0 deletions espi-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,29 @@
#![allow(clippy::panic)]
#![allow(clippy::unwrap_used)]

// This module has a hard dependency on embassy-imxrt, which doesn't work on desktop.
// This means that the entire workspace's tests won't compile if this module is enabled.
//
// On Linux, we sort-of get away with it - as far as I can tell, the linker on Linux is more aggressive
// with pruning unused code, so as long as there's no test that calls into anything that eventually calls
// into embassy-imxrt, we at least compile on Linux.
//
// However, on Windows, it looks like the linker is erroring out because it can't find embassy-imxrt-related
// symbols before it does the analysis to determine that those symbols aren't reachable anyway, so we have to
// disable this module entirely to be able to compile the workspace's tests at all on Windows.
//
// If we ever want to run tests for this module on Windows, we'll need some way to break the dependency
// on embassy-imxrt - probably by switching to some sort of trait-based interface with eSPI. Until then,
// we need to gate everything on #[cfg(not(test))].

#[cfg(not(test))]
mod espi_service;

#[cfg(not(test))]
mod mctp;

#[cfg(not(test))]
pub mod task;

#[cfg(not(test))]
pub use espi_service::*;
2 changes: 1 addition & 1 deletion partition-manager/partition-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ partition-manager-macros = { path = "../macros", features = [
defmt = { workspace = true, optional = true }

[features]
default = ["esa", "bdd", "macros", "defmt"]
default = ["esa", "bdd", "macros"]

macros = ["dep:partition-manager-macros"]

Expand Down