Skip to content

Commit

Permalink
Allow running release binary
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Oct 24, 2023
1 parent 4125bc0 commit dee5316
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 11 deletions.
29 changes: 29 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,35 @@
"c"
]
},
{
// more info at: https://github.com/Marus/cortex-debug/blob/master/package.json
"name": "Attach (USB JTAG, release)",
"type": "cortex-debug",
"request": "attach", // attach instead of launch, because otherwise flash write is attempted, but fails
"cwd": "${workspaceRoot}",
"executable": "target/xtensa-esp32s3-none-elf/release/card_io_fw",
"servertype": "openocd",
"interface": "jtag",
"svdFile": ".vscode/esp32s3.base.svd",
"toolchainPrefix": "xtensa-esp32s3-elf",
"openOCDPreConfigLaunchCommands": [
"set ESP_RTOS none"
],
"serverpath": "${userHome}/openocd-esp32/bin/openocd.exe",
"configFiles": [
"board/esp32s3-builtin.cfg"
],
"overrideAttachCommands": [
"set remote hardware-watchpoint-limit 2",
"mon halt",
"flushregs"
],
"overrideRestartCommands": [
"mon reset halt",
"flushregs",
"c"
]
},
{
// more info at: https://github.com/Marus/cortex-debug/blob/master/package.json
"name": "Attach (esp-prog JTAG)",
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"rust-analyzer.check.allTargets": false,
"rust-analyzer.showUnlinkedFileNotification": false
"rust-analyzer.showUnlinkedFileNotification": false,
"cortex-debug.variableUseNaturalFormat": false
}
30 changes: 20 additions & 10 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ pub enum Subcommands {
Run {
/// Which hardware version to run on.
hw: Option<HardwareVersion>,

#[arg(long)]
release: bool,
},

/// Checks the project for errors.
Expand Down Expand Up @@ -165,17 +168,24 @@ fn build(hw: HardwareVersion, opt: Option<BuildVariant>, timings: bool) -> AnyRe
Ok(())
}

fn run(hw: HardwareVersion) -> AnyResult<()> {
cargo(&[
"espflash",
"flash",
"-M",
"--erase-parts=otadata",
fn run(hw: HardwareVersion, release: bool) -> AnyResult<()> {
let hw = format!("--features={}", hw.feature());
let mut build_flags = vec![
"--target=xtensa-esp32s3-none-elf",
&hw,
"-Zbuild-std=core,alloc",
&format!("--features={}", hw.feature()),
])
.run()?;
"-Zbuild-std-features=panic_immediate_abort",
];

if release {
build_flags.push("--release");
}

let mut args = vec!["espflash", "flash", "-M"];

args.extend_from_slice(&build_flags);

cargo(&args).run()?;

Ok(())
}
Expand Down Expand Up @@ -321,7 +331,7 @@ fn main() -> AnyResult<()> {
asm()
}
Subcommands::Monitor { variant } => monitor(variant.unwrap_or(MonitorVariant::Debug)),
Subcommands::Run { hw } => run(hw.unwrap_or_default()),
Subcommands::Run { hw, release } => run(hw.unwrap_or_default(), release),
Subcommands::Check { hw } => checks(hw.unwrap_or_default()),
Subcommands::Doc { open, hw } => docs(open, hw.unwrap_or_default()),
Subcommands::ExtraCheck { hw } => extra_checks(hw.unwrap_or_default()),
Expand Down

0 comments on commit dee5316

Please sign in to comment.