flash at91samd, at91sam4l: fix improper use of mem_ap_ call
authorTomas Vanek <vanekt@fbl.cz>
Wed, 27 Jul 2016 14:50:25 +0000 (16:50 +0200)
committerAndreas Fritiofson <andreas.fritiofson@gmail.com>
Sat, 5 Nov 2016 10:35:19 +0000 (10:35 +0000)
commit7d2ad65c6400dea415cd7e0b19d502488b371bfc
tree99be2cd1b526d844ab3370f7e9c31db8ed35427d
parent607edefb53ae5ca4120a7967c4cfed3184bb09d2
flash at91samd, at91sam4l: fix improper use of mem_ap_ call

Since merge of #3149 OpenOCD start with an unresponsive SAMD or SAM4L
resulted in segfaults. First was in cortex_m_assert_reset
(fixed by #3552), second was in samd_handle_reset_deassert()
/sam4l_handle_reset_deassert().

The change replaces mem_ap_write_u32/8 by target_write_u32/8.
It also takes better care about examining and polling target before
debug control registers are set. It prevents lockup when 'reset halt'
is issued on unresponsive cpu.

Change-Id: I2516489f4771aebfc1118d174f527497b8a201ad
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: http://openocd.zylin.com/3603
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
src/flash/nor/at91sam4l.c
src/flash/nor/at91samd.c