def deploy_linaro(self, hwpack, rootfs, image, dtb, rootfstype, bootfstype, bootloadertype, qemu_pflash=None): if image is None: if hwpack is None or rootfs is None: raise CriticalError("must specify both hwpack and rootfs \ when not specifying image") elif hwpack is not None or rootfs is not None: raise CriticalError( "cannot specify hwpack or rootfs when specifying image") if image is None: self.target_device.deploy_linaro(hwpack, rootfs, dtb, rootfstype, bootfstype, bootloadertype, qemu_pflash=qemu_pflash) else: self.target_device.deploy_linaro_prebuilt(image, dtb, rootfstype, bootfstype, bootloadertype, qemu_pflash=qemu_pflash)
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 boot(self, boot_cmds=None): logging.info("In Base Class boot()") if self.__boot_image__ is None: raise CriticalError('Deploy action must be run first') if self._kernel is not None: if self._ramdisk is not None: if self.config.fastboot_kernel_load_addr: boot_cmds = ''.join(boot_cmds) self.fastboot( 'boot -c "%s" -b %s %s %s' % (boot_cmds, self.config.fastboot_kernel_load_addr, self._kernel, self._ramdisk), timeout=10) else: raise CriticalError('Kernel load address not defined!') else: if self.config.fastboot_kernel_load_addr: boot_cmds = ''.join(boot_cmds) self.fastboot( 'boot -c "%s" -b %s %s' % (boot_cmds, self.config.fastboot_kernel_load_addr, self._kernel), timeout=10) else: raise CriticalError('Kernel load address not defined!') else: self.fastboot.boot(self.__boot_image__)
def start_vms(self): if not self.is_host: return runner = NetworkCommandRunner( self.client, self.client.target_device.tester_ps1_pattern, self.client.target_device.tester_ps1_includes_rc ) logging.debug("vm-group host: injecting SSH public key") public_key_file = os.path.join(os.path.dirname(__file__), '../device/dynamic_vm_keys/lava.pub') public_key = read_content(public_key_file).strip() runner.run('mkdir -p /root/.ssh && echo "%s" >> /root/.ssh/authorized_keys' % public_key) logging.debug("vm-group host: obtaining host IP for guest VM.") try: host_ip = runner.get_target_ip() except NetworkError as e: raise CriticalError("Failed to get network up: " % e) runner.run('export _LAVA_VM_GROUP_HOST_IP=%s' % host_ip) if self.auto_start_vms: # send a message to each guest msg = {"request": "lava_send", "messageID": "lava_vm_start", "message": {"host_ip": host_ip}} reply = self.client.context.transport(json.dumps(msg)) if reply == "nack": raise CriticalError("lava_vm_start failed") logging.info("[ACTION-B] LAVA VM start, using %s" % host_ip) self.vms_started = True
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 boot(self, boot_cmds=None): if self.__boot_image__ is None: raise CriticalError('Deploy action must be run first') if self._kernel is not None: if self.config.mkbootimg_binary: if self.config.dtbtool_binary: if self.config.fastboot_kernel_load_addr: self._dtb = create_dt_image(self.config.dtbtool_binary, self._dtb, self.working_dir) boot_cmds = ''.join(boot_cmds) self._kernel = create_boot_image( self.config.mkbootimg_binary, self._kernel, self._ramdisk, self._dtb, self.config.fastboot_kernel_load_addr, boot_cmds, self.working_dir) else: raise CriticalError('Kernel load address not defined!') else: raise CriticalError('No dtbtool binary set') else: raise CriticalError('No mkbootimg binary set') self.fastboot.boot(self._kernel) else: self.fastboot.boot(self.__boot_image__)
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 create_fat_boot_image(kernel, tmpdir, fastboot, dtb=None, ramdisk=None): logging.info("Attempting to create fat boot image") boot_fat_dir = os.path.join(tmpdir, 'boot-fat') boot_fat_img = os.path.join(tmpdir, 'boot-fat.img') if logging_system("mkdir -p %s" % boot_fat_dir): raise CriticalError("Unable to create boot-fat directory") if logging_system("dd if=/dev/zero of=%s bs=512 count=131072" % boot_fat_img): raise CriticalError("Unable to create boot-fat image") if logging_system("mkfs.fat -n \"BOOT IMG\" %s" % boot_fat_img): raise CriticalError("Unable to format boot-fat image") if logging_system("mount -o loop,rw,sync %s %s" % (boot_fat_img, boot_fat_dir)): raise CriticalError("Unable to mount boot-fat image") if logging_system("cp -a %s %s" % (kernel, boot_fat_dir)): raise CriticalError('Unable copy kernel') if logging_system("cp -a %s %s/fastboot.efi" % (fastboot, boot_fat_dir)): raise CriticalError('Unable copy fastboot image') if ramdisk: if logging_system("cp -a %s %s" % (ramdisk, boot_fat_dir)): raise CriticalError('Unable copy ramdisk') if dtb: if logging_system("cp -a %s %s" % (dtb, boot_fat_dir)): raise CriticalError('Unable copy dtb') if logging_system("umount %s" % boot_fat_dir): raise CriticalError("Unable to unmount boot-fat directory") if logging_system("rm -rf %s" % boot_fat_dir): raise CriticalError('Unable remove boot-fat directory') return boot_fat_img
def _install_test_firmware(self, mount_point): if self.config.vexpress_complete_firmware: if unicode_path_check(self.complete_firmware_test): self._copy_firmware_to_juno(self.complete_firmware_test, mount_point) else: raise CriticalError("No path to complete firmware") else: uefi_path = self.config.vexpress_uefi_path uefi = os.path.join(mount_point, uefi_path) if unicode_path_check(self.test_uefi): self.context.run_command('cp %s %s' % (self.test_uefi, uefi)) else: raise CriticalError("No path to uefi firmware") if self.config.vexpress_requires_trusted_firmware: bl1_path = self.config.vexpress_bl1_path bl1 = os.path.join(mount_point, bl1_path) if unicode_path_check(self.test_bl1): self.context.run_command('cp %s %s' % (self.test_bl1, bl1)) else: raise CriticalError("No path to bl1 firmware") if self.config.vexpress_requires_bl0: bl0_path = self.config.vexpress_bl0_path bl0 = os.path.join(mount_point, bl0_path) if unicode_path_check(self.test_bl0): self.context.run_command('cp %s %s' % (self.test_bl0, bl0)) else: raise CriticalError("No path to bl0 firmware")
def _check_boot_image_args(self, params): print(params.keys()) if 'type' not in params.keys(): raise CriticalError("You should add type parameter!") if 'check_msg' not in params.keys(): raise CriticalError("You should add check_msg parameter!") if 'timeout' not in params.keys(): raise CriticalError("You should add timeout parameter!")
def __init__(self, context, config): super(VexpressTarget, self).__init__(context, config) self.test_uefi = None self.test_bl0 = None self.test_bl1 = None self.complete_firmware_master = None self.complete_firmware_test = None if self.config.vexpress_complete_firmware: if (self.config.vexpress_firmware_path_hwpack is None or self.config.vexpress_firmware_path_android is None): raise CriticalError("Vexpress complete firmware devices must " "have vexpress_firmware_path_android and " "vexpress_firmware_hwpack specified") elif self.config.vexpress_requires_trusted_firmware: if (self.config.vexpress_bl1_image_filename is None or self.config.vexpress_bl1_image_files is None or self.config.vexpress_uefi_image_filename is None or self.config.vexpress_uefi_image_files is None or self.config.vexpress_bl1_path is None or self.config.vexpress_bl1_backup_path is None or self.config.vexpress_uefi_path is None or self.config.vexpress_uefi_backup_path is None or self.config.vexpress_usb_mass_storage_device is None): raise CriticalError( "Versatile Express devices that use " "trusted firmware must specify all " "of the following configuration variables: " "vexpress_bl1_image_filename, vexpress_bl1_image_files, " "vexpress_uefi_image_filename, vexpress_uefi_image_files, " "vexpress_bl1_path, vexpress_bl1_backup_path " "vexpress_uefi_path, vexpress_uefi_backup_path and " "vexpress_usb_mass_storage_device") if self.config.vexpress_requires_bl0: if (self.config.vexpress_bl0_path is None or self.config.vexpress_bl0_backup_path is None): raise CriticalError( "Versatile Express devices that use " "require bl0 must specify all " "of the following configuration variables: " "vexpress_bl0_path, vexpress_bl0_backup_path ") else: if (self.config.vexpress_uefi_image_filename is None or self.config.vexpress_uefi_image_files is None or self.config.vexpress_uefi_path is None or self.config.vexpress_uefi_backup_path is None or self.config.vexpress_usb_mass_storage_device is None): raise CriticalError( "Versatile Express devices must specify all " "of the following configuration variables: " "vexpress_uefi_image_filename, vexpress_uefi_image_files, " "vexpress_uefi_path, vexpress_uefi_backup_path and " "vexpress_usb_mass_storage_device")
def extract_overlay(overlay, root): """ Extracts the contents of a compressed tar (bz2, gz, xz, lzma, etc) to the filesystem root. """ logging.info('Attempting to install overlay onto the filesystem') if logging_system('nice tar --selinux -C %s -xaf %s' % (root, overlay)): raise CriticalError('Unable to extract tarball: %s to %s' % (overlay, root)) if logging_system('rm %s' % overlay): raise CriticalError('Unable to remove tarball: %s' % overlay)
def create_ramdisk(ramdisk_dir, tmpdir): """ Creates a cpio.gz filesystem from a directory """ logging.info('Attempting to create ramdisk') ramdisk_data = os.path.join(tmpdir, 'ramdisk.cpio') if logging_system("cd %s && find . | cpio --create --format='newc' > %s" % (ramdisk_dir, ramdisk_data)): raise CriticalError('Unable to create cpio filesystem') if logging_system("cd %s && gzip %s" % (tmpdir, ramdisk_data)): raise CriticalError('Unable to compress cpio filesystem') if logging_system("rm -rf %s" % ramdisk_dir): raise CriticalError('Unable extracted ramdisk directory') return os.path.join(tmpdir, 'ramdisk.cpio.gz')
def copy_to(self, context, local_path=None): # copy file from image to local path des_path = None # make default local path in the lava if local_path is None: local_path = utils.mkdtemp( basedir=context.config.lava_image_tmpdir) src_path = '%s/%s' % (self.part_mntdir, self.path) if not unicode_path_check(src_path): raise CriticalError( 'Can not find source in image (%s at part %s)!' % (self.path, self.part)) if os.path.isdir(src_path): if not unicode_path_check(local_path): des_path = local_path else: if self.file_name == '': des_name = self.dir_name else: des_name = self.file_name des_path = os.path.join(local_path, des_name) logging.debug("Copying dir from #%s:%s(%s) to %s!", self.part, self.path, src_path, des_path) shutil.copytree(src_path, des_path) elif os.path.isfile(src_path): if not unicode_path_check(local_path): if os.path.basename(local_path) == '': des_name = os.path.basename(src_path) des_path = os.path.join(local_path, des_name) os.makedirs(local_path) else: if not unicode_path_check(os.path.dirname(local_path)): os.makedirs(os.path.dirname(local_path)) des_path = local_path else: if os.path.isdir(local_path): des_name = os.path.basename(src_path) des_path = os.path.join(local_path, des_name) else: des_path = local_path logging.debug("Copying file from #%s:%s(%s) to %s!", self.part, self.path, src_path, des_path) shutil.copyfile(src_path, des_path) else: raise CriticalError( 'Please check the source file type, we only support file and dir!' ) return des_path
def file_system(self, partition, directory): """ This works in conjunction with the "mux_device" function to safely access a partition/directory on the sdmux filesystem """ self.proc.sendline('sync') self.proc.expect(self.tester_ps1_pattern) logging.info('powering off') self.context.run_command(self.config.power_off_cmd) sdmux.dut_disconnect(self.config.sdmux_id) sdmux.host_usda(self.config.sdmux_id) mntdir = os.path.join(self.scratch_dir, 'sdmux_mnt') ensure_directory(mntdir) device = self.mux_device() device = '%s%s' % (device, partition) try: self.context.run_command(['mount', device, mntdir], failok=False) if directory[0] == '/': directory = directory[1:] path = os.path.join(mntdir, directory) ensure_directory(path) logging.info('sdmux(%s) mounted at: %s', device, path) yield path except CriticalError: raise except subprocess.CalledProcessError: raise CriticalError('Unable to access sdmux device') except KeyboardInterrupt: raise KeyboardInterrupt except: logging.exception('Error accessing sdmux filesystem') raise CriticalError('Error accessing sdmux filesystem') finally: logging.info('unmounting sdmux') try: _flush_files(mntdir) self.context.run_command(['umount', device], failok=False) except subprocess.CalledProcessError: logging.exception('umount failed, re-try in 10 seconds') time.sleep(10) if self.context.run_command(['umount', device]) != 0: logging.error( 'Unable to unmount sdmux device %s', device) sdmux.host_disconnect(self.config.sdmux_id)
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 boot_master_image(self): """ reboot the system, and check that we are in a master shell """ self.context.client.vm_group.wait_for_vms() boot_attempts = self.config.boot_retries attempts = 0 in_master_image = False while (attempts < boot_attempts) and (not in_master_image): logging.info("Booting the system master image. Attempt: %d", attempts + 1) try: self.master_ip = None if self.config.hard_reset_command: self._hard_reboot(self.proc) self._load_master_firmware() self._wait_for_master_boot() else: self._soft_reboot(self.proc) self._load_master_firmware() self._wait_for_master_boot() except (OperationFailed, pexpect.TIMEOUT) as e: msg = "Resetting platform into master image failed: %s" % e logging.warning(msg) attempts += 1 continue try: self.proc.sendline('export PS1="%s"' % self.MASTER_PS1) self.proc.expect(self.MASTER_PS1_PATTERN, timeout=120, lava_no_logging=1) except pexpect.TIMEOUT as e: msg = "Failed to get command line prompt: %s" % e logging.warning(msg) attempts += 1 continue runner = MasterCommandRunner(self) try: self.master_ip = runner.get_target_ip() self.device_version = runner.get_device_version() except NetworkError as e: msg = "Failed to get network up: %s" % e logging.warning(msg) attempts += 1 continue lava_proxy = self.context.config.lava_proxy if lava_proxy: logging.info("Setting up http proxy") runner.run("export http_proxy=%s" % lava_proxy, timeout=30) logging.info("System is in master image now") in_master_image = True if not in_master_image: msg = "Could not get master image booted properly" logging.critical(msg) raise CriticalError(msg)
def extract_rootfs(rootfs, root): """ Extracts the contents of a .tar.(bz2, gz, xz, lzma, etc) rootfs to the root. """ logging.warning('Attempting to extract tarball with --strip-components=1') if logging_system('nice tar --selinux --strip-components=1 -C %s -xaf %s' % (root, rootfs)): logging.warning('Unable to extract tarball with --strip-components=1') logging.warning('Cleaning up temporary directory') if logging_system('rm -rf %s/*' % root): raise CriticalError('Unable to clean up temporary directory') logging.warning( 'Attempting to extract tarball without --strip-components=1') if logging_system('nice tar --selinux -C %s -xaf %s' % (root, rootfs)): raise CriticalError('Unable to extract tarball: %s' % rootfs) if logging_system('rm %s' % rootfs): raise CriticalError('Unable to remove tarball: %s' % rootfs)
def connect(self): if self.config.connection_command: proc = connect_to_serial(self.context) else: raise CriticalError('The connection_command is not defined!') return proc
def connect(self): if self.wait_for_adb(): proc = self.adb('shell', spawn=True) else: raise CriticalError('This device only supports Android!') return proc
def wait_for_vms(self): if not (self.is_host and self.vms_started): return logging.info("Waiting for all VMs to finish ...") self.client.context.transport( json.dumps({ "request": "lava_send", "messageID": "lava_vm_stop", "message": {} }) ) reply = self.client.context.transport( json.dumps({ "request": "lava_wait_all", "messageID": "lava_vm_stop" }) ) if reply == 'nack': raise CriticalError("Failure while waiting for VMs to finish") logging.info("All VMs finished, proceeding with reboot") self.vms_started = False
def boot_whaley_image(self, skip, emmc): """ Reboot the system to the test image """ logging.info("Start to boot whaley image") boot_attempts = self.config.boot_retries attempts = 0 in_whaley_image = False while (attempts < boot_attempts) and (not in_whaley_image): logging.info("Booting the test image. Attempt: %d", attempts + 1) self.vm_group.wait_for_vms() try: self._boot_linaro_image(skip, emmc) except (OperationFailed, pexpect.TIMEOUT): self.context.test_data.add_metadata({'boot_retries': str(attempts)}) attempts += 1 continue logging.info("System is in whaley image now, deploy and boot image successfully") # don't need add result here, since job.py will add it finally # comment at 2016.02.17 # self.context.test_data.add_result('boot_whaley_image', 'pass') in_whaley_image = True if not in_whaley_image: msg = "Test Image Error: Could not get whaley image booted properly" logging.error(msg) self.context.test_data.add_result('boot_whaley_image', 'fail') raise CriticalError(msg)
def nexell_reset_or_reboot(self): # after this command, board state is u-boot command line logging.info("start command nexell_reset_or_reboot") expect_response_list = [ "Hit any key to stop", "nxp4330#", "nxp5430#", "- try 'help'", "BAT:", TIMEOUT ] logging.debug("nexell_reset_or_reboot start...") self.proc.sendcontrol('c') self.proc.sendline("reboot") logging.debug("end of sendline reboot") index = self.proc.expect(expect_response_list, timeout=5) logging.debug("expect result %d" % index) #if index < 5: if index < (len(expect_response_list) - 1): if index == 4: self.proc.sendcontrol('c') logging.info("succeed to reboot") self.proc.sendline("\n") else: logging.info("send reset command for bootloader") #time.sleep(1) self.proc.sendline("reset") index = self.proc.expect(expect_response_list, timeout=5) if index < (len(expect_response_list) - 1): if index == 4: self.proc.sendcontrol('c') logging.info("succeed to reset") self.proc.sendline("\n") else: logging.info("board state is unknown") raise CriticalError("Unknown Board State!!!") time.sleep(1)
def create_boot_image(mkbootimg, kernel, ramdisk, dtb, load_addr, cmdline, tmp_dir, page_size=2048): load_addr = int(load_addr, 16) image_path = os.path.join(tmp_dir, 'boot-lava.img') cmd = '%s --kernel %s \ --ramdisk %s \ --output %s \ --dt %s \ --pagesize %s \ --base 0x%x \ --cmdline "%s"' % (mkbootimg, kernel, ramdisk, image_path, dtb, page_size, load_addr, cmdline) logging.info('Creating boot image') logging.debug(cmd) r = subprocess.call(cmd, shell=True) if r == 0: return image_path else: raise CriticalError("Boot image creation failed")
def run(self, options=[], boot_cmds=None, sim_options=None, test_image_prompt=None, interrupt_boot_prompt=None, repeat_count=0): client = self.client if boot_cmds is not None: client.config.boot_cmds = boot_cmds if sim_options is not None: client.config.simulator_options = sim_options if test_image_prompt is not None: test_image_prompts = client.config.test_image_prompts test_image_prompts.append(test_image_prompt) client.config.test_image_prompts = test_image_prompts if interrupt_boot_prompt is not None: client.config.interrupt_boot_prompt = interrupt_boot_prompt client.target_device.boot_options = options client.target_device.reset_boot(in_test_shell=False) status = 'pass' try: client.boot_linaro_image() except KeyboardInterrupt: raise KeyboardInterrupt except: status = 'fail' raise CriticalError("Failed to boot test image.")
def deploy_android(self, images, rootfstype, bootloadertype, target_type): self._target_type = target_type self._image_deployment = True self.deployment_data = deployment_data.get(self._target_type) deploy_attempts = self.config.boot_retries attempts = 0 deployed = False while (attempts < deploy_attempts) and (not deployed): logging.info("Deploying test images image Attempt: %d", attempts + 1) try: self._enter_fastboot() self.driver.deploy_android(images, rootfstype, bootloadertype, self._target_type, self.scratch_dir) deployed = True except (subprocess.CalledProcessError, pexpect.TIMEOUT) as e: msg = "Deployment failed: %s" % e logging.error(msg) attempts += 1 continue if not deployed: logging.error("Infrastructure Error: image deployment failed") msg = "Deployment Failed" logging.critical(msg) raise CriticalError(msg)
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 _recreate_ramdisk(session, target): logging.debug("Recreate Ramdisk") ramdisk_name = None is_uboot = False session.run('mkdir -p ~/tmp/') for ramdisk in target.config.android_ramdisk_files: rc = session.run('mv /mnt/lava/boot/%s ~/tmp/' % ramdisk, failok=True) if rc == 0: ramdisk_name = ramdisk break if ramdisk_name is None: raise CriticalError("No valid ramdisk found!") session.run('cd ~/tmp/') rc = session.run('file %s | grep u-boot' % ramdisk_name, failok=True) if rc == 0: logging.info("U-Boot Header Detected") is_uboot = True session.run('nice dd if=%s of=ramdisk.cpio.gz ibs=64 skip=1' % ramdisk_name) else: session.run('mv %s ramdisk.cpio.gz' % ramdisk_name) session.run('nice gzip -d -f ramdisk.cpio.gz; cpio -i -F ramdisk.cpio') for init in target.config.android_init_files: rc = session.run('test -f %s' % init, failok=True) if rc == 0: session.run( 'sed -i "/export PATH/a \ \ \ \ export PS1 \'%s\'" %s' % (target.tester_ps1, init)) # The mount partitions have moved from init.rc to init.partitions.rc # For backward compatible with early android build, we update both rc files # For omapzoom and aosp and JB4.2 the operation for mounting partitions are # in init.omap4pandaboard.rc and fstab.* files possible_partitions_files = session._client.config.possible_partitions_files for f in possible_partitions_files: if session.is_file_exist(f): _update_ramdisk_partitions(session, f) session.run("cat %s" % f, failok=True) session.run('nice cpio -i -t -F ramdisk.cpio | cpio -o -H newc | \ gzip > ramdisk_new.cpio.gz') if is_uboot: session.run( 'nice mkimage -A arm -O linux -T ramdisk -n "Android Ramdisk Image" \ -d ramdisk_new.cpio.gz %s' % ramdisk_name) else: session.run('mv ramdisk_new.cpio.gz %s' % ramdisk_name) session.run('cd -') session.run('mv ~/tmp/%s /mnt/lava/boot/%s' % (ramdisk_name, ramdisk_name)) session.run('rm -rf ~/tmp')
def connect(self): if self._client.target_device.config.android_adb_over_tcp: self._setup_adb_over_tcp() elif self._client.target_device.config.android_adb_over_usb: self._setup_adb_over_usb() else: raise CriticalError('ADB not configured for TCP or USB')
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): self._target_type = target_type self._use_boot_cmds = True if rootfs is not None: self._image_deployment = True else: self._ramdisk_deployment = True self.deployment_data = deployment_data.get(self._target_type) deploy_attempts = self.config.boot_retries attempts = 0 deployed = False while (attempts < deploy_attempts) and (not deployed): logging.info("Deploying test image. Attempt: %d", attempts + 1) try: if self._image_deployment: self._enter_fastboot() self.driver.deploy_linaro_kernel(kernel, ramdisk, dtb, overlays, rootfs, nfsrootfs, image, bootloader, firmware, bl0, bl1, bl2, bl31, rootfstype, bootloadertype, self._target_type, self.scratch_dir, qemu_pflash=qemu_pflash) deployed = True except (subprocess.CalledProcessError, pexpect.TIMEOUT) as e: msg = "Deployment failed: %s" % e logging.error(msg) attempts += 1 continue if not deployed: logging.error("Infrastructure Error: image deployment failed") msg = "Deployment Failed" logging.critical(msg) raise CriticalError(msg)