Ejemplo n.º 1
0
    def connect(self):
        if self.config.connection_command:
            proc = connect_to_serial(self.context)
        else:
            raise CriticalError('The connection_command is not defined!')

        return proc
Ejemplo n.º 2
0
 def _boot_linaro_image(self, skip, emmc):
     if self.proc:
         if self.config.connection_command_terminate:
             self.proc.sendline(self.config.connection_command_terminate)
         finalize_process(self.proc)
         self.proc = None
     self.proc = connect_to_serial(self.context)
     # add below part
     # skip=True, only connect to the device, don't reboot & deploy the image
     # skip=False, connect to the device, then reboot to bootloader & deploy the image
     # emmc=True, make factory emmc
     if skip is True:
         self._booted = True
     # bootloader and not booted, 2016.01.21
     if self._is_bootloader() and not self._booted:
         if self.config.hard_reset_command or self.config.hard_reset_command == "":
             self._hard_reboot(self.proc)
             self._run_boot()
         else:
             self._soft_reboot(self.proc)
             self._run_boot()
         self._booted = True
     # bootloader and booted, 2016.01.21
     elif self._is_bootloader() and self._booted:
         self.proc.sendline('export PS1="%s"' % self.tester_ps1,
                            send_char=self.config.send_char)
     else:
         super(BootloaderTarget, self)._boot_linaro_image()
Ejemplo n.º 3
0
    def connect(self):
        if self.config.connection_command:
            proc = connect_to_serial(self.context)
        else:
            raise CriticalError('The connection_command is not defined!')

        return proc
Ejemplo n.º 4
0
 def reconnect_serial(self):
     if not self.proc:
         logging.info("reconnect the serial connection")
         self.proc = connect_to_serial(self.context)
         self.context.client.proc = self.proc
         # install busybox, close shutdown again
         self._install_busybox_whaley(self.proc)
         self._close_shutdown_whaley(self.proc)
         self.proc.empty_buffer()
     else:
         logging.info("no need to reconnect the serial connection")
Ejemplo n.º 5
0
    def __init__(self, context, config):
        super(SDMuxTarget, self).__init__(context, config)

        if not config.sdmux_usb_id:
            raise CriticalError('Device config requires "sdmux_usb_id"')

        if not config.sdmux_id:
            raise CriticalError('Device config requires "sdmux_id"')

        if not config.power_off_cmd:
            raise CriticalError('Device config requires "power_off"')

        if not config.hard_reset_command:
            raise CriticalError('Device config requires "hard_reset_command"')

        if config.pre_connect_command:
            self.context.run_command(config.pre_connect_command)

        self.proc = connect_to_serial(self.context)
Ejemplo n.º 6
0
    def __init__(self, context, config):
        super(SDMuxTarget, self).__init__(context, config)

        if not config.sdmux_usb_id:
            raise CriticalError('Device config requires "sdmux_usb_id"')

        if not config.sdmux_id:
            raise CriticalError('Device config requires "sdmux_id"')

        if not config.power_off_cmd:
            raise CriticalError('Device config requires "power_off"')

        if not config.hard_reset_command:
            raise CriticalError('Device config requires "hard_reset_command"')

        if config.pre_connect_command:
            self.context.run_command(config.pre_connect_command)

        self.proc = connect_to_serial(self.context)
Ejemplo n.º 7
0
    def __init__(self, context, config):
        super(MasterImageTarget, self).__init__(context, config)

        # Update variable according to config file
        self.MASTER_PS1 = self.config.master_str + self.MASTER_PS1
        self.MASTER_PS1_PATTERN = self.config.master_str + self.MASTER_PS1_PATTERN

        self.master_ip = None
        self.device_version = None

        self.testboot_dir = self.config.master_testboot_dir
        self.testboot_label = self.config.master_testboot_label
        self.testboot_path = '%s%s' % (self.testboot_dir, self.testboot_label)

        self.testrootfs_dir = self.config.master_testrootfs_dir
        self.testrootfs_label = self.config.master_testrootfs_label
        self.testrootfs_path = '%s%s' % (self.testrootfs_dir,
                                         self.testrootfs_label)

        self.sdcard_dir = self.config.master_sdcard_dir
        self.sdcard_label = self.config.master_sdcard_label
        self.sdcard_path = '%s%s' % (self.sdcard_dir, self.sdcard_label)

        self.userdata_dir = self.config.master_userdata_dir
        self.userdata_label = self.config.master_userdata_label
        self.userdata_path = '%s%s' % (self.userdata_dir, self.userdata_label)

        self.master_kernel = None
        self.master_ramdisk = None
        self.master_modules = None
        self.master_dtb = None
        self.master_firmware = None
        self.master_nfsrootfs = None
        self.master_base_tmpdir, self.master_tmpdir = self._setup_tmpdir()
        self.master_boot_tags = {}

        if config.pre_connect_command:
            self.context.run_command(config.pre_connect_command)

        self.proc = connect_to_serial(self.context)

        self.__boot_cmds_dynamic__ = None
Ejemplo n.º 8
0
    def __init__(self, context, config):
        super(MasterImageTarget, self).__init__(context, config)

        # Update variable according to config file
        self.MASTER_PS1 = self.config.master_str + self.MASTER_PS1
        self.MASTER_PS1_PATTERN = self.config.master_str + self.MASTER_PS1_PATTERN

        self.master_ip = None
        self.device_version = None

        self.testboot_dir = self.config.master_testboot_dir
        self.testboot_label = self.config.master_testboot_label
        self.testboot_path = '%s%s' % (self.testboot_dir, self.testboot_label)

        self.testrootfs_dir = self.config.master_testrootfs_dir
        self.testrootfs_label = self.config.master_testrootfs_label
        self.testrootfs_path = '%s%s' % (self.testrootfs_dir, self.testrootfs_label)

        self.sdcard_dir = self.config.master_sdcard_dir
        self.sdcard_label = self.config.master_sdcard_label
        self.sdcard_path = '%s%s' % (self.sdcard_dir, self.sdcard_label)

        self.userdata_dir = self.config.master_userdata_dir
        self.userdata_label = self.config.master_userdata_label
        self.userdata_path = '%s%s' % (self.userdata_dir, self.userdata_label)

        self.master_kernel = None
        self.master_ramdisk = None
        self.master_modules = None
        self.master_dtb = None
        self.master_firmware = None
        self.master_nfsrootfs = None
        self.master_base_tmpdir, self.master_tmpdir = self._setup_tmpdir()
        self.master_boot_tags = {}

        if config.pre_connect_command:
            self.context.run_command(config.pre_connect_command)

        self.proc = connect_to_serial(self.context)

        self.__boot_cmds_dynamic__ = None
Ejemplo n.º 9
0
 def _boot_linaro_image(self):
     if self.proc:
         if self.config.connection_command_terminate:
             self.proc.sendline(self.config.connection_command_terminate)
         finalize_process(self.proc)
         self.proc = None
     self.proc = connect_to_serial(self.context)
     if self._is_bootloader() and not self._booted:
         if self.config.hard_reset_command or self.config.hard_reset_command != "":
             self._hard_reboot(self.proc)
             self._run_boot()
         else:
             self._soft_reboot(self.proc)
             self._run_boot()
         self._booted = True
     elif self._is_bootloader() and self._booted:
         self.proc.sendline('export PS1="%s"'
                            % self.tester_ps1,
                            send_char=self.config.send_char)
     else:
         super(BootloaderTarget, self)._boot_linaro_image()
Ejemplo n.º 10
0
 def _boot_linaro_image(self):
     if self.proc:
         if self.config.connection_command_terminate:
             self.proc.sendline(self.config.connection_command_terminate)
         else:
             self._politely_close_console(self.proc)
         finalize_process(self.proc)
         self.proc = None
     self.proc = connect_to_serial(self.context)
     if self._is_bootloader() and not self._booted:
         if self.config.hard_reset_command or self.config.hard_reset_command == "":
             self._hard_reboot(self.proc)
             self._run_boot()
         else:
             self._soft_reboot(self.proc)
             self._run_boot()
         self._booted = True
     elif self._is_bootloader() and self._booted:
         self.proc.sendline('export PS1="%s"' % self.tester_ps1,
                            send_char=self.config.send_char)
     else:
         super(BootloaderTarget, self)._boot_linaro_image()
Ejemplo n.º 11
0
    def boot_master_image(self):
        """
        reboot the system, and check that we are in a master shell
        """
        self.context.client.vm_group.wait_for_vms()

        boot_attempts = self.config.boot_retries
        attempts = 0
        in_master_image = False
        while (attempts < boot_attempts) and (not in_master_image):
            logging.info("Booting the system master image. Attempt: %d",
                         attempts + 1)
            try:
                if self.proc:
                    if self.config.connection_command_terminate:
                        self.proc.sendline(self.config.connection_command_terminate)
                    finalize_process(self.proc)
                    self.proc = None
                self.proc = connect_to_serial(self.context)
                self.master_ip = None
                if self.config.hard_reset_command:
                    self._hard_reboot(self.proc)
                    self._load_master_firmware()
                    self._wait_for_master_boot()
                else:
                    self._soft_reboot(self.proc)
                    self._load_master_firmware()
                    self._wait_for_master_boot()
            except (OperationFailed, pexpect.TIMEOUT) as e:
                msg = "Resetting platform into master image failed: %s" % e
                logging.warning(msg)
                attempts += 1
                continue

            runner = MasterCommandRunner(self)
            try:
                self.master_ip = runner.get_target_ip()
                self.device_version = runner.get_device_version()
            except NetworkError as e:
                msg = "Failed to get network up: %s" % e
                logging.warning(msg)
                attempts += 1
                continue

            lava_proxy = self.context.config.lava_proxy
            if lava_proxy:
                logging.info("Setting up http proxy")
                runner.run("export http_proxy=%s" % lava_proxy, timeout=30)
            lava_no_proxy = self.context.config.lava_no_proxy
            if lava_no_proxy:
                runner.run("export no_proxy=%s" % lava_no_proxy, timeout=30)
            logging.info("System is in master image now")
            self.context.test_data.add_result('boot_master_image',
                                              'pass')
            in_master_image = True

        if not in_master_image:
            msg = "Master Image Error: Could not get master image booted properly"
            logging.error(msg)
            self.context.test_data.add_result('boot_master_image',
                                              'fail')
            raise CriticalError(msg)
Ejemplo n.º 12
0
    def connect(self, boot_cmds):
        if self.context.test_data.metadata.get('is_slave', 'false') == 'true':
            # Wait for the STMC2 to be ready
            self.context.transport.request_wait('lava_ms_ready')

            # Connect to the STMC serial relay
            logging.info("Connecting to STMC serial relay")
            proc = connect_to_serial(self.context)

            # Ask the master to deliver the image
            self.context.transport.request_send('lava_ms_boot', None)

            proc.expect(self.config.image_boot_msg, timeout=300)
            return proc
        else:
            boot_cmds.insert(0, self._stmc_command)
            jtag_command = ' '.join(boot_cmds)

            # jtag_stmcconfig is required
            if not self.config.jtag_stmcconfig:
                raise CriticalError("STMC config command should be present")

            # Check the STMC status command
            logging.info("Checking STMC status")
            if not self.stmc_status_ok():
                logging.info("Hard resetting STMC")
                # JTAG hard reset is required
                if not self.config.jtag_hard_reset_command:
                    raise CriticalError("STMC is not working and 'jtag_hard_reset_command' is not set")

                self.context.run_command(self.config.jtag_hard_reset_command)
                logging.info("Waiting for STMC to initialize")
                success = False
                for loop_index in range(1, 5):
                    logging.info("  checking STMC status (%d)", loop_index)
                    if self.stmc_status_ok():
                        success = True
                        break
                    time.sleep(5)

                if not success:
                    raise CriticalError("The STMC fails to reboot after hard reset")

                # Setup the serial-relay
                if not self.stmc_serial_relay():
                    raise CriticalError("Unable to setup the serial relay. The STMC is not working properly")

            # Hard reset platform
            if self.config.hard_reset_command:
                logging.info("Hard resetting platform")
                self.context.run_command(self.config.hard_reset_command)
            else:
                raise CriticalError("Must have a hard_reset_command defined")

            # Connect to the STMC serial relay
            logging.info("Connecting to STMC serial relay")
            proc = connect_to_serial(self.context)

            # Deliver images with STMC
            logging.info("Delivering images with STMC")
            self.context.run_command(jtag_command, failok=False)

            proc.expect(self.config.image_boot_msg, timeout=300)
            return proc
Ejemplo n.º 13
0
    def connect(self, boot_cmds):
        if self.context.test_data.metadata.get('is_slave', 'false') == 'true':
            # When booting in master-slave, the protocol is:
            # 1/ self  : reboot the STMC2
            # 2/ master: wait for the STMC2 prompt
            # 3/ self  : reboot the board
            # 4/ master: setup the serial relay
            # 5/ self  : connect to the serial
            # 6/ master: boot the board

            # Reboot the STMC2 when the master is ready
            self.context.transport.request_wait('lava_ms_reboot_STMC2')
            logging.info("Hard resetting STMC2")
            if not self.config.jtag_hard_reset_command:
                raise CriticalError("'jtag_hard_reset_command' is required")
            self.context.run_command(self.config.jtag_hard_reset_command)
            self.context.transport.request_send('lava_ms_reboot_STMC2_done', None)

            self.context.transport.request_wait('lava_ms_reboot_board')
            logging.info("Hard resetting platform")
            if not self.config.hard_reset_command:
                raise CriticalError("'hard_reset_command' is required")
            self.context.run_command(self.config.hard_reset_command)
            self.context.transport.request_send('lava_ms_reboot_board_done', None)

            # Connect to the STMC serial relay
            self.context.transport.request_wait('lava_ms_ready')
            logging.info("Connecting to STMC serial relay")
            proc = connect_to_serial(self.context)

            # Ask the master to deliver the image
            self.context.transport.request_send('lava_ms_boot', None)

        else:
            boot_cmds.insert(0, self._stmc_command)
            jtag_command = ' '.join(boot_cmds)

            # jtag_stmcconfig is required
            if not self.config.jtag_stmcconfig:
                raise CriticalError("STMC config command should be present")

            # Check the STMC status command
            logging.info("Checking STMC status")
            if not self.stmc_status_ok():
                logging.info("Hard resetting STMC")
                # JTAG hard reset is required
                if not self.config.jtag_hard_reset_command:
                    raise CriticalError("STMC is not working and 'jtag_hard_reset_command' is not set")

                self.context.run_command(self.config.jtag_hard_reset_command)
                logging.info("Waiting for STMC to initialize")
                success = False
                for loop_index in range(1, 5):
                    logging.info("  checking STMC status (%d)", loop_index)
                    if self.stmc_status_ok():
                        success = True
                        break
                    time.sleep(5)

                if not success:
                    raise CriticalError("The STMC fails to reboot after hard reset")

            # Hard reset platform
            if self.config.hard_reset_command:
                logging.info("Hard resetting platform")
                self.context.run_command(self.config.hard_reset_command)
            else:
                raise CriticalError("Must have a hard_reset_command defined")

            # Setup the serial-relay
            if not self.stmc_serial_relay():
                raise CriticalError("Unable to setup the serial relay. The STMC is not working properly")

            # Connect to the STMC serial relay
            logging.info("Connecting to STMC serial relay")
            proc = connect_to_serial(self.context)

            # Deliver images with STMC
            logging.info("Delivering images with STMC")
            # Boot the board with a timeout on this command that MUST finish on
            # time (the command block when failing to boot)
            boot_proc = self.context.spawn(jtag_command, timeout=240)
            try:
                boot_proc.expect(pexpect.EOF)
            except pexpect.TIMEOUT:
                raise CriticalError("GDB is unable to boot the board")

            logging.info("GDB has finished, waiting for the board prompt")

        # Wait for the prompt
        proc.expect(self.config.image_boot_msg,
                    timeout=self.config.image_boot_msg_timeout)
        return proc
Ejemplo n.º 14
0
    def boot_master_image(self):
        """
        reboot the system, and check that we are in a master shell
        """
        self.context.client.vm_group.wait_for_vms()

        boot_attempts = self.config.boot_retries
        attempts = 0
        in_master_image = False
        while (attempts < boot_attempts) and (not in_master_image):
            logging.info("Booting the system master image. Attempt: %d",
                         attempts + 1)
            try:
                if self.proc:
                    if self.config.connection_command_terminate:
                        self.proc.sendline(
                            self.config.connection_command_terminate)
                    finalize_process(self.proc)
                    self.proc = None
                self.proc = connect_to_serial(self.context)
                self.master_ip = None
                if self.config.hard_reset_command:
                    self._hard_reboot(self.proc)
                    self._load_master_firmware()
                    self._wait_for_master_boot()
                else:
                    self._soft_reboot(self.proc)
                    self._load_master_firmware()
                    self._wait_for_master_boot()
            except (OperationFailed, pexpect.TIMEOUT) as e:
                msg = "Resetting platform into master image failed: %s" % e
                logging.warning(msg)
                attempts += 1
                continue

            runner = MasterCommandRunner(self)
            try:
                self.master_ip = runner.get_target_ip()
                self.device_version = runner.get_device_version()
            except NetworkError as e:
                msg = "Failed to get network up: %s" % e
                logging.warning(msg)
                attempts += 1
                continue

            lava_proxy = self.context.config.lava_proxy
            if lava_proxy:
                logging.info("Setting up http proxy")
                runner.run("export http_proxy=%s" % lava_proxy, timeout=30)
            lava_no_proxy = self.context.config.lava_no_proxy
            if lava_no_proxy:
                runner.run("export no_proxy=%s" % lava_no_proxy, timeout=30)
            logging.info("System is in master image now")
            self.context.test_data.add_result('boot_master_image', 'pass')
            in_master_image = True

        if not in_master_image:
            msg = "Master Image Error: Could not get master image booted properly"
            logging.error(msg)
            self.context.test_data.add_result('boot_master_image', 'fail')
            raise CriticalError(msg)
Ejemplo n.º 15
0
    def connect(self, boot_cmds):
        if self.context.test_data.metadata.get("is_slave", "false") == "true":
            # When booting in master-slave, the protocol is:
            # 1/ self  : reboot the STMC2
            # 2/ master: wait for the STMC2 prompt
            # 3/ self  : reboot the board
            # 4/ master: setup the serial relay
            # 5/ self  : connect to the serial
            # 6/ master: boot the board

            # Reboot the STMC2 when the master is ready
            self.context.transport.request_wait("lava_ms_reboot_STMC2")
            logging.info("Hard resetting STMC2")
            if not self.config.jtag_hard_reset_command:
                raise CriticalError("'jtag_hard_reset_command' is required")
            self.context.run_command(self.config.jtag_hard_reset_command)
            self.context.transport.request_send("lava_ms_reboot_STMC2_done", None)

            self.context.transport.request_wait("lava_ms_reboot_board")
            logging.info("Hard resetting platform")
            if not self.config.hard_reset_command:
                raise CriticalError("'hard_reset_command' is required")
            self.context.run_command(self.config.hard_reset_command)
            self.context.transport.request_send("lava_ms_reboot_board_done", None)

            # Connect to the STMC serial relay
            self.context.transport.request_wait("lava_ms_ready")
            logging.info("Connecting to STMC serial relay")
            proc = connect_to_serial(self.context)

            # Ask the master to deliver the image
            self.context.transport.request_send("lava_ms_boot", None)

        else:
            boot_cmds.insert(0, self._stmc_command)
            jtag_command = " ".join(boot_cmds)

            # jtag_stmcconfig is required
            if not self.config.jtag_stmcconfig:
                raise CriticalError("STMC config command should be present")

            # Check the STMC status command
            logging.info("Checking STMC status")
            if not self.stmc_status_ok():
                logging.info("Hard resetting STMC")
                # JTAG hard reset is required
                if not self.config.jtag_hard_reset_command:
                    raise CriticalError("STMC is not working and 'jtag_hard_reset_command' is not set")

                self.context.run_command(self.config.jtag_hard_reset_command)
                logging.info("Waiting for STMC to initialize")
                success = False
                for loop_index in range(1, 5):
                    logging.info("  checking STMC status (%d)", loop_index)
                    if self.stmc_status_ok():
                        success = True
                        break
                    time.sleep(5)

                if not success:
                    raise CriticalError("The STMC fails to reboot after hard reset")

            # Hard reset platform
            if self.config.hard_reset_command:
                logging.info("Hard resetting platform")
                self.context.run_command(self.config.hard_reset_command)
            else:
                raise CriticalError("Must have a hard_reset_command defined")

            # Setup the serial-relay
            if not self.stmc_serial_relay():
                raise CriticalError("Unable to setup the serial relay. The STMC is not working properly")

            # Connect to the STMC serial relay
            logging.info("Connecting to STMC serial relay")
            proc = connect_to_serial(self.context)

            # Deliver images with STMC
            logging.info("Delivering images with STMC")
            # Boot the board with a timeout on this command that MUST finish on
            # time (the command block when failing to boot)
            boot_proc = self.context.spawn(jtag_command, timeout=240)
            try:
                boot_proc.expect(pexpect.EOF)
            except pexpect.TIMEOUT:
                raise CriticalError("GDB is unable to boot the board")

            logging.info("GDB has finished, waiting for the board prompt")

        # Wait for the prompt
        proc.expect(self.config.image_boot_msg, timeout=self.config.image_boot_msg_timeout)
        return proc