System:
DA14683
SDK = 1.0.14.1081 (last updated in 2018)
Situation:
I understand that having the debugger attached will keep the system from going to sleep. What I am wondering is, Where in the SDK sleep code is it checking for an attached debugger and what sort of error/response happens when the SDK detects the debugger is attached?
Questions:
1) Where in the SDK sleep code is it checking if there is an attached debugger (file and line please)?
2) If the SDK sleep code detects an attached debugger, what does it do? Does it set any flags, return an error value, or just abort sleep without any explanation?
3) If there a way to detect that the system aborted sleep because of an attached debugger?
Hi Nathan,
Pleas check lines 1555-1559 in sys_power_mgr.c files.
In general, this has nothing to do with the SW side and when the debugger is attached, the HW does not allow the system to go to sleep.
You will always need to run the FW with the debugger de-attached. By doing this, you will be 100% that the sleep is not aborted due to the debugger.
Regards,
PM_Renesas
Thank you for the response.
In case anyone else cares, here is the code mentioned above at sys_power_mgr.c lines 1555-1559:
/* * Disable watchdog when the debugger is attached or when deep sleep is prohibited * and the only monitored task is the IDLE task. In both cases System PD would * remain active causing the watchdog to hit. */ if (dg_configUSE_WDOG == 1) { if (hw_cpm_is_debugger_attached() || (!allow_entering_sleep && sys_watchdog_monitor_mask_empty())) { hw_watchdog_freeze(); } }
The hw_cpm_is_debugger_attached() function lives in the hw_cpm.h file:
/** * \brief Check if the debugger is attached. * * \return true, if the debugger is attached, else false. * */ __STATIC_INLINE bool hw_cpm_is_debugger_attached(void) __attribute__((always_inline)); __STATIC_INLINE bool hw_cpm_is_debugger_attached(void) { return (REG_GETF(CRG_TOP, SYS_STAT_REG, DBG_IS_ACTIVE) != 0); }
Doing a code search, the hw_cpm_is_debugger_attached() function is called nowhere else other than that one time listed above in sys_power_mgr.c.
If I dig in deeper...
REG_GETF(CRG_TOP, SYS_STAT_REG, DBG_IS_ACTIVE)
... is the code line that is doing the query if the debugger is attached. This code shows up multiple other times by itself in the following places:
sys_power_mgr.c: "void pm_wait_debugger_detach(sleep_mode_t mode)"
hw_watchdog.c: "__RETAINED_CODE void hw_watchdog_handle_int(unsigned long *exception_args)"
New question:
1) If the system rejects sleep in hardware if the debugger is attached, what state does that leave the system when it wakes back up? Does it set a flag to notify why sleep was canceled? Does it throw a specific callback? Etc.
2) What wake up path does it use in this case of the debugger attachment not allowing sleep (what interrupt does it throw?)