The “Cannot stop Cortex-M device” error when trying to debug RTX applications on Cortex-M1 devices is a common issue developers face. This error occurs because there is a mismatch between the debug configuration in your IDE and the actual setup on the target device. The good news is that this error can be easily fixed once you understand what is causing it.
What Causes the “Cannot Stop Device” Error
There are a few key reasons why you may see this error when trying to debug your RTX app on a Cortex-M1 chip:
- The debug interface on the target device is not enabled or configured properly.
- The debug mode settings in your IDE don’t match the settings on the device.
- RTX OS aware debugging is not enabled in your IDE.
- The RTX kernel version on the device is different from what the IDE expects.
The first step in debugging this issue is to understand exactly why the IDE is unable to halt the target device. Let’s look at each of these causes in more detail.
Debug Interface Not Enabled/Configured Properly
For debugging to work, the debug interface on the Cortex-M1 chip needs to be enabled and set up correctly. This includes things like:
- The debug port pins are connected and enabled.
- The debug clock is configured properly.
- Any debug power/reset signals are connected.
- The chip debug access port (DAP) is functional.
If any of these debug interface settings are incorrect or disabled, the IDE will not be able to halt and control the target device, resulting in the “cannot stop device” error.
Debug Mode Mismatch
Another common reason for this error is the debug mode configuration doesn’t match between the IDE and the target. Cortex-M devices can be configured in different debug modes like Software Debug Mode or Hardware Debug Mode. The mode used must be the same in both the IDE and on the device itself.
For example, if the IDE is configured for Software Debug but the chip is in Hardware Debug mode, the IDE will not be able to halt the core. This mode mismatch leads to the confusing “cannot stop device” error even though the debug interface is working.
RTX OS Aware Debugging Not Enabled
When debugging RTOS-based applications, you need to enable OS aware debugging in your IDE. This allows the debugger to understand RTOS constructs like threads, task switches, mutexes, etc. If OS aware debugging is not enabled, the IDE will not be able to properly halt threads and debug the RTX application code.
Forgetting to enable RTX debugging support in the IDE is a very common oversight that will result in not being able to stop program execution on the device.
RTX Version Mismatch
Lastly, a version mismatch between the RTX kernel running on the device and the kernel version expected by the IDE can also lead to this error. The IDE relies on debug symbols and definitions from a specific RTX version to enable OS aware debugging. If the version on the device doesn’t align with what the IDE expects, it will not be able to debug the application properly.
So in summary, the “cannot stop device” error occurs because the IDE is unable to halt and control code execution on the target device. This is usually caused by incorrect debug interface configuration, debug mode mismatches, lacking OS aware debug support, or RTX version differences.
Fixing the “Cannot Stop Device” Error
Once you know the underlying cause, fixing the issue is straightforward. Here are the steps to resolve a “cannot stop device” error when debugging RTX on Cortex-M1:
- Verify debug interface setup: Double check that the debug port, clock, power, and DAP are configured correctly on the device based on the reference manual.
- Confirm debug mode: Ensure the Cortex-M1 debug mode (SWD vs HWD) matches what the IDE expects and is configured for.
- Enable RTX OS aware debugging: In your IDE, make sure OS support for RTX is enabled under the debug configuration or project settings.
- Check RTX version: Verify the IDE and device RTX version match and update as needed.
- Restart debugging session: Cycle the debug power or restart the IDE session to re-initialize the debug link.
- Update IDE and firmware: As a last resort, update the IDE software and device firmware to the latest versions.
Going through these steps methodically will usually reveal the specific issue causing the error. The most common fixes are enabling RTX debugging in the IDE, standardizing the debug mode, and ensuring the debug interface signals are connected properly.
Verifying Debug Configuration
It can be helpful to verify the entire debug configuration step-by-step to isolate the mismatch or incorrect setting leading to the error:
- Examine IDE debug settings: Debug mode (SWD/HWD), symbol file, RTOS awareness, device selection, etc.
- Check device docs: Review chip reference manual for supported debug modes and configuration.
- Verify board schematic: Confirm debug port is connected to chip and all signals are routed properly.
- Check firmware config: Examine initialization code that sets up clock, pins, DAP, and debug mode.
- Compare configs: Use a checklist to compare IDE vs hardware debug configuration side-by-side.
- List assumptions: Note assumptions made about debug setup that may require validation.
Performing a thorough debug configuration audit will surface any incorrect settings, documentation errors, firmware bugs, or invalid assumptions that could be triggering the error.
Debug Interface Issues
If you confirm a configuration mismatch is not the root cause, the next step is to troubleshoot the target device debug interface and connections.
Verifying Debug Port
Start by validating the debug port pins are properly connected from the target Cortex-M1 device to the debug host computer:
- Check datasheet and pinout diagram for debug pins (SWCLK, SWDIO, nRESET, DBGRESET).
- Confirm right pins are wired to debug connector on board.
- Check for shorts or opens on debug signal connections.
- Measure reset and clock signals with oscilloscope if available.
- Try wiggling debug connector to check for intermittent contacts.
A loose, shorted, or improperly routed debug pin can certainly cause failure to halt the processor. The debug port wiring needs to be scrutinized closely.
Examining Power/Resets
Next, power and reset signals should be validated:
- Ensure debug power (VDDD) is within specification and clean.
- Check that nRESET and DBGRESET are properly asserted and toggled.
- Verify VDD reset supervisor configuration if powering debug separately.
- Load test power line with adjacent GPIO toggling to confirm noise-free supply.
Unreliable power or incorrect reset signaling could prevent proper debug initialization. This needs to be eliminated as a potential culprit.
Debug Access Port (DAP)
Finally, check that the Cortex-M1 DAP is operational:
- Confirm DAPCLK clock frequency meets requirements.
- Check for initialized DAP in ARM CoreSight debug logs.
- Toggle TEST and RESET signals and check for response.
- Attempt basic JTAG/SWD DAP register read/write operations.
- Verify SWJ-DP and SW-DP interfaces work if available.
A non-functional debug AP subsystem on the chip could certainly cause debug to fail. But this is relatively rare compared to the other common issues covered earlier.
Debug Workflow Tips
Here are some additional tips for smoothing out the debug process when working with RTX on Cortex-M1 chips:
- Review documentation thoroughly: Chip errata, reference manual, RTX user guide. Know the hardware and software.
- Use debug checklists: Checklist for verifying debug setup prevents mistakes.
- Validate on known good board: Try to reproduce issue on proven test board first.
- Start with simple non-RTOS code: Confirm basic debug works before adding OS complexity.
- Add debugging code: Use GPIOs, printfs, and SWV to get runtime debug data.
- Know OS debug limitations: Be aware of RTX debug limitations like 4 breakpoint hardware restriction.
- Leverage tools fully: Make use of IDE features like live peripheral register views.
- Don’t make assumptions: Question and validate every aspect of debug setup.
- Check stack usage: Make sure thread stacks don’t overflow and corrupt memory.
Following best practices for Cortex-M debugging eliminates many common issues developers can run into. Proper preparation and diligence upfront pays off when tracking down those inevitable debug problems.
Conclusion
The “cannot stop device” error when debugging RTX code on Cortex-M1 processors is usually caused by incorrect debug configuration or interface issues. Following a methodical debug validation process can quickly identify the specific mismatch or connection problem causing the error. Double checking the IDE debug mode, verifying debug signals, enabling OS support, and ruling out interface faults will get your RTX debugging back on track.
With robust debug validation and sound troubleshooting technique, the cryptic “cannot stop device” error doesn’t need to become a showstopper. Carefully verifying the entire debug toolchain from IDE to firmware to hardware will uncover the issue and let you continue building your RTX-based Cortex-M1 application.