def deploy_linaro_kernel(self, kernel, ramdisk, dtb, overlays, rootfs, nfsrootfs, image, bootloader, firmware, bl0, bl1,
                             bl2, bl31, rootfstype, bootloadertype, target_type, qemu_pflash=None):
        # Check for errors
        if rootfs is None and ramdisk is None:
            raise CriticalError("You must specify a QEMU file system image or ramdisk")
        if kernel is None and firmware is None:
            raise CriticalError("No bootloader or kernel image to boot")
        if bootloadertype == 'uefi':
            if firmware is None and qemu_pflash is None \
               and self.config.qemu_pflash is None:
                raise CriticalError("No firmware or qemu_pflash specified with "
                                    "bootloadertype UEFI")

        if rootfs:
            self._sd_image = download_image(rootfs, self.context)
            self.customize_image(self._sd_image)

        self._kernel = download_image(kernel, self.context)

        if ramdisk is not None:
            ramdisk = download_image(ramdisk, self.context,
                                     decompress=False)
            if overlays is not None:
                ramdisk_dir = extract_ramdisk(ramdisk, self.scratch_dir,
                                              is_uboot=self._is_uboot_ramdisk(ramdisk))
                for overlay in overlays:
                    overlay = download_image(overlay, self.context,
                                             self.scratch_dir,
                                             decompress=False)
                    extract_overlay(overlay, ramdisk_dir)
                ramdisk = create_ramdisk(ramdisk_dir, self.scratch_dir)
            self._ramdisk = ramdisk
            if rootfs is None:
                logging.debug("Attempting to set deployment data")
                self.deployment_data = deployment_data.get(target_type)

        if dtb is not None:
            dtb = download_image(dtb, self.context)
            self._dtb = dtb

        if bootloadertype == 'uefi':
            self._bootloadertype = 'uefi'

        if firmware is not None:
            firmware = download_image(firmware, self.context)
            self._firmware = firmware
        else:
            # Try downloading pflash files, if it exists.
            self._download_qemu_pflash_files(qemu_pflash=qemu_pflash)
    def deploy_linaro_kernel(self, kernel, ramdisk, dtb, overlays, rootfs, nfsrootfs, image, bootloader, firmware, bl0, bl1,
                             bl2, bl31, rootfstype, bootloadertype, target_type, qemu_pflash=None):
        if self.__deployment_data__ is None:
            # Get deployment data
            logging.debug("Attempting to set deployment data")
            self.deployment_data = deployment_data.get(target_type)
        else:
            # Reset deployment data
            logging.debug("Attempting to reset deployment data")
            self.power_off(self.proc)
            self.__init__(self.context, self.config)
            # Get deployment data
            self.deployment_data = deployment_data.get(target_type)
        # We set the boot type
        self._set_boot_type(bootloadertype)
        # At a minimum we must have a kernel
        if kernel is None:
            raise CriticalError("No kernel image to boot")
        if self._is_uboot() or self._is_uefi() or self._is_ipxe():
            # Set the server IP (Dispatcher)
            self._boot_tags['{SERVER_IP}'] = self.context.config.lava_server_ip
            # We have been passed kernel image
            kernel = download_image(kernel, self.context,
                                    self._tmpdir, decompress=False)
            if self._is_uboot() or self._is_uefi():
                if self.config.uimage_only and not is_uimage(kernel, self.context):
                    if len(self.config.u_load_addrs) == 3:
                        if self.config.text_offset:
                            load_addr = self.config.text_offset
                        else:
                            load_addr = self.config.u_load_addrs[0]
                        kernel = create_uimage(kernel, load_addr,
                                               self._tmpdir, self.config.uimage_xip,
                                               self.config.uimage_arch)
                        logging.info('uImage created successfully')
                    else:
                        logging.error('Undefined u_load_addrs, aborting uImage creation')
            self._boot_tags['{KERNEL}'] = self._get_rel_path(kernel, self._base_tmpdir)

            if ramdisk is not None:
                # We have been passed a ramdisk
                ramdisk = download_image(ramdisk, self.context,
                                         self._tmpdir,
                                         decompress=False)
                if overlays is not None:
                    ramdisk_dir = extract_ramdisk(ramdisk, self._tmpdir,
                                                  is_uboot=self._is_uboot_ramdisk(ramdisk))
                    for overlay in overlays:
                        overlay = download_image(overlay, self.context,
                                                 self._tmpdir,
                                                 decompress=False)
                        extract_overlay(overlay, ramdisk_dir)
                    ramdisk = create_ramdisk(ramdisk_dir, self._tmpdir)
                if self._is_uboot():
                    # Ensure ramdisk has u-boot header
                    if not self._is_uboot_ramdisk(ramdisk):
                        ramdisk_uboot = ramdisk + ".uboot"
                        logging.info("RAMdisk needs u-boot header.  Adding.")
                        cmd = "mkimage -A %s -T ramdisk -C none -d %s %s > /dev/null" \
                            % (self.config.uimage_arch, ramdisk, ramdisk_uboot)
                        r = subprocess.call(cmd, shell=True)
                        if r == 0:
                            ramdisk = ramdisk_uboot
                        else:
                            logging.warning("Unable to add u-boot header to ramdisk.  Tried %s", cmd)
                self._boot_tags['{RAMDISK}'] = self._get_rel_path(ramdisk, self._base_tmpdir)
            if dtb is not None:
                # We have been passed a device tree blob
                dtb = download_image(dtb, self.context,
                                     self._tmpdir, decompress=False)
                if self.config.append_dtb:
                    kernel = append_dtb(kernel, dtb, self._tmpdir)
                    logging.info('Appended dtb to kernel image successfully')
                    self._boot_tags['{KERNEL}'] = self._get_rel_path(kernel, self._base_tmpdir)
                else:
                    self._boot_tags['{DTB}'] = self._get_rel_path(dtb, self._base_tmpdir)
            if rootfs is not None:
                # We have been passed a rootfs
                rootfs = download_image(rootfs, self.context,
                                        self._tmpdir, decompress=False)
                self._boot_tags['{ROOTFS}'] = self._get_rel_path(rootfs, self._base_tmpdir)
            if nfsrootfs is not None:
                # Extract rootfs into nfsrootfs directory
                nfsrootfs = download_image(nfsrootfs, self.context,
                                           self._tmpdir,
                                           decompress=False)
                self._lava_nfsrootfs = self._setup_nfs(nfsrootfs, self._tmpdir)
                self._default_boot_cmds = 'boot_cmds_nfs'
                self._boot_tags['{NFSROOTFS}'] = self._lava_nfsrootfs
                if overlays is not None and ramdisk is None:
                    for overlay in overlays:
                        overlay = download_image(overlay, self.context,
                                                 self._tmpdir,
                                                 decompress=False)
                        extract_overlay(overlay, self._lava_nfsrootfs)
            if bootloader is not None:
                # We have been passed a bootloader
                bootloader = download_image(bootloader, self.context,
                                            self._tmpdir,
                                            decompress=False)
                self._boot_tags['{BOOTLOADER}'] = self._get_rel_path(bootloader, self._base_tmpdir)
            if firmware is not None:
                # We have been passed firmware
                firmware = download_image(firmware, self.context,
                                          self._tmpdir,
                                          decompress=False)

                self._boot_tags['{FIRMWARE}'] = self._get_rel_path(firmware, self._base_tmpdir)
            if self._is_uboot():
                self._boot_tags['{BOOTX}'] = self._get_uboot_boot_command(kernel,
                                                                          ramdisk,
                                                                          dtb)
Exemple #3
0
    def deploy_linaro_kernel(self, kernel, ramdisk, dtb, overlays, rootfs, nfsrootfs,
                             image, bootloader, firmware, bl0, bl1, bl2, bl31, rootfstype,
                             bootloadertype, target_type, scratch_dir, qemu_pflash=None):
        kernel_url = kernel
        dtb_url = dtb
        # At a minimum we must have a kernel
        if kernel is None:
            raise CriticalError("No kernel image to boot")
        # Set the server IP (Dispatcher)
        self._boot_tags['{SERVER_IP}'] = self.context.config.lava_server_ip
        # Get the JTAG command fragments
        stmc_command = ' '.join([self.config.jtag_stmc_boot_script,
                                 self.config.jtag_stmc_boot_options])
        # We have been passed kernel image
        kernel = download_image(kernel, self.context,
                                scratch_dir, decompress=False)
        stmc_command = ' '.join([stmc_command,
                                 self.config.jtag_stmc_kernel_command.format(KERNEL=kernel)])
        if ramdisk is not None:
            # We have been passed a ramdisk
            ramdisk = download_image(ramdisk, self.context,
                                     scratch_dir,
                                     decompress=False)
            if overlays is not None:
                ramdisk_dir = extract_ramdisk(ramdisk, scratch_dir,
                                              is_uboot=False)
                for overlay in overlays:
                    overlay = download_image(overlay, self.context,
                                             scratch_dir,
                                             decompress=False)
                    extract_overlay(overlay, ramdisk_dir)
                ramdisk = create_ramdisk(ramdisk_dir, scratch_dir)
            stmc_command = ' '.join([stmc_command,
                                    self.config.jtag_stmc_ramdisk_command.format(RAMDISK=ramdisk)])
        if dtb is not None:
            # We have been passed a device tree blob
            dtb = download_image(dtb, self.context,
                                 scratch_dir, decompress=False)
            stmc_command = ' '.join([stmc_command,
                                    self.config.jtag_stmc_dtb_command.format(DTB=dtb)])
        if nfsrootfs is not None:
            # Extract rootfs into nfsrootfs directory
            nfsrootfs = download_image(nfsrootfs, self.context,
                                       scratch_dir,
                                       decompress=False)
            scratch_dir = mkdtemp(self.context.config.lava_image_tmpdir)
            lava_nfsrootfs = mkdtemp(basedir=scratch_dir)
            extract_rootfs(nfsrootfs, lava_nfsrootfs)
            self._boot_tags['{NFSROOTFS}'] = lava_nfsrootfs
            self._default_boot_cmds = 'boot_cmds_nfs'
            if overlays is not None and ramdisk is None:
                for overlay in overlays:
                    overlay = download_image(overlay, self.context,
                                             scratch_dir,
                                             decompress=False)
                extract_overlay(overlay, lava_nfsrootfs)

        # Add suffix for boot commands
        self._stmc_command = stmc_command + ' --'

        if self.context.test_data.metadata.get('is_slave', 'false') == 'true':
            logging.info("Booting in the master/slave mode, as *slave*")
            logging.info("Sending the kernel, dtb, nfsrootfs urls")
            self.context.transport.request_send('lava_ms_slave_data',
                                                {'kernel': kernel_url,
                                                 'dtb': dtb_url if dtb_url else '',
                                                 'nfs_rootfs': lava_nfsrootfs,
                                                 'nfs_server_ip': self.context.config.lava_server_ip,
                                                 'stmc_ip': self.config.jtag_stmc_ip})

        return self._boot_tags, self._default_boot_cmds
    def deploy_linaro_kernel(self, kernel, ramdisk, dtb, overlays, rootfs, nfsrootfs, image, bootloader, firmware, bl0, bl1,
                             bl2, bl31, rootfstype, bootloadertype, target_type, qemu_pflash=None):
        if self.__deployment_data__ is None:
            # Get deployment data
            logging.debug("Attempting to set deployment data")
            self.deployment_data = deployment_data.get(target_type)
        else:
            # Reset deployment data
            logging.debug("Attempting to reset deployment data")
            self.power_off(self.proc)
            self.__init__(self.context, self.config)
            # Get deployment data
            self.deployment_data = deployment_data.get(target_type)
        # We set the boot type
        self._set_boot_type(bootloadertype)
        # At a minimum we must have a kernel
        if kernel is None:
            raise CriticalError("No kernel image to boot")
        if self._is_uboot() or self._is_uefi() or self._is_ipxe():
            # Set the server IP (Dispatcher)
            self._boot_tags['{SERVER_IP}'] = self.context.config.lava_server_ip
            # We have been passed kernel image
            kernel = download_image(kernel, self.context,
                                    self._tmpdir, decompress=False)
            if self._is_uboot() or self._is_uefi():
                if self.config.uimage_only and not is_uimage(kernel, self.context):
                    if len(self.config.u_load_addrs) == 3:
                        if self.config.text_offset:
                            load_addr = self.config.text_offset
                        else:
                            load_addr = self.config.u_load_addrs[0]
                        kernel = create_uimage(kernel, load_addr,
                                               self._tmpdir, self.config.uimage_xip,
                                               self.config.uimage_arch)
                        logging.info('uImage created successfully')
                    else:
                        logging.error('Undefined u_load_addrs, aborting uImage creation')
            self._boot_tags['{KERNEL}'] = self._get_rel_path(kernel, self._base_tmpdir)

            if ramdisk is not None:
                # We have been passed a ramdisk
                ramdisk = download_image(ramdisk, self.context,
                                         self._tmpdir,
                                         decompress=False)
                if overlays is not None:
                    ramdisk_dir = extract_ramdisk(ramdisk, self._tmpdir,
                                                  is_uboot=self._is_uboot_ramdisk(ramdisk))
                    for overlay in overlays:
                        overlay = download_image(overlay, self.context,
                                                 self._tmpdir,
                                                 decompress=False)
                        extract_overlay(overlay, ramdisk_dir)
                    ramdisk = create_ramdisk(ramdisk_dir, self._tmpdir)
                if self._is_uboot() and not self.config.ramdisk_raw:
                    # Ensure ramdisk has u-boot header
                    if not self._is_uboot_ramdisk(ramdisk):
                        ramdisk_uboot = ramdisk + ".uboot"
                        logging.info("RAMdisk needs u-boot header.  Adding.")
                        cmd = "mkimage -A %s -T ramdisk -C none -d %s %s > /dev/null" \
                            % (self.config.uimage_arch, ramdisk, ramdisk_uboot)
                        r = subprocess.call(cmd, shell=True)
                        if r == 0:
                            ramdisk = ramdisk_uboot
                        else:
                            logging.warning("Unable to add u-boot header to ramdisk.  Tried %s", cmd)
                self._boot_tags['{RAMDISK}'] = self._get_rel_path(ramdisk, self._base_tmpdir)
            if dtb is not None:
                # We have been passed a device tree blob
                dtb = download_image(dtb, self.context,
                                     self._tmpdir, decompress=False)
                if self.config.append_dtb:
                    kernel = append_dtb(kernel, dtb, self._tmpdir)
                    logging.info('Appended dtb to kernel image successfully')
                    self._boot_tags['{KERNEL}'] = self._get_rel_path(kernel, self._base_tmpdir)
                else:
                    self._boot_tags['{DTB}'] = self._get_rel_path(dtb, self._base_tmpdir)
            if rootfs is not None:
                # We have been passed a rootfs
                rootfs = download_image(rootfs, self.context,
                                        self._tmpdir, decompress=False)
                self._boot_tags['{ROOTFS}'] = self._get_rel_path(rootfs, self._base_tmpdir)
            if nfsrootfs is not None:
                # Extract rootfs into nfsrootfs directory
                nfsrootfs = download_image(nfsrootfs, self.context,
                                           self._tmpdir,
                                           decompress=False)
                self._lava_nfsrootfs = self._setup_nfs(nfsrootfs, self._tmpdir)
                self._default_boot_cmds = 'boot_cmds_nfs'
                self._boot_tags['{NFSROOTFS}'] = self._lava_nfsrootfs
                if overlays is not None and ramdisk is None:
                    for overlay in overlays:
                        overlay = download_image(overlay, self.context,
                                                 self._tmpdir,
                                                 decompress=False)
                        extract_overlay(overlay, self._lava_nfsrootfs)
            if bootloader is not None:
                # We have been passed a bootloader
                bootloader = download_image(bootloader, self.context,
                                            self._tmpdir,
                                            decompress=False)
                self._boot_tags['{BOOTLOADER}'] = self._get_rel_path(bootloader, self._base_tmpdir)
            if firmware is not None:
                # We have been passed firmware
                firmware = download_image(firmware, self.context,
                                          self._tmpdir,
                                          decompress=False)

                self._boot_tags['{FIRMWARE}'] = self._get_rel_path(firmware, self._base_tmpdir)
            if self._is_uboot():
                self._boot_tags['{BOOTX}'] = self._get_uboot_boot_command(kernel,
                                                                          ramdisk,
                                                                          dtb)
Exemple #5
0
    def deploy_linaro_kernel(self,
                             kernel,
                             ramdisk,
                             dtb,
                             overlays,
                             rootfs,
                             nfsrootfs,
                             image,
                             bootloader,
                             firmware,
                             bl0,
                             bl1,
                             bl2,
                             bl31,
                             rootfstype,
                             bootloadertype,
                             target_type,
                             scratch_dir,
                             qemu_pflash=None):
        self.target_type = target_type
        self.scratch_dir = scratch_dir
        if kernel is not None:
            self._kernel = download_image(kernel,
                                          self.context,
                                          self._working_dir,
                                          decompress=False)
            if self.config.prepend_blob:
                blob = self._get_image(self.config.prepend_blob)
                self._kernel = prepend_blob(self._kernel, blob,
                                            self.working_dir)
            self._boot_tags['{SERVER_IP}'] = self.context.config.lava_server_ip
            self._boot_tags['{KERNEL}'] = os.path.basename(self._kernel)
            self._default_boot_cmds = 'boot_cmds_ramdisk'
        else:
            raise CriticalError('A kernel image is required!')
        if ramdisk is not None:
            self._ramdisk = download_image(ramdisk,
                                           self.context,
                                           self._working_dir,
                                           decompress=False)
            if overlays is not None:
                ramdisk_dir = extract_ramdisk(self._ramdisk,
                                              self.working_dir,
                                              is_uboot=False)
                for overlay in overlays:
                    overlay = download_image(overlay,
                                             self.context,
                                             self._working_dir,
                                             decompress=False)
                    extract_overlay(overlay, ramdisk_dir)
                self._ramdisk = create_ramdisk(ramdisk_dir, self.working_dir)
            self._boot_tags['{RAMDISK}'] = os.path.basename(self._ramdisk)
        if dtb is not None:
            self._dtb = download_image(dtb,
                                       self.context,
                                       self._working_dir,
                                       decompress=False)
            if self.config.append_dtb:
                self._kernel = append_dtb(self._kernel, self._dtb,
                                          self.working_dir)
                logging.info('Appended dtb to kernel image successfully')
            self._boot_tags['{DTB}'] = os.path.basename(self._dtb)
        if rootfs is not None:
            self._default_boot_cmds = 'boot_cmds_rootfs'
            rootfs = self._get_image(rootfs)
            self.fastboot.flash(self.config.rootfs_partition, rootfs)
        if self.config.multi_image_only:
            if self.config.fastboot_kernel_load_addr:
                if self.config.text_offset:
                    load_addr = self.config.text_offset
                else:
                    load_addr = self.config.fastboot_kernel_load_addr
                if self._ramdisk:
                    self._kernel = create_multi_image(self._kernel,
                                                      self._ramdisk, load_addr,
                                                      self.working_dir)
                else:
                    self._kernel = create_uimage(self._kernel, load_addr,
                                                 self.working_dir,
                                                 self.config.uimage_xip,
                                                 self.config.uimage_arch)
            else:
                raise CriticalError('Kernel load address not defined!')
        elif self.config.boot_fat_image_only:
            if self.config.fastboot_efi_image:
                efi = download_image(self.config.fastboot_efi_image,
                                     self.context,
                                     self._working_dir,
                                     decompress=False)
                self._kernel = create_fat_boot_image(self._kernel,
                                                     self.working_dir, efi,
                                                     self._ramdisk, self._dtb)
            else:
                raise CriticalError("No fastboot image provided")

        self.__boot_image__ = 'kernel'
    def deploy_linaro_kernel(self, kernel, ramdisk, dtb, overlays, rootfs, nfsrootfs, image, bootloader, firmware, bl0, bl1,
                             bl2, bl31, rootfstype, bootloadertype, target_type, qemu_pflash=None):
        # Required
        if kernel is None:
            raise CriticalError("A kernel image is required")
        elif ramdisk is None:
            raise CriticalError("A ramdisk image is required")

        if rootfs is not None or nfsrootfs is not None or firmware is not None:
            logging.warning("This platform only supports ramdisk booting, ignoring other parameters")

        self._ramdisk_boot = True

        self._kernel = download_image(kernel, self.context, self._scratch_dir,
                                      decompress=False)
        self._boot_tags['{KERNEL}'] = os.path.relpath(self._kernel, self._scratch_dir)
        self._initrd = download_image(ramdisk, self.context, self._scratch_dir,
                                      decompress=False)
        if overlays is not None:
            ramdisk_dir = extract_ramdisk(self._initrd, self._scratch_dir,
                                          is_uboot=self._is_uboot_ramdisk(ramdisk))
            for overlay in overlays:
                overlay = download_image(overlay, self.context,
                                         self._scratch_dir,
                                         decompress=False)
                extract_overlay(overlay, ramdisk_dir)
            self._initrd = create_ramdisk(ramdisk_dir, self._scratch_dir)
        self._boot_tags['{RAMDISK}'] = os.path.relpath(self._initrd, self._scratch_dir)

        # Optional
        if dtb is not None:
            self._dtb = download_image(dtb, self.context, self._scratch_dir,
                                       decompress=False)
            self._boot_tags['{DTB}'] = os.path.relpath(self._dtb, self._scratch_dir)

        if bootloader is None:
            if self.config.simulator_uefi_default is None:
                raise CriticalError("UEFI image is required")
            else:
                self._uefi = download_image(self.config.simulator_uefi_default, self.context,
                                            self._scratch_dir, decompress=False)
        else:
            self._uefi = download_image(bootloader, self.context,
                                        self._scratch_dir, decompress=False)

        if bl1 is None:
            if self.config.simulator_bl1_default is None:
                raise CriticalError("BL1 firmware is required")
            else:
                self._bl1 = download_image(self.config.simulator_bl1_default, self.context,
                                           self._scratch_dir, decompress=False)
        else:
            self._bl1 = download_image(bl1, self.context,
                                       self._scratch_dir, decompress=False)

        if bl0 is not None:
            self._bl0 = download_image(bl0, self.context, self._scratch_dir,
                                       decompress=False)
        if bl2 is not None:
            self._bl2 = download_image(bl2, self.context, self._scratch_dir,
                                       decompress=False)
        if bl31 is not None:
            self._bl31 = download_image(bl31, self.context, self._scratch_dir,
                                        decompress=False)

        if self.config.simulator_uefi_vars and self._uefi_vars is None:
            # Create file for flashloader1
            self._uefi_vars = os.path.join(self._scratch_dir, self.config.simulator_uefi_vars)
            touch(self._uefi_vars)

        # Get deployment data
        self.deployment_data = deployment_data.get(target_type)

        if image is not None:
            self._sd_image = download_image(image, self.context, self._scratch_dir,
                                            decompress=False)
        else:
            # Booting is not supported without an _sd_image defined
            self._sd_image = self._kernel

        self._default_boot_cmds = 'boot_cmds_ramdisk'
Exemple #7
0
    def deploy_linaro_kernel(self, kernel, ramdisk, dtb, overlays, rootfs, nfsrootfs, image, bootloader, firmware, bl0, bl1,
                             bl2, bl31, rootfstype, bootloadertype, target_type, qemu_pflash=None):
        # Required
        if kernel is None:
            raise CriticalError("A kernel image is required")
        elif ramdisk is None:
            raise CriticalError("A ramdisk image is required")

        if rootfs is not None or nfsrootfs is not None or firmware is not None:
            logging.warning("This platform only supports ramdisk booting, ignoring other parameters")

        self._ramdisk_boot = True

        self._kernel = download_image(kernel, self.context, self._scratch_dir,
                                      decompress=False)
        self._boot_tags['{KERNEL}'] = os.path.relpath(self._kernel, self._scratch_dir)
        self._initrd = download_image(ramdisk, self.context, self._scratch_dir,
                                      decompress=False)
        if overlays is not None:
            ramdisk_dir = extract_ramdisk(self._initrd, self._scratch_dir,
                                          is_uboot=self._is_uboot_ramdisk(ramdisk))
            for overlay in overlays:
                overlay = download_image(overlay, self.context,
                                         self._scratch_dir,
                                         decompress=False)
                extract_overlay(overlay, ramdisk_dir)
            self._initrd = create_ramdisk(ramdisk_dir, self._scratch_dir)
        self._boot_tags['{RAMDISK}'] = os.path.relpath(self._initrd, self._scratch_dir)

        # Optional
        if dtb is not None:
            self._dtb = download_image(dtb, self.context, self._scratch_dir,
                                       decompress=False)
            self._boot_tags['{DTB}'] = os.path.relpath(self._dtb, self._scratch_dir)

        if bootloader is None:
            if self.config.simulator_uefi_default is None:
                raise CriticalError("UEFI image is required")
            else:
                self._uefi = download_image(self.config.simulator_uefi_default, self.context,
                                            self._scratch_dir, decompress=False)
        else:
            self._uefi = download_image(bootloader, self.context,
                                        self._scratch_dir, decompress=False)

        if bl1 is None:
            if self.config.simulator_bl1_default is None:
                raise CriticalError("BL1 firmware is required")
            else:
                self._bl1 = download_image(self.config.simulator_bl1_default, self.context,
                                           self._scratch_dir, decompress=False)
        else:
            self._bl1 = download_image(bl1, self.context,
                                       self._scratch_dir, decompress=False)

        if bl0 is not None:
            self._bl0 = download_image(bl0, self.context, self._scratch_dir,
                                       decompress=False)
        if bl2 is not None:
            self._bl2 = download_image(bl2, self.context, self._scratch_dir,
                                       decompress=False)
        if bl31 is not None:
            self._bl31 = download_image(bl31, self.context, self._scratch_dir,
                                        decompress=False)

        if self.config.simulator_uefi_vars and self._uefi_vars is None:
            # Create file for flashloader1
            self._uefi_vars = os.path.join(self._scratch_dir, self.config.simulator_uefi_vars)
            touch(self._uefi_vars)

        # Get deployment data
        self.deployment_data = deployment_data.get(target_type)

        if image is not None:
            self._sd_image = download_image(image, self.context, self._scratch_dir,
                                            decompress=True)
        else:
            # Booting is not supported without an _sd_image defined
            self._sd_image = self._kernel

        self._default_boot_cmds = 'boot_cmds_ramdisk'
Exemple #8
0
    def deploy_linaro_kernel(self,
                             kernel,
                             ramdisk,
                             dtb,
                             overlays,
                             rootfs,
                             nfsrootfs,
                             image,
                             bootloader,
                             firmware,
                             bl0,
                             bl1,
                             bl2,
                             bl31,
                             rootfstype,
                             bootloadertype,
                             target_type,
                             qemu_pflash=None):
        # Check for errors
        if rootfs is None and ramdisk is None:
            raise CriticalError(
                "You must specify a QEMU file system image or ramdisk")
        if kernel is None and firmware is None:
            raise CriticalError("No bootloader or kernel image to boot")
        if bootloadertype == 'uefi':
            if firmware is None and qemu_pflash is None \
               and self.config.qemu_pflash is None:
                raise CriticalError(
                    "No firmware or qemu_pflash specified with "
                    "bootloadertype UEFI")

        if rootfs:
            self._sd_image = download_image(rootfs, self.context)
            self.customize_image(self._sd_image)

        self._kernel = download_image(kernel, self.context)

        if ramdisk is not None:
            ramdisk = download_image(ramdisk, self.context, decompress=False)
            if overlays is not None:
                ramdisk_dir = extract_ramdisk(
                    ramdisk,
                    self.scratch_dir,
                    is_uboot=self._is_uboot_ramdisk(ramdisk))
                for overlay in overlays:
                    overlay = download_image(overlay,
                                             self.context,
                                             self.scratch_dir,
                                             decompress=False)
                    extract_overlay(overlay, ramdisk_dir)
                ramdisk = create_ramdisk(ramdisk_dir, self.scratch_dir)
            self._ramdisk = ramdisk
            if rootfs is None:
                logging.debug("Attempting to set deployment data")
                self.deployment_data = deployment_data.get(target_type)

        if dtb is not None:
            dtb = download_image(dtb, self.context)
            self._dtb = dtb

        if bootloadertype == 'uefi':
            self._bootloadertype = 'uefi'

        if firmware is not None:
            firmware = download_image(firmware, self.context)
            self._firmware = firmware
        else:
            # Try downloading pflash files, if it exists.
            self._download_qemu_pflash_files(qemu_pflash=qemu_pflash)
    def deploy_linaro_kernel(self, kernel, ramdisk, dtb, overlays, rootfs, nfsrootfs,
                             image, bootloader, firmware, bl0, bl1, bl2, bl31,
                             rootfstype, bootloadertype, target_type, scratch_dir,
                             qemu_pflash=None):
        self.target_type = target_type
        self.scratch_dir = scratch_dir
        if kernel is not None:
            self._kernel = download_image(kernel, self.context,
                                          self._working_dir,
                                          decompress=False)
            if self.config.prepend_blob:
                blob = self._get_image(self.config.prepend_blob)
                self._kernel = prepend_blob(self._kernel,
                                            blob,
                                            self.working_dir)
            self._boot_tags['{SERVER_IP}'] = self.context.config.lava_server_ip
            self._boot_tags['{KERNEL}'] = os.path.basename(self._kernel)
            self._default_boot_cmds = 'boot_cmds_ramdisk'
        else:
            raise CriticalError('A kernel image is required!')
        if ramdisk is not None:
            self._ramdisk = download_image(ramdisk, self.context,
                                           self._working_dir,
                                           decompress=False)
            if overlays is not None:
                ramdisk_dir = extract_ramdisk(self._ramdisk, self.working_dir,
                                              is_uboot=False)
                for overlay in overlays:
                    overlay = download_image(overlay, self.context,
                                             self._working_dir,
                                             decompress=False)
                    extract_overlay(overlay, ramdisk_dir)
                self._ramdisk = create_ramdisk(ramdisk_dir, self.working_dir)
            self._boot_tags['{RAMDISK}'] = os.path.basename(self._ramdisk)
        if dtb is not None:
            self._dtb = download_image(dtb, self.context,
                                       self._working_dir,
                                       decompress=False)
            if self.config.append_dtb:
                self._kernel = append_dtb(self._kernel, self._dtb, self.working_dir)
                logging.info('Appended dtb to kernel image successfully')
            self._boot_tags['{DTB}'] = os.path.basename(self._dtb)
        if rootfs is not None:
            self._default_boot_cmds = 'boot_cmds_rootfs'
            rootfs = self._get_image(rootfs)
            self.fastboot.flash(self.config.rootfs_partition, rootfs)
        if self.config.multi_image_only:
            if self.config.fastboot_kernel_load_addr:
                if self.config.text_offset:
                    load_addr = self.config.text_offset
                else:
                    load_addr = self.config.fastboot_kernel_load_addr
                if self._ramdisk:
                    self._kernel = create_multi_image(self._kernel,
                                                      self._ramdisk,
                                                      load_addr,
                                                      self.working_dir)
                else:
                    self._kernel = create_uimage(self._kernel,
                                                 load_addr,
                                                 self.working_dir,
                                                 self.config.uimage_xip)
            else:
                raise CriticalError('Kernel load address not defined!')
        elif self.config.boot_fat_image_only:
            if self.config.fastboot_efi_image:
                efi = download_image(self.config.fastboot_efi_image, self.context,
                                     self._working_dir, decompress=False)
                self._kernel = create_fat_boot_image(self._kernel,
                                                     self.working_dir,
                                                     efi,
                                                     self._ramdisk,
                                                     self._dtb)
            else:
                raise CriticalError("No fastboot image provided")

        self.__boot_image__ = 'kernel'
    def deploy_linaro_kernel(
        self,
        kernel,
        ramdisk,
        dtb,
        overlays,
        rootfs,
        nfsrootfs,
        image,
        bootloader,
        firmware,
        bl0,
        bl1,
        bl2,
        bl31,
        rootfstype,
        bootloadertype,
        target_type,
        scratch_dir,
        qemu_pflash=None,
    ):
        kernel_url = kernel
        dtb_url = dtb
        # At a minimum we must have a kernel
        if kernel is None:
            raise CriticalError("No kernel image to boot")
        # Set the server IP (Dispatcher)
        self._boot_tags["{SERVER_IP}"] = self.context.config.lava_server_ip
        # Get the JTAG command fragments
        stmc_command = " ".join([self.config.jtag_stmc_boot_script, self.config.jtag_stmc_boot_options])
        # We have been passed kernel image
        kernel = download_image(kernel, self.context, scratch_dir, decompress=False)
        stmc_command = " ".join([stmc_command, self.config.jtag_stmc_kernel_command.format(KERNEL=kernel)])
        if ramdisk is not None:
            # We have been passed a ramdisk
            ramdisk = download_image(ramdisk, self.context, scratch_dir, decompress=False)
            if overlays is not None:
                ramdisk_dir = extract_ramdisk(ramdisk, scratch_dir, is_uboot=False)
                for overlay in overlays:
                    overlay = download_image(overlay, self.context, scratch_dir, decompress=False)
                    extract_overlay(overlay, ramdisk_dir)
                ramdisk = create_ramdisk(ramdisk_dir, scratch_dir)
            stmc_command = " ".join([stmc_command, self.config.jtag_stmc_ramdisk_command.format(RAMDISK=ramdisk)])
        if dtb is not None:
            # We have been passed a device tree blob
            dtb = download_image(dtb, self.context, scratch_dir, decompress=False)
            stmc_command = " ".join([stmc_command, self.config.jtag_stmc_dtb_command.format(DTB=dtb)])
        if nfsrootfs is not None:
            # Extract rootfs into nfsrootfs directory
            nfsrootfs = download_image(nfsrootfs, self.context, scratch_dir, decompress=False)
            scratch_dir = mkdtemp(self.context.config.lava_image_tmpdir)
            lava_nfsrootfs = mkdtemp(basedir=scratch_dir)
            extract_rootfs(nfsrootfs, lava_nfsrootfs)
            self._boot_tags["{NFSROOTFS}"] = lava_nfsrootfs
            self._default_boot_cmds = "boot_cmds_nfs"
            if overlays is not None and ramdisk is None:
                for overlay in overlays:
                    overlay = download_image(overlay, self.context, scratch_dir, decompress=False)
                extract_overlay(overlay, lava_nfsrootfs)

        # Add suffix for boot commands
        self._stmc_command = stmc_command + " --"

        if self.context.test_data.metadata.get("is_slave", "false") == "true":
            logging.info("Booting in the master/slave mode, as *slave*")
            logging.info("Sending the kernel, dtb, nfsrootfs urls")
            self.context.transport.request_send(
                "lava_ms_slave_data",
                {
                    "kernel": kernel_url,
                    "dtb": dtb_url if dtb_url else "",
                    "nfs_rootfs": lava_nfsrootfs,
                    "nfs_server_ip": self.context.config.lava_server_ip,
                    "stmc_ip": self.config.jtag_stmc_ip,
                },
            )

        return self._boot_tags, self._default_boot_cmds