Skip to content

Commit

Permalink
Use probe-rs and rtt-target
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Oct 10, 2024
1 parent 8e2f0ac commit a48ad2c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 72 deletions.
11 changes: 4 additions & 7 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
[target.xtensa-esp32s3-none-elf]
runner = "probe-rs run"
rustflags = [
"-C", "link-arg=-nostartfiles",
"-C", "link-arg=-Wl,-Tlinkall.x",
"-C", "link-arg=-Trom_functions.x",
]

[target.xtensa-esp32s2-none-elf]
rustflags = [
"-C", "link-arg=-nostartfiles",
"-C", "link-arg=-Wl,-Tlinkall.x",
"-C", "link-arg=-Trom_functions.x",
"-C", "link-arg=-Tdefmt.x",
]

[target.riscv32imac-unknown-none-elf]
runner = "probe-rs run"
rustflags = [
"-C", "force-frame-pointers",
"-C", "link-arg=-Tlinkall.x",
"-C", "link-arg=-Trom_functions.x",
"-C", "link-arg=-Tdefmt.x",
]

[alias]
Expand Down
56 changes: 11 additions & 45 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,14 @@ embassy-executor = { workspace = true, features = ["nightly"] }
embassy-time = { version = "0.3.0" }

embedded-hal-old = { package = "embedded-hal", version = "0.2.7" }
rtt-target = { version = "0.6.0", git = "https://github.com/probe-rs/rtt-target" }

esp-hal = { version = "0.21.0" }
esp-hal-embassy = { version = "0.4.0" }
esp-backtrace = { version = "0.14.2", features = [
"panic-handler",
"exception-handler",
] }
esp-println = { version = "0.12.0", default-features = false, features = [
"critical-section",
"defmt"
] }
esp-alloc = "0.5.0"
esp-wifi = { version = "0.10.1", default-features = false, features = [
Expand Down Expand Up @@ -111,23 +110,22 @@ embedded-menu.workspace = true
embassy-net.workspace = true
embassy-sync.workspace = true

norfs = { workspace = true }
norfs-driver = { workspace = true }
norfs.workspace = true
norfs-driver.workspace = true
norfs-esp32s3 = { workspace = true, optional = true, features = [
"critical-section",
] }
norfs-esp32c6 = { workspace = true, optional = true, features = [
"critical-section",
] }
heapless = { workspace = true }
object-chain = { workspace = true }
ufmt = { workspace = true }
heapless.workspace = true
object-chain.workspace = true
ufmt.workspace = true

logger = { workspace = true }
log = { workspace = true, optional = true }
defmt = { workspace = true, optional = true }
logger.workspace = true
defmt.workspace = true

smoltcp = { workspace = true }
smoltcp.workspace = true
crc = "3.0.1"
enumset = "1.1.3"

Expand All @@ -148,14 +146,11 @@ hw_v4 = ["battery_max17055", "esp32s3"]
hw_v6 = ["battery_max17055"] # skipped v5, v6 has S3 and C6 options

# MCU options
# esp32s2 = ["dep:esp32s2", "dep:esp32s2-hal", "esp-backtrace/esp32s2", "esp-println/esp32s2", "rtt"]
esp32s3 = [
"esp-hal/esp32s3",
"embassy-executor/integrated-timers",
"dep:norfs-esp32s3",
"esp-backtrace/esp32s3",
"esp-println/esp32s3",
"jtag-serial",
"esp-wifi/esp32s3",
"esp-hal-embassy/esp32s3",
]
Expand All @@ -164,49 +159,19 @@ esp32c6 = [
"embassy-time/generic-queue-8",
"dep:norfs-esp32c6",
"esp-backtrace/esp32c6",
"esp-println/esp32c6",
"jtag-serial",
"esp-wifi/esp32c6",
"esp-hal-embassy/esp32c6",
]

# Signal processing
downsampler-light = [] # uses IIR-based filtering and less memory

# Print options
uart = ["esp-println/uart"]
jtag-serial = ["esp-println/jtag-serial"]

log = [
"dep:log",
"norfs/log",
"esp-println/log",
"esp-println/colors",
"esp-wifi/log",
"esp-hal/log",
"esp-backtrace/println",

"logger/log",
"config-site/log",
"ads129x/log",
"max17055?/log",
"bad-server/log",
"gui/log",
"signal-processing/log",

"embassy-net/log",
"smoltcp/log",
]

defmt = [
"dep:defmt",
"norfs/defmt",
"embedded-io/defmt-03",
"embedded-graphics/defmt",
"esp-println/defmt-espflash",
"esp-wifi/defmt",
"esp-hal/defmt",
"esp-backtrace/defmt",

"logger/defmt",
"config-site/defmt",
Expand All @@ -220,6 +185,7 @@ defmt = [

"embassy-net/defmt",
"smoltcp/defmt",
"rtt-target/defmt",
]

[package.metadata.espflash]
Expand Down
4 changes: 0 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ fn main() {

let build_config = BuildConfig { mcu, hw_version };

if cfg!(feature = "defmt") {
println!("cargo:rustc-link-arg=-Tdefmt.x");
}

let pkg_version = env!("CARGO_PKG_VERSION");
let git_hash_bytes = std::process::Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
Expand Down
6 changes: 0 additions & 6 deletions src/board/startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ use {
max17055::{DesignData, Max17055},
};

#[cfg(feature = "log")]
use esp_println::logger::init_logger;

use fugit::RateExtU32;

pub struct StartupResources {
Expand All @@ -51,9 +48,6 @@ pub struct StartupResources {

impl StartupResources {
pub(super) fn common_init() -> Peripherals {
#[cfg(feature = "log")]
init_logger(log::LevelFilter::Trace); // we let the compile-time log level filter do the work

use core::ptr::addr_of;

#[cfg(feature = "esp32s3")]
Expand Down
13 changes: 10 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
#![allow(incomplete_features)] // generic_const_exprs

extern crate alloc;

#[macro_use]
extern crate logger;

use esp_println as _;

use alloc::{boxed::Box, rc::Rc};
use embassy_executor::Spawner;
use embassy_sync::{
Expand Down Expand Up @@ -195,6 +192,16 @@ where

#[main]
async fn main(_spawner: Spawner) {
let channels = rtt_target::rtt_init! {
up: {
0: {
size: 1024,
name: "defmt"
}
}
};
rtt_target::set_defmt_channel(channels.up.0);

esp_alloc::heap_allocator!((48 + 96) * 1024);

let resources = StartupResources::initialize().await;
Expand Down
8 changes: 1 addition & 7 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,7 @@ fn run(config: BuildConfig) -> AnyResult<()> {
SocConfig::C6 => std::fs::copy("cfg_esp32c6.toml", "cfg.toml").ok(),
};

let mut args = vec![
"espflash",
"flash",
"-M",
"--erase-parts=otadata",
"--log-format=defmt",
];
let mut args = vec!["run"];
args.extend_from_slice(&build_flags);

cargo(config.soc.toolchain(), &args).run()?;
Expand Down

0 comments on commit a48ad2c

Please sign in to comment.