def read_device_id(self): """ Read the device info :returns: Device ID raw bytes (Little endian) """ sib = bytearray(self.avr.sib_read()) decode_sib(sib) self.logger.info( "PDI revision = 0x%02X", self.avr.memory_read(Avr8Protocol.AVR8_MEMTYPE_CS, 0, 1)[0] >> 4) device_memory_info = DeviceMemoryInfo(self.device_info) signatures_info = device_memory_info.memory_info_by_name( MemoryNames.SIGNATURES) signatures_address = signatures_info[DeviceMemoryInfoKeys.ADDRESS] sig = self.avr.memory_read(self.avr.memtype_read_from_string("raw"), signatures_address, 3) device_id_read = binary.unpack_be24(sig) self.logger.info("Device ID: '%06X'", device_id_read) if not self.device_info.get( DeviceInfoKeysAvr.DEVICE_ID) == device_id_read: self.logger.warning( "ID read ('%06X') does not match expected device id! ('%06X')", device_id_read, self.device_info.get(DeviceInfoKeysAvr.DEVICE_ID)) revision = self.avr.memory_read( self.avr.memtype_read_from_string("raw"), self.device_info.get(DeviceInfoKeysAvr.SYSCFG_BASE) + 1, 1) self.logger.info("Device revision: '%s'", chr(revision[0] + ord('A'))) # Return the raw signature bytes, but swap the endianness as target sends ID as Big endian return bytearray([sig[2], sig[1], sig[0]])
def read_device_id(self): """ Read and display (log) the device info :returns: Device ID raw bytes (Little endian) """ self.avr.read_device_info() signatures_base = self.dut.sigrow_address # Read 3 bytes sig = self.avr.read_data(signatures_base, 3) device_id_read = binary.unpack_be24(sig) self.logger.info("Device ID: '%06X'", device_id_read) if not self.device_info.get( DeviceInfoKeysAvr.DEVICE_ID) == device_id_read: self.logger.warning( "ID read ('%06X') does not match expected device id! ('%06X')", device_id_read, self.device_info.get(DeviceInfoKeysAvr.DEVICE_ID)) raise ValueError("Device ID does not match") revision = self.avr.read_data( self.device_info.get(DeviceInfoKeysAvr.SYSCFG_BASE) + 1, 1) self.logger.info("Device revision: '%s'", chr(revision[0] + ord('A'))) serial = self.avr.read_data(signatures_base + 3, 10) self.logger.info("Device serial number: '%s'", binascii.hexlify(serial)) # Return the raw signature bytes, but swap the endianness as target sends ID as Big endian return bytearray([sig[2], sig[1], sig[0]])
def read_device_id(self): """ Read and display (log) the device info :returns: Device ID raw bytes (little endian) :raises PymcuprogSessionError: if device ID does not match """ sib_info = self.avr.read_device_info() self.logger.info("Device family: '%s'", sib_info['family']) signatures_base = self.dut.sigrow_address # Read 3 bytes sig = self.avr.read_data(signatures_base, 3) if len(sig) != 3: self.logger.error( "Unable to read signature for detected device in family: '%s'", sib_info['family']) raise PymcuprogSessionError("Unable to read device ID") device_id_read = binary.unpack_be24(sig) self.logger.info("Device ID: '%06X'", device_id_read) if not self.device_info.get( DeviceInfoKeysAvr.DEVICE_ID) == device_id_read: raise PymcuprogSessionError( "Device ID mismatch: read out '{0:X}'; expected '{1:X}'.". format(device_id_read, self.device_info.get(DeviceInfoKeysAvr.DEVICE_ID))) revision = self.avr.read_data( self.device_info.get(DeviceInfoKeysAvr.SYSCFG_BASE) + 1, 1) self.logger.debug("Device revision: 0x%02x", revision[0]) self.logger.info("Device revision: '%x.%x'", revision[0] >> 4, revision[0] & 0x0F) serial = self.avr.read_data(signatures_base + 3, 10) self.logger.info("Device serial number: '%s'", binascii.hexlify(serial)) # Return the raw signature bytes, but swap the endianness as target sends ID as Big endian return bytearray([sig[2], sig[1], sig[0]])
def read_device_id(self): """ Read the device info :returns: Device ID raw bytes (little endian) :raises PymcuprogSessionError: if device ID does not match """ sib = bytearray(self.avr.sib_read()) decode_sib(sib) self.logger.info( "PDI revision = 0x%02X", self.avr.memory_read(Avr8Protocol.AVR8_MEMTYPE_CS, 0, 1)[0] >> 4) device_memory_info = DeviceMemoryInfo(self.device_info) signatures_info = device_memory_info.memory_info_by_name( MemoryNames.SIGNATURES) signatures_address = signatures_info[DeviceMemoryInfoKeys.ADDRESS] sig = self.avr.memory_read(self.avr.memtype_read_from_string("raw"), signatures_address, 3) device_id_read = binary.unpack_be24(sig) self.logger.info("Device ID: '%06X'", device_id_read) if not self.device_info.get( DeviceInfoKeysAvr.DEVICE_ID) == device_id_read: raise PymcuprogSessionError( "Device ID mismatch: read out '{0:X}'; expected '{1:X}'.". format(device_id_read, self.device_info.get(DeviceInfoKeysAvr.DEVICE_ID))) revision = self.avr.memory_read( self.avr.memtype_read_from_string("raw"), self.device_info.get(DeviceInfoKeysAvr.SYSCFG_BASE) + 1, 1) self.logger.debug("Device revision: 0x%02x", revision[0]) self.logger.info("Device revision: '%x.%x'", revision[0] >> 4, revision[0] & 0x0F) # Return the raw signature bytes, but swap the endianness as target sends ID as Big endian return bytearray([sig[2], sig[1], sig[0]])