85 lines
2.1 KiB
Plaintext
Executable File
85 lines
2.1 KiB
Plaintext
Executable File
#!/usr/bin/expect -d
|
|
|
|
set timeout 100
|
|
exp_internal 1
|
|
set send_slow {1 0.005}
|
|
|
|
#
|
|
# A procedure to send a string character by character,
|
|
# waiting for each character to be echoed before sending the next.
|
|
#
|
|
proc reliable_send {str} {
|
|
# Set a timeout for waiting for the echo of a single character
|
|
set timeout 2
|
|
|
|
# Loop through each character of the input string
|
|
for {set i 0} {$i < [string length $str]} {incr i} {
|
|
set char [string index $str $i]
|
|
|
|
# Send the single character.
|
|
# The "--" argument ensures that if the character is a dash,
|
|
# it isn't interpreted as an option to the send command.
|
|
send -- $char
|
|
|
|
# Expect the character to be echoed back
|
|
expect {
|
|
# If the echo is received, continue to the next iteration
|
|
-ex $char {
|
|
# Optional: uncomment the next line for debugging
|
|
# puts "Sent and received: $char"
|
|
continue
|
|
}
|
|
# If we time out waiting for the echo, handle the error
|
|
timeout {
|
|
puts "ERROR: Timed out waiting for echo of character: '$char'"
|
|
exit 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
spawn picocom -b 115200 $env(SERIAL_PORT) --logfile $env(OUTPUT_LOG_FILE)
|
|
set term_id $spawn_id
|
|
spawn ./toggle_jg928a_port.sh $env(LAN_PORT)
|
|
set spawn_id $term_id
|
|
|
|
expect "DRAM"
|
|
send " "
|
|
|
|
expect {[30s timeout]}
|
|
expect "login:"
|
|
send "admin\n"
|
|
expect "password:"
|
|
send "new2day\n"
|
|
|
|
expect {
|
|
"Boot (PRI)-> " {
|
|
send -s {setenv ramboot_openwrt "setenv ipaddr }
|
|
# "
|
|
send -s "$env(MACHINE_ADDRESS)"
|
|
send -s {; setenv serverip 192.168.0.1; tftpboot 0x2000000 }
|
|
send -s "$env(INITRAMFS_FILENAME)"
|
|
send -s {; interrupts off; bootm 0x2000000;"}
|
|
# "
|
|
send -s "\n"
|
|
send -s {setenv boot_openwrt "bootm 0xEC000000;"; setenv bootcmd "run boot_openwrt"; saveenv;}
|
|
send -s "\n"
|
|
}
|
|
}
|
|
expect {
|
|
"Protected 1 sectors\r\nBoot (PRI)-> " {
|
|
send -s "run ramboot_openwrt;\n"
|
|
}
|
|
}
|
|
|
|
expect {
|
|
"Please press Enter to activate this console." {
|
|
send "\n"
|
|
sleep 5
|
|
reliable_send {while true; do sysupgrade https://downloads.openwrt.org/releases/23.05.2/targets/mpc85xx/p1020/openwrt-23.05.2-mpc85xx-p1020-extreme-networks_ws-ap3825i-squashfs-sysupgrade.bin; done
|
|
}
|
|
}
|
|
}
|
|
|
|
expect {Sending KILL to remaining processes}
|