pub fn flash_to_target(
    input: &FlashInput,
    settings: &RaukSettings,
    metadata: &RaukMetadata,
) -> Result<PathBuf> {
    let mut target_dir = metadata.project_directory.clone();
    let mut cargo_path = metadata.project_directory.clone();
    target_dir.push("target/");
    cargo_path.push("Cargo.toml");

    let mut updated_input = input.clone();
    updated_input.get_missing_input(settings);
    let halt_timeout = updated_input
        .halt_timeout
        .unwrap_or(DEFAULT_HALT_TIMEOUT_SECONDS);

    build_replay_harness(&updated_input, &mut cargo_path, &mut target_dir)
        .context("Failed to build the replay harness")?;
    let mut session = if let Some(chip) = updated_input.chip {
        core_utils::open_and_attach_probe(&chip)?
    } else {
        return Err(anyhow!(
            "Can't attach to hardware. No chip type given as input"
        ));
    };

    // Flash the card with binary
    download_file(&mut session, &target_dir.as_path(), Format::Elf)
        .context("Could not flash replay harness to hardware")?;

    // Reset the core and halt
    let mut core = session.core(0)?;
    core.reset_and_halt(std::time::Duration::from_secs(halt_timeout))?;

    Ok(target_dir)
}
/// Builds the replay harness and flashes it to the target hardware.
/// Returns the path to the built executable.
Builds the replay harness and flashes it to the target hardware.
Returns the path to the built executable.
Builds the replay harness and flashes it to the target hardware . Returns the path to the built executable .
pub fn flash_to_target(
    input: &FlashInput,
    settings: &RaukSettings,
    metadata: &RaukMetadata,
) -> Result<PathBuf> {
    let mut target_dir = metadata.project_directory.clone();
    let mut cargo_path = metadata.project_directory.clone();
    target_dir.push("target/");
    cargo_path.push("Cargo.toml");
    let mut updated_input = input.clone();
    updated_input.get_missing_input(settings);
    let halt_timeout = updated_input
        .halt_timeout
        .unwrap_or(DEFAULT_HALT_TIMEOUT_SECONDS);
    build_replay_harness(&updated_input, &mut cargo_path, &mut target_dir)
        .context("Failed to build the replay harness")?;
    let mut session = if let Some(chip) = updated_input.chip {
        core_utils::open_and_attach_probe(&chip)?
    } else {
        return Err(anyhow!(
            "Can't attach to hardware. No chip type given as input"
        ));
    };
    // Flash the card with binary
    download_file(&mut session, &target_dir.as_path(), Format::Elf)
        .context("Could not flash replay harness to hardware")?;
    // Reset the core and halt
    let mut core = session.core(0)?;
    core.reset_and_halt(std::time::Duration::from_secs(halt_timeout))?;
    Ok(target_dir)
}
pub fn flash_to_target ( input : & FlashInput , settings : & RaukSettings , metadata : & RaukMetadata , ) -> Result < PathBuf > { let mut target_dir = metadata . project_directory . clone ( ) ; let mut cargo_path = metadata . project_directory . clone ( ) ; target_dir . push ( " " ) ; cargo_path . push ( " " ) ; let mut updated_input = input . clone ( ) ; updated_input . get_missing_input ( settings ) ; let halt_timeout = updated_input . halt_timeout . unwrap_or ( DEFAULT_HALT_TIMEOUT_SECONDS ) ; build_replay_harness ( & updated_input , & mut cargo_path , & mut target_dir ) . context ( " " ) ? ; let mut session = if let Some ( chip ) = updated_input . chip { core_utils :: open_and_attach_probe ( & chip ) ? } else { return Err ( anyhow ! ( " " ) ) ; } ; // Flash the card with binary download_file ( & mut session , & target_dir . as_path ( ) , Format :: Elf ) . context ( " " ) ? ; // Reset the core and halt let mut core = session . core ( 0 ) ? ; core . reset_and_halt ( std :: time :: Duration :: from_secs ( halt_timeout ) ) ? ; Ok ( target_dir ) }
Builds the replay harness and flashes it to the target hardware.
Builds the replay harness and flashes it to the target hardware .
input
&FlashInput
settings
&RaukSettings
metadata
&RaukMetadata
input
&FlashInput
settings
&RaukSettings
metadata
&RaukMetadata