Expand description
Support for in-kernel debugging.
For printing, this module uses an internal buffer to write the strings into.
If you are writing and the buffer fills up, you can make the size of
output_buffer larger.
Before debug interfaces can be used, the board file must assign them hardware:
ⓘ
kernel::debug::assign_gpios(
Some(&sam4l::gpio::PA[13]),
Some(&sam4l::gpio::PA[15]),
None,
);
components::debug_writer::DebugWriterComponent::new(
uart_mux,
create_capability!(kernel::capabilities::SetDebugWriterCapability)
)
.finalize(components::debug_writer_component_static!());An alternative to using the default DebugWriterComponent, which defaults
to sending over UART, is to implement a custom DebugWriter that can be
used for other types of output. For example a simple “endless” FIFO with
fixed “push” address:
ⓘ
use kernel::debug::DebugWriter;
pub struct SyncDebugWriter;
impl DebugWriter for SyncDebugWriter {
fn write(&self, buf: &[u8], _overflow: &[u8]) -> usize {
let out_reg = 0x4000 as *mut u8; // Replace with the actual address of the FIFO
for c in buf.iter() {
unsafe { out_reg.write_volatile(*c) };
}
buf.len()
}
fn available_len(&self) -> usize {
usize::MAX
}
fn to_write_len(&self) -> usize {
0
}
fn publish(&self) -> usize {
0
}
fn flush(&self, _writer: &mut dyn IoWrite) { }And instantiate it in the main board file:
ⓘ
let debug_writer = static_init!(
utils::SyncDebugWriter,
utils::SyncDebugWriter
);
kernel::debug::set_debug_writer_wrapper(
static_init!(
kernel::debug::DebugWriterWrapper,
kernel::debug::DebugWriterWrapper::new(debug_writer)
),
);§Example
debug!("Yes the code gets here with value {}", i);
debug_verbose!("got here"); // Includes message count, file, and line.
debug_gpio!(0, toggle); // Toggles the first debug GPIO.
Yes the code gets here with value 42
TOCK_DEBUG(0): /tock/capsules/src/sensys.rs:24: got hereStatics§
- DEBUG_
GPIOS - Object to hold the assigned debugging GPIOs.
Traits§
- Debug
Writer - A trait for writing debug output.
- IoWrite
- Implementation of
std::io::Writeforno_std.
Functions§
- assign_
gpios ⚠ - Map up to three GPIO pins to use for debugging.
- debug_
available_ len - Return how many bytes are remaining in the internal debug buffer.
- debug_
print - Write a debug message without a trailing newline.
- debug_
println - Write a debug message with a trailing newline.
- debug_
slice - Write a
ReadableProcessSliceto the debug output. - debug_
verbose_ print - Write a debug message with file and line information without a trailing newline.
- debug_
verbose_ println - Write a debug message with file and line information with a trailing newline.
- flush⚠
- Flush any stored messages to the output writer.
- initialize_
debug_ writer_ wrapper - Initialize the static debug writer.
- initialize_
debug_ ⚠writer_ wrapper_ unsafe - Initialize the static debug writer.
- panic⚠
- Tock default panic routine.
- panic_
banner ⚠ - Lightweight prints about the current panic and kernel version.
- panic_
begin ⚠ - Generic panic entry.
- panic_
blink_ forever - Blinks a recognizable pattern forever.
- panic_
cpu_ ⚠state - Print current machine (CPU) state.
- panic_
print ⚠ - Tock panic routine, without the infinite LED-blinking loop.
- panic_
process_ ⚠info - More detailed prints about all processes.
- set_
debug_ writer_ wrapper - Function used by board main.rs to set a reference to the writer.