Add JTAG helpers
This commit is contained in:
parent
c378250aba
commit
3415ccd68c
|
@ -119,6 +119,9 @@ jobs:
|
|||
"noserial",
|
||||
"qemu",
|
||||
"noserial,qemu",
|
||||
"jtag",
|
||||
"noserial,jtag",
|
||||
# jtag and qemu together don't make much sense
|
||||
]
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
|
|
|
@ -17,6 +17,9 @@ maintenance = { status = "experimental" }
|
|||
|
||||
[features]
|
||||
noserial = []
|
||||
# Enable JTAG debugging of kernel - enable jtag helpers and
|
||||
# block waiting for JTAG probe attach at the start of kernel main.
|
||||
jtag = []
|
||||
# Build for running under QEMU with semihosting, so various halt/reboot options would for example quit QEMU instead.
|
||||
qemu = ["qemu-exit"]
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
//! JTAG helper functions.
|
||||
|
||||
use cortex_a::asm;
|
||||
|
||||
#[no_mangle]
|
||||
static mut WAIT_FLAG: bool = true;
|
||||
|
||||
/// Wait for debugger to attach.
|
||||
/// Then in gdb issue `> set var *(&WAIT_FLAG) = 0`
|
||||
/// from inside this function's frame to contiue running.
|
||||
pub fn wait_debugger() {
|
||||
use core::ptr::{read_volatile, write_volatile};
|
||||
|
||||
while unsafe { read_volatile(&WAIT_FLAG) } {
|
||||
asm::nop();
|
||||
}
|
||||
// Reset the flag so that next jtag::wait_debugger() would block again.
|
||||
unsafe { write_volatile(&mut WAIT_FLAG, true) }
|
||||
}
|
|
@ -8,6 +8,8 @@
|
|||
use cortex_a::asm;
|
||||
|
||||
mod boot;
|
||||
#[cfg(feature = "jtag")]
|
||||
pub mod jtag;
|
||||
pub mod memory;
|
||||
pub mod traps;
|
||||
|
||||
|
|
|
@ -111,6 +111,9 @@ fn init_uart_serial() {
|
|||
/// `arch` crate is responsible for calling it.
|
||||
#[inline]
|
||||
pub fn kmain() -> ! {
|
||||
#[cfg(feature = "jtag")]
|
||||
jtag::wait_debugger();
|
||||
|
||||
#[cfg(not(feature = "noserial"))]
|
||||
init_uart_serial();
|
||||
|
||||
|
|
Loading…
Reference in New Issue