Exemplo n.º 1
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):
        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)
Exemplo n.º 2
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):
        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)
Exemplo n.º 4
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)
            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'