openocd: generic halt function

Halting can now be done for cortex-a9 and cortex-m3 target with the halting
function which originally was only able to halt the cortex-a9 target.

Change-Id: I9ced64253405654c4155c8f776534bc7231387b2
This commit is contained in:
Lars Rademacher
2013-11-25 23:16:43 +01:00
parent f9cc503b7e
commit 14cd9346ec
2 changed files with 23 additions and 14 deletions

View File

@ -717,10 +717,19 @@ void oocdw_delete_halt_condition(struct halt_condition *hc)
} }
} }
bool oocdw_halt_target() bool oocdw_halt_target(struct target *target)
{ {
if (target_halt(target_a9)) { if (target_poll(target)) {
LOG << "FATAL ERROR: Target could not be halted" << endl; LOG << "FATAL ERROR: Target polling failed for target " << target->cmd_name << endl;
return false;
}
if (target->state == TARGET_RESET) {
LOG << "FATAL ERROR: Target " << target->cmd_name << " could not be halted, because in reset mode" << endl;
}
if (target_halt(target)) {
LOG << "FATAL ERROR: Could could not halt target " << target->cmd_name << endl;
return false; return false;
} }
@ -728,17 +737,17 @@ bool oocdw_halt_target()
* Wait for target to actually stop. * Wait for target to actually stop.
*/ */
long long then = timeval_ms(); long long then = timeval_ms();
if (target_poll(target_a9)) { if (target_poll(target)) {
LOG << "FATAL ERROR: Target polling failed" << endl; LOG << "FATAL ERROR: Target polling failed for target " << target->cmd_name << endl;
return false; return false;
} }
while (target_a9->state != TARGET_HALTED) { while (target->state != TARGET_HALTED) {
if (target_poll(target_a9)) { if (target_poll(target)) {
LOG << "FATAL ERROR: Target polling failed" << endl; LOG << "FATAL ERROR: Target polling failed for target " << target->cmd_name << endl;
return false; return false;
} }
if (timeval_ms() > then + 1000) { if (timeval_ms() > then + 1000) {
LOG << "FATAL ERROR: Timeout waiting for target halt" << endl; LOG << "FATAL ERROR: Timeout waiting for halt of target " << target->cmd_name << endl;
return false; return false;
} }
} }
@ -778,7 +787,7 @@ void oocdw_reboot()
// If target is not halted, reset will result in freeze // If target is not halted, reset will result in freeze
if (target_a9->state != TARGET_HALTED) { if (target_a9->state != TARGET_HALTED) {
if (!oocdw_halt_target()) { if (!oocdw_halt_target(target_a9)) {
reboot_success = false; reboot_success = false;
if (fail_counter++ > 4) { if (fail_counter++ > 4) {
LOG << "FATAL ERROR: Rebooting not possible" << endl; LOG << "FATAL ERROR: Rebooting not possible" << endl;
@ -833,7 +842,7 @@ void oocdw_reboot()
usleep(750*1000); usleep(750*1000);
// Immediate halt after reset. // Immediate halt after reset.
if (!oocdw_halt_target()) { if (!oocdw_halt_target(target_a9)) {
reboot_success = false; reboot_success = false;
if (fail_counter++ > 4) { if (fail_counter++ > 4) {
LOG << "FATAL ERROR: Rebooting not possible" << endl; LOG << "FATAL ERROR: Rebooting not possible" << endl;
@ -879,7 +888,7 @@ void oocdw_reboot()
LOG << "FATAL ERROR: Rebooting not possible" << endl; LOG << "FATAL ERROR: Rebooting not possible" << endl;
exit(-1); exit(-1);
} }
oocdw_halt_target(); oocdw_halt_target(target_a9);
break; break;
} }
} }
@ -1228,7 +1237,7 @@ static void update_timers()
if (timers[i].timeToFire <= useconds_delta) { if (timers[i].timeToFire <= useconds_delta) {
// Halt target to get defined halted state at experiment end // Halt target to get defined halted state at experiment end
oocdw_halt_target(); oocdw_halt_target(target_a9);
// Fire // Fire
timers[i].funct(timers[i].this_ptr); timers[i].funct(timers[i].this_ptr);
} }

View File

@ -65,7 +65,7 @@ void oocdw_delete_halt_condition(struct halt_condition *hc);
/* /*
* Immediate target halt without sepcific target instruction * Immediate target halt without sepcific target instruction
*/ */
bool oocdw_halt_target(); bool oocdw_halt_target(struct target *target);
/* /*
* Target reboot * Target reboot