def ota_update(self, fwcmp, fwlen, chunksize, fwhash=None, patchlen=None, cb=None,
                   gcov_dump=False):
        """
        RPC call to attempt to update the unit's firmware.

        Parameters
        ----------
        fwcmp : bytes
            The compressed firmware image to upload to the Jade unit.  Can be a full firmware or
            and incremental diff to be applied to the currently running firmware image.
        fwlen : int
            The size of the new complete (uncompressed) firmware image (after any delta is applied).
        chunksize : int
            The size of the chunks used to upload the compressed firmware.  Each chunk is uploaded
            and ack'd by the hw unit.
            The maximum supported chunk size is given in the version info data, under the key
            'JADE_OTA_MAX_CHUNK'.
        fwhash: 32-bytes, optional
            The sha256 hash of the full uncompressed final firmware image.  In the case of a full
            firmware upload this should be the hash of the uncompressed file.  In the case of a
            delta update this is the hash of the expected final image - ie. the existing firmware
            with the uploaded delta applied.  ie. it is a verification of the fw image Jade will try
            to boot. Optional for backward-compatibility - may become mandatory in a future release.
        patchlen: int, optional
            If the compressed firmware bytes are an incremental diff to be applied to the running
            firmware image, this is the size of that patch when uncompressed.
            Defaults to None, implying the compressed data is a full firmware image upload.
            (Compare with fwlen - the size of the final fw image.)
        cb : function, optional
            Callback function accepting two integers - the amount of compressed firmware sent thus
            far, and the total length of the compressed firmware to send.
            If passed, this function is invoked each time a fw chunk is successfully uploaded and
            ack'd by the hw, to notify of upload progress.
            Defaults to None, and nothing is called to report upload progress.

        Returns
        -------
        bool
            True if no errors were reported - on next restart the hw unit will attempt to boot the
            new firmware.
        """

        # Compute the sha256 hash of the compressed file being uploaded
        cmphasher = hashlib.sha256()
        cmphasher.update(fwcmp)
        cmphash = cmphasher.digest()
        cmplen = len(fwcmp)

        # Initiate OTA
        ota_method = 'ota'
        params = {'fwsize': fwlen,
                  'cmpsize': cmplen,
                  'cmphash': cmphash}

        if fwhash is not None:
            params['fwhash'] = fwhash

        if patchlen is not None:
            ota_method = 'ota_delta'
            params['patchsize'] = patchlen

        result = self._jadeRpc(ota_method, params)
        assert result is True

        # Write binary chunks
        written = 0
        while written < cmplen:
            remaining = cmplen - written
            length = min(remaining, chunksize)
            chunk = bytes(fwcmp[written:written + length])
            result = self._jadeRpc('ota_data', chunk)
            assert result is True
            written += length

            if (cb):
                cb(written, cmplen)

        if gcov_dump:
            self.run_remote_gcov_dump()

        # All binary data uploaded
        return self._jadeRpc('ota_complete')

        RPC call to attempt to update the unit's firmware.

        Parameters
        ----------
        fwcmp : bytes
            The compressed firmware image to upload to the Jade unit.  Can be a full firmware or
            and incremental diff to be applied to the currently running firmware image.
        fwlen : int
            The size of the new complete (uncompressed) firmware image (after any delta is applied).
        chunksize : int
            The size of the chunks used to upload the compressed firmware.  Each chunk is uploaded
            and ack'd by the hw unit.
            The maximum supported chunk size is given in the version info data, under the key
            'JADE_OTA_MAX_CHUNK'.
        fwhash: 32-bytes, optional
            The sha256 hash of the full uncompressed final firmware image.  In the case of a full
            firmware upload this should be the hash of the uncompressed file.  In the case of a
            delta update this is the hash of the expected final image - ie. the existing firmware
            with the uploaded delta applied.  ie. it is a verification of the fw image Jade will try
            to boot. Optional for backward-compatibility - may become mandatory in a future release.
        patchlen: int, optional
            If the compressed firmware bytes are an incremental diff to be applied to the running
            firmware image, this is the size of that patch when uncompressed.
            Defaults to None, implying the compressed data is a full firmware image upload.
            (Compare with fwlen - the size of the final fw image.)
        cb : function, optional
            Callback function accepting two integers - the amount of compressed firmware sent thus
            far, and the total length of the compressed firmware to send.
            If passed, this function is invoked each time a fw chunk is successfully uploaded and
            ack'd by the hw, to notify of upload progress.
            Defaults to None, and nothing is called to report upload progress.

        Returns
        -------
        bool
            True if no errors were reported - on next restart the hw unit will attempt to boot the
            new firmware.
        
electrum/plugins/jade/jadepy/jade.py