def bootload_8(paddr, hex_file, power_communicator): """ Bootload a 8 port power module. :param paddr: The address of a power module (integer). :param hex_file: The filename of the hex file to write. :param power_communicator: Communication with the power modules. """ reader = HexReader(hex_file) print "E%d - Going to bootloader" % paddr power_communicator.do_command(paddr, bootloader_goto(), 10) print "E%d - Reading chip id" % paddr id = power_communicator.do_command(paddr, bootloader_read_id()) if id[0] != 213: raise Exception("Unknown chip id: %d" % id[0]) print "E%d - Writing vector tabel" % paddr for address in range(0, 1024, 128): # 0x000 - 0x400 print " Writing %d" % address bytes = reader.get_bytes_8(address) power_communicator.do_command(paddr, bootloader_write_code(POWER_API_8_PORTS), *bytes) print "E%d - Writing code" % paddr for address in range(8192, 44032, 128): # 0x2000 - 0xAC00 print " Writing %d" % address bytes = reader.get_bytes_8(address) power_communicator.do_command(paddr, bootloader_write_code(POWER_API_8_PORTS), *bytes) print "E%d - Jumping to application" % paddr power_communicator.do_command(paddr, bootloader_jump_application())
def bootload_power_module(module_address, hex_file, power_communicator, version): """ Bootload a 8 port power module. :param module_address: The address of a power module (integer). :param hex_file: The filename of the hex file to write. :param power_communicator: Communication with the power modules. :param version: Version of the provided hexfile """ firmware_version, hardware_version = get_module_firmware_version( module_address, power_api.POWER_MODULE, power_communicator) logger.info('P{0} - Version: {1} ({2})'.format(module_address, firmware_version, hardware_version)) if firmware_version == version: logger.info('P{0} - Already up-to-date. Skipping') return logger.info('P{0} - Start bootloading'.format(module_address)) reader = HexReader(hex_file) logger.info('P{0} - Going to bootloader'.format(module_address)) power_communicator.do_command( module_address, power_api.bootloader_goto(power_api.POWER_MODULE), 10) logger.info('P{0} - Reading chip id'.format(module_address)) chip_id = power_communicator.do_command(module_address, power_api.bootloader_read_id()) if chip_id[0] != 213: raise Exception('Unknown chip id: {0}'.format(chip_id[0])) logger.info('P{0} - Writing vector tabel'.format(module_address)) for address in range(0, 1024, 128): # 0x000 - 0x400 data = reader.get_bytes_version_8(address) power_communicator.do_command( module_address, power_api.bootloader_write_code(power_api.POWER_MODULE), *data) logger.info('P{0} - Writing code'.format(module_address)) for address in range(8192, 44032, 128): # 0x2000 - 0xAC00 data = reader.get_bytes_version_8(address) power_communicator.do_command( module_address, power_api.bootloader_write_code(power_api.POWER_MODULE), *data) logger.info('P{0} - Jumping to application'.format(module_address)) power_communicator.do_command(module_address, power_api.bootloader_jump_application()) logger.info('P{0} - Done'.format(module_address))
def bootload_8(module_address, hex_file, power_communicator): """ Bootload a 8 port power module. :param module_address: The address of a power module (integer). :param hex_file: The filename of the hex file to write. :param power_communicator: Communication with the power modules. """ logger.info('E{0} - Version: {0}'.format( module_address, get_module_firmware_version(module_address, power_communicator))) logger.info('E{0} - Start bootloading'.format(module_address)) reader = HexReader(hex_file) logger.info('E{0} - Going to bootloader'.format(module_address)) power_communicator.do_command(module_address, bootloader_goto(), 10) logger.info('E{0} - Reading chip id'.format(module_address)) chip_id = power_communicator.do_command(module_address, bootloader_read_id()) if chip_id[0] != 213: raise Exception('Unknown chip id: {0}'.format(chip_id[0])) logger.info('E{0} - Writing vector tabel'.format(module_address)) for address in range(0, 1024, 128): # 0x000 - 0x400 data = reader.get_bytes_version_8(address) power_communicator.do_command(module_address, bootloader_write_code(POWER_API_8_PORTS), *data) logger.info('E{0} - Writing code'.format(module_address)) for address in range(8192, 44032, 128): # 0x2000 - 0xAC00 data = reader.get_bytes_version_8(address) power_communicator.do_command(module_address, bootloader_write_code(POWER_API_8_PORTS), *data) logger.info('E{0} - Jumping to application'.format(module_address)) power_communicator.do_command(module_address, bootloader_jump_application()) logger.info('E{0} - Done'.format(module_address))
def bootload_8(paddr, hex_file, power_communicator, verbose=False): """ Bootload a 8 port power module. :param paddr: The address of a power module (integer). :param hex_file: The filename of the hex file to write. :param power_communicator: Communication with the power modules. :param verbose: Show serial command on output if verbose is True. """ reader = HexReader(hex_file) print "E%d - Going to bootloader" % paddr power_communicator.do_command(paddr, bootloader_goto(), 10) print "E%d - Reading chip id" % paddr id = power_communicator.do_command(paddr, bootloader_read_id()) if id[0] != 213: raise Exception("Unknown chip id: %d" % id[0]) print "E%d - Writing vector tabel" % paddr for address in range(0, 1024, 128): # 0x000 - 0x400 print " Writing %d" % address bytes = reader.get_bytes_8(address) power_communicator.do_command(paddr, bootloader_write_code(POWER_API_8_PORTS), *bytes) print "E%d - Writing code" % paddr for address in range(8192, 44032, 128): # 0x2000 - 0xAC00 print " Writing %d" % address bytes = reader.get_bytes_8(address) power_communicator.do_command(paddr, bootloader_write_code(POWER_API_8_PORTS), *bytes) print "E%d - Jumping to application" % paddr power_communicator.do_command(paddr, bootloader_jump_application())