#!/usr/bin/env python # -*- coding: utf-8 -*- # # SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 from __future__ import unicode_literals import filecmp import hashlib import os import random import struct import sys import tempfile import time import unittest from functools import partial from io import open from itertools import chain import pexpect current_dir = os.path.dirname(os.path.realpath(__file__)) mkuf2_dir = os.path.abspath(os.path.join(current_dir, '..')) mkuf2_path = os.path.join(mkuf2_dir, 'mkuf2.py') try: import mkuf2 except ImportError: sys.path.append(mkuf2_dir) import mkuf2 class UF2Block(object): def __init__(self, bs): self.length = len(bs) # See https://github.com/microsoft/uf2 for the format first_part = '<' + 'I' * 8 # payload is between last_part = '