Beispiel #1
0
    def wait_unlocked(self, timeout_ms):
        """
            Waits for the device to be unlocked.
            All devices boot up as locked until proven otherwise
        """

        timeout = Timeout(timeout_ms)

        while not timeout.expired():
            if not self.datalink.ldcs(constants.UPDI_ASI_SYS_STATUS) & (1 << constants.UPDI_ASI_SYS_STATUS_LOCKSTATUS):
                return True

        self.logger.info("Timeout waiting for device to unlock")
        return False
Beispiel #2
0
    def wait_flash_ready(self):
        """
            Waits for the NVM controller to be ready
        """

        timeout = Timeout(10000) # TODO 10 sec timeout, just to be sure

        self.logger.info("Wait flash ready")
        while not timeout.expired():
            status = self.datalink.ld(self.device.nvmctrl_address + constants.UPDI_NVMCTRL_STATUS)
            if status & (1 << constants.UPDI_NVM_STATUS_WRITE_ERROR):
                self.logger.info("NVM error")
                return False

            if not status & ((1 <<constants.UPDI_NVM_STATUS_EEPROM_BUSY) | (1 << constants.UPDI_NVM_STATUS_FLASH_BUSY)):
                return True

        self.logger.error("Wait flash ready timed out")
        return False