pub fn new(
        probe: Probe,
        target: impl Into<TargetSelector>,
        attach_method: AttachMethod,
    ) -> Result<Self, Error> {
        let (probe, target) = get_target_from_selector(target, probe)?;

        let mut session = match target.architecture() {
            Architecture::Arm => {
                let core = (
                    SpecificCoreState::from_core_type(target.core_type),
                    Core::create_state(0),
                );

                let interface = probe.into_arm_interface()?;

                let mut session = Session {
                    target,
                    interface: ArchitectureInterface::Arm(interface.unwrap()),
                    cores: vec![core],
                };

                // Enable debug mode
                debug_core_start(&mut session.core(0)?)?;

                if attach_method == AttachMethod::UnderReset {
                    // we need to halt the chip here
                    reset_catch_set(&mut session.core(0)?)?;

                    // Deassert the reset pin
                    session.interface.as_mut().target_reset_deassert()?;

                    // Wait for the core to be halted
                    let mut core = session.core(0)?;

                    core.wait_for_core_halted(Duration::from_millis(100))?;

                    reset_catch_clear(&mut core)?;
                }

                session
            }
            Architecture::Riscv => {
                // TODO: Handle attach under reset

                let core = (
                    SpecificCoreState::from_core_type(target.core_type),
                    Core::create_state(0),
                );

                let interface = probe.into_riscv_interface()?;

                let mut session = Session {
                    target,
                    interface: ArchitectureInterface::Riscv(interface.unwrap()),
                    cores: vec![core],
                };

                {
                    let mut core = session.core(0)?;

                    core.halt(Duration::from_millis(100))?;
                }

                session
            }
        };

        session.clear_all_hw_breakpoints()?;

        Ok(session)
    }
/// Open a new session with a given debug target
Open a new session with a given debug target
Open a new session with a given debug target
pub fn new(
        probe: Probe,
        target: impl Into<TargetSelector>,
        attach_method: AttachMethod,
    ) -> Result<Self, Error> {
        let (probe, target) = get_target_from_selector(target, probe)?;
        let mut session = match target.architecture() {
            Architecture::Arm => {
                let core = (
                    SpecificCoreState::from_core_type(target.core_type),
                    Core::create_state(0),
                );
                let interface = probe.into_arm_interface()?;
                let mut session = Session {
                    target,
                    interface: ArchitectureInterface::Arm(interface.unwrap()),
                    cores: vec![core],
                };
                // Enable debug mode
                debug_core_start(&mut session.core(0)?)?;
                if attach_method == AttachMethod::UnderReset {
                    // we need to halt the chip here
                    reset_catch_set(&mut session.core(0)?)?;
                    // Deassert the reset pin
                    session.interface.as_mut().target_reset_deassert()?;
                    // Wait for the core to be halted
                    let mut core = session.core(0)?;
                    core.wait_for_core_halted(Duration::from_millis(100))?;
                    reset_catch_clear(&mut core)?;
                }
                session
            }
            Architecture::Riscv => {
                // TODO: Handle attach under reset
                let core = (
                    SpecificCoreState::from_core_type(target.core_type),
                    Core::create_state(0),
                );
                let interface = probe.into_riscv_interface()?;
                let mut session = Session {
                    target,
                    interface: ArchitectureInterface::Riscv(interface.unwrap()),
                    cores: vec![core],
                };
                {
                    let mut core = session.core(0)?;
                    core.halt(Duration::from_millis(100))?;
                }
                session
            }
        };
        session.clear_all_hw_breakpoints()?;
        Ok(session)
    }
pub fn new ( probe : Probe , target : impl Into < TargetSelector > , attach_method : AttachMethod , ) -> Result < Self , Error > { let ( probe , target ) = get_target_from_selector ( target , probe ) ? ; let mut session = match target . architecture ( ) { Architecture :: Arm => { let core = ( SpecificCoreState :: from_core_type ( target . core_type ) , Core :: create_state ( 0 ) , ) ; let interface = probe . into_arm_interface ( ) ? ; let mut session = Session { target , interface : ArchitectureInterface :: Arm ( interface . unwrap ( ) ) , cores : vec ! [ core ] , } ; // Enable debug mode debug_core_start ( & mut session . core ( 0 ) ? ) ? ; if attach_method == AttachMethod :: UnderReset { // we need to halt the chip here reset_catch_set ( & mut session . core ( 0 ) ? ) ? ; // Deassert the reset pin session . interface . as_mut ( ) . target_reset_deassert ( ) ? ; // Wait for the core to be halted let mut core = session . core ( 0 ) ? ; core . wait_for_core_halted ( Duration :: from_millis ( 100 ) ) ? ; reset_catch_clear ( & mut core ) ? ; } session } Architecture :: Riscv => { // TODO: Handle attach under reset let core = ( SpecificCoreState :: from_core_type ( target . core_type ) , Core :: create_state ( 0 ) , ) ; let interface = probe . into_riscv_interface ( ) ? ; let mut session = Session { target , interface : ArchitectureInterface :: Riscv ( interface . unwrap ( ) ) , cores : vec ! [ core ] , } ; { let mut core = session . core ( 0 ) ? ; core . halt ( Duration :: from_millis ( 100 ) ) ? ; } session } } ; session . clear_all_hw_breakpoints ( ) ? ; Ok ( session ) }
Open a new session with a given debug target
Open a new session with a given debug target
probe
Probe
target
impl Into<TargetSelector>
attach_method
AttachMethod
probe
Probe
target
impl Into<TargetSelector>
attach_method
AttachMethod