bootloader_serial.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:tockloader 作者: helena-project 项目源码 文件源码
def _get_crc_internal_flash (self, address, length):
        '''
        Get the bootloader to compute a CRC.
        '''
        message = struct.pack('<II', address, length)
        success, crc = self._issue_command(self.COMMAND_CRC_INTERNAL_FLASH, message, True, 4, self.RESPONSE_CRC_INTERNAL_FLASH)

        # There is a bug in a version of the bootloader where the CRC returns 6
        # bytes and not just 4. Need to read just in case to grab those extra
        # bytes.
        self.sp.read(2)

        if not success:
            if crc[1] == self.RESPONSE_BADADDR:
                raise TockLoaderException('Error: RESPONSE_BADADDR: Invalid address for CRC (address: 0x{:X})'.format(address))
            elif crc[1] == self.RESPONSE_BADARGS:
                raise TockLoaderException('Error: RESPONSE_BADARGS: Invalid length for CRC check')
            else:
                raise TockLoaderException('Error: 0x{:X}'.format(crc[1]))

        return crc
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号