diff options
author | Tomas Vanek <vanekt@fbl.cz> | 2020-06-29 13:34:07 +0200 |
---|---|---|
committer | Tomas Vanek <vanekt@fbl.cz> | 2020-12-02 23:15:08 +0000 |
commit | 646c3c99020f8fdf7ee0adf821582238aac4a80c (patch) | |
tree | 58647f4f4ef0b211e69203a980d47aa4d08d4f00 /src/target/arm_adi_v5.h | |
parent | a8edbd0200560bfd412c5c563908d860ed2c96a6 (diff) | |
download | riscv-openocd-646c3c99020f8fdf7ee0adf821582238aac4a80c.zip riscv-openocd-646c3c99020f8fdf7ee0adf821582238aac4a80c.tar.gz riscv-openocd-646c3c99020f8fdf7ee0adf821582238aac4a80c.tar.bz2 |
arm_adi_v5: prevent possibly endless recursion in dap_dp_init()
If dap_dp_read_atomic() in 30 trials loop fails, dap->do_reconnect is set.
Following dap_dp_read_atomic() calls dap_queue_dp_read() which in case
of SWD transport calls swd_queue_dp_read(). It starts
with swd_check_reconnect() and it calls swd_connect() because
dap->do_reconnect is set. swd_connect() does some initialization,
reads DPIDR and calls dap_dp_init() again!
Moreover if dap_dp_init() is called from cortex_m_reset_(de)assert()
one level of recursion is necessary to reconnect the target.
Introduce dap_dp_init_or_reconnect() for use in cortex_m reset
and similar.
Remove loop of 30 atomic reads of DP_STAT to prevent unwanted recursion.
Change-Id: I54052fdefe50bf5f7c7b59fe751fe2063d5710c9
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/5729
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Diffstat (limited to 'src/target/arm_adi_v5.h')
-rw-r--r-- | src/target/arm_adi_v5.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h index f319a06..8edfaa8 100644 --- a/src/target/arm_adi_v5.h +++ b/src/target/arm_adi_v5.h @@ -550,6 +550,7 @@ int mem_ap_write_buf_noincr(struct adiv5_ap *ap, /* Initialisation of the debug system, power domains and registers */ int dap_dp_init(struct adiv5_dap *dap); +int dap_dp_init_or_reconnect(struct adiv5_dap *dap); int mem_ap_init(struct adiv5_ap *ap); /* Invalidate cached DP select and cached TAR and CSW of all APs */ |