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>
impl<'probe> Core<'probe>
sourcepub fn new(
core: impl CoreInterface + 'probe,
state: &'probe mut CoreState
) -> Core<'probe>
pub fn new(
core: impl CoreInterface + 'probe,
state: &'probe mut CoreState
) -> Core<'probe>
Create a new Core
.
sourcepub fn create_state(id: usize, options: CoreAccessOptions) -> CoreState
pub fn create_state(id: usize, options: CoreAccessOptions) -> CoreState
Creates a new CoreState
sourcepub fn wait_for_core_halted(&mut self, timeout: Duration) -> Result<(), Error>
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.
sourcepub fn core_halted(&mut self) -> Result<bool, Error>
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.
sourcepub fn halt(&mut self, timeout: Duration) -> Result<CoreInformation, Error>
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.
sourcepub fn reset(&mut self) -> Result<(), Error>
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.
sourcepub fn reset_and_halt(
&mut self,
timeout: Duration
) -> Result<CoreInformation, Error>
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.
sourcepub fn step(&mut self) -> Result<CoreInformation, Error>
pub fn step(&mut self) -> Result<CoreInformation, Error>
Steps one instruction and then enters halted state again.
sourcepub fn status(&mut self) -> Result<CoreStatus, Error>
pub fn status(&mut self) -> Result<CoreStatus, Error>
Returns the current status of the core.
sourcepub 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>,
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.
sourcepub fn write_core_reg<T>(
&mut self,
address: RegisterId,
value: T
) -> Result<(), Error>where
T: Into<RegisterValue>,
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.
sourcepub fn available_breakpoint_units(&mut self) -> Result<u32, Error>
pub fn available_breakpoint_units(&mut self) -> Result<u32, Error>
Returns all the available breakpoint units of the core.
sourcepub fn debug_on_sw_breakpoint(&mut self, enabled: bool) -> Result<(), Error>
pub fn debug_on_sw_breakpoint(&mut self, enabled: bool) -> Result<(), Error>
Configure the debug module to ensure software breakpoints will enter Debug Mode.
sourcepub fn registers(&self) -> &'static RegisterFile
pub fn registers(&self) -> &'static RegisterFile
Returns a list of all the registers of this core.
sourcepub fn set_hw_breakpoint(&mut self, address: u64) -> Result<(), Error>
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.
sourcepub fn clear_hw_breakpoint(&mut self, address: u64) -> Result<(), Error>
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.
sourcepub fn clear_all_hw_breakpoints(&mut self) -> Result<(), Error>
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
.
sourcepub fn architecture(&self) -> Architecture
pub fn architecture(&self) -> Architecture
Returns the architecture of the core.
sourcepub fn instruction_set(&mut self) -> Result<InstructionSet, Error>
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
sourcepub fn fpu_support(&mut self) -> Result<bool, Error>
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>
impl<'probe> MemoryInterface for Core<'probe>
source§fn supports_native_64bit_access(&mut self) -> bool
fn supports_native_64bit_access(&mut self) -> bool
source§fn read_word_64(&mut self, address: u64) -> Result<u64, Error>
fn read_word_64(&mut self, address: u64) -> Result<u64, Error>
address
. Read moresource§fn read_word_32(&mut self, address: u64) -> Result<u32, Error>
fn read_word_32(&mut self, address: u64) -> Result<u32, Error>
address
. Read moresource§fn read_64(&mut self, address: u64, data: &mut [u64]) -> Result<(), Error>
fn read_64(&mut self, address: u64, data: &mut [u64]) -> Result<(), Error>
address
. Read moresource§fn read_32(&mut self, address: u64, data: &mut [u32]) -> Result<(), Error>
fn read_32(&mut self, address: u64, data: &mut [u32]) -> Result<(), Error>
address
. Read moresource§fn read_8(&mut self, address: u64, data: &mut [u8]) -> Result<(), Error>
fn read_8(&mut self, address: u64, data: &mut [u8]) -> Result<(), Error>
address
.source§fn read(&mut self, address: u64, data: &mut [u8]) -> Result<(), Error>
fn read(&mut self, address: u64, data: &mut [u8]) -> Result<(), Error>
address
. Read moresource§fn write_word_64(&mut self, addr: u64, data: u64) -> Result<(), Error>
fn write_word_64(&mut self, addr: u64, data: u64) -> Result<(), Error>
address
. Read moresource§fn write_word_32(&mut self, addr: u64, data: u32) -> Result<(), Error>
fn write_word_32(&mut self, addr: u64, data: u32) -> Result<(), Error>
address
. Read moresource§fn write_word_8(&mut self, addr: u64, data: u8) -> Result<(), Error>
fn write_word_8(&mut self, addr: u64, data: u8) -> Result<(), Error>
address
.source§fn write_64(&mut self, addr: u64, data: &[u64]) -> Result<(), Error>
fn write_64(&mut self, addr: u64, data: &[u64]) -> Result<(), Error>
address
. Read moresource§fn write_32(&mut self, addr: u64, data: &[u32]) -> Result<(), Error>
fn write_32(&mut self, addr: u64, data: &[u32]) -> Result<(), Error>
address
. Read moresource§fn write_8(&mut self, addr: u64, data: &[u8]) -> Result<(), Error>
fn write_8(&mut self, addr: u64, data: &[u8]) -> Result<(), Error>
address
.source§fn write(&mut self, addr: u64, data: &[u8]) -> Result<(), Error>
fn write(&mut self, addr: u64, data: &[u8]) -> Result<(), Error>
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 moresource§fn supports_8bit_transfers(&self) -> Result<bool, Error>
fn supports_8bit_transfers(&self) -> Result<bool, Error>
source§fn read_mem_64bit(&mut self, address: u64, data: &mut [u8]) -> Result<(), Error>
fn read_mem_64bit(&mut self, address: u64, data: &mut [u8]) -> Result<(), Error>
source§fn read_mem_32bit(&mut self, address: u64, data: &mut [u8]) -> Result<(), Error>
fn read_mem_32bit(&mut self, address: u64, data: &mut [u8]) -> Result<(), Error>
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§
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
self
, then passes self.as_mut()
into the pipe
function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds.