diff --git a/tools/42-nxp-flash.rules b/tools/42-nxp-flash.rules new file mode 100644 index 0000000..15b2c06 --- /dev/null +++ b/tools/42-nxp-flash.rules @@ -0,0 +1,3 @@ +# rule for NXP LPC134X-Flash + +SUBSYSTEM=="block", ATTRS{idVendor}=="04cc", ATTRS{idProduct}=="0003", SYMLINK+="lpcflash/%k", MODE="0666" diff --git a/tools/README.autoflash b/tools/README.autoflash new file mode 100644 index 0000000..e73f89d --- /dev/null +++ b/tools/README.autoflash @@ -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 + diff --git a/tools/autoflash b/tools/autoflash new file mode 100755 index 0000000..d3e6c29 --- /dev/null +++ b/tools/autoflash @@ -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) +