rust-embedded / book

Documentation on how to use the Rust Programming Language to develop firmware for bare metal (microcontroller) devices
https://docs.rust-embedded.org/book/
Apache License 2.0
1.12k stars 179 forks source link

Use aligned address to demonstrate HardFault #374

Closed decorator-factory closed 3 months ago

decorator-factory commented 3 months ago

A volatile read from an unaligned pointer results in this when running in debug mode:

panicked at core/src/panicking.rs:221:5:
unsafe precondition(s) violated: ptr::read_volatile requires that the pointer argument is aligned and non-null

I changed the address to be aligned (but still invalid on F3 Discovery), so that the expected output is produced.

P.S. I was confused about the lack of output. Maybe default to panic-semihosting/panic-itm instead of panic-halt in these examples?