-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update GDB settings to enable ITM, add example
- Loading branch information
Showing
8 changed files
with
101 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ Cargo.lock | |
**.bk | ||
**.sw* | ||
bloat_log* | ||
itm.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//! Sends "Hello, world!" through the ITM port 0 | ||
//! | ||
//! ITM is much faster than semihosting. Like 4 orders of magnitude or so. | ||
//! | ||
//! **NOTE** Cortex-M0 chips don't support ITM. | ||
//! | ||
//! You'll have to connect the microcontroller's SWO pin to the SWD interface. Note that some | ||
//! development boards don't provide this option. | ||
//! | ||
//! You'll need [`itmdump`] to receive the message on the host plus you'll need to uncomment two | ||
//! `monitor` commands in the `.gdbinit` file. | ||
//! | ||
//! [`itmdump`]: https://docs.rs/itm/0.2.1/itm/ | ||
//! | ||
//! --- | ||
#![no_main] | ||
#![no_std] | ||
|
||
extern crate panic_itm; | ||
extern crate stm32f407g_disc; | ||
|
||
use cortex_m::{iprintln, Peripherals}; | ||
use cortex_m_rt::entry; | ||
|
||
#[entry] | ||
fn main() -> ! { | ||
let mut p = Peripherals::take().unwrap(); | ||
let stim = &mut p.ITM.stim[0]; | ||
|
||
iprintln!(stim, "Hello, world!"); | ||
|
||
loop {} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
target extended-remote :3333 | ||
|
||
# print demangled symbols | ||
set print asm-demangle on | ||
|
||
# set backtrace limit to not have infinite backtrace loops | ||
set backtrace limit 32 | ||
|
||
# detect unhandled exceptions, hard faults and panics | ||
break DefaultHandler | ||
break HardFault | ||
break rust_begin_unwind | ||
# # run the next few lines so the panic message is printed immediately | ||
# # the number needs to be adjusted for your panic handler | ||
# commands $bpnum | ||
# next 4 | ||
# end | ||
|
||
# *try* to stop at the user entry point (it might be gone due to inlining) | ||
break main | ||
|
||
set mem inaccessible-by-default off | ||
|
||
# monitor arm semihosting enable | ||
|
||
# # send captured ITM to the file itm.fifo | ||
# # (the microcontroller SWO pin must be connected to the programmer SWO pin) | ||
# # 16000000 must match the core clock frequency | ||
# monitor tpiu config internal itm.txt uart off 16000000 | ||
|
||
# # OR: make the microcontroller SWO pin output compatible with UART (8N1) | ||
# # 8000000 is the frequency of the SWO pin | ||
# monitor tpiu config external uart off 8000000 2000000 | ||
|
||
# # enable ITM port 0 | ||
monitor itm port 0 on | ||
|
||
load | ||
|
||
# start the process but immediately halt the processor | ||
stepi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters