class BootLoaderJobs(): def __init__(self, port, baund=115200, address=0x08000000): self.port = port self.baund = baund self.address = address self.cmd = CommandInterface() def initialChip(self): self.cmd.open(self.port, self.baund) print "Run " + self.port self.cmd.initChip() def getChipInformation(self): bootversion = self.cmd.cmdGet() print "Bootloader version " + str(bootversion) chipId = self.cmd.cmdGetID() print "Chip id: 0x" + str(chipId) + " " + self.chip_ids.get( chipId, "Unknown") def releasePort(self): self.cmd.releaseChip() self.cmd.sp.close() def killport(self): self.cmd.killChip() self.cmd.sp.close()
class BootLoaderJobs(): def __init__(self,port,baund = 115200, address = 0x08000000): self.port = port self.baund = baund self.address = address self.cmd = CommandInterface() def initialChip(self): self.cmd.open(self.port, self.baund) print "Run " + self.port self.cmd.initChip() def getChipInformation(self): bootversion = self.cmd.cmdGet() print "Bootloader version " + str(bootversion) chipId = self.cmd.cmdGetID() print "Chip id: 0x" + str(chipId) + " " + self.chip_ids.get(chipId, "Unknown") def releasePort(self): self.cmd.releaseChip() self.cmd.sp.close() def killport(self): self.cmd.killChip() self.cmd.sp.close()
def __init__(self, port, baund=115200, address=0x08000000): self.port = port self.baund = baund self.address = address self.cmd = CommandInterface()
class BootLoaderJobs(): chip_ids = { 0x412: "STM32 Low-density", 0x410: "STM32 Medium-density", 0x414: "STM32 High-density", 0x420: "STM32 Medium-density value line", 0x428: "STM32 High-density value line", 0x430: "STM32 XL-density", 0x416: "STM32 Medium-density ultralow power line", 0x411: "STM32F2xx", 0x413: "STM32F4xx", } def __init__(self, port, baund=115200, address=0x08000000): self.port = port self.baund = baund self.address = address self.cmd = CommandInterface() def initialChip(self): self.cmd.open(self.port, self.baund) print "Open port" + self.port + ", baud " + str(self.baund) self.cmd.initChip() # turn of debugging information def turnOffDebugging(self): self.cmd.quiet() # this function will download the target file to the device at 0x8000000 and verify. def downloadJob(self, binFile): status = False # True instead of success, False instead of Failed print "1. Erase memory first. Erasing..." self.cmd.cmdEraseMemory(WRPxPages) print "2. Erase Done. Waiting for writing..." data = map(lambda c: ord(c), file(binFile, 'rb').read()) self.cmd.writeMemory(self.address, data) print "3. EndOfWrite. Waiting for verifying..." verify = self.cmd.readMemory(self.address, len(data)) if (data == verify): print "4. Verification OK" print "Download on port " + self.port + " successfully! :)" status = True else: print "4. Verification FAILED" print str(len(data)) + ' vs ' + str(len(verify)) for i in xrange(0, len(data)): if data[i] != verify[i]: print hex(i) + ': ' + hex(data[i]) + ' vs ' + hex( verify[i]) return status def getChipInformation(self): bootversion = self.cmd.cmdGet() print "Bootloader version " + str(bootversion) chipId = self.cmd.cmdGetID() print "Chip id: 0x" + str(chipId) + " " + self.chip_ids.get( chipId, "Unknown") def releasePort(self): self.cmd.releaseChip() self.cmd.sp.close() def killport(self): self.cmd.killChip() self.cmd.sp.close()
def __init__(self,port,baund = 115200, address = 0x08000000): self.port = port self.baund = baund self.address = address self.cmd = CommandInterface()
class BootLoaderJobs(): chip_ids = { 0x412: "STM32 Low-density", 0x410: "STM32 Medium-density", 0x414: "STM32 High-density", 0x420: "STM32 Medium-density value line", 0x428: "STM32 High-density value line", 0x430: "STM32 XL-density", 0x416: "STM32 Medium-density ultralow power line", 0x411: "STM32F2xx", 0x413: "STM32F4xx", } def __init__(self,port,baund = 115200, address = 0x08000000): self.port = port self.baund = baund self.address = address self.cmd = CommandInterface() def initialChip(self): self.cmd.open(self.port, self.baund) print "Open port" + self.port + ", baud " + str(self.baund) self.cmd.initChip() # turn of debugging information def turnOffDebugging(self): self.cmd.quiet() # this function will download the target file to the device at 0x8000000 and verify. def downloadJob(self,binFile): status = False # True instead of success, False instead of Failed print "Erase memory first. Erasing..." self.cmd.cmdEraseMemory(WRPxPages) print "Waiting for writing..." data = map(lambda c: ord(c), file(binFile, 'rb').read()) self.cmd.writeMemory(self.address, data) print "\nEndOfWrite. Waiting for verifying..." verify = self.cmd.readMemory(self.address, len(data)) if(data == verify): print "\nVerification OK!" print "Download on port " + self.port + " successfully! :)" status = True else: print "\nVerification FAILED!" print str(len(data)) + ' vs ' + str(len(verify)) for i in xrange(0, len(data)): if data[i] != verify[i]: print hex(i) + ': ' + hex(data[i]) + ' vs ' + hex(verify[i]) return status def getChipInformation(self): bootversion = self.cmd.cmdGet() print "Bootloader version " + str(bootversion) chipId = self.cmd.cmdGetID() print "Chip id: 0x" + str(chipId) + " " + self.chip_ids.get(chipId, "Unknown") def releasePort(self): self.cmd.releaseChip() self.cmd.sp.close()