def deploy_android(self, images, rootfstype, bootloadertype, target_type): scratch = self.scratch_dir for image in images: if image['partition'] == 'boot': boot = download_image(image['url'], self.context, scratch, decompress=False) elif image['parition'] == 'system': system = download_image(image['url'], self.context, scratch, decompress=False) elif image['partition'] == 'userdata': data = download_image(image['url'], self.context, scratch, decompress=False) else: msg = 'Unsupported partition option: %s' % image['partition'] logging.warning(msg) raise CriticalError(msg) img = os.path.join(scratch, 'android.img') device_type = self.config.lmc_dev_arg generate_android_image(self.context, device_type, boot, data, system, img) self._customize_android(img) self._write_image(img)
def deploy_android(self, images, rootfstype, bootloadertype, target_type): logging.info("Deploying Android on %s", self.config.hostname) self._bootloadertype = bootloadertype self._boot = None self._system = None self._data = None for image in images: if 'boot' in image['partition']: self._boot = download_image(image['url'], self.context, decompress=False) elif 'system' in image['partition']: self._system = download_image(image['url'], self.context, decompress=False) elif 'userdata' in image['partition']: self._data = download_image(image['url'], self.context, decompress=False) else: msg = 'Unsupported partition option: %s' % image['partition'] logging.warning(msg) raise CriticalError(msg) if not all([self._boot, self._system, self._data]): msg = 'Must supply a boot, system, and userdata image for fastmodel image deployment' logging.warning(msg) raise CriticalError(msg) self._sd_image = '%s/android.img' % os.path.dirname(self._system) generate_android_image( self.context, 'vexpress', self._boot, self._data, self._system, self._sd_image ) self._copy_needed_files_from_partition(self.config.boot_part, '') self._customize_android()
def deploy_android(self, images, rootfstype, bootloadertype, target_type): self.deployment_data = deployment_data.android self.boot_master_image() boot = None system = None data = None sdir = self.scratch_dir for image in images: if 'boot' in image['partition']: boot = download_image(image['url'], self.context, sdir, decompress=False) elif 'system' in image['partition']: system = download_image(image['url'], self.context, sdir, decompress=False) elif 'userdata' in image['partition']: data = download_image(image['url'], self.context, sdir, decompress=False) else: msg = 'Unsupported partition option: %s' % image['partition'] logging.warning(msg) raise CriticalError(msg) if not all([boot, system, data]): msg = 'Must supply a boot, system, and userdata image for master image deployment' logging.warning(msg) raise CriticalError(msg) with self._as_master() as master: self._format_testpartition(master, rootfstype) self._deploy_android_tarballs(master, boot, system, data) if master.has_partition_with_label(self.userdata_label) and \ master.has_partition_with_label(self.sdcard_label): self._purge_linaro_android_sdcard(master)
def generate_image(client, hwpack_url, rootfs_url, dtb, outdir, bootloadertype, rootfstype, extra_boot_args=None, image_size=None): """Generate image from a hwpack and rootfs url :param hwpack_url: url of the Linaro hwpack to download :param rootfs_url: url of the Linaro image to download """ logging.info("preparing to deploy on %s" % client.config.hostname) logging.info(" hwpack: %s" % hwpack_url) logging.info(" rootfs: %s" % rootfs_url) logging.info("Downloading the %s file" % hwpack_url) hwpack_path = download_image(hwpack_url, client.context, outdir, decompress=False) logging.info("Downloading the %s file" % rootfs_url) rootfs_path = download_image(rootfs_url, client.context, outdir, decompress=False) logging.info("linaro-media-create version information") cmd = "sudo linaro-media-create -v" rc, output = getstatusoutput(cmd) metadata = client.context.test_data.get_metadata() metadata['target.linaro-media-create-version'] = output client.context.test_data.add_metadata(metadata) image_file = os.path.join(outdir, "lava.img") logging.info("client.device_type = %s" % client.config.device_type) cmd = ( "sudo flock /var/lock/lava-lmc.lck linaro-media-create --hwpack-force-yes --dev %s " "--image-file %s --binary %s --hwpack %s --image-size 3G --bootloader %s" % (client.config.lmc_dev_arg, image_file, rootfs_path, hwpack_path, bootloadertype)) if dtb is not None: cmd += ' --dtb ' + dtb if rootfstype is not None: cmd += ' --rootfs ' + rootfstype if image_size is not None: cmd += ' --image-size ' + image_size if extra_boot_args is not None: cmd += ' --extra-boot-args "%s"' % extra_boot_args logging.info("Executing the linaro-media-create command") logging.info(cmd) _run_linaro_media_create(client.context, cmd) return image_file
def _download_qemu_pflash_files(self, qemu_pflash=None): self._qemu_pflash = [] if qemu_pflash: for pflash in qemu_pflash: self._qemu_pflash.append(download_image(pflash, self.context)) elif self.config.qemu_pflash: for pflash in self.config.qemu_pflash: self._qemu_pflash.append(download_image(pflash, self.context)) else: self._qemu_pflash = None
def _wait_for_master_boot(self): if self.config.boot_cmds_master: # Break the boot sequence self._enter_bootloader(self.proc) # Configure dynamic master image boot if self.config.master_kernel and self.master_kernel is None: # Set the server IP (Dispatcher) self.master_boot_tags[ '{SERVER_IP}'] = self.context.config.lava_server_ip self.master_kernel = download_image(self.config.master_kernel, self.context, self.master_tmpdir, decompress=False) self.master_boot_tags['{KERNEL}'] = self._get_rel_path( self.master_kernel, self.master_base_tmpdir) if self.config.master_ramdisk: self.master_ramdisk = download_image( self.config.master_ramdisk, self.context, self.master_tmpdir, decompress=False) self.master_boot_tags['{RAMDISK}'] = self._get_rel_path( self.master_ramdisk, self.master_base_tmpdir) if self.config.master_dtb: self.master_dtb = download_image(self.config.master_dtb, self.context, self.master_tmpdir, decompress=False) self.master_boot_tags['{DTB}'] = self._get_rel_path( self.master_dtb, self.master_base_tmpdir) if self.config.master_firmware: self.master_firmware = download_image( self.config.master_firmware, self.context, self.master_tmpdir, decompress=False) self.master_boot_tags['{FIRMWARE}'] = self._get_rel_path( self.master_firmware, self.master_base_tmpdir) if self.config.master_nfsrootfs: self.master_nfsrootfs = download_image( self.config.master_nfsrootfs, self.context, self.master_tmpdir, decompress=False) self.master_boot_tags['{NFSROOTFS}'] = self._setup_nfs( self.master_nfsrootfs, self.master_tmpdir) boot_cmds = self._load_boot_cmds(default='boot_cmds_master', boot_tags=self.master_boot_tags) self._customize_bootloader(self.proc, boot_cmds) self._monitor_boot(self.proc, self.MASTER_PS1, self.MASTER_PS1_PATTERN, is_master=True)
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.config.vexpress_complete_firmware: if firmware is None: if self.config.vexpress_firmware_default is None: raise CriticalError("No default board recovery image defined") else: tarball = download_image(self.config.vexpress_firmware_default, self.context, self._tmpdir, decompress=False) self._extract_compressed_firmware(tarball) else: tarball = download_image(firmware, self.context, self._tmpdir, decompress=False) self._extract_compressed_firmware(tarball) firmware = None else: if bootloader is None: if self.config.vexpress_uefi_default is None: raise CriticalError("UEFI image is required") else: self.test_uefi = download_image(self.config.vexpress_uefi_default, self.context, self._tmpdir, decompress=False) else: self.test_uefi = download_image(bootloader, self.context, self._tmpdir, decompress=False) bootloader = None if self.config.vexpress_requires_trusted_firmware: if bl1 is None and self.config.vexpress_requires_trusted_firmware: if self.config.vexpress_bl1_default is None: raise CriticalError("BL1 firmware is required") else: self.test_bl1 = download_image(self.config.vexpress_bl1_default, self.context, self._tmpdir, decompress=False) else: self.test_bl1 = download_image(bl1, self.context, self._tmpdir, decompress=False) bl1 = None if bl0 is None and self.config.vexpress_requires_bl0: if self.config.vexpress_bl0_default is None: raise CriticalError("BL0 firmware is required") else: self.test_bl0 = download_image(self.config.vexpress_bl0_default, self.context, self._tmpdir, decompress=False) elif bl0 is not None: self.test_bl0 = download_image(bl0, self.context, self._tmpdir, decompress=False) bl0 = None super(VexpressTarget, self).deploy_linaro_kernel(kernel, ramdisk, dtb, overlays, rootfs, nfsrootfs, image, bootloader, firmware, bl0, bl1, bl2, bl31, rootfstype, bootloadertype, target_type, qemu_pflash=qemu_pflash)
def deploy_linaro(self, hwpack, rootfs, dtb, rootfstype, bootloadertype, qemu_pflash=None): hwpack = download_image(hwpack, self.context, decompress=False) rootfs = download_image(rootfs, self.context, decompress=False) odir = os.path.dirname(rootfs) self._bootloadertype = bootloadertype generate_fastmodel_image(self.context, hwpack, rootfs, dtb, odir, bootloadertype) self._sd_image = '%s/sd.img' % odir self.customize_image(self._sd_image) self._copy_needed_files_from_partition(self.config.boot_part, '') self._copy_needed_files_from_partition(self.config.root_part, 'boot') self._copy_needed_files_from_partition(self.config.root_part, 'lib')
def deploy_linaro(self, hwpack, rootfs, dtb, rootfstype, bootfstype, bootloadertype, qemu_pflash=None): hwpack = download_image(hwpack, self.context, decompress=False) rootfs = download_image(rootfs, self.context, decompress=False) odir = os.path.dirname(rootfs) self._bootloadertype = bootloadertype generate_fastmodel_image(self.context, hwpack, rootfs, dtb, odir, bootloadertype) self._sd_image = '%s/sd.img' % odir self.customize_image(self._sd_image) self._copy_needed_files_from_partition(self.config.boot_part, '') self._copy_needed_files_from_partition(self.config.root_part, 'boot') self._copy_needed_files_from_partition(self.config.root_part, 'lib')
def deploy_linaro_prebuilt(self, image, dtb, rootfstype, bootfstype, bootloadertype, qemu_pflash=None): self._uboot_boot = False if self._is_ipxe(): if image is not None: self._ipxe_boot = True # We are not booted yet self._booted = False # We specify OE deployment data, vanilla as possible self.deployment_data = deployment_data.oe # We have been passed a image image = download_image(image, self.context, self._tmpdir, decompress=False) image_url = self._get_http_url(image) # We are booting an image, can be iso or whole disk self._boot_tags['{IMAGE}'] = image_url else: raise CriticalError("No image to boot") else: super(BootloaderTarget, self).deploy_linaro_prebuilt(image, dtb, rootfstype, bootfstype, bootloadertype, qemu_pflash=qemu_pflash)
def __init__(self, testdef_obj, post_process_script, probe_args=None): SignalHandler.__init__(self, testdef_obj) self.scratch_dir = testdef_obj.context.client.target_device.scratch_dir # post_process_script can be local to the repo or a URL if not urlparse.urlparse(post_process_script).scheme: self.post_process_script = os.path.join( testdef_obj.repo, post_process_script) else: self.post_process_script = download_image( post_process_script, testdef_obj.context, self.scratch_dir) os.chmod(self.post_process_script, 755) # make sure we can execute it # build up the command we'll use for running the probe config = testdef_obj.context.client.config self.aep_channels = config.arm_probe_channels self.aep_args = [ config.arm_probe_binary, '-C', config.arm_probe_config] for c in self.aep_channels: self.aep_args.append('-c') self.aep_args.append(c) for arg in probe_args: self.aep_args.append(arg)
def extract_tarball(self, tarball_url, partition, directory='/'): logging.info('extracting %s to target', tarball_url) self._check_power_state() with image_partition_mounted(self._sd_image, partition) as mntdir: tb = download_image(tarball_url, self.context, decompress=False) extract_tar(tb, '%s/%s' % (mntdir, directory))
def get_tarballs(context, image_url, scratch_dir, generator): """ Tries to return a cached copy array of (boot_tgz, root_tgz, distro). If no cache exists for this image_url, then it: * places a global lock for the image_url to prevent other dispatchers from concurrently building tarballs for the same image * downloads the image * calls the generator function to build the tarballs generator - a callback to a function that can generate the tarballs given a local copy .img file """ logging.info('try to find cached tarballs for %s' % image_url) with _cache_locked(image_url, context.config.lava_cachedir) as cachedir: boot_tgz = os.path.join(cachedir, 'boot.tgz') root_tgz = os.path.join(cachedir, 'root.tgz') distro_file = os.path.join(cachedir, 'distro') if os.path.exists(boot_tgz) and os.path.exists(root_tgz): distro = _get_distro(cachedir, distro_file) if distro is not None: logging.info('returning cached copies') (boot_tgz, root_tgz) = _link(boot_tgz, root_tgz, scratch_dir) return boot_tgz, root_tgz, distro else: logging.info('no cache found for %s' % image_url) _clear_cache(boot_tgz, root_tgz, distro_file) image = download_image(image_url, context, cachedir) (boot_tgz, root_tgz, distro) = generator(image) with open(distro_file, 'w') as f: f.write(distro) _link(boot_tgz, root_tgz, cachedir) os.unlink(image) return boot_tgz, root_tgz, distro
def load_from_url(self, url): i = [] tmpdir = utils.mkdtemp(self.tmpbase) testdef_file = download_image(url, self.context, tmpdir) with open(testdef_file, 'r') as f: logging.debug('loading test definition ...') testdef = yaml.safe_load(f) for e in INVALID_CHARS: i.extend(indices(testdef["metadata"]["name"], e)) if i: msg = "Test name contains invalid symbol(s) at position(s): %s" % ", ".join(map(str, i)) raise GeneralError(msg) try: testdef["metadata"]["name"].encode() except UnicodeEncodeError as e: msg = "Test name contains non-ascii symbols: %s" % e raise GeneralError(msg) if 'test-case-deps' in testdef: self._get_dependent_test_cases(testdef) idx = len(self.testdefs) testdef_metadata = {'url': url, 'location': 'URL'} testdef_metadata.update(_get_testdef_info(testdef)) self._append_testdef(URLTestDefinition(self.context, idx, testdef, testdef_metadata))
def deploy_android(self, boot, system, data, rootfstype, bootloadertype, target_type): scratch = self.scratch_dir boot = download_image(boot, self.context, scratch, decompress=False) data = download_image(data, self.context, scratch, decompress=False) system = download_image(system, self.context, scratch, decompress=False) img = os.path.join(scratch, 'android.img') device_type = self.config.lmc_dev_arg generate_android_image(self.context, device_type, boot, data, system, img) self._customize_android(img) self._write_image(img)
def deploy_android(self, boot, system, userdata, rootfstype, bootloadertype, target_type): self.deployment_data = deployment_data.android self.boot_master_image() sdir = self.scratch_dir boot = download_image(boot, self.context, sdir, decompress=False) system = download_image(system, self.context, sdir, decompress=False) data = download_image(userdata, self.context, sdir, decompress=False) with self._as_master() as master: self._format_testpartition(master, rootfstype) self._deploy_android_tarballs(master, boot, system, data) if master.has_partition_with_label(self.userdata_label) and \ master.has_partition_with_label(self.sdcard_label): self._purge_linaro_android_sdcard(master)
def deploy_linaro_prebuilt(self, image, dtb, rootfstype, bootloadertype, qemu_pflash=None): if bootloadertype == 'uefi': self._bootloadertype = 'uefi' # Try downloading pflash files, if it exists. self._download_qemu_pflash_files(qemu_pflash=qemu_pflash) self._sd_image = download_image(image, self.context) self.customize_image(self._sd_image)
def deploy_android(self, boot, system, data, rootfstype, bootloadertype, target_type): logging.info("Deploying Android on %s", self.config.hostname) self._bootloadertype = bootloadertype self._boot = download_image(boot, self.context, decompress=False) self._data = download_image(data, self.context, decompress=False) self._system = download_image(system, self.context, decompress=False) self._sd_image = '%s/android.img' % os.path.dirname(self._system) generate_android_image(self.context, 'vexpress', self._boot, self._data, self._system, self._sd_image) self._copy_needed_files_from_partition(self.config.boot_part, '') self._customize_android()
def generate_image(client, hwpack_url, rootfs_url, dtb, outdir, bootloadertype, rootfstype, extra_boot_args=None, image_size=None): """Generate image from a hwpack and rootfs url :param hwpack_url: url of the Linaro hwpack to download :param rootfs_url: url of the Linaro image to download """ logging.info("preparing to deploy on %s" % client.config.hostname) logging.info(" hwpack: %s" % hwpack_url) logging.info(" rootfs: %s" % rootfs_url) logging.info("Downloading the %s file" % hwpack_url) hwpack_path = download_image(hwpack_url, client.context, outdir, decompress=False) logging.info("Downloading the %s file" % rootfs_url) rootfs_path = download_image(rootfs_url, client.context, outdir, decompress=False) logging.info("linaro-media-create version information") cmd = "sudo linaro-media-create -v" rc, output = getstatusoutput(cmd) metadata = client.context.test_data.get_metadata() metadata['target.linaro-media-create-version'] = output client.context.test_data.add_metadata(metadata) image_file = os.path.join(outdir, "lava.img") logging.info("client.device_type = %s" % client.config.device_type) cmd = ("sudo flock /var/lock/lava-lmc.lck linaro-media-create --hwpack-force-yes --dev %s " "--image-file %s --binary %s --hwpack %s --image-size 3G --bootloader %s" % (client.config.lmc_dev_arg, image_file, rootfs_path, hwpack_path, bootloadertype)) if dtb is not None: cmd += ' --dtb ' + dtb if rootfstype is not None: cmd += ' --rootfs ' + rootfstype if image_size is not None: cmd += ' --image-size ' + image_size if extra_boot_args is not None: cmd += ' --extra-boot-args "%s"' % extra_boot_args logging.info("Executing the linaro-media-create command") logging.info(cmd) _run_linaro_media_create(client.context, cmd) return image_file
def _restore_firmware_backup(self, mount_point): if self.config.vexpress_complete_firmware: tarball = download_image(self.config.vexpress_firmware_default, self.context, self.scratch_dir, decompress=False) self._extract_compressed_firmware_master(tarball) self._copy_firmware_to_juno(self.complete_firmware_master, mount_point) else: uefi_path = self.config.vexpress_uefi_path uefi = os.path.join(mount_point, uefi_path) uefi_backup_path = self.config.vexpress_uefi_backup_path uefi_backup = os.path.join(mount_point, uefi_backup_path) if unicode_path_check(uefi_backup): # restore the uefi backup self.context.run_command_with_retries('cp %s %s' % (uefi_backup, uefi)) else: # no existing backup yet means that this is the first time ever; # the uefi in there is the good one, and we backup it up. self.context.run_command_with_retries('cp %s %s' % (uefi, uefi_backup)) if self.config.vexpress_requires_trusted_firmware: bl1_path = self.config.vexpress_bl1_path bl1 = os.path.join(mount_point, bl1_path) bl1_backup_path = self.config.vexpress_bl1_backup_path bl1_backup = os.path.join(mount_point, bl1_backup_path) if unicode_path_check(bl1_backup): # restore the firmware backup self.context.run_command_with_retries('cp %s %s' % (bl1_backup, bl1)) else: # no existing backup yet means that this is the first time ever; # the firmware in there is the good one, and we backup it up. self.context.run_command_with_retries('cp %s %s' % (bl1, bl1_backup)) if self.config.vexpress_requires_bl0: bl0_path = self.config.vexpress_bl0_path bl0 = os.path.join(mount_point, bl0_path) bl0_backup_path = self.config.vexpress_bl0_backup_path bl0_backup = os.path.join(mount_point, bl0_backup_path) if unicode_path_check(bl0_backup): # restore the bl0 backup self.context.run_command_with_retries( 'cp %s %s' % (bl0_backup, bl0)) else: # no existing backup yet means that this is the first time ever; # the bl0 in there is the good one, and we backup it up. self.context.run_command_with_retries( 'cp %s %s' % (bl0, bl0_backup))
def deploy_linaro_prebuilt(self, image, dtb, rootfstype, bootloadertype, qemu_pflash=None): self._sd_image = download_image(image, self.context) self._bootloadertype = bootloadertype self.customize_image(self._sd_image) if dtb is not None: self.config.simulator_dtb_files = [dtb] self._copy_needed_files_from_partition(self.config.boot_part, '') self._copy_needed_files_from_partition(self.config.root_part, 'boot') self._copy_needed_files_from_partition(self.config.root_part, 'lib')
def deploy_linaro_prebuilt(self, image, dtb, rootfstype, bootfstype, bootloadertype, qemu_pflash=None): self._sd_image = download_image(image, self.context) self._bootloadertype = bootloadertype self.customize_image(self._sd_image) if dtb is not None: self.config.simulator_dtb_files = [dtb] self._copy_needed_files_from_partition(self.config.boot_part, '') self._copy_needed_files_from_partition(self.config.root_part, 'boot') self._copy_needed_files_from_partition(self.config.root_part, 'lib')
def deploy_linaro_prebuilt(self, image, dtb, rootfstype, bootfstype, bootloadertype, qemu_pflash=None): img = download_image(image, self.context) self.customize_image(img) self._write_image(img)
def _busybox_file_system(self, runner, directory, mounted=False): error_detected = False try: if mounted: targetdir = os.path.abspath(os.path.join('/mnt/%s' % directory)) else: targetdir = os.path.abspath(os.path.join('/', directory)) runner.run('mkdir -p %s' % targetdir) parent_dir, target_name = os.path.split(targetdir) runner.run('/bin/tar -cmzf /tmp/fs.tgz -C %s %s' % (parent_dir, target_name)) runner.run('cd /tmp') # need to be in same dir as fs.tgz try: ip = runner.get_target_ip() except NetworkError as e: error_detected = True raise CriticalError("Network error detected..aborting") url_base = self._start_busybox_http_server(runner, ip) url = url_base + '/fs.tgz' logging.info("Fetching url: %s", url) tf = download_image(url, self.context, self.scratch_dir, decompress=False) tfdir = os.path.join(self.scratch_dir, str(time.time())) try: utils.ensure_directory(tfdir) self.context.run_command('/bin/tar -C %s -xzf %s' % (tfdir, tf)) yield os.path.join(tfdir, target_name) finally: tf = os.path.join(self.scratch_dir, 'fs.tgz') utils.mk_targz(tf, tfdir) utils.rmtree(tfdir) # get the last 2 parts of tf, ie "scratchdir/tf.tgz" tf = '/'.join(tf.split('/')[-2:]) runner.run('rm -rf %s' % targetdir) self._target_extract(runner, tf, parent_dir, busybox=True) finally: if not error_detected: self._stop_busybox_http_server(runner) if mounted: runner.run('umount /mnt')
def deploy_linaro_kernel(self, kernel, ramdisk, dtb, modules, rootfs, nfsrootfs, bootloader, firmware, bl1, bl2, bl31, rootfstype, bootloadertype, target_type): if bootloader is None: if self.config.vexpress_uefi_default is None: raise CriticalError("UEFI image is required") else: self.test_uefi = download_image( self.config.vexpress_uefi_default, self.context, self._tmpdir, decompress=False) else: self.test_uefi = download_image(bootloader, self.context, self._tmpdir, decompress=False) bootloader = None if bl1 is None and self.config.vexpress_requires_trusted_firmware: if self.config.vexpress_bl1_default is None: raise CriticalError("BL1 firmware is required") else: self.test_bl1 = download_image( self.config.vexpress_bl1_default, self.context, self._tmpdir, decompress=False) else: self.test_bl1 = download_image(bl1, self.context, self._tmpdir, decompress=False) bl1 = None super(VexpressTarget, self).deploy_linaro_kernel(kernel, ramdisk, dtb, modules, rootfs, nfsrootfs, bootloader, firmware, bl1, bl2, bl31, rootfstype, bootloadertype, target_type)
def deploy_linaro_kernel(self, kernel, ramdisk, dtb, modules, rootfs, nfsrootfs, bootloader, firmware, bl1, bl2, bl31, rootfstype, bootloadertype, target_type): # Check for errors if rootfs is None: raise CriticalError("You must specify a QEMU file system image") if kernel is None: raise CriticalError("No kernel images to boot") 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) if modules is not None: modules = download_image(modules, self.context, self._scratch_dir, decompress=False) ramdisk_dir = extract_ramdisk(ramdisk, self._scratch_dir, is_uboot=self._is_uboot_ramdisk(ramdisk)) extract_modules(modules, ramdisk_dir) ramdisk = create_ramdisk(ramdisk_dir, self._scratch_dir) self._ramdisk = ramdisk if dtb is not None: dtb = download_image(dtb, self.context) self._dtb = dtb if firmware is not None: firmware = download_image(firmware, self.context) self._firmware = firmware
def deploy_linaro_prebuilt(self, image, dtb, rootfstype, bootloadertype, qemu_pflash=None): self.boot_master_image() if self.context.job_data.get('health_check', False): (boot_tgz, root_tgz, distro) = tarballcache.get_tarballs( self.context, image, self.scratch_dir, self._generate_tarballs) self.deployment_data = deployment_data.get(distro) else: image_file = download_image(image, self.context, self.scratch_dir) (boot_tgz, root_tgz, distro) = self._generate_tarballs(image_file) self._read_boot_cmds(boot_tgz=boot_tgz) self._deploy_tarballs(boot_tgz, root_tgz, rootfstype)
def _run_uiautomator_commands(self): """ run uiautomator commands""" jar = self.config.android_boot_uiautomator_jar commands = self.config.android_boot_uiautomator_commands session = AndroidTesterCommandRunner(self) jar = download_image(jar, self.context, decompress=False) jar_file = os.path.basename(jar) self.target_device.driver.adb('push %s /data/local/tmp/' % jar) if commands is not None: for command in commands: session.run('uiautomator runtest %s %s' % (jar_file, command)) else: session.run('uiautomator runtest %s' % jar_file)
def deploy_linaro_prebuilt(self, image, dtb, rootfstype, bootfstype, bootloadertype, qemu_pflash=None): self.boot_master_image() if self.context.job_data.get('health_check', False): (boot_tgz, root_tgz, distro) = tarballcache.get_tarballs( self.context, image, self.scratch_dir, self._generate_tarballs) self.deployment_data = deployment_data.get(distro) else: image_file = download_image(image, self.context, self.scratch_dir) (boot_tgz, root_tgz, distro) = self._generate_tarballs(image_file) self._read_boot_cmds(boot_tgz=boot_tgz) self._deploy_tarballs(boot_tgz, root_tgz, rootfstype, bootfstype)
def deploy_linaro_prebuilt(self, image, dtb, rootfstype, bootfstype, bootloadertype, qemu_pflash=None): if bootloadertype == 'uefi': self._bootloadertype = 'uefi' # Try downloading pflash files, if it exists. self._download_qemu_pflash_files(qemu_pflash=qemu_pflash) self._sd_image = download_image(image, self.context) self.customize_image(self._sd_image)
def _wait_for_master_boot(self): if self.config.boot_cmds_master: # Break the boot sequence self._enter_bootloader(self.proc) # Configure dynamic master image boot if self.config.master_kernel and self.master_kernel is None: # Set the server IP (Dispatcher) self.master_boot_tags['{SERVER_IP}'] = self.context.config.lava_server_ip self.master_kernel = download_image( self.config.master_kernel, self.context, self.master_tmpdir, decompress=False) self.master_boot_tags['{KERNEL}'] = self._get_rel_path(self.master_kernel, self.master_base_tmpdir) if self.config.master_ramdisk: self.master_ramdisk = download_image( self.config.master_ramdisk, self.context, self.master_tmpdir, decompress=False) self.master_boot_tags['{RAMDISK}'] = self._get_rel_path(self.master_ramdisk, self.master_base_tmpdir) if self.config.master_dtb: self.master_dtb = download_image( self.config.master_dtb, self.context, self.master_tmpdir, decompress=False) self.master_boot_tags['{DTB}'] = self._get_rel_path(self.master_dtb, self.master_base_tmpdir) if self.config.master_firmware: self.master_firmware = download_image( self.config.master_firmware, self.context, self.master_tmpdir, decompress=False) self.master_boot_tags['{FIRMWARE}'] = self._get_rel_path(self.master_firmware, self.master_base_tmpdir) if self.config.master_nfsrootfs: self.master_nfsrootfs = download_image( self.config.master_nfsrootfs, self.context, self.master_tmpdir, decompress=False) self.master_boot_tags['{NFSROOTFS}'] = self._setup_nfs(self.master_nfsrootfs, self.master_tmpdir) boot_cmds = self._load_boot_cmds(default='boot_cmds_master', boot_tags=self.master_boot_tags) self._customize_bootloader(self.proc, boot_cmds) self.proc.expect(self.config.image_boot_msg, timeout=300) self._auto_login(self.proc, is_master=True) self._wait_for_prompt(self.proc, self.config.master_str, timeout=300)
def _pre_download_src(self, customize_info, image=None): # for self.customize_image if image is not None: for customize_object in customize_info["image"]: image_path = ImagePathHandle(image, customize_object["src"], self.config, self.mount_info) temp_file = image_path.copy_to(self.context, None) customize_object["src"] = temp_file else: customize_info["image"] = [] logging.debug("There are not image files which will be pre-download to temp dir!") for customize_object in customize_info["remote"]: temp_file = download_image(customize_object["src"], self.context) customize_object["src"] = temp_file
def load_from_url(self, url): tmpdir = utils.mkdtemp(self.tmpbase) testdef_file = download_image(url, self.context, tmpdir) with open(testdef_file, 'r') as f: logging.debug('loading test definition ...') testdef = yaml.safe_load(f) if 'test-case-deps' in testdef: self._get_dependent_test_cases(testdef) idx = len(self.testdefs) testdef_metadata = {'url': url, 'location': 'URL'} testdef_metadata.update(_get_testdef_info(testdef)) self._append_testdef(URLTestDefinition(self.context, idx, testdef, testdef_metadata))
def _restore_firmware_backup(self, mount_point): if self.config.vexpress_complete_firmware: tarball = download_image(self.config.vexpress_firmware_default, self.context, self.scratch_dir, decompress=False) self._extract_compressed_firmware_master(tarball) self._copy_firmware_to_juno(self.complete_firmware_master, mount_point) else: uefi_path = self.config.vexpress_uefi_path uefi = os.path.join(mount_point, uefi_path) uefi_backup_path = self.config.vexpress_uefi_backup_path uefi_backup = os.path.join(mount_point, uefi_backup_path) if unicode_path_check(uefi_backup): # restore the uefi backup self.context.run_command_with_retries('cp %s %s' % (uefi_backup, uefi)) else: # no existing backup yet means that this is the first time ever; # the uefi in there is the good one, and we backup it up. self.context.run_command_with_retries('cp %s %s' % (uefi, uefi_backup)) if self.config.vexpress_requires_trusted_firmware: bl1_path = self.config.vexpress_bl1_path bl1 = os.path.join(mount_point, bl1_path) bl1_backup_path = self.config.vexpress_bl1_backup_path bl1_backup = os.path.join(mount_point, bl1_backup_path) if unicode_path_check(bl1_backup): # restore the firmware backup self.context.run_command_with_retries('cp %s %s' % (bl1_backup, bl1)) else: # no existing backup yet means that this is the first time ever; # the firmware in there is the good one, and we backup it up. self.context.run_command_with_retries('cp %s %s' % (bl1, bl1_backup)) if self.config.vexpress_requires_bl0: bl0_path = self.config.vexpress_bl0_path bl0 = os.path.join(mount_point, bl0_path) bl0_backup_path = self.config.vexpress_bl0_backup_path bl0_backup = os.path.join(mount_point, bl0_backup_path) if unicode_path_check(bl0_backup): # restore the bl0 backup self.context.run_command_with_retries('cp %s %s' % (bl0_backup, bl0)) else: # no existing backup yet means that this is the first time ever; # the bl0 in there is the good one, and we backup it up. self.context.run_command_with_retries('cp %s %s' % (bl0, bl0_backup))
def _get_testdef_url_repo(testdef_repo, context, tmpdir): """Download the provided test definition file into tmpdir.""" urldir = os.path.join(tmpdir, 'urltestrepo') try: if not os.path.isdir(urldir): logging.info("Creating directory to download the url file into.") os.makedirs(urldir) # we will not use 'testdef_file' here, we can get this info from URL testdef_file = download_image(testdef_repo, context, urldir) except Exception as e: logging.error('Unable to get test definition from url\n' + str(e)) return None finally: logging.info("Downloaded test definition file to %s." % urldir) return urldir
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 nexell_deploy_image(self, interface, image): print("nexell_deploy_image: interface %s, image %s" % (interface, image)) if interface == "fastboot": if image is None: raise CriticalError("image is None!!!") self._check_host_fastboot() self._get_fastboot_device() fname = download_image(url_string=image, context=self.context, imgdir="/tmp") if fname.endswith(".tar"): subprocess.call(['tar', 'xf', fname, '-C', '/tmp']) fname = fname.replace(".tar", "") self._deploy_image_by_fastboot(image_dir=fname) self.proc.sendcontrol('c') self.proc.sendcontrol('c') self.proc.sendline("\n") self._clear_uboot_env() time.sleep(1)
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'
def _python_file_system(self, runner, directory, prompt_pattern, mounted=False): connection = runner.get_connection() error_detected = False try: if mounted: targetdir = os.path.abspath(os.path.join('/mnt/%s' % directory)) else: targetdir = os.path.abspath(os.path.join('/', directory)) runner.run('mkdir -p %s' % targetdir) parent_dir, target_name = os.path.split(targetdir) runner.run('nice tar -czf /tmp/fs.tgz -C %s %s' % (parent_dir, target_name)) runner.run('cd /tmp') # need to be in same dir as fs.tgz try: ip = runner.get_target_ip() except NetworkError as e: error_detected = True raise CriticalError("Network error detected..aborting") connection.sendline('python -m SimpleHTTPServer 0 2>/dev/null') match_id = connection.expect([ 'Serving HTTP on 0.0.0.0 port (\d+) \.\.', pexpect.EOF, pexpect.TIMEOUT]) if match_id != 0: msg = "Unable to start HTTP server" logging.error(msg) raise CriticalError(msg) port = connection.match.groups()[match_id] url = "http://%s:%s/fs.tgz" % (ip, port) tf = download_image(url, self.context, self.scratch_dir, decompress=False) tfdir = os.path.join(self.scratch_dir, str(time.time())) try: utils.ensure_directory(tfdir) self.context.run_command('nice tar --selinux -C %s -xzf %s' % (tfdir, tf)) yield os.path.join(tfdir, target_name) finally: tf = os.path.join(self.scratch_dir, 'fs.tgz') utils.mk_targz(tf, tfdir) utils.rmtree(tfdir) connection.sendcontrol('c') # kill SimpleHTTPServer self._wait_for_prompt(connection, prompt_pattern, timeout=30) # get the last 2 parts of tf, ie "scratchdir/tf.tgz" tf = '/'.join(tf.split('/')[-2:]) runner.run('rm -rf %s' % targetdir) self._target_extract(runner, tf, parent_dir) finally: if not error_detected: # kill SimpleHTTPServer connection.sendcontrol('c') self._wait_for_prompt(connection, prompt_pattern, timeout=30) if mounted: runner.run('umount /mnt')
def extract_tarball(self, tarball_url, partition, directory='/'): logging.info('extracting %s to target', tarball_url) with self.file_system(partition, directory) as mntdir: tb = download_image(tarball_url, self.context, decompress=False) extract_tar(tb, '%s/%s' % (mntdir, directory))
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)
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, modules, rootfs, nfsrootfs, bootloader, firmware, bl1, bl2, bl31, rootfstype, bootloadertype, target_type, scratch_dir): kernel_url = kernel # 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 modules is not None: modules = download_image(modules, self.context, scratch_dir, decompress=False) ramdisk_dir = extract_ramdisk(ramdisk, scratch_dir, is_uboot=False) extract_modules(modules, 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 modules is not None and ramdisk is None: modules = download_image(modules, self.context, scratch_dir, decompress=False) extract_modules(modules, 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, '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(): # 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.config.vexpress_complete_firmware: if firmware is None: if self.config.vexpress_firmware_default is None: raise CriticalError( "No default board recovery image defined") else: tarball = download_image( self.config.vexpress_firmware_default, self.context, self._tmpdir, decompress=False) self._extract_compressed_firmware(tarball) else: tarball = download_image(firmware, self.context, self._tmpdir, decompress=False) self._extract_compressed_firmware(tarball) firmware = None else: if bootloader is None: if self.config.vexpress_uefi_default is None: raise CriticalError("UEFI image is required") else: self.test_uefi = download_image( self.config.vexpress_uefi_default, self.context, self._tmpdir, decompress=False) else: self.test_uefi = download_image(bootloader, self.context, self._tmpdir, decompress=False) bootloader = None if self.config.vexpress_requires_trusted_firmware: if bl1 is None and self.config.vexpress_requires_trusted_firmware: if self.config.vexpress_bl1_default is None: raise CriticalError("BL1 firmware is required") else: self.test_bl1 = download_image( self.config.vexpress_bl1_default, self.context, self._tmpdir, decompress=False) else: self.test_bl1 = download_image(bl1, self.context, self._tmpdir, decompress=False) bl1 = None if bl0 is None and self.config.vexpress_requires_bl0: if self.config.vexpress_bl0_default is None: raise CriticalError("BL0 firmware is required") else: self.test_bl0 = download_image( self.config.vexpress_bl0_default, self.context, self._tmpdir, decompress=False) else: self.test_bl0 = download_image(bl0, self.context, self._tmpdir, decompress=False) bl0 = None super(VexpressTarget, self).deploy_linaro_kernel(kernel, ramdisk, dtb, overlays, rootfs, nfsrootfs, image, bootloader, firmware, bl0, bl1, bl2, bl31, rootfstype, bootloadertype, target_type, qemu_pflash=qemu_pflash)