コード例 #1
0
ファイル: qt4-ide.py プロジェクト: mrmichalis/openmv
    def flash_update(self, buf):
        flash_offsets = [0x08000000, 0x08004000, 0x08008000, 0x0800C000,
                         0x08010000, 0x08020000, 0x08040000, 0x08060000,
                         0x08080000, 0x080A0000, 0x080C0000, 0x080E0000]

        # Erasing
        total = len(flash_offsets)

        progress = QProgressDialog(self)
        progress.setRange(0, total)
        progress.setValue(0)
        progress.setModal(True)
        progress.show()
        progress.setAutoReset(False)
        progress.setLabelText('Initializing')

        # call dfu-util
        openmv.enter_dfu()
        sleep(1.0)

        # Initialize
        pydfu.init()

        progress.setLabelText('Erasing')
        progress.setValue(0)

        pg = 0
        for offset in flash_offsets:
            progress.setValue(pg)
            pydfu.page_erase(flash_offsets[pg])
            pg += 1

        offset = 0
        size = len(buf)
        progress.setRange(0, size)
        progress.setLabelText('Downloading')

        while offset < size:
            progress.setValue(offset)
            pg_size = min(64, size - offset)
            page = buf[offset:offset + pg_size]
            pydfu.write_page(page, offset)
            offset += pg_size

        progress.hide()
        pydfu.exit_dfu()
コード例 #2
0
ファイル: openmv-ide.py プロジェクト: 12019/openmv
    def fwupdate_task(self, state):
        if (state["init"]):
            pydfu.init()
            state["init"]=False
            state["erase"]=True
            state["bar"].set_text("Erasing...")
            return True
        elif (state["erase"]):
            page = state["page"]
            total = len(FLASH_OFFSETS)
            pydfu.page_erase(FLASH_OFFSETS[page])
            page +=1
            state["bar"].set_fraction(page/float(total))
            if (page == total):
                state["erase"] = False
                state["write"] = True
                state["bar"].set_text("Uploading...")
            state["page"] = page
            return True
        elif (state["write"]):
            buf = state["buf"]
            xfer_bytes = state["xfer_bytes"]
            xfer_total = state["xfer_total"]

            # Send chunk
            chunk = min (64, xfer_total-xfer_bytes)
            pydfu.write_page(buf[xfer_bytes:xfer_bytes+chunk], xfer_bytes)

            xfer_bytes += chunk
            state["xfer_bytes"] = xfer_bytes
            state["bar"].set_fraction(xfer_bytes/float(xfer_total))

            if (xfer_bytes == xfer_total):
                pydfu.exit_dfu()
                state["dialog"].hide()
                self.disconnect()
                return False

            return True
コード例 #3
0
ファイル: openmv-ide.py プロジェクト: rpg-rs/openmv
    def fwupdate_task(self, state):
        if (state["init"]):
            pydfu.init()
            state["init"] = False
            state["erase"] = True
            state["bar"].set_text("Erasing...")
            return True
        elif (state["erase"]):
            page = state["page"]
            total = len(FLASH_OFFSETS)
            pydfu.page_erase(FLASH_OFFSETS[page])
            page += 1
            state["bar"].set_fraction(page / float(total))
            if (page == total):
                state["erase"] = False
                state["write"] = True
                state["bar"].set_text("Uploading...")
            state["page"] = page
            return True
        elif (state["write"]):
            buf = state["buf"]
            xfer_bytes = state["xfer_bytes"]
            xfer_total = state["xfer_total"]

            # Send chunk
            chunk = min(64, xfer_total - xfer_bytes)
            pydfu.write_page(buf[xfer_bytes:xfer_bytes + chunk], xfer_bytes)

            xfer_bytes += chunk
            state["xfer_bytes"] = xfer_bytes
            state["bar"].set_fraction(xfer_bytes / float(xfer_total))

            if (xfer_bytes == xfer_total):
                pydfu.exit_dfu()
                state["dialog"].hide()
                self.disconnect()
                return False

            return True