added tool to automatically flash a badge attached

This commit is contained in:
bsx 2011-05-22 21:09:45 +02:00
parent f3b14ba4de
commit 8189a7687d
3 changed files with 46 additions and 0 deletions

3
tools/42-nxp-flash.rules Normal file
View File

@ -0,0 +1,3 @@
# rule for NXP LPC134X-Flash
SUBSYSTEM=="block", ATTRS{idVendor}=="04cc", ATTRS{idProduct}=="0003", SYMLINK+="lpcflash/%k", MODE="0666"

6
tools/README.autoflash Normal file
View File

@ -0,0 +1,6 @@
1. place the udev rules 42-nxp-flash.rules in /etc/udev/rules.d/ and restart udevd
2. run tools/autoflash from the project directory
3. attach badges to flash
4. legen ... wait for it ... dary ;)
5. if autoflash says "flashed", remove the badge

37
tools/autoflash Executable file
View File

@ -0,0 +1,37 @@
#!/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:
flashed.append(file)
else:
print "removed %s" % file
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)