stlink: fix open AP for v2j37 and v3j7
authorAntonio Borneo <borneo.antonio@gmail.com>
Thu, 21 May 2020 11:24:32 +0000 (13:24 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sun, 24 May 2020 20:36:02 +0000 (21:36 +0100)
commit7456e6bac5a3f13818d16660f3cd049a73a6e3fb
tree4cf8e80a296da18e68c55828b8224b6f04632020
parentb342c67f7786fd17734763902dcb0c39286834a0
stlink: fix open AP for v2j37 and v3j7

The new stlink firmware requires opening the AP before issuing
any operation.
In the current code we have a 'questionable' check about the core
model to set the TAR autoincrement, that is issued without opening
the AP, thus causing a STLINK_BAD_AP_ERROR.

Modify the AP open API to handle this case and open AP#0 before
the memory access to check the core model.

Change-Id: I576955b5094bd41d63ff1fbad7b4fd9433253321
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reported-by: Andreas Bolsch <hyphen0break@gmail.com>
Reviewed-on: http://openocd.zylin.com/5691
Tested-by: jenkins
Reviewed-by: Andreas Bolsch <hyphen0break@gmail.com>
src/jtag/drivers/stlink_usb.c