Skip to content

Commit 77bc3eb

Browse files
Merge pull request #399 from Nitrokey/delog-knock-it-off
Add no-delog feature
2 parents a788f3c + c8d75a6 commit 77bc3eb

File tree

6 files changed

+17
-5
lines changed

6 files changed

+17
-5
lines changed

runners/embedded/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,13 @@ toml = "0.5"
7272
[features]
7373
default = ["alloc"]
7474

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

80+
no-delog = ["delog/knock-it-off"]
81+
8082
# Do not use encryption for the filesystem
8183
no-encrypted-storage = []
8284

runners/embedded/Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@ OUT_BIN = $(ARTIFACTS)/runner-$(BUILD_ID).bin
3232
OUT_ELF = $(ARTIFACTS)/runner-$(BUILD_ID).elf
3333
OUT_IHEX = $(OUT_BIN).ihex
3434
CUSTOM_PROFILE=$(shell python3 -c "p = 'release-thin-lto' if '$(BOARD)' == 'nk3am' and 'test' in '$(COMMA_FEATURES)'.split(',') else 'release'; print(p); " )
35+
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; ")
3536
RAW_OUT = $(CARGO_TARGET_DIR)/$(TARGET)/$(CUSTOM_PROFILE)/$(SOC)_runner
3637

3738
# feature definition
3839
BUILD_FEATURES := board-$(BOARD) $(FEATURES)
40+
ALL_FEATURES = $(BUILD_FEATURES) $(NO_DELOG_FEATURE)
3941
# assemble comma-seperated list to pass to `cargo build`
4042
delim = ,
4143
space := $(null) #
42-
COMMA_FEATURES = $(subst $(space),$(delim),$(BUILD_FEATURES))
44+
COMMA_FEATURES = $(subst $(space),$(delim),$(ALL_FEATURES))
4345

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

runners/embedded/src/bin/app-lpc.rs

+2
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ mod app {
143143
perf_timer.start(60_000_000.microseconds());
144144
}
145145
});
146+
147+
#[cfg(not(feature = "no-delog"))]
146148
if time > 1_200_000 {
147149
soc::Delogger::flush();
148150
}

runners/embedded/src/bin/app-nrf.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33

44
use embedded_runner_lib as ERL;
55

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

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

1213
#[rtic::app(device = nrf52840_hal::pac, peripherals = true, dispatchers = [SWI3_EGU3, SWI4_EGU4, SWI5_EGU5])]
1314
mod app {
14-
use super::{Delogger, ERL, ERL::soc::rtic_monotonic::RtcDuration};
15+
#[cfg(not(feature = "no-delog"))]
16+
use super::Delogger;
17+
use super::{ERL, ERL::soc::rtic_monotonic::RtcDuration};
1518
use apdu_dispatch::interchanges::Channel as CcidChannel;
1619
use interchange::Channel;
1720
use nrf52840_hal::{
@@ -63,6 +66,7 @@ mod app {
6366

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

@@ -257,6 +261,7 @@ mod app {
257261
// cortex_m::asm::wfi();
258262

259263
loop {
264+
#[cfg(not(feature = "no-delog"))]
260265
Delogger::flush();
261266

262267
let (usb_activity, _nfc_activity) = apps.lock(|apps| {

runners/embedded/src/soc_lpc55/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub mod board;
1414

1515
use delog::delog;
1616

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

1920
const SECURE_FIRMWARE_VERSION: u32 = utils::VERSION.encode();

rust-toolchain.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[toolchain]
2-
channel = "1.72.0"
2+
channel = "1.74.0"
33
components = ["rustfmt", "llvm-tools-preview"]
44
targets = ["thumbv7em-none-eabihf", "thumbv8m.main-none-eabi"]

0 commit comments

Comments
 (0)