Resolving the -chain-position error with OpenOCD

This page explains how to resolve the "target requires -dap parameter instead of -chain-position" error shown by the recent builds of OpenOCD for some target scripts.

The error was introduced by a change #2231da8ec4e7d7ae9b652f3dd1a7104f5a110f3f in the original OpenOCD repository. It changed the way OpenOCD scripts should define targets. Instead of a single "target create $_TARGETNAME" statement, each script must now contain 2 separate statements:

dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
target create <...> -dap $_CHIPNAME.dap

The commit introducing this change updated the most frequently used scripts, however many other scripts were left unchanged. If you encounter this error while debugging your target, please follow the steps below to update your configuration script:

  1. Locate the target script you are using. It is typically a .cfg file located in the <openocd>\share\openocd\scripts\target directory.
  2. Open the script in a text editor and locate the "target create" statement:
  3. target create <...> $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
    The $_CHIPNAME.dap statement typically refers to the TAP created with the "jtag newtap" or "swj_newdap" command:
    jtag newtap $_CHIPNAME dap <...>
  4. Locate the newtap/swj_newdap command and change tap name from "dap" to "cpu":
    jtag newtap $_CHIPNAME cpu <...>
  5. Add a statement creating the DAP:
    dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
  6. Finally update the "target create" statement to reference the explicitly created DAP using the "-dap" argument instead of creating it implicitly with "-chain-position":
    target create <...> -dap $_CHIPNAME.dap