crashtest-r0ket/tools/bootloader/autoflash

38 lines
850 B
Plaintext
Raw Permalink Normal View History

#!/usr/bin/env python
# -*- coding: utf8 -*-
import os
import time
flashed = []
while True:
filelist = []
try:
filelist = os.listdir("/dev/lpcflash")
except:
pass
oldflashed = flashed
flashed = []
for x in oldflashed:
if x in filelist:
2011-08-05 16:49:36 +00:00
flashed.append(x)
else:
2011-08-05 16:49:36 +00:00
print "removed %s" % x
filelist = [x for x in filelist if x not in flashed]
for file in filelist:
try:
firmware = open("firmware.bin", "r")
dev = open("/dev/lpcflash/%s" % file, "w")
dev.seek(0x800)
dev.write(firmware.read())
firmware.close()
dev.close()
print "flashed %s" % file
except Exception, ex:
print "error!"
print ex
flashed.append(file)
time.sleep(1)