Skip to content

Commit

Permalink
Merge pull request #399 from Nitrokey/delog-knock-it-off
Browse files Browse the repository at this point in the history
Add no-delog feature
  • Loading branch information
sosthene-nitrokey authored Dec 4, 2023
2 parents a788f3c + c8d75a6 commit 77bc3eb
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
4 changes: 3 additions & 1 deletion runners/embedded/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ toml = "0.5"
[features]
default = ["alloc"]

test = ["apps/test", "utils/test", "se050"]
test = ["apps/test", "utils/test"]
develop = ["no-encrypted-storage", "apps/no-reset-time-window", "log-traceP"]
develop-no-press = ["develop", "no-buttons"]
provisioner = ["apps/provisioner", "write-undefined-flash", "no-buttons", "apps/no-reset-time-window", "lpc55-hardware-checks"]

no-delog = ["delog/knock-it-off"]

# Do not use encryption for the filesystem
no-encrypted-storage = []

Expand Down
4 changes: 3 additions & 1 deletion runners/embedded/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ OUT_BIN = $(ARTIFACTS)/runner-$(BUILD_ID).bin
OUT_ELF = $(ARTIFACTS)/runner-$(BUILD_ID).elf
OUT_IHEX = $(OUT_BIN).ihex
CUSTOM_PROFILE=$(shell python3 -c "p = 'release-thin-lto' if '$(BOARD)' == 'nk3am' and 'test' in '$(COMMA_FEATURES)'.split(',') else 'release'; print(p); " )
NO_DELOG_FEATURE=$(shell python3 -c "print('no-delog') if 'no-delog' not in '$(BUILD_FEATURES)'.split(',') and 'log-semihosting' not in '$(BUILD_FEATURES)'.split(',') and 'log-rtt' not in '$(BUILD_FEATURES)'.split(',') else None; ")
RAW_OUT = $(CARGO_TARGET_DIR)/$(TARGET)/$(CUSTOM_PROFILE)/$(SOC)_runner

# feature definition
BUILD_FEATURES := board-$(BOARD) $(FEATURES)
ALL_FEATURES = $(BUILD_FEATURES) $(NO_DELOG_FEATURE)
# assemble comma-seperated list to pass to `cargo build`
delim = ,
space := $(null) #
COMMA_FEATURES = $(subst $(space),$(delim),$(BUILD_FEATURES))
COMMA_FEATURES = $(subst $(space),$(delim),$(ALL_FEATURES))

.PHONY: list build reset program check doc check-all clean clean-all check-env set-vars

Expand Down
2 changes: 2 additions & 0 deletions runners/embedded/src/bin/app-lpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ mod app {
perf_timer.start(60_000_000.microseconds());
}
});

#[cfg(not(feature = "no-delog"))]
if time > 1_200_000 {
soc::Delogger::flush();
}
Expand Down
9 changes: 7 additions & 2 deletions runners/embedded/src/bin/app-nrf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@

use embedded_runner_lib as ERL;

#[macro_use]
#[cfg_attr(not(feature = "no-delog"), macro_use)]
extern crate delog;
delog::generate_macros!();

#[cfg(not(feature = "no-delog"))]
delog!(Delogger, 3 * 1024, 512, ERL::types::DelogFlusher);

#[rtic::app(device = nrf52840_hal::pac, peripherals = true, dispatchers = [SWI3_EGU3, SWI4_EGU4, SWI5_EGU5])]
mod app {
use super::{Delogger, ERL, ERL::soc::rtic_monotonic::RtcDuration};
#[cfg(not(feature = "no-delog"))]
use super::Delogger;
use super::{ERL, ERL::soc::rtic_monotonic::RtcDuration};
use apdu_dispatch::interchanges::Channel as CcidChannel;
use interchange::Channel;
use nrf52840_hal::{
Expand Down Expand Up @@ -63,6 +66,7 @@ mod app {

#[cfg(feature = "log-rtt")]
rtt_target::rtt_init_print!();
#[cfg(not(feature = "no-delog"))]
Delogger::init_default(delog::LevelFilter::Trace, &ERL::types::DELOG_FLUSHER).ok();
ERL::banner();

Expand Down Expand Up @@ -257,6 +261,7 @@ mod app {
// cortex_m::asm::wfi();

loop {
#[cfg(not(feature = "no-delog"))]
Delogger::flush();

let (usb_activity, _nfc_activity) = apps.lock(|apps| {
Expand Down
1 change: 1 addition & 0 deletions runners/embedded/src/soc_lpc55/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub mod board;

use delog::delog;

#[cfg(not(feature = "no-delog"))]
delog!(Delogger, 3 * 1024, 512, crate::types::DelogFlusher);

const SECURE_FIRMWARE_VERSION: u32 = utils::VERSION.encode();
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.72.0"
channel = "1.74.0"
components = ["rustfmt", "llvm-tools-preview"]
targets = ["thumbv7em-none-eabihf", "thumbv8m.main-none-eabi"]

0 comments on commit 77bc3eb

Please sign in to comment.