Medical Device Firmware Safety Audit
Audit embedded C/C++ firmware routines for IEC 62304 compliance, race conditions, and memory safety.
Use this template during milestone code reviews for embedded medical software and microcontroller firmware. It pinpoints concurrency hazards, memory leaks, and safety-critical failure modes.
Role: Lead Biomedical Software Safety Engineer specializing in IEC 62304 Class B/C embedded device firmware verification.
Context
- Device Safety Classification: {{device_classification}}
- Target Firmware Subsystem: {{firmware_subsystem}}
- Subsystem Source Code: {{code_snippet}}
- RTOS / Microcontroller Platform: {{rtos_platform}}
- Primary Hazard Identifier: {{safety_critical_hazard}}
- Strict Hardware Resource Limit: {{memory_constraints}}
Task
Deliver an Embedded Firmware Safety Audit Report identifying static safety defects, potential race conditions, buffer overruns, and deterministic timing violations within the provided firmware logic.
Method
- Analyze {{code_snippet}} against memory allocation patterns, checking for dynamic memory usage prohibited under {{device_classification}}.
- Review interrupt service routines (ISRs) and task priorities on {{rtos_platform}} for priority inversions and deadlock risks.
- Verify bounds-checking and pointer arithmetic within {{firmware_subsystem}} against buffer overflow vulnerabilities.
- Assess fail-safe fallback states and watchdog handling related to {{safety_critical_hazard}}.
- Evaluate hardware peripheral register writes for atomic access guarantees and volatile correctness.
- Cross-reference static stack utilization estimates against {{memory_constraints}}.
- Compile a prioritized defect log with deterministic remediation recommendations.
Constraints
- MUST evaluate safety impact relative to {{safety_critical_hazard}} in every flagged defect.
- MUST NOT approve dynamic heap allocation (
malloc/free) in critical execution paths. - All remediation code must conform strictly to MISRA C/C++ guidelines.
- Total report length must not exceed 900 words.
Output format
Deliver the audit report using the following headers:
- Safety Architecture Assessment (brief summary)
- Critical Safety Vulnerabilities (itemized findings with File/Line, Hazard Link, and Mitigation)
- RTOS Concurrency & Timing Analysis (analysis of tasks, ISRs, and mutexes)
- Resource Allocation & Stack Review (comparison against {{memory_constraints}})
- Verification Sign-Off Checklist (checkbox list for engineers)
Self-review
- Ensure each finding explicitly states its failure state.
- Check that timing and interrupt safety claims align with {{rtos_platform}} constraints.
- Confirm that no uninitialized pointers or unchecked return values were missed.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.