def _get_uboot_boot_command(self, kernel, ramdisk, dtb): bootz = False bootx = [] if is_uimage(kernel, self.context): logging.info('Attempting to set boot command as bootm') bootx.append('bootm') else: logging.info('Attempting to set boot command as bootz') bootx.append('bootz') bootz = True # At minimal we have a kernel bootx.append('${kernel_addr_r}') if ramdisk is not None: bootx.append('${initrd_addr_r}') elif ramdisk is None and dtb is not None: bootx.append('-') if dtb is not None: bootx.append('${fdt_addr_r}') self._set_load_addresses(bootz) return ' '.join(bootx)
def _get_uboot_boot_command(self, kernel, ramdisk, dtb): bootz = False bootx = [] if is_uimage(kernel, self.context): logging.info('Attempting to set boot command as bootm') bootx.append('bootm') else: logging.info('Attempting to set boot command as bootz') bootx.append('bootz') bootz = True # At minimal we have a kernel bootx.append('${kernel_addr_r}') if self.config.ramdisk_raw: bootx.append('-') elif ramdisk is not None: bootx.append('${initrd_addr_r}') elif ramdisk is None and dtb is not None: bootx.append('-') if dtb is not None: bootx.append('${fdt_addr_r}') self._set_load_addresses(bootz) return ' '.join(bootx)
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)
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)