|
4 | 4 | //!
|
5 | 5 | //! - Before main initialization of the `.bss` and `.data` sections
|
6 | 6 | //!
|
7 |
| -//! - An overridable (\*) `panic_fmt` implementation that prints overs the ITM |
8 |
| -//! or through semihosting depending on the enabled Cargo feature. |
| 7 | +//! - An overridable (\*) `panic_fmt` implementation that prints to the ITM or |
| 8 | +//! to the host stdout (through semihosting) depending on which Cargo feature |
| 9 | +//! has been enabled: `"panic-over-itm"` or `"panic-over-semihosting"`. |
9 | 10 | //!
|
10 |
| -//! - Minimal `start` lang item, to support vanilla `fn main()`. NOTE the |
| 11 | +//! - A minimal `start` lang item, to support vanilla `fn main()`. NOTE the |
11 | 12 | //! processor goes into "reactive" mode (`loop { asm!("wfi") }`) after
|
12 | 13 | //! returning from `main`.
|
13 | 14 | //!
|
| 15 | +//! - An opt-in linker script (`"linker-script"` Cargo feature) that encodes |
| 16 | +//! the memory layout of a generic Cortex-M microcontroller. This linker |
| 17 | +//! script is missing the definition of the FLASH and RAM memory regions of |
| 18 | +//! the device. This missing information must be supplied through a `memory.x` |
| 19 | +//! linker script of the form: |
| 20 | +//! |
| 21 | +//! ``` text |
| 22 | +//! MEMORY |
| 23 | +//! { |
| 24 | +//! FLASH : ORIGIN = 0x08000000, LENGTH = 128K |
| 25 | +//! RAM : ORIGIN = 0x20000000, LENGTH = 8K |
| 26 | +//! } |
| 27 | +//! ``` |
| 28 | +//! |
| 29 | +//! - A default exception handler tailored for debugging and that provides |
| 30 | +//! access to the stacked registers under the debugger. By default, all |
| 31 | +//! exceptions (\*\*) are serviced by this handler but this can be overridden |
| 32 | +//! on a per exception basis by opting out of the "exceptions" Cargo feature |
| 33 | +//! and then defining the following `struct` |
| 34 | +//! |
| 35 | +//! ``` ignore,no_run |
| 36 | +//! use cortex_m::exception; |
| 37 | +//! |
| 38 | +//! #[link_section = ".rodata.exceptions"] |
| 39 | +//! #[used] |
| 40 | +//! static EXCEPTIONS: exception::Handlers = exception::Handlers { |
| 41 | +//! hard_fault: my_override, |
| 42 | +//! nmi: another_handler, |
| 43 | +//! ..exception::DEFAULT_HANDLERS |
| 44 | +//! }; |
| 45 | +//! ```` |
| 46 | +//! |
14 | 47 | //! (\*) To override the `panic_fmt` implementation, simply create a new
|
15 | 48 | //! `rust_begin_unwind` symbol:
|
16 | 49 | //!
|
|
24 | 57 | //! ..
|
25 | 58 | //! }
|
26 | 59 | //! ```
|
| 60 | +//! |
| 61 | +//! (\*\*) All the device specific exceptions, i.e. the interrupts, are left |
| 62 | +//! unpopulated. You must fill that part of the vector table by defining the |
| 63 | +//! following static (with the right memory layout): |
| 64 | +//! |
| 65 | +//! ``` ignore,no_run |
| 66 | +//! #[link_section = ".rodata.interrupts"] |
| 67 | +//! #[used] |
| 68 | +//! static INTERRUPTS: SomeStruct = SomeStruct { .. } |
| 69 | +//! ``` |
27 | 70 |
|
28 | 71 | #![deny(missing_docs)]
|
29 | 72 | #![deny(warnings)]
|
|
0 commit comments