openocd/src/target
Antonio Borneo 65d7629183 cortex_m: poll S_REGRDY on register r/w
Accordingly to arm documentation [1], chapter C1.6.4, the
operation to read/write from/to core registers can require time,
and the specific flag DHCSR.S_REGRDY has to be polled to verify
that the operation has been completed.
The lack of check on S_REGRDY causes OpenOCD to fail handling
correctly the core registers on a Cortex-M4 emulated in a slow
FPGA, and it could also fail on devices clocked at very low speed
while using a fast adapter.

Poll S_REGRDY as specified in [1] while either reading or writing
the core registers.
A timeout of 0.5s is added. This could still be too small in some
extremely slow cases, but at least now we log the timeout event,
which can help tracking down such odd issue.
During register read include in the polling loop the read of DCRSR
and to flush the JTAG queue only once.
During register write, relax the write in DCRSR by removing the
atomicity that is now useless since followed by the atomic read to
S_REGRDY.
During register read include the read of DCRSR inside the polling
loop to relax the read of S_REGRDY since followed by the atomic
read to DCRSR.

This change has the drawback of adding other transfers to the
adapter while reading/writing the registers, so it is expected to
introduce some speed degradation during step-by-step.

[1] DDI0403E - "ARMv7-M Architecture Reference Manual"

Change-Id: I61f454248f11a3bec6dcf4c58a50c5c996d7ef81
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/5319
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2021-11-18 21:08:37 +00:00
..
openrisc openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
riscv riscv: use relative path to include contrib's data 2021-10-25 16:12:54 +00:00
a64_disassembler.c target/aarch64: a64 disassembler 2020-10-03 11:21:15 +01:00
a64_disassembler.h target/aarch64: a64 disassembler 2020-10-03 11:21:15 +01:00
aarch64.c arm_coresight: add include file and use it 2021-09-25 13:00:27 +00:00
aarch64.h target/arm: rename CamelCase symbols 2021-07-20 14:52:25 +01:00
adi_v5_dapdirect.c adi_v5_dapdirect: fix connect under reset 2020-02-24 10:28:46 +00:00
adi_v5_jtag.c target/adi_v5_jtag: Add support for 8-bit IR JTAG-DP 2021-08-22 20:27:59 +00:00
adi_v5_swd.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
algorithm.c
algorithm.h Cleanup of config/includes. 2021-05-01 14:35:09 +01:00
arc_cmd.c helper/jim-nvp: comply with coding style [2/2] 2021-06-04 17:40:48 +01:00
arc_cmd.h Introduce ARCv2 architecture related code 2020-02-27 06:46:51 +00:00
arc_jtag.c openocd: fix doxygen parameters of functions 2021-01-13 11:33:53 +00:00
arc_jtag.h Introduce ARCv2 architecture related code 2020-02-27 06:46:51 +00:00
arc_mem.c openocd: fix simple cases of Yoda condition 2021-07-20 14:55:24 +01:00
arc_mem.h Introduce ARCv2 architecture related code 2020-02-27 06:46:51 +00:00
arc.c openocd: remove NULL comparisons with checkpatch [1/2] 2021-07-24 10:38:00 +01:00
arc.h target: fix some minor typo 2021-05-22 10:06:45 +01:00
arm_adi_v5.c arm_adi_v5: drop ANY_ID from table dap_part_nums 2021-09-25 13:11:41 +00:00
arm_adi_v5.h arm_adi_v5: simplify handling of AP type 2021-09-25 13:00:55 +00:00
arm_coresight.h openocd: remove 'src' prefix from #include path 2021-10-25 16:12:42 +00:00
arm_cti.c openocd: prevent jimtcl error message while testing commands 2021-09-25 13:13:28 +00:00
arm_cti.h
arm_dap.c openocd: prevent jimtcl error message while testing commands 2021-09-25 13:13:28 +00:00
arm_disassembler.c target/arm: opcodes: rename CamelCase symbols and uppercase variables 2021-07-20 14:52:49 +01:00
arm_disassembler.h target/arm: opcodes: rename CamelCase symbols and uppercase variables 2021-07-20 14:52:49 +01:00
arm_dpm.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
arm_dpm.h target/arm: rename CamelCase symbols 2021-07-20 14:52:25 +01:00
arm_jtag.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
arm_jtag.h target/arm926ejs: fix memory leaks 2020-07-08 22:07:38 +01:00
arm_opcodes.h target/arm: opcodes: rename CamelCase symbols and uppercase variables 2021-07-20 14:52:49 +01:00
arm_semihosting.c arm_semihosting: fix two dead assignments 2021-10-25 16:09:12 +00:00
arm_semihosting.h
arm_simulator.c target/arm: opcodes: rename CamelCase symbols and uppercase variables 2021-07-20 14:52:49 +01:00
arm_simulator.h
arm_tpiu_swo.c arm_tpiu_swo: fix two dead assignments 2021-10-25 16:09:02 +00:00
arm_tpiu_swo.h armv7m_trace: get rid of the old tpiu code 2021-03-10 21:34:04 +00:00
arm.h openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
arm7_9_common.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
arm7_9_common.h target/arm926ejs: fix memory leaks 2020-07-08 22:07:38 +01:00
arm7tdmi.c target/arm: optimize architecture flags 2021-06-18 23:12:54 +01:00
arm7tdmi.h target/arm7tdmi: fix memory leak of register cache 2020-07-26 20:12:48 +01:00
arm9tdmi.c target/arm: optimize architecture flags 2021-06-18 23:12:54 +01:00
arm9tdmi.h target: fix memory leaks on targets based on arm9tdmi 2020-07-26 20:12:21 +01:00
arm11_dbgtap.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
arm11_dbgtap.h target/arm: rename CamelCase symbols 2021-07-20 14:52:25 +01:00
arm11.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
arm11.h
arm720t.c target/arm: rename CamelCase symbols 2021-07-20 14:52:25 +01:00
arm720t.h
arm920t.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
arm920t.h
arm926ejs.c target/arm: rename CamelCase symbols 2021-07-20 14:52:25 +01:00
arm926ejs.h target/arm: rename CamelCase symbols 2021-07-20 14:52:25 +01:00
arm946e.c target: declare local symbols as static 2020-11-04 17:39:17 +00:00
arm946e.h
arm966e.c target: use proper format with uint32_t 2020-09-05 17:12:39 +01:00
arm966e.h
armv4_5_cache.c helper/command: change prototype of command_print/command_print_sameline 2019-05-14 19:37:11 +01:00
armv4_5_cache.h Cleanup of config/includes. 2021-05-01 14:35:09 +01:00
armv4_5_mmu.c
armv4_5_mmu.h
armv4_5.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
armv4_5.h target/cortex_a: add hypervisor mode 2020-03-12 10:11:19 +00:00
armv7a_cache_l2x.c openocd: remove last NULL comparisons 2021-09-18 15:22:30 +00:00
armv7a_cache_l2x.h
armv7a_cache.c openocd: remove last NULL comparisons 2021-09-18 15:22:30 +00:00
armv7a_cache.h target: use proper format with uint32_t 2020-09-05 17:12:39 +01:00
armv7a_mmu.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
armv7a_mmu.h armv7a_mmu: Do not restrict virtual addresses to uint32_t 2019-06-12 15:14:44 +01:00
armv7a.c openocd: remove last NULL comparisons 2021-09-18 15:22:30 +00:00
armv7a.h target/adiv5: Large Physical Address Extension 2021-07-02 17:12:11 +01:00
armv7m_trace.c armv7m_trace: get rid of the old tpiu code 2021-03-10 21:34:04 +00:00
armv7m_trace.h helper: Remove src/helper from include dirs 2021-10-02 13:18:15 +00:00
armv7m.c armv7m.h: relax dependency from 'arm_adi_v5.h' 2021-09-25 12:59:12 +00:00
armv7m.h armv7m.h: relax dependency from 'arm_adi_v5.h' 2021-09-25 12:59:12 +00:00
armv8_cache.c openocd: remove last NULL comparisons 2021-09-18 15:22:30 +00:00
armv8_cache.h
armv8_dpm.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
armv8_dpm.h target/aarch64: fix watchpoint management 2021-05-22 10:04:20 +01:00
armv8_opcodes.c target/armv8_opcodes: use T32 instructions when the PE is in AArch32 state 2020-03-12 09:47:08 +00:00
armv8_opcodes.h target/arm: opcodes: rename CamelCase symbols and uppercase variables 2021-07-20 14:52:49 +01:00
armv8.c armv8: fix five dead assignments 2021-10-25 16:09:26 +00:00
armv8.h target/adiv5: Large Physical Address Extension 2021-07-02 17:12:11 +01:00
avr32_ap7k.c target: rename CamelCase symbols 2021-07-24 10:37:25 +01:00
avr32_ap7k.h target: rename CamelCase symbols 2021-07-24 10:37:25 +01:00
avr32_jtag.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
avr32_jtag.h
avr32_mem.c target: fix some minor typo 2021-05-22 10:06:45 +01:00
avr32_mem.h
avr32_regs.c
avr32_regs.h
avrt.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
avrt.h
breakpoints.c openocd: remove last NULL comparisons 2021-09-18 15:22:30 +00:00
breakpoints.h target: Rename 'linked_BRP' to 'linked_brp' 2021-06-18 23:10:57 +01:00
cortex_a.c arm_coresight: add include file and use it 2021-09-25 13:00:27 +00:00
cortex_a.h target/arm: rename CamelCase symbols 2021-07-20 14:52:25 +01:00
cortex_m.c cortex_m: poll S_REGRDY on register r/w 2021-11-18 21:08:37 +00:00
cortex_m.h target/cortex_m: cumulate DHCSR sticky bits 2021-11-18 21:08:00 +00:00
dsp563xx_once.c coding style: wrap lines longer than 120 chars 2020-05-09 14:40:52 +01:00
dsp563xx_once.h coding style: fix space around pointer's asterisk 2020-02-24 10:30:36 +00:00
dsp563xx.c target: rename CamelCase symbols 2021-07-24 10:37:25 +01:00
dsp563xx.h target/dsp563xx: Use bool data type for 'hardware_breakpoints_cleared' 2021-06-26 14:40:34 +01:00
dsp5680xx.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
dsp5680xx.h target: rename CamelCase symbols 2021-07-24 10:37:25 +01:00
embeddedice.c jtag: remove minidriver code and minidriver-dummy 2021-03-19 21:56:06 +00:00
embeddedice.h target/arm: rename CamelCase symbols 2021-07-20 14:52:25 +01:00
esirisc_jtag.c openocd: remove NULL comparisons with checkpatch [1/2] 2021-07-24 10:38:00 +01:00
esirisc_jtag.h
esirisc_regs.h target: rename CamelCase symbols 2021-07-24 10:37:25 +01:00
esirisc_trace.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
esirisc_trace.h
esirisc.c openocd: remove NULL comparisons with checkpatch [1/2] 2021-07-24 10:38:00 +01:00
esirisc.h target: rename CamelCase symbols 2021-07-24 10:37:25 +01:00
etb.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
etb.h
etm_dummy.c helper/command: change prototype of command_print/command_print_sameline 2019-05-14 19:37:11 +01:00
etm_dummy.h
etm.c openocd: remove NULL comparisons with checkpatch [1/2] 2021-07-24 10:38:00 +01:00
etm.h target: fix minor typos and duplicated words 2020-07-26 23:09:45 +01:00
fa526.c target: fix memory leaks on targets based on arm9tdmi 2020-07-26 20:12:21 +01:00
feroceon.c target/arm: rename CamelCase symbols 2021-07-20 14:52:25 +01:00
hla_target.c armv7m.h: relax dependency from 'arm_adi_v5.h' 2021-09-25 12:59:12 +00:00
image.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
image.h Cleanup of config/includes. 2021-05-01 14:35:09 +01:00
lakemont.c target/lakemont: fix dead assignment 2021-10-25 16:10:04 +00:00
lakemont.h
ls1_sap.c openocd: remove NULL comparisons with checkpatch [1/2] 2021-07-24 10:38:00 +01:00
Makefile.am arm_coresight: add include file and use it 2021-09-25 13:00:27 +00:00
mem_ap.c openocd: remove NULL comparisons with checkpatch [1/2] 2021-07-24 10:38:00 +01:00
mips_ejtag.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
mips_ejtag.h target/mips: rename CamelCase symbols 2021-07-20 14:53:03 +01:00
mips_m4k.c openocd: remove last NULL comparisons 2021-09-18 15:22:30 +00:00
mips_m4k.h
mips_mips64.c openocd: fix simple cases of Yoda condition 2021-07-20 14:55:24 +01:00
mips_mips64.h mips64: Add generic mips64 target support 2019-11-28 19:49:10 +00:00
mips32_dmaacc.c
mips32_dmaacc.h
mips32_pracc.c jtag: align adapter speed code to new structure 2021-11-13 10:50:34 +00:00
mips32_pracc.h target/mips: Remove typedef'd struct 2021-03-10 21:30:04 +00:00
mips32.c Use boolean argument for register_get_by_name() 2021-06-18 23:14:27 +01:00
mips32.h target/mips: rename CamelCase symbols 2021-07-20 14:53:03 +01:00
mips64_pracc.c jtag: align adapter speed code to new structure 2021-11-13 10:50:34 +00:00
mips64_pracc.h mips: Add MIPS64 support 2019-11-28 16:59:15 +00:00
mips64.c coding style: fix space separation 2020-07-08 22:08:08 +01:00
mips64.h mips: Add MIPS64 support 2019-11-28 16:59:15 +00:00
nds32_aice.c openocd: remove NULL comparisons with checkpatch [1/2] 2021-07-24 10:38:00 +01:00
nds32_aice.h
nds32_cmd.c openocd: fix Yoda conditions with checkpatch 2021-07-24 10:38:31 +01:00
nds32_cmd.h
nds32_disassembler.c openocd: manually fix Yoda conditions 2021-07-20 14:55:43 +01:00
nds32_disassembler.h
nds32_edm.h Cleanup of config/includes. 2021-05-01 14:35:09 +01:00
nds32_insn.h target/nds32: use lowercase for C variables 2021-07-20 14:54:27 +01:00
nds32_reg.c target: use proper format with uint32_t 2020-09-05 17:12:39 +01:00
nds32_reg.h
nds32_tlb.c target/nds32: rename CamelCase symbols 2021-07-20 14:53:12 +01:00
nds32_tlb.h target/nds32: rename CamelCase symbols 2021-07-20 14:53:12 +01:00
nds32_v2.c openocd: fix Yoda conditions with checkpatch 2021-07-24 10:38:31 +01:00
nds32_v2.h
nds32_v3_common.c openocd: fix Yoda conditions with checkpatch 2021-07-24 10:38:31 +01:00
nds32_v3_common.h
nds32_v3.c openocd: fix simple cases of Yoda condition 2021-07-20 14:55:24 +01:00
nds32_v3.h
nds32_v3m.c openocd: fix simple cases of Yoda condition 2021-07-20 14:55:24 +01:00
nds32_v3m.h
nds32.c openocd: fix Yoda conditions with checkpatch 2021-07-24 10:38:31 +01:00
nds32.h openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
quark_d20xx.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
quark_x10xx.c
register.c target/register: Minor code cleanup 2021-06-18 23:14:09 +01:00
register.h Cleanup of config/includes. 2021-05-01 14:35:09 +01:00
rtt.c Add initial RTT support 2020-12-02 23:15:52 +00:00
rtt.h Add initial RTT support 2020-12-02 23:15:52 +00:00
semihosting_common.c openocd: remove NULL comparisons with checkpatch [1/2] 2021-07-24 10:38:00 +01:00
semihosting_common.h Cleanup of config/includes. 2021-05-01 14:35:09 +01:00
smp.c openocd: remove last NULL comparisons 2021-09-18 15:22:30 +00:00
smp.h openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
startup.tcl target/startup.tcl: Do not use 'Yoda conditions' 2021-06-04 17:46:48 +01:00
stm8.c target/stm8: Remove unused member 'stm8_common' 2021-07-02 17:12:38 +01:00
stm8.h target/stm8: Make 'stm8_command_handlers' static 2021-05-08 09:49:32 +01:00
target_request.c openocd: manually remove NULL comparisons 2021-07-24 10:38:19 +01:00
target_request.h
target_type.h helper: Remove src/helper from include dirs 2021-10-02 13:18:15 +00:00
target.c target: reset target examined flag if target::examine() fails 2021-10-02 13:15:57 +00:00
target.h Call poll at a fixed interval. 2021-07-31 10:08:47 +01:00
testee.c
trace.c target: avoid checking for non NULL pointer to free it 2020-09-05 20:47:11 +01:00
trace.h Cleanup of config/includes. 2021-05-01 14:35:09 +01:00
x86_32_common.c openocd: remove NULL comparisons with checkpatch [1/2] 2021-07-24 10:38:00 +01:00
x86_32_common.h
xscale.c openocd: fix simple cases of NULL comparison 2021-07-24 10:37:49 +01:00
xscale.h