/** Executes all queued DAP operations. */
static int cmsis_dap_run(struct adiv5_dap *dap)
{
- LOG_DEBUG("CMSIS-ADI: cmsis_dap_run");
+ LOG_DEBUG(" ");
/* FIXME: for now the CMSIS-DAP interface hard-wires a zero-size queue. */
+ int ret;
+ uint32_t ctrlstat;
- return ERROR_OK;
+ /*
+ Some debug dongles do more than asked for(e.g. EDBG from
+ Atmel) behind the scene and issuing an AP write
+ may result in more than just APACC SWD transaction, which in
+ turn can possibly set sticky error bit in CTRL/STAT register
+ of the DP(an example would be writing SYSRESETREQ to AIRCR).
+ Such adapters may interpret CMSIS-DAP secification
+ differently and not guarantee to be report those failures
+ via status byte of the return USB packet from CMSIS-DAP, so
+ we need to check CTRL/STAT and if that happens to clear it.
+ */
+ ret = cmsis_dap_queue_dp_read(dap, DP_CTRL_STAT, &ctrlstat);
+ if (ret != ERROR_OK) {
+ LOG_ERROR("Failed to read CTRL/STAT register");
+ return ret;
+ }
+
+ if (ctrlstat & SSTICKYERR) {
+ LOG_WARNING("SSTICKYERR was set, clearing it");
+ ret = cmsis_dap_clear_sticky_errors(dap);
+ if (ret != ERROR_OK) {
+ LOG_ERROR("Failed to clear sticky errors");
+ return ret;
+ }
+ }
+
+ return ret;
}
const struct dap_ops cmsis_dap_ops = {
"handler to reset any peripherals or configure hardware srst support.");
}
+ /*
+ SAM4L needs to execute security initalization
+ startup sequence before AP access would be enabled.
+ During the intialization CDBGPWRUPACK is pulled low and we
+ need to wait for it to be set to 1 again.
+ */
+ retval = dap_dp_poll_register(swjdp, DP_CTRL_STAT,
+ CDBGPWRUPACK, CDBGPWRUPACK, 100);
+ if (retval != ERROR_OK) {
+ LOG_ERROR("Failed waitnig for CDBGPWRUPACK");
+ return ERROR_FAIL;
+ }
+
{
/* I do not know why this is necessary, but it
* fixes strange effects (step/resume cause NMI
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME at91sam4l 0x00000000 0 1 1 $_TARGETNAME
-
-# if srst is not fitted use VECTRESET to perform a soft reset
-# this will only reset the core, not the peripherals
-cortex_m reset_config vectreset