From 01691ae22e986a3a0c276c3cb6765db3087ed360 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Tue, 16 Mar 2010 21:20:21 +0100 Subject: Improve online chip documentation Signed-off-by: Michael Buesch --- libtoprammer/chip.py | 67 +++++++++++++++++++++++++++++++------ libtoprammer/chip_at89c2051dip20.py | 7 +++- libtoprammer/chip_atmega32dip40.py | 9 +++-- libtoprammer/chip_atmega88dip28.py | 7 +++- libtoprammer/chip_atmega8dip28.py | 7 +++- libtoprammer/chip_attiny26dip20.py | 9 ++++- libtoprammer/chip_m2764a.py | 7 +++- libtoprammer/chip_m8cissp.py | 9 ++++- libtoprammer/chip_unitest.py | 6 +++- libtoprammer/chip_w29ee011dip32.py | 7 +++- libtoprammer/toprammer_main.py | 4 +-- toprammer | 13 ++++--- 12 files changed, 125 insertions(+), 27 deletions(-) diff --git a/libtoprammer/chip.py b/libtoprammer/chip.py index 26d8c50..3998188 100644 --- a/libtoprammer/chip.py +++ b/libtoprammer/chip.py @@ -188,12 +188,24 @@ class Chip: registeredChips = [] class RegisteredChip: - def __init__(self, chipImplClass, bitfile, broken=False): + def __init__(self, chipImplClass, bitfile, + description="", packages=None, comment="", + broken=False): """Register a chip implementation class. - chipImplClass => The implementation class of the chip - bitfile => The bitfile ID of the chip""" + chipImplClass => The implementation class of the chip. + bitfile => The bitfile ID of the chip. + description => Human readable chip description string. + packages => List of supported packages. + Each entry is a tuple of two strings: ("PACKAGE", "description") + comment => Additional comment string. + broken => Boolean flag to mark the implementation as broken. + """ + self.chipImplClass = chipImplClass self.bitfile = bitfile + self.description = description + self.packages = packages + self.comment = comment self.broken = broken registeredChips.append(self) @@ -210,13 +222,48 @@ class RegisteredChip: return None @staticmethod - def dumpAll(fd, showBroken=True): + def dumpAll(fd, verbose=1, showBroken=True): "Dump all supported chips to file fd." + count = 0 for chip in registeredChips: - broken = "" - if chip.broken: - if not showBroken: - continue - broken = " (broken)" - fd.write("%20s%s\n" % (chip.bitfile, broken)) + if chip.broken and not showBroken: + continue + count = count + 1 + if count >= 2: + fd.write("\n") + chip.dump(fd, verbose) + + def dump(self, fd, verbose=1): + "Dump information about a registered chip to file fd." + if self.description: + fd.write(self.description) + else: + fd.write(self.bitfile) + if self.broken: + fd.write(" (broken implementation)") + fd.write("\n") + fd.write("%25s: %s\n" % ("BIT-file", self.bitfile)) + if verbose >= 3 and self.packages: + for (package, description) in self.packages: + if description: + description = " (" + description + ")" + fd.write("%25s: %s%s\n" % ("Supported package", package, description)) + if verbose >= 4: + supportedFeatures = ( + ("erase", "Full chip erase"), + ("readSignature", "Chip signature reading"), + ("readProgmem", "Program memory reading (flash)"), + ("writeProgmem", "Program memory writing (flash)"), + ("readEEPROM", "(E)EPROM memory reading"), + ("writeEEPROM", "(E)EPROM memory writing"), + ("readFuse", "Fuse bits reading"), + ("writeFuse", "Fuse bits writing"), + ("readLockbits", "Lock bits reading"), + ("writeLockbits", "Lock bits writing"), + ) + for (attr, description) in supportedFeatures: + if getattr(self.chipImplClass, attr) != getattr(Chip, attr): + fd.write("%25s: %s\n" % ("Support for", description)) + if verbose >= 2 and self.comment: + fd.write("%25s: %s\n" % ("Comment", self.comment)) diff --git a/libtoprammer/chip_at89c2051dip20.py b/libtoprammer/chip_at89c2051dip20.py index be1b3a4..67d2da4 100644 --- a/libtoprammer/chip_at89c2051dip20.py +++ b/libtoprammer/chip_at89c2051dip20.py @@ -225,4 +225,9 @@ class Chip_AT89C2051dip20(Chip): self.top.delay(0.001) self.throwError("Timeout in busywait.") -RegisteredChip(Chip_AT89C2051dip20, "at89c2051dip20") +RegisteredChip( + Chip_AT89C2051dip20, + bitfile = "at89c2051dip20", + description = "Atmel AT89C2051", + packages = ( ("DIP20", ""), ) +) diff --git a/libtoprammer/chip_atmega32dip40.py b/libtoprammer/chip_atmega32dip40.py index f6aac7c..d9c0660 100644 --- a/libtoprammer/chip_atmega32dip40.py +++ b/libtoprammer/chip_atmega32dip40.py @@ -22,7 +22,6 @@ from chip_atmega_common import * -# Note: Chip has to be inserted upside-down into the ZIF class Chip_ATMega32DIP40(Chip_ATMega_common): def __init__(self): @@ -37,4 +36,10 @@ class Chip_ATMega32DIP40(Chip_ATMega_common): eepromPageSize = 4, eepromPages = 256) -RegisteredChip(Chip_ATMega32DIP40, "atmega32dip40") +RegisteredChip( + Chip_ATMega32DIP40, + bitfile = "atmega32dip40", + description = "Atmel AtMega32", + packages = ( ("DIP40", ""), ), + comment = "Insert upside down into ZIF socket" +) diff --git a/libtoprammer/chip_atmega88dip28.py b/libtoprammer/chip_atmega88dip28.py index eff7e4a..6add218 100644 --- a/libtoprammer/chip_atmega88dip28.py +++ b/libtoprammer/chip_atmega88dip28.py @@ -36,4 +36,9 @@ class Chip_ATMega88DIP28(Chip_ATMega_common): eepromPageSize = 4, eepromPages = 128) -RegisteredChip(Chip_ATMega88DIP28, "atmega88dip28") +RegisteredChip( + Chip_ATMega88DIP28, + bitfile = "atmega88dip28", + description = "Atmel AtMega88", + packages = ( ("DIP28", ""), ), +) diff --git a/libtoprammer/chip_atmega8dip28.py b/libtoprammer/chip_atmega8dip28.py index 6b012ec..657ac97 100644 --- a/libtoprammer/chip_atmega8dip28.py +++ b/libtoprammer/chip_atmega8dip28.py @@ -36,4 +36,9 @@ class Chip_ATMega8DIP28(Chip_ATMega_common): eepromPageSize = 4, eepromPages = 128) -RegisteredChip(Chip_ATMega8DIP28, "atmega8dip28") +RegisteredChip( + Chip_ATMega8DIP28, + bitfile = "atmega8dip28", + description = "Atmel AtMega8", + packages = ( ("DIP28", ""), ) +) diff --git a/libtoprammer/chip_attiny26dip20.py b/libtoprammer/chip_attiny26dip20.py index e666b1a..c6815ec 100644 --- a/libtoprammer/chip_attiny26dip20.py +++ b/libtoprammer/chip_attiny26dip20.py @@ -36,4 +36,11 @@ class Chip_ATTiny26DIP20(Chip_ATMega_common): eepromPageSize = 4, eepromPages = 32) -RegisteredChip(Chip_ATTiny26DIP20, "attiny26dip20", broken=True) +RegisteredChip( + Chip_ATTiny26DIP20, + bitfile = "attiny26dip20", + description = "Atmel AtTiny26", + packages = ( ("DIP20", ""), ), + comment = "Special ZIF position", + broken = True +) diff --git a/libtoprammer/chip_m2764a.py b/libtoprammer/chip_m2764a.py index 80fcf3f..b4df5fc 100644 --- a/libtoprammer/chip_m2764a.py +++ b/libtoprammer/chip_m2764a.py @@ -170,4 +170,9 @@ class Chip_M2764A(Chip): self.top.delay(0.01) self.throwError("Timeout in busywait.") -RegisteredChip(Chip_M2764A, "m2764a") +RegisteredChip( + Chip_M2764A, + bitfile = "m2764a", + description = "M2764A EPROM", + packages = ( ("DIP28", ""), ), +) diff --git a/libtoprammer/chip_m8cissp.py b/libtoprammer/chip_m8cissp.py index 31f79dd..b6cc6bb 100644 --- a/libtoprammer/chip_m8cissp.py +++ b/libtoprammer/chip_m8cissp.py @@ -344,4 +344,11 @@ class Chip_M8C_ISSP(Chip): self.__loadVectorInputMask(inputMask) self.__loadVector(vector) -RegisteredChip(Chip_M8C_ISSP, "m8c-issp", broken=True) +RegisteredChip( + Chip_M8C_ISSP, + bitfile = "m8c-issp", + description = "Cypress M8C In System Serial Programmer", + packages = ( ("M8C ISSP header", "Special adapter"), ), + comment = "Special adapter required", + broken = True +) diff --git a/libtoprammer/chip_unitest.py b/libtoprammer/chip_unitest.py index ad55e6a..3a10df1 100644 --- a/libtoprammer/chip_unitest.py +++ b/libtoprammer/chip_unitest.py @@ -90,4 +90,8 @@ class Chip_Unitest(Chip): inputs = self.top.cmdReadStatusReg48() return inputs -RegisteredChip(Chip_Unitest, "unitest") +RegisteredChip( + Chip_Unitest, + bitfile = "unitest", + description = "Universal device tester", +) diff --git a/libtoprammer/chip_w29ee011dip32.py b/libtoprammer/chip_w29ee011dip32.py index faf02e8..89c252e 100644 --- a/libtoprammer/chip_w29ee011dip32.py +++ b/libtoprammer/chip_w29ee011dip32.py @@ -222,4 +222,9 @@ class Chip_w29ee011dip32(Chip): self.top.delay(0.01) self.throwError("Timeout in busywait.") -RegisteredChip(Chip_w29ee011dip32, "w29ee011dip32") +RegisteredChip( + Chip_w29ee011dip32, + bitfile = "w29ee011dip32", + description = "Winbond W29EE011 EEPROM", + packages = ( ("DIP32", ""), ("PLCC32", "Use 1:1 PLCC32->DIP32 adapter"), ) +) diff --git a/libtoprammer/toprammer_main.py b/libtoprammer/toprammer_main.py index e6d5c6f..05d2196 100644 --- a/libtoprammer/toprammer_main.py +++ b/libtoprammer/toprammer_main.py @@ -35,12 +35,12 @@ except (ImportError), e: from top_xxxx import * -# Import the supported chip modules +# Import the supported chip modules in alphabetical order +from chip_at89c2051dip20 import * from chip_atmega32dip40 import * from chip_atmega8dip28 import * from chip_atmega88dip28 import * from chip_attiny26dip20 import * -from chip_at89c2051dip20 import * from chip_m2764a import * from chip_m8cissp import * from chip_unitest import * diff --git a/toprammer b/toprammer index 90c0ab1..8e4a738 100755 --- a/toprammer +++ b/toprammer @@ -52,7 +52,8 @@ def usage(): print " -L|--write-lock FILE Write the lock bits" print "" print "Optional:" - print " -t|--list Print a list of supported chips and exit" + print " -t|--list Print a list of supported chips and exit." + print " Use -V|--verbose to control the list verbosity (1-4)" print " -d|--device BUS.DEV Use the programmer at BUS.DEV" print " First found programmer is used, if not given." print " -V|--verbose LEVEL Set the verbosity level. Default = 1" @@ -247,9 +248,7 @@ def main(argv): if o in ("-b", "--bitfile"): opt_bitfile = v if o in ("-t", "--list"): - print "Supported chips:" - RegisteredChip.dumpAll(sys.stdout) - return 0 + opt_action = "print-list" if o in ("-d", "--device"): try: v = v.split(".") @@ -301,7 +300,7 @@ def main(argv): except (getopt.GetoptError, ValueError), e: usage() return 1 - if not opt_bitfile: + if opt_action and opt_action != "print-list" and not opt_bitfile: print "-b|--bitfile is mandatory!" return 1 if not opt_action: @@ -315,6 +314,10 @@ def main(argv): return 1 try: + if opt_action == "print-list": + RegisteredChip.dumpAll(sys.stdout, verbose=opt_verbose, showBroken=True) + return 0 + bitfile = bitfileFind(opt_bitfile) if not bitfile: print "Bitfile " + opt_bitfile + " not found" -- cgit v1.2.3