Select Git revision
Forked from
Per Lindgren / rtfm-app
Source project has a limited visibility.
bare1.rs 2.63 KiB
//! bare1.rs
//! Simple bare metal tracing
// feature to ensure symbols to be linked
#![feature(used)]
// build without the Rust standard library
#![no_std]
// API to the ARM Cortex M Peripherals
extern crate cortex_m;
// Minimal runtime / startup for Cortex-M microcontrollers
extern crate cortex_m_rt;
// Convenient tracing over semihosting and ITM
#[macro_use]
extern crate cortex_m_debug;
#[inline(never)]
fn main() {
// ITM trace (fast)
// start `itmdump` before `openocd`
ipln!("ITM: Hello World");
// semihosting trace (slow)
// sprintln!("SEMIHOSTING: Hello World");
// to prevent returning
loop {
ipln!("here");
// cortex_m::asm::nop();
// cortex_m::asm::bkpt();
}
}
// 1. build and run the application
// start ITM tracing to console
// > itmdump /tmp/itm.log
// start openocd (in my case...)
// > openocd -f interface/stlink.cfg -f target/stm32f4x.cfg
//
// when debugging the application it should get stuck in the
// loop, (press pause/suspend to verify this).
// what is the output in the ITM console
// ** your answer here **
//
// what is the output in the semihosting (openocd) console
// ** your answer here **
//
// commit your answers (bare1_1)
//
// 2. inspecting the assembly
// what is shown in the Dissasmbly view, what instruction is executing
// (if you are NOT under eclipse, then give the command in gdb console
// (gdb) disassemble
// ** your answer here **
//
// commit your answers (bare1_2)
//
// 3. now remove the comment line 30.
// rebuild and debug, pause the program.
// what is shown in the Dissasmbly view, what instruction is executing
// ** your answer here **
//
// commit your answers (bare1_3)
//
// 4. now remeve the comment line 31
// what is shown in the Dissasmbly view, what instruction is executing
// ** your answer here **
//
// commit your answers (bare1_4)
//
// 5. release mode (optimized builds)
// rebuild bare1 in release (optimized mode)
// compare the generated assembly for the loop
// between the dev (unoptimized) and release (optimized) build
// in Atollic/eclipse the easiest way is to build the target using
// > xargo build --release --examples
// in gdb console
// > file target/thumbv7em-none-eabihf/release/examples/bare1
// so l
// (which sources/executes the gbd script l, which loads the file)
// c
// (to continue executing)
// ** your answer here **
//
// commit your answers (bare1_5)
// As we are not using interrupts, we just register a dummy catch all handler
#[link_section = ".vector_table.interrupts"]
#[used]
static INTERRUPTS: [extern "C" fn(); 240] = [default_handler; 240];
extern "C" fn default_handler() {
// cortex_m::asm::bkpt();
}