Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

Feature: BMP platform Cortex-M exception handlers#1957

Open
ALTracer wants to merge 257 commits into
blackmagic-debug:mainfrom
ALTracer:feature/fault_handlers
Open

Feature: BMP platform Cortex-M exception handlers#1957
ALTracer wants to merge 257 commits into
blackmagic-debug:mainfrom
ALTracer:feature/fault_handlers

Conversation

@ALTracer
Copy link
Copy Markdown
Contributor

Detailed description

  • This is a new feature.
  • The existing problem is BMPs hanging upon a HardFault etc. with no indication of that happening.
  • This PR solves it by overriding default libopencm3-provided weak blocking_handler()'s with meaningful handlers which set a morse message and spin the systick (because of priority) for 10 seconds then reboot the probe.

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

@ALTracer ALTracer force-pushed the feature/fault_handlers branch 2 times, most recently from 1e868ae to 3dd0927 Compare November 1, 2024 17:26
@ALTracer ALTracer force-pushed the feature/fault_handlers branch from 3dd0927 to 75968ed Compare December 30, 2024 11:32
@ALTracer ALTracer force-pushed the feature/fault_handlers branch from 75968ed to 928fb9f Compare February 9, 2025 18:39
@ALTracer ALTracer mentioned this pull request Mar 30, 2025
6 tasks
dragonmux added 25 commits March 8, 2026 16:27
…p USB, timing, and setting up the correct vector table address
emeb and others added 29 commits May 5, 2026 04:21
* Any delays necessary will exist at callsites
* Most platforms do not have this delay
* Duration of 10000 iterations depends on Hclk and architecture (stlinkv3 CM7 may complete faster)
The first was that we forgot a `!` on a `calloc` check, the second is we were doing a `CMD_LSC_READ_CRC` vs a `CMD_LSC_RESET_CRC`
It seems to have inexplicably changed? It was 0x5U, but now it's 0x1U? I have no idea what happened.
…he `final_tms` adjustment for `bits` into account
 * All of SRAM is declared regardless of parity checking
 * Two SRAM sizes are detected from idcode
 * Flash size detected from F_SIZE (should be readable)
 * DEBUG sleep and watchdog bits handling is enabled
… function that requires `target` to be a valid non-NULL pointer
…rd response when the argument decoder fails
@ALTracer ALTracer force-pushed the feature/fault_handlers branch from fcbf2e2 to f713ebb Compare May 22, 2026 19:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants