load_base_board_description "cygmon";

set_board_info testcase_timeout 30;

proc ${board}_init { dest } {
    global usparc_init_count;
    set shell_prompt [board_info $dest shell_prompt];

    if ![info exists usparc_init_count] {
	set usparc_init_count 0;
    } else {
	incr usparc_init_count;
	if { $usparc_init_count == 3 } {
	    return -1;
	}
	    
    }
    remote_close $dest;
    set shell_id [remote_open $dest];
    if { $shell_id == "" || $shell_id < 0 } {
	return [remote_reboot $dest];
    } else {
	remote_binary $dest;
	remote_send $dest "\n";
	set got_one 0;
	remote_expect $dest 5 {
	    -re "$shell_prompt" { set got_one 1; exp_continue; }
	    default {
		if { ! $got_one } {
		    remote_close $dest;
		    return [remote_reboot $dest];
		}
	    }
	}
    	remote_send $dest "m \[15\]1fff1001f00 32\n";
	remote_expect $dest 5 {
	    -re "$shell_prompt" {
		unset usparc_init_count;
		remote_close $dest;
		return 0; 
	    }
	    default {
		remote_close $dest;
		return [remote_reboot $dest];
	    }
	}
    }
}
