I want to switch off background JTAG polling when OpenOCD is idle then switch it on when before any target activity e.g. step, run, etc.
I have Tcl handlers for the 'halted', 'debug-halted' & 'gdb-end' events to run the 'poll off' command and a handler for 'debug-resumed' which issues the 'poll on' command. After flashing the target I can see the halted handler(s) get called but the poll-off command seems to be overridden. Even issuing 'poll off' in the 'gdb-flash-write-end' handler has no effect. If I run 'poll off' from Telnet when the target is idle after flashing then polling does stop. Polling restarts when I then step or run the target and stops again when I halt the target, as expected.
The start/stop polling works it's just the initial idle state after flashing the target where it's halted and ready to be stepped/run for the first time where the polling won't stop.
Any ideas what I can do to overcome this ?