def flash_defl_begin(self, size, compsize, offset):
        """ Start downloading compressed data to Flash (performs an erase)

        Returns number of blocks (size self.FLASH_WRITE_SIZE) to write.
        """
        num_blocks = (compsize + self.FLASH_WRITE_SIZE - 1) // self.FLASH_WRITE_SIZE
        erase_blocks = (size + self.FLASH_WRITE_SIZE - 1) // self.FLASH_WRITE_SIZE

        t = time.time()
        if self.IS_STUB:
            write_size = size  # stub expects number of bytes here, manages erasing internally
            timeout = DEFAULT_TIMEOUT
        else:
            write_size = erase_blocks * self.FLASH_WRITE_SIZE  # ROM expects rounded up to erase block size
            timeout = timeout_per_mb(ERASE_REGION_TIMEOUT_PER_MB, write_size)  # ROM performs the erase up front
        print("Compressed %d bytes to %d..." % (size, compsize))
        self.check_command("enter compressed flash mode", self.ESP_FLASH_DEFL_BEGIN,
                           struct.pack('<IIII', write_size, num_blocks, self.FLASH_WRITE_SIZE, offset),
                           timeout=timeout)
        if size != 0 and not self.IS_STUB:
            # (stub erases as it writes, but ROM loaders erase on begin)
            print("Took %.2fs to erase flash block" % (time.time() - t))
        return num_blocks
def flash_defl_begin ( self , size , compsize , offset ) : num_blocks = ( compsize + self . FLASH_WRITE_SIZE - 1 ) // self . FLASH_WRITE_SIZE erase_blocks = ( size + self . FLASH_WRITE_SIZE - 1 ) // self . FLASH_WRITE_SIZE t = time . time ( ) if self . IS_STUB : write_size = size timeout = DEFAULT_TIMEOUT else : write_size = erase_blocks * self . FLASH_WRITE_SIZE timeout = timeout_per_mb ( ERASE_REGION_TIMEOUT_PER_MB , write_size ) print ( "Compressed %d bytes to %d..." % ( size , compsize ) ) self . check_command ( "enter compressed flash mode" , self . ESP_FLASH_DEFL_BEGIN , struct . pack ( '<IIII' , write_size , num_blocks , self . FLASH_WRITE_SIZE , offset ) , timeout = timeout ) if size != 0 and not self . IS_STUB : print ( "Took %.2fs to erase flash block" % ( time . time ( ) - t ) ) return num_blocks
Start downloading compressed data to Flash (performs an erase)

        Returns number of blocks (size self.FLASH_WRITE_SIZE) to write.