blackmagic-debug / blackmagic

In application debugger for ARM Cortex microcontrollers.
GNU General Public License v3.0
3.22k stars 767 forks source link

Feature: SRAM layout reorganisation #1830

Closed dragonmux closed 3 months ago

dragonmux commented 4 months ago

Detailed description

This PR implements a change to the SRAM layout designed to improve the diagnostics and detectability of heap and stack overflows by placing them at the ends of SRAM. This is done such that when each get exhausted, the cause of that exhaustion will become evident by the probe crashing and entering the hard fault handler.

This gives us free diagnostics for when these conditions occur and, with some changes to the hard fault handler that can be done in a follow-up, the ability to automatically reboot a probe when this happens, or catch it and halt if a debugger is attached. Alternatively, we can use a blink pattern on the LEDs designed to indicate this kind of crash.

This should prevent any further "maybe it crashed, but we're not sure, it's acting real strange" kind of issues.

Your checklist for this pull request

Closing issues

HrMitrev commented 4 months ago

Hi! when building with make I get the following error:

make PROBE_HOST=stlink BMP_BOOTLOADER=1 ENABLE_RTT=1 STLINK_V2_ISOL=0 ENABLE_DEBUG=0 OPT_FLAGS='-Os' -j12
make[1]: warning: -j12 forced in submake: resetting jobserver mode.
  BUILD   lib/stm32/f4
  BUILD   lib/stm32/f1
  BUILD   lib/stm32/f7
  BUILD   lib/lm4f
make[2]: Nothing to be done for 'all'.
make[2]: Nothing to be done for 'all'.
make[2]: Nothing to be done for 'all'.
make[2]: Nothing to be done for 'all'.
make[1]: warning: -j12 forced in submake: resetting jobserver mode.
 GEN      include/version.h
  CC      command.c
  CC      remote.c
  CC      platforms/common/stm32/dfucore.c
  CC      platforms/common/usb.c
  LD      blackmagic_dfu.elf
  LD      blackmagic.elf
c:/tools/scoop/apps/gcc-arm-none-eabi/current/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: cannot open linker script file ../common/blackmagic.ld: No such file or directory
collect2.exe: error: ld returned 1 exit status
make[1]: *** [platforms/stlink/Makefile.inc:63: blackmagic_dfu.elf] Error 1
make[1]: *** Waiting for unfinished jobs....
c:/tools/scoop/apps/gcc-arm-none-eabi/current/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: cannot open linker script file ../common/blackmagic.ld: No such file or directory
collect2.exe: error: ld returned 1 exit status
make[1]: *** [Makefile:162: blackmagic.elf] Error 1
make: *** [Makefile:17: all] Error 2
dragonmux commented 4 months ago

The Makefile build error should now be solved across all platforms.