west: runners: jlink: Disable DAP after flashing

Disables the Debug-Access-Port of the microcontroller after flashing.
If not disabled, the DAP consumes ~1.6mA until the debugger disables it
or a hard power cycle is applied.

The DAP is typically automatically disabled after flashing, but if other
instances of JLink software are running (not connected), it will not be.

The added command resets the value of the CTRL/STAT register of the DAP.
This clears the CSYSPWRUPREQ and CDBGPRWUPREQ bits, leaving the debug
hardware free to power off the appropriate hardware. In no way does it
hinder the ability to later connect to the device for debugging.

This resolves the jlink portion of #26139

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
This commit is contained in:
Jordan Yates 2020-06-12 21:35:07 +10:00 committed by Carles Cufí
parent 611fa04847
commit 9c39a93014
1 changed files with 10 additions and 0 deletions

View File

@ -159,6 +159,16 @@ class JLinkBinaryRunner(ZephyrBinaryRunner):
lines.append('r') # Reset and halt the target
lines.append('g') # Start the CPU
# Reset the Debug Port CTRL/STAT register
# Under normal operation this is done automatically, but if other
# JLink tools are running, it is not performed.
# The J-Link scripting layer chains commands, meaning that writes are
# not actually performed until after the next operation. After writing
# the register, read it back to perform this flushing.
lines.append('writeDP 1 0')
lines.append('readDP 1')
lines.append('q') # Close the connection and quit
self.logger.debug('JLink commander script:')