blackmagic-debug / blackmagic

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

Feature: BMP platform Cortex-M exception handlers #1957

Open ALTracer opened 1 month ago

ALTracer commented 1 month ago

Detailed description

I'm not sure if platform_request_boot() to request "stay in DFU" is better than just rebooting the probe, or if USB D+ pulse low is needed to trigger re-enumeration on some platforms, so I coded a direct scb_reset_system() instead. Future PRs could unwind the stack (I have tried implementing just that) and/or record crash dumps to SRAM or SPI flash or UART. If MPU is enabled by platform, to e.g. catch NULL dereferences, then there's a simple handler for that, too. Platforms should enable separate SCB->SHCSR BusFault and UsageFault bits for this code to distinguish between them.

Note I don't spin the UART/DMA/TIM or USB device IRQ handlers, but it technically could also be done to keep UART DMA and USB (DFU runtime stub, CDC-ACM, suspend/reset) working for a while for logging purposes. Notably sys_tick_handler() on native indirectly checks for Vtpwr undervoltage. I have not tested how this behaves yet.

Your checklist for this pull request

Closing issues