This is often caused by the kernel power management, which turns the on-chip debug module off while going to power saving mode.
Possible solutions are:
- Re-compile the kernel with disabled power management.
- Disable the idle states for all cores from the Linux shell e.g.
echo 1 > /sys/devices/system/cpu/cpu
- remove the idle-states property from the device tree if available
- add a command line parameter that disables power management if supported by the used Linux distribution. This can be done for instance in some NXP Linux distributions for i.MX using the "jtag=on" parameter. In some other distributions, the "nohlt" parameter is used. Please refer to the documentation of the kernel command line parameters of your Linux distribution for more information.