therealprof / panic-ramdump

A Rust `no_std` embedded panic crate to record the panic reason in RAM
Apache License 2.0
10 stars 2 forks source link

Initial implementation #2

Closed jamesmunns closed 4 years ago

jamesmunns commented 5 years ago

Implements #1. Not yet tested or really well thought about yet.

example memory.x changes:

BEFORE

MEMORY
{
  /* FLASH and RAM are mandatory memory regions */
  /* Update examples/data_overflow.rs if you change these sizes. */
  FLASH : ORIGIN = 0x00000000, LENGTH = 256K
  RAM : ORIGIN = 0x20000000, LENGTH = 64K
}

AFTER

MEMORY
{
  /* FLASH and RAM are mandatory memory regions */
  /* Update examples/data_overflow.rs if you change these sizes. */
  FLASH : ORIGIN = 0x00000000, LENGTH = 256K
  RAM : ORIGIN = 0x20000000, LENGTH = 63K
  PANDUMP: ORIGIN = 0x20010000, LENGTH = 1K
}

_panic_dump_start = ORIGIN(PANDUMP);
_panic_dump_end = ORIGIN(PANDUMP) + LENGTH(PANDUMP);
jamesmunns commented 4 years ago

@korken89 implemented unaligned pointer methods.

@therealprof changed function signature to return a byte slice, added an optional utf8 feature which enables checked utf8 strings. In a totally non-scientific test, this feature seemed to add 1KiB to the code size. At opt-level=3:

Before (without utf8):

arm-none-eabi-size target/thumbv7em-none-eabihf/release/timer-uart
   text    data     bss     dec     hex filename
  19714    4136       4   23854    5d2e target/thumbv7em-none-eabihf/release/timer-uart

After (with utf8):

arm-none-eabi-size target/thumbv7em-none-eabihf/release/timer-uart
   text    data     bss     dec     hex filename
  20714    4136       4   24854    6116 target/thumbv7em-none-eabihf/release/timer-uart
jamesmunns commented 4 years ago

This was also tested on the nrf52832, specifically on this stream: https://youtu.be/KT6VnwuouPY.

This should be ready to merge, or if you don't want it here, I'll fork this and make another crate as-is.

therealprof commented 4 years ago

@jamesmunns Considering that this implements a somewhat different idea and is not a drop-in compatible change I think it would make sense to have this in another crate. How about calling this panic-persist?

jamesmunns commented 4 years ago

Will do!