Thc cortex_m3_poll function does not identify that a target is running unless we transition from RESET.

This patch correctly identifies a running target.

Regards
Magnus

Index: src/target/cortex_m3.c
===================================================================
--- src/target/cortex_m3.c	(revision 2503)
+++ src/target/cortex_m3.c	(working copy)
@@ -512,17 +512,24 @@
 		}
 	}
 
-	/*
+#if 0
 	if (cortex_m3->dcb_dhcsr & S_SLEEP)
+	{
 		target->state = TARGET_SLEEP;
-	*/
-
-#if 0
-	/* Read Debug Fault Status Register, added to figure out the lockup when running flashtest.script  */
-	mem_ap_read_atomic_u32(swjdp, NVIC_DFSR, &cortex_m3->nvic_dfsr);
-	LOG_DEBUG("dcb_dhcsr 0x%x, nvic_dfsr 0x%x, target->state: %s", cortex_m3->dcb_dhcsr, cortex_m3->nvic_dfsr, target_state_name(target));
+		return ERROR_OK;
+	}
 #endif
 
+	if (target->state == TARGET_UNKNOWN)
+	{
+		/* check if processor is retiring instructions */
+		if (cortex_m3->dcb_dhcsr & S_RETIRE_ST)
+		{
+			target->state = TARGET_RUNNING;
+			return ERROR_OK;
+		}
+	}
+
 	return ERROR_OK;
 }
 

_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to