コード例 #1
0
    def __init__(self, logger=None):
        """
        Constructor

        :type logger: object
        :param logger: logger name
        """
        FlashToolBase.__init__(self, "EFT", logger)

        # Specific to Flash Tool
        self._logger = logger if logger else LOGGER_TEST_SCRIPT
        self._flash_tool_state = "INIT"
        self._serial = None
        self._soc_serial = None
        self._switch_device_state_fct = None
        self._first_file_flashing = False
        self._pos_mode_on_exec_thread = None
        self._flash_file = None
コード例 #2
0
    def flash(self, flash_file_list, device_info, timeout):
        """
        Start the flash execution for the flash tool (flash procedure with device state change)

        :type flash_file_list: list
        :param flash_file_list: list containing flash file absolute paths
        :type device_info: FlashDeviceInfo
        :param device_info: contain all device information needed by the flash tool
        :type timeout: int
        :param timeout: max time in seconds to do flash procedure

        :rtype: int
        :return: result of the flash procedure (Global.SUCCESS, Global.FAILURE, Global.BLOCKED)
        """
        # Check flash file availability and format
        self._flash_file = self._check_flash_files(flash_file_list)

        self.__check_flash_script()

        self._retrieve_device_info(device_info)

        self._logger.info("EFT: Initiate flashing procedure")
        # Device can be flashed
        self._flash_tool_state = "FLASH_INIT_STATE"
        self._first_file_flashing = True

        # Flash flash file passed
        flash_return_code = FlashToolBase._flash(self, timeout)

        self._first_file_flashing = False

        if flash_return_code == Global.FAILURE:
            # Flash has failed on a flash file => stop the flash procedure (do not flash other flash files)
            err_msg = "EFT: Unable to flash %s (%s)" % (str(
                self._flash_file), str(self.error_message))
            raise AcsToolException(AcsToolException.CRITICAL_FAILURE, err_msg)

        return flash_return_code
コード例 #3
0
    def _analyze_output(self, data):
        """
        Analyze in real time the output log from flash tool command execution
        and switch the device state when needed

        :type data: str
        :param data: string to analyze
        """
        # FLash initialization
        flash_mode_start_trigger = ["Please reboot your phone device"]
        # Flash start here
        flash_mode_trigger = ["Device synchronized"]
        # Final verdict at end of script
        flash_mode_stop_trigger = ["Success!"]

        flash_error_trigger = ["Error opening device"]

        for d in data:
            self._logger.debug(d)
            # Search in logging trigger for flashing event
            if d != "":
                if any(word in d for word in flash_mode_start_trigger):
                    # Switch the device in FLASH MODE state if not already in
                    if self._flash_tool_state == "FLASH_INIT_STATE":
                        # Activate usb host line to allow FTE2 to connect device as soon as it
                        # is ready (device in DNX or COS mode)
                        if self._switch_device_state_fct(
                                "COS_MODE_ON") == Global.SUCCESS:
                            self._logger.debug(
                                "Changing flash state to FLASH_MODE_START")
                            self._flash_tool_state = "FLASH_MODE_START"
                            # Log it
                            self._logger.info(
                                "FTE2: Starting flashing procedure")
                        else:
                            self.exec_result = False
                            self.error_message = "FTE2: Issue can not enable usb host line on the device"
                            self._flash_tool_state = "UNUSED"
                            FlashToolBase._stop(self)

                if any(word in d for word in flash_mode_trigger):
                    # Change the device state => Stop the flash mode as now started
                    if self._flash_tool_state == "FLASH_MODE_START":
                        # Change the device state => Stop the flash mode as now started
                        self._logger.debug(
                            "Changing flash state to FLASH_MODE")
                        self._flash_tool_state = "FLASH_MODE"
                        # Log it
                        self._logger.info(
                            "FTE2: Flashing procedure in progress")

                if any(word in d for word in flash_mode_stop_trigger):
                    self._logger.info(
                        "FTE2: Flashing procedure done successfully")
                    # Change the device state => Stop the flash mode as it finish
                    if self._flash_tool_state == "FLASH_MODE":
                        code, message = self._switch_device_state_fct(
                            "WAIT_BOOT")
                        if code == Global.SUCCESS:
                            self._logger.debug(
                                "Changing flash state to FLASH_MODE_STOP")
                            self._flash_tool_state = "FLASH_MODE_STOP"
                            self.exec_result = True
                        else:
                            self.exec_result = False
                            self.error_message = "FTE2: Issue can not check board status after flash success (%s)" \
                                                 % str(message)
                            self._flash_tool_state = "UNUSED"
                            FlashToolBase._stop(self)

                if any(word in d for word in flash_error_trigger):
                    self._logger.error(
                        "FTE2: An error occur during flash procedure !")
                    # Change the device state => Stop the flash mode as it finish
                    self.exec_result = False
                    self.error_message = "FTE2: An error occur during flash procedure ! (%s)" \
                                         % str(d)
                    self._flash_tool_state = "UNUSED"
                    FlashToolBase._stop(self)
コード例 #4
0
    def flash(self, flash_file_list, device_info, timeout):
        """
        Start the flash execution for the flash tool (flash procedure with device state change)

        :type flash_file_list: list
        :param flash_file_list: list containing flash file absolute paths
        :type device_info: FlashDeviceInfo
        :param device_info: contain all device information needed by the flash tool
        :type timeout: int
        :param timeout: max time in seconds to do flash procedure

        :rtype: int
        :return: result of the flash procedure (Global.SUCCESS, Global.FAILURE, Global.BLOCKED)

        """
        # Check flash file availability and format
        flash_file = self._check_flash_files(flash_file_list)

        if not self._flash_user_data:
            self._logger.info(
                "FTE2: Flashing procedure will not flash userdata !")
            ff_list = str(flash_file).split(" ")
            flash_file = []
            for f in ff_list:
                if "userdata" not in f:
                    flash_file.append(f)
            flash_file = " ".join(flash_file)

        self._flash_file = flash_file

        self._retrieve_device_info(device_info)

        flash_return_code = Global.FAILURE

        # Disconnect USB
        if self._switch_device_state_fct("COS_MODE_OFF") == Global.FAILURE:
            err_msg = "FTE2: Unable to switch to COS_MODE_OFF"
            raise AcsToolException(AcsToolException.CRITICAL_FAILURE, err_msg)

        # Change the device state => Trig the flash mode
        if self._switch_device_state_fct("FLASH_SWITCH_OFF") == Global.SUCCESS:
            self._logger.info("FTE2: Initiate flashing procedure")
            # Device can be flashed
            self._flash_tool_state = "FLASH_INIT_STATE"
            self._first_file_flashing = True

            # Flash all flash files passed
            flash_return_code = FlashToolBase._flash(self, timeout)

            self._first_file_flashing = False

            if flash_return_code == Global.FAILURE:
                # Flash has failed on a flash file => stop the flash procedure (do not flash other flash files)
                err_msg = "FTE2: Unable to flash %s" % str(self._flash_file)
                raise AcsToolException(AcsToolException.CRITICAL_FAILURE,
                                       err_msg)
        else:
            self._logger.error(
                "FTE2: Issue can not switch off the device state")

        return flash_return_code
コード例 #5
0
    def _analyze_output(self, data):
        """
        Analyze in real time the output log from flash tool command execution
        and switch the device state when needed

        :type data: str
        :param data: string to analyze
        """
        # FLash initialization
        start_ifw_flash_trigger = [
            "Detecting Intel Device - Attempt ",
            "Please plug and reboot the board"
        ]
        # Flash start here
        ifw_flash_trigger = [
            "IFW flash started", "Flashing IFWI", "Initiating download..."
        ]
        # Final verdict at end of script
        flash_success_trigger = ["complete the flashing procedure"]

        for d in data:
            self._logger.debug(d)
            # Search in logging trigger for flashing event
            if d != "":
                # Trigger for Flash initialization (FLASH_INIT_STATE -> FLASH_MODE_START)
                if any(word in d for word in start_ifw_flash_trigger):
                    # Switch the device in FLASH_MODE_START state if not already in
                    if self._flash_tool_state == "FLASH_INIT_STATE":
                        # Change the device state => Trig the flash mode (reboot device)
                        if self._switch_device_state_fct(
                                "FLASH_SWITCH_OFF") == Global.SUCCESS:
                            # if reboot ok should flash, see next step
                            self._logger.debug(
                                "Changing flash state to FLASH_MODE_START")
                            self._flash_tool_state = "FLASH_MODE_START"
                            # Log it
                            self._logger.info(
                                "EFT: Starting flashing procedure")
                        else:
                            msg = "EFT: Issue can not switch off the device"
                            self._logger.error(msg)
                            self._logger.debug(
                                "Changing flash state to FLASH_MODE_STOP")
                            self._flash_tool_state = "FLASH_MODE_STOP"
                            self.exec_result = False
                            self.error_message = msg
                            FlashToolBase._stop(self)
                    else:
                        self._logger.warning(
                            "EFT: Wrong flash tool state %s when \"%s\" should be %s"
                            % (self._flash_tool_state, start_ifw_flash_trigger,
                               "FLASH_INIT_STATE"))

                # Trigger for Flash Start (FLASH_MODE_START -> FLASH_MODE)
                if any(word in d for word in ifw_flash_trigger):
                    # Change the device state => Stop the flash mode as now started
                    if self._flash_tool_state == "FLASH_MODE_START":
                        # Change the device state => Stop the flash mode as now started
                        self._logger.debug(
                            "Changing flash state to FLASH_MODE")
                        self._flash_tool_state = "FLASH_MODE"
                        # Log it
                        self._logger.info(
                            "EFT: Flashing procedure in progress")
                    else:
                        self._logger.warning(
                            "EFT: Wrong flash tool state %s when \"%s\" should be %s"
                            % (self._flash_tool_state, ifw_flash_trigger,
                               "FLASH_MODE_START"))

                # Trigger final flash verdict (FLASH_MODE -> FLASH_MODE_STOP)
                if any(word in d for word in flash_success_trigger):
                    self._logger.info(
                        "EFT: Flashing procedure done successfully")
                    # Change the device state => Stop the flash mode as it finish
                    if self._flash_tool_state == "FLASH_MODE":
                        if self._switch_device_state_fct(
                                "WAIT_BOOT") == Global.SUCCESS:
                            # If boot ok, then full flash procedure is ok
                            self._logger.debug(
                                "Changing flash state to FLASH_MODE_STOP")
                            self._flash_tool_state = "FLASH_MODE_STOP"
                            # Set final exec result
                            self.exec_result = True
                        else:
                            self._logger.debug(
                                "Changing flash state to UNUSED")
                            self._flash_tool_state = "UNUSED"
                            # Set final exec result and error message
                            self.exec_result = False
                            self.error_message = "EFT: Issue can not check board status after flash success"
                            FlashToolBase._stop(self)
                    else:
                        self._logger.warning(
                            "EFT: Wrong flash tool state %s when \"%s\" should be %s"
                            % (self._flash_tool_state,
                               flash_success_trigger[0], "FLASH_MODE"))