[ECOS] RedBoot file download expect script

eibach@gdsys.de eibach@gdsys.de
Tue Nov 23 12:39:00 GMT 2004


Hi,

> Does anybody have an "expect" script that they would care to share that can
> be used to download an image to RedBoot and scribble it into flash?

Yes, it is attached to this mail. For uploading images you will have to modify it slightly, because we are using the Abatron BDI JTAG-interface for uploading data, but Redboot is used for flashing images. Maybe you should use kermit for uploading. However you will find a lot of useful hints in this script.

Regards,
Dirk

(Since the list doesn't like my attachment, I insert the script here)

#!/usr/bin/expect --

#
# Konstanten definieren
#
if {$argc < 2} {
 puts "Not enough arguments."
 exit
}

set catc_tty [lindex $argv 0]

set bdi_ip [lindex $argv 1]

#
# Sleep-Befehl
#
proc sleep {timeout} {
	expect
}

#
# Telnet-Sitzung zum BDI oeffnen
#
spawn telnet $bdi_ip
expect {
	timeout {
		puts "telnet timed out"; exit
	}
	"CATCenter>" {
		set telnet_id $spawn_id
	}
}

#
# Redboot flashen
#
send "res halt\r"
expect {
	timeout {
		puts "telnet timed out"; exit
	}
	"CATCenter>" {
		set telnet_id $spawn_id
	}
}

send "erase 0x1000000 chip\r"
set timeout 60
expect {
	timeout {
		puts "Flash erase timed out"; exit
	}
	"Erasing flash passed"
}

send "prog 0x1000000 images/redboot_110.bin bin\r"
set timeout 10
expect {
	timeout {
		puts "Flash programming timed out"; exit
	}
	"Programming flash passed"
}

send "res run\r"
expect {
	timeout {
		puts "CPU reset timed out"; exit
	}
	"processing target startup passed"
}

#
# Kermit oeffnen und mit CATCenter verbinden
#
spawn kermit
expect {
	timeout {
		puts "kermit timed out"; exit
	}
	"C-Kermit>" {
		set kermit_id $spawn_id
	}
}

send "set line $catc_tty\n"
send "set speed 38400\n"
expect {
	timeout {
		puts "kermit timed out"; exit
	}
	"38400 bps"
}
send "set flow none\n"
send "set carrier-watch off\n"
send "c\n"
expect {
	timeout {
		puts "Kermit timed out"; exit
	}
	"\n-------*\n"
}

send "\n"
send "\n"
expect {
	timeout {
		puts "Redboot timed out"; exit
	}
	"enter ^C to abort" {
		send \x03
		expect {
			timeout {
				puts "Redboot timed out"; exit
			}
                        "RedBoot> "
		}
	}
	"RedBoot> "
}

#
# Redboot Erstkonfiguration
#
send "fconfig -i\r"
set timeout 10
expect {
	timeout {
		puts "init timed out"; exit
	}
	"Initialize non-volatile configuration - continue (y/n)?"
}

send "y\r"
set timeout 10
expect {
	timeout {
		puts "init timed out"; exit
	}
	"Run script at boot: false"
}

set send_slow {1 .005}
send -s "\x8\x8\x8\x8\x8"
send -s "true\r"
expect {
	timeout {
		puts "load timed out"; exit
	}
	">>"
}

send -s "fis load BIN_INT\r"
send -s "go\r"
send "\r"
expect {
	timeout {
		puts "init timed out"; exit
	}
	"Boot script timeout (1000ms resolution):"
}

send "3\r"
expect {
	timeout {
		puts "init timed out"; exit
	}
	"Console baud rate:"
}


send "\r"
expect {
	timeout {
		puts "init timed out"; exit
	}
	"Update RedBoot non-volatile configuration - continue (y/n)?"
}

send "y\r"
expect {
	timeout {
		puts "init timed out"; exit
	}
	"RedBoot>"
}

send "fis init\r"
expect {
	timeout {
		puts "init timed out"; exit
	}
	"FLASH image system - continue (y/n)?"
}

send "y\r"
expect {
	timeout {
		puts "init timed out"; exit
	}
	"RedBoot>"
}

#
# Firmware fuer Adresse 0xc000 laden
#
set spawn_id $telnet_id

send "halt\r"
send "load 0x400000 images/de/matrix2_CATCENTER_c000.bin bin\r"
set timeout 30
expect {
	timeout {
		puts "load timed out"; exit
	}
	"Loading program file passed"
}
send "go\r"
sleep 1

set spawn_id $kermit_id

send "fis delete BIN_INT\r"
set timeout 30
expect {
	timeout {
		puts "delete timed out"; exit
	}
	"continue (y/n)?" {
		send "y\r"
		expect {
			timeout {
				puts "delete timed out"; exit
			}
			"RedBoot> "
		}	
	}
	"RedBoot> "
}

send -- "fis create -b 0x400000 -l 0x20000 -s 0x20000"
send -- " -f 0x1700000 -r 0xc000 BIN_INT\r"
set timeout 40
expect {
	timeout {
		puts "flash timed out"; exit
	}
	"RedBoot> "
}

#
# ROMFS laden
#
set spawn_id $telnet_id

send "halt\r"
send "load 0x400000 images/de/romfs.img BIN\r"
set timeout 30
expect {
	timeout {
		puts "load timed out"; exit
	}
	"Loading program file passed"
}
send "go\r"
sleep 1

set spawn_id $kermit_id

send "fis delete ROMFS\r"
set timeout 30
expect {
	timeout {
		puts "delete timed out"; exit
	}
	"continue (y/n)?" {
		send "y\r"
		expect {
			timeout {
				puts "delete timed out"; exit
			}
			"RedBoot> "
		}	
	}
	"RedBoot> "
}

send -- "fis create -b 0x400000 -l 0xD0000 -s 0xD0000"
send -- " -f 0x1020000 ROMFS\r"
set timeout 40
expect {
	timeout {
		puts "flash timed out"; exit
	}
	"RedBoot> "
}

#
# JFFS2 laden
#
set spawn_id $telnet_id

send "halt\r"
send "load 0x400000 images/jffs2.img bin\r"
set timeout 30
expect {
	timeout {
		puts "load timed out"; exit
	}
	"Loading program file passed"
}
send "go\r"
sleep 1

set spawn_id $kermit_id

send "fis delete JFFS2\r"
set timeout 30 
expect {
	timeout {
		 puts "delete timed out"; exit
	}
	"continue (y/n)?" { 
		send "y\r" 
		expect {
			timeout { 
				puts "delete timed out"; exit
			}
			"RedBoot> "
		}	
	}
	"RedBoot> "
}

send -- "fis create -b 0x400000 -l 0x400000 -s 0x164" 
send -- " -f 0x1300000 JFFS2\r" 
set timeout 40 
expect {
	timeout { 
		puts "flash timed out"; exit
	}
	"RedBoot> "
}

#
# Geraet starten
#
set spawn_id $telnet_id

send "res run\r"

set spawn_id $kermit_id
set timeout 40
expect {
	timeout {
		 puts "startup timed out"; exit
	}

	"Here we go"
}

puts "succes!!!\n"

To: WPD@dtccom.com
Cc: ecos-discuss@ecos.sourceware.org


-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list