def create_execfw_cmd(self): """ Creates a command to excute firmware """ cmd = 'Execute' print('CMD >>> %s.' % cmd) code = self.get_cmd_code(cmd) EXE_FW_HEADER_LEN = 1 count = EXE_FW_HEADER_LEN self.init_tx_data() index = list(self.message_id.values()).index('Control') msg_id = list(self.message_id.keys())[index] bitstruct.pack_into_dict( self.cmd_word_fmt, self.cmd_keys, self.tx_data, 0, { 'cmd': 1, 'rsvd1': 0, 'rsp': 0, 'msg_id': msg_id, 'rsvd2': 0, 'cmd_rsp': code }) self.tx_index += 4 bitstruct.pack_into('u32', self.tx_data, self.tx_index * 8, count) self.tx_index += 4 bitstruct.pack_into('u32', self.tx_data, self.tx_index * 8, 0xbe000000) self.tx_index += 4 return self.tx_data
def create_memread_cmd(self, tuple): """ Creates a memory read command with memory addresses """ cmd = 'Memory Read' print('CMD >>> %s.' % cmd) code = self.get_cmd_code(cmd) self.init_tx_data() index = list(self.message_id.values()).index('Control') msg_id = list(self.message_id.keys())[index] bitstruct.pack_into_dict( self.cmd_word_fmt, self.cmd_keys, self.tx_data, 0, { 'cmd': 1, 'rsvd1': 0, 'rsp': 0, 'msg_id': msg_id, 'rsvd2': 0, 'cmd_rsp': code }) self.tx_index += 4 bitstruct.pack_into('u32', self.tx_data, self.tx_index * 8, len(tuple)) self.tx_index += 4 for index in range(len(tuple)): bitstruct.pack_into('u32', self.tx_data, self.tx_index * 8, tuple[index]) self.tx_index += 4 return self.tx_data
def create_execfw_cmd(self): """ Creates a command to excute firmware """ cmd = 'Execute' print('CMD >>> %s.' % cmd) code = self.get_cmd_code(cmd) EXE_FW_HEADER_LEN = 1 count = EXE_FW_HEADER_LEN self.init_tx_data() index = list(self.message_id.values()).index('Control') msg_id = list(self.message_id.keys())[index] bitstruct.pack_into_dict(self.cmd_word_fmt, self.cmd_keys, self.tx_data, 0, {'cmd': 1, 'rsvd1': 0, 'rsp': 0, 'msg_id': msg_id, 'rsvd2': 0, 'cmd_rsp': code}) self.tx_index += 4 bitstruct.pack_into('u32', self.tx_data, self.tx_index * 8, count) self.tx_index += 4 bitstruct.pack_into('u32', self.tx_data, self.tx_index * 8, 0xbe000000) self.tx_index += 4 return self.tx_data
def create_loadfw_cmd(self, size, sha): """ Creates a command to load firmware with associated paramters """ cmd = 'Load Firmware' print('CMD >>> %s.' % cmd) code = self.get_cmd_code(cmd) FW_NO_EXEC_FLAG = (1 << 26) SEL_HP_CLK = (1 << 21) LD_FW_HEADER_LEN = 3 count_flags = FW_NO_EXEC_FLAG | SEL_HP_CLK count_flags |= (LD_FW_HEADER_LEN + int(len(sha) / 4)) self.init_tx_data() index = list(self.message_id.values()).index('Control') msg_id = list(self.message_id.keys())[index] bitstruct.pack_into_dict(self.cmd_word_fmt, self.cmd_keys, self.tx_data, 0, {'cmd': 1, 'rsvd1': 0, 'rsp': 0, 'msg_id': msg_id, 'rsvd2': 0, 'cmd_rsp': code}) self.tx_index += 4 bitstruct.pack_into('u32', self.tx_data, self.tx_index * 8, count_flags) self.tx_index += 4 bitstruct.pack_into('u32', self.tx_data, self.tx_index * 8, 0xbe000000) self.tx_index += 4 bitstruct.pack_into('u32', self.tx_data, self.tx_index * 8, 0) self.tx_index += 4 bitstruct.pack_into('u32', self.tx_data, self.tx_index * 8, size) self.tx_index += 4 self.endian_swap(self.tx_data, self.tx_index, sha) self.tx_index += len(sha) return self.tx_data
def create_loadfw_cmd(self, size, sha): """ Creates a command to load firmware with associated paramters """ cmd = 'Load Firmware' print('CMD >>> %s.' % cmd) code = self.get_cmd_code(cmd) FW_NO_EXEC_FLAG = (1 << 26) SEL_HP_CLK = (1 << 21) LD_FW_HEADER_LEN = 3 count_flags = FW_NO_EXEC_FLAG | SEL_HP_CLK count_flags |= (LD_FW_HEADER_LEN + int(len(sha) / 4)) self.init_tx_data() index = list(self.message_id.values()).index('Control') msg_id = list(self.message_id.keys())[index] bitstruct.pack_into_dict( self.cmd_word_fmt, self.cmd_keys, self.tx_data, 0, { 'cmd': 1, 'rsvd1': 0, 'rsp': 0, 'msg_id': msg_id, 'rsvd2': 0, 'cmd_rsp': code }) self.tx_index += 4 bitstruct.pack_into('u32', self.tx_data, self.tx_index * 8, count_flags) self.tx_index += 4 bitstruct.pack_into('u32', self.tx_data, self.tx_index * 8, 0xbe000000) self.tx_index += 4 bitstruct.pack_into('u32', self.tx_data, self.tx_index * 8, 0) self.tx_index += 4 bitstruct.pack_into('u32', self.tx_data, self.tx_index * 8, size) self.tx_index += 4 self.endian_swap(self.tx_data, self.tx_index, sha) self.tx_index += len(sha) return self.tx_data
def create_memread_cmd(self, tuple): """ Creates a memory read command with memory addresses """ cmd = 'Memory Read' print('CMD >>> %s.' % cmd) code = self.get_cmd_code(cmd) self.init_tx_data() index = list(self.message_id.values()).index('Control') msg_id = list(self.message_id.keys())[index] bitstruct.pack_into_dict(self.cmd_word_fmt, self.cmd_keys, self.tx_data, 0, {'cmd': 1, 'rsvd1': 0, 'rsp': 0, 'msg_id': msg_id, 'rsvd2': 0, 'cmd_rsp': code}) self.tx_index += 4 bitstruct.pack_into('u32', self.tx_data, self.tx_index * 8, len(tuple)) self.tx_index += 4 for index in range(len(tuple)): bitstruct.pack_into('u32', self.tx_data, self.tx_index * 8, tuple[index]) self.tx_index += 4 return self.tx_data