From e1f0ece1c8a3c4d30bb31d0b36639c73bfd08946 Mon Sep 17 00:00:00 2001 From: Travis Goodspeed Date: Sat, 23 Sep 2017 12:21:58 -0400 Subject: [PATCH] Proper argument parsing, will continue development on a machine with hardware. --- bin/cc430-bsl.py | 47 ++++++++++++++++++++++++++++++++--------------- firmware/Makefile | 2 +- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/bin/cc430-bsl.py b/bin/cc430-bsl.py index e16ce02..d662a07 100755 --- a/bin/cc430-bsl.py +++ b/bin/cc430-bsl.py @@ -6,13 +6,13 @@ ## bad checksums. It is free for any use, provided you tip your ## bartender. -import serial, time, sys; +import serial, time, sys, argparse; class BSL: def __init__(self, port): print("Opening %s" % port); - self.serial=serial.Serial("/dev/ttyUSB0", + self.serial=serial.Serial(port, baudrate=9600, parity=serial.PARITY_EVEN, stopbits=serial.STOPBITS_ONE, @@ -216,18 +216,35 @@ def writetest(bsl): assert(readmsg==msg); if __name__=='__main__': - bsl=BSL("/dev/ttyUSB0"); - - print "Testing the BSL library:" - - bsl.enter_bsl(); - - if not bsl.unlock(): - print "Unable to unlock BSL. Try a bulk erase." - sys.exit(1); - - bsl.version(); - coredump(bsl); - writetest(bsl); + parser = argparse.ArgumentParser(description='CC430F6137 BSL Client') + parser.add_argument('-e','--erase', help='Mass Erase',action='count'); + parser.add_argument('-p','--port', help='Serial Port',default='/dev/ttyUSB0'); + parser.add_argument('-f','--file', help='Flash File'); + parser.add_argument('-P','--password', help='Password File or Hex'); + parser.add_argument('-d','--dump', help='Produce a core dump.',action='count'); + + + args = parser.parse_args() + + bsl=BSL(args.port); + + if args.erase!=None: + bsl.masserase(); + if args.dump!=None: + coredump(bsl); + + # bsl=BSL("/dev/ttyUSB0"); + + # print "Testing the BSL library:" + + # bsl.enter_bsl(); + + # if not bsl.unlock(): + # print "Unable to unlock BSL. Try a bulk erase." + # sys.exit(1); + + # bsl.version(); + # coredump(bsl); + # writetest(bsl); diff --git a/firmware/Makefile b/firmware/Makefile index 4e70364..26a927c 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -4,7 +4,7 @@ CC = msp430-gcc -mmcu=cc430f6137 modules=main.o lcd.o -all: goodwatch +all: goodwatch.hex goodwatch: $(modules) $(CC) -o goodwatch $(modules)