Hi,
There is a problem with setting JLink power on. JLink has a possibility to feed
the target hardware from the J-Link debugger.
There is a command already in OpenOCD: `jlink config targetpower on`, however
the current implementation does not work. The target power has to be ON before
the `init` command because the init command needs to connect to the chip.
Currently this is not allowed: `The ‘link config targetpower’ command must be
used after ‘init’`. This does not make sense as init will fail when there’s no
power applied to the target chip.
I did some changes to jlink.c in order to make it work, however I’m not
familiar with the OpenOCD development and I’m unsure about the correct coding
style for OpenOCD.
I did these modifications to /jtag/drivers/jlink.c for version 0.12.0-rc2+dev:
Changed the command mode of `jlink config targetpower` from COMMAND_EXEC to
COMMAND_CONFIG (line 1822)
Inserted the following code at line 754 (just after the check of the J-Link
hardware version) to check if the `jlink config targetpower on` has been
issued:
```
if (tmp_config.target_power)
{
ret = jaylink_set_target_power(devh, true);
if (ret != JAYLINK_OK) {
LOG_ERROR("jaylink_set_target_power() failed: %s",
jaylink_strerror(ret));
jaylink_close(devh);
jaylink_exit(jayctx);
return ERROR_JTAG_INIT_FAILED;
}
jtag_sleep(50000); // Wait for 50mS for
power to settle
}
```
This works perfect and I hope this modification (or similar) can be considered
for next update.
Thanks!
Rolf