On Sat, Dec 10, 2022 at 4:03 PM Rolf | Onethinx <r...@onethinx.com> wrote:
>
> 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.

Hi,
thanks for highlighting this issue.
I agree with your analysis, and I add that _every_ command in the
array jlink_config_subcommand_handlers[] has incorrect .mode =
COMMAND_EXEC !

> 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 would like to invite you to contribute to OpenOCD by following the guide in
https://openocd.org/doc/doxygen/html/index.html
where there is the coding style and the Patch Guidelines
If there is anything unclear, we can assist you and also take your
feedback to improve the documentation.

> 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:

I'm surprised this works, but maybe I didn't checked well the code.
The command 'jlink config targetpower' executes
jlink_handle_config_target_power_command() that has:
        if (!jaylink_has_cap(caps, JAYLINK_DEV_CAP_READ_CONFIG)) {
                command_print(CMD, "Reading configuration is not
supported by the "
                        "device");
                return ERROR_OK;
        }
so the command should return immediately if the command is called before init.
The capabilities in caps are set during init.

Antonio

Reply via email to