Struct probe_rs::Core

source ·
pub struct Core<'probe> { /* private fields */ }
Expand description

Generic core handle representing a physical core on an MCU.

This should be considere as a temporary view of the core which locks the debug probe driver to as single consumer by borrowing it.

As soon as you did your atomic task (e.g. halt the core, read the core state and all other debug relevant info) you should drop this object, to allow potential other shareholders of the session struct to grab a core handle too.

Implementations§

source§

impl<'probe> Core<'probe>

source

pub fn new( core: impl CoreInterface + 'probe, state: &'probe mut CoreState ) -> Core<'probe>

Create a new Core.

source

pub fn create_state(id: usize, options: CoreAccessOptions) -> CoreState

Creates a new CoreState

source

pub fn id(&self) -> usize

Returns the ID of this core.

source

pub fn wait_for_core_halted(&mut self, timeout: Duration) -> Result<(), Error>

Wait until the core is halted. If the core does not halt on its own, a DebugProbeError::Timeout error will be returned.

source

pub fn core_halted(&mut self) -> Result<bool, Error>

Check if the core is halted. If the core does not halt on its own, a DebugProbeError::Timeout error will be returned.

source

pub fn halt(&mut self, timeout: Duration) -> Result<CoreInformation, Error>

Try to halt the core. This function ensures the core is actually halted, and returns a DebugProbeError::Timeout otherwise.

source

pub fn run(&mut self) -> Result<(), Error>

Continue to execute instructions.

source

pub fn reset(&mut self) -> Result<(), Error>

Reset the core, and then continue to execute instructions. If the core should be halted after reset, use the reset_and_halt function.

source

pub fn reset_and_halt( &mut self, timeout: Duration ) -> Result<CoreInformation, Error>

Reset the core, and then immediately halt. To continue execution after reset, use the reset function.

source

pub fn step(&mut self) -> Result<CoreInformation, Error>

Steps one instruction and then enters halted state again.

source

pub fn status(&mut self) -> Result<CoreStatus, Error>

Returns the current status of the core.

source

pub fn read_core_reg<T>( &mut self, address: impl Into<RegisterId> ) -> Result<T, Error>where RegisterValue: TryInto<T>, Result<T, <RegisterValue as TryInto<T>>::Error>: RegisterValueResultExt<T>,

Read the value of a core register.

Remarks

T can be an unsigned interger type, such as u32 or u64, or it can be RegisterValue to allow the caller to support arbitrary length registers.

To add support to convert to a custom type implement TryInto<CustomType> for RegisterValue].

Errors

If T isn’t large enough to hold the register value an error will be raised.

source

pub fn write_core_reg<T>( &mut self, address: RegisterId, value: T ) -> Result<(), Error>where T: Into<RegisterValue>,

Write the value of a core register.

Errors

If T is too large to write to the target register an error will be raised.

source

pub fn available_breakpoint_units(&mut self) -> Result<u32, Error>

Returns all the available breakpoint units of the core.

source

pub fn debug_on_sw_breakpoint(&mut self, enabled: bool) -> Result<(), Error>

Configure the debug module to ensure software breakpoints will enter Debug Mode.

source

pub fn registers(&self) -> &'static RegisterFile

Returns a list of all the registers of this core.

source

pub fn set_hw_breakpoint(&mut self, address: u64) -> Result<(), Error>

Set a hardware breakpoint

This function will try to set a hardware breakpoint att address.

The amount of hardware breakpoints which are supported is chip specific, and can be queried using the get_available_breakpoint_units function.

source

pub fn clear_hw_breakpoint(&mut self, address: u64) -> Result<(), Error>

Set a hardware breakpoint

This function will try to clear a hardware breakpoint at address if there exists a breakpoint at that address.

source

pub fn clear_all_hw_breakpoints(&mut self) -> Result<(), Error>

Clear all hardware breakpoints

This function will clear all HW breakpoints which are configured on the target, regardless if they are set by probe-rs, AND regardless if they are enabled or not. Also used as a helper function in Session::drop.

source

pub fn architecture(&self) -> Architecture

Returns the architecture of the core.

source

pub fn core_type(&self) -> CoreType

Returns the core type of the core

source

pub fn instruction_set(&mut self) -> Result<InstructionSet, Error>

Determine the instruction set the core is operating in This must be queried while halted as this is a runtime decision for some core types

source

pub fn fpu_support(&mut self) -> Result<bool, Error>

Determine if an FPU is present. This must be queried while halted as this is a runtime decision for some core types.

Trait Implementations§

source§

impl<'probe> MemoryInterface for Core<'probe>

source§

fn supports_native_64bit_access(&mut self) -> bool

Does this interface support native 64-bit wide accesses Read more
source§

fn read_word_64(&mut self, address: u64) -> Result<u64, Error>

Read a 64bit word of at address. Read more
source§

fn read_word_32(&mut self, address: u64) -> Result<u32, Error>

Read a 32bit word of at address. Read more
source§

fn read_word_8(&mut self, address: u64) -> Result<u8, Error>

Read an 8bit word of at address.
source§

fn read_64(&mut self, address: u64, data: &mut [u64]) -> Result<(), Error>

Read a block of 64bit words at address. Read more
source§

fn read_32(&mut self, address: u64, data: &mut [u32]) -> Result<(), Error>

Read a block of 32bit words at address. Read more
source§

fn read_8(&mut self, address: u64, data: &mut [u8]) -> Result<(), Error>

Read a block of 8bit words at address.
source§

fn read(&mut self, address: u64, data: &mut [u8]) -> Result<(), Error>

Read data from address. Read more
source§

fn write_word_64(&mut self, addr: u64, data: u64) -> Result<(), Error>

Write a 64bit word at address. Read more
source§

fn write_word_32(&mut self, addr: u64, data: u32) -> Result<(), Error>

Write a 32bit word at address. Read more
source§

fn write_word_8(&mut self, addr: u64, data: u8) -> Result<(), Error>

Write an 8bit word at address.
source§

fn write_64(&mut self, addr: u64, data: &[u64]) -> Result<(), Error>

Write a block of 64bit words at address. Read more
source§

fn write_32(&mut self, addr: u64, data: &[u32]) -> Result<(), Error>

Write a block of 32bit words at address. Read more
source§

fn write_8(&mut self, addr: u64, data: &[u8]) -> Result<(), Error>

Write a block of 8bit words at address.
source§

fn write(&mut self, addr: u64, data: &[u8]) -> Result<(), Error>

Write a block of 8bit words at address. May use 64 bit memory access, so should only be used if reading memory locations that don’t have side effects. Generally faster than MemoryInterface::write_8. Read more
source§

fn supports_8bit_transfers(&self) -> Result<bool, Error>

Returns whether the current platform supports native 8bit transfers.
source§

fn flush(&mut self) -> Result<(), Error>

Flush any outstanding operations. Read more
source§

fn read_mem_64bit(&mut self, address: u64, data: &mut [u8]) -> Result<(), Error>

Reads bytes using 64 bit memory access. Address must be 64 bit aligned and data must be an exact multiple of 8.
source§

fn read_mem_32bit(&mut self, address: u64, data: &mut [u8]) -> Result<(), Error>

Reads bytes using 32 bit memory access. Address must be 32 bit aligned and data must be an exact multiple of 4.
source§

fn write_mem_64bit(&mut self, address: u64, data: &[u8]) -> Result<(), Error>

Writes bytes using 64 bit memory access. Address must be 64 bit aligned and data must be an exact multiple of 8.
source§

fn write_mem_32bit(&mut self, address: u64, data: &[u8]) -> Result<(), Error>

Writes bytes using 32 bit memory access. Address must be 32 bit aligned and data must be an exact multiple of 8.

Auto Trait Implementations§

§

impl<'probe> !RefUnwindSafe for Core<'probe>

§

impl<'probe> !Send for Core<'probe>

§

impl<'probe> !Sync for Core<'probe>

§

impl<'probe> Unpin for Core<'probe>

§

impl<'probe> !UnwindSafe for Core<'probe>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more