Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: BMP platform Cortex-M exception handlers #1957

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ALTracer
Copy link
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant