93
95
def _copy_needed_files_from_directory(self, subdir):
94
96
odir = os.path.dirname(self._sd_image)
97
if self._bootloader == 'u_boot':
98
# Extract the bootwrapper from the image
97
99
for fname in self.config.simulator_axf_files:
98
src = os.path.join(subdir, fname)
99
if os.path.exists(src):
100
self._axf = '%s/%s' % (odir, os.path.split(src)[1])
102
shutil.copyfile(src, self._axf)
100
if self._axf is None:
101
self._axf = self._find_and_copy(
105
if self.config.simulator_kernel:
106
self._copy_boot_files_from_directory(odir, subdir)
108
def _copy_boot_files_from_directory(self, odir, subdir):
109
# TODO: Optimize this loop
110
for root, dirs, files in os.walk(subdir):
112
if re.match(self.config.simulator_kernel, file) and self._kernel is None:
113
self._kernel = os.path.join(odir, file)
115
kernel = os.path.join(subdir, file)
116
shutil.copyfile(kernel, self._kernel)
117
elif re.match(self.config.simulator_initrd, file) and self._initrd is None:
118
self._initrd = os.path.join(odir, file)
120
initrd = os.path.join(subdir, file)
121
shutil.copyfile(initrd, self._initrd)
122
elif re.match(self.config.simulator_dtb, file) and self._dtb is None:
123
self._dtb = os.path.join(odir, file)
125
dtb = os.path.join(subdir, file)
126
shutil.copyfile(dtb, self._dtb)
127
elif re.match(self.config.simulator_uefi, file) and self._uefi is None:
128
self._uefi = os.path.join(odir, file)
130
uefi = os.path.join(subdir, file)
131
shutil.copyfile(uefi, self._uefi)
105
# Extract the kernel from the image
106
if self.config.simulator_kernel and self._kernel is None:
107
self._kernel = self._find_and_copy(
108
subdir, odir, self.config.simulator_kernel)
109
# Extract the initrd from the image
110
if self.config.simulator_initrd and self._initrd is None:
111
self._initrd = self._find_and_copy(
112
subdir, odir, self.config.simulator_initrd)
113
# Extract the dtb from the image
114
if self.config.simulator_dtb and self._dtb is None:
115
self._dtb = self._find_and_copy(
116
subdir, odir, self.config.simulator_dtb)
117
elif self._bootloader == 'uefi':
118
# Extract the uefi binary from the image
119
if self.config.simulator_uefi and self._uefi is None:
120
self._uefi = self._find_and_copy(
121
subdir, odir, self.config.simulator_uefi)
133
123
def _check_needed_files(self):
134
# AXF is needed in all cases
136
raise RuntimeError('No AXF found, %r' %
137
self.config.simulator_axf_files)
138
# Kernel is needed only for b.L models
139
if self._kernel is None and self.config.simulator_kernel:
140
raise RuntimeError('No kernel found, %r' %
141
self.config.simulator_kernel)
142
# Initrd is needed only for b.L models
143
if self._initrd is None and self.config.simulator_initrd:
144
raise RuntimeError('No initrd found, %r' %
145
self.config.simulator_initrd)
146
# DTB is needed only for b.L models
147
if self._dtb is None and self.config.simulator_dtb:
148
raise RuntimeError('No initrd found, %r' %
149
self.config.simulator_dtb)
124
if self._bootloader == 'u_boot':
125
# AXF is needed when we are not using UEFI
126
if self._axf is None and self.config.simulator_axf_files:
127
raise RuntimeError('No AXF found, %r' %
128
self.config.simulator_axf_files)
129
# Kernel is needed only for b.L models
130
if self._kernel is None and self.config.simulator_kernel:
131
raise RuntimeError('No KERNEL found, %r' %
132
self.config.simulator_kernel)
133
# Initrd is needed only for b.L models
134
if self._initrd is None and self.config.simulator_initrd:
135
raise RuntimeError('No INITRD found, %r' %
136
self.config.simulator_initrd)
137
# DTB is needed only for b.L models
138
if self._dtb is None and self.config.simulator_dtb:
139
raise RuntimeError('No DTB found, %r' %
140
self.config.simulator_dtb)
141
elif self._bootloader == 'uefi':
142
# UEFI binary is needed when specified
143
if self._uefi is None and self.config.simulator_uefi:
144
raise RuntimeError('No UEFI binary found, %r' %
145
self.config.simulator_uefi)
151
147
def deploy_android(self, boot, system, data):
152
148
logging.info("Deploying Android on %s" % self.config.hostname)
210
208
d = os.path.dirname(self._sd_image)
211
209
os.chmod(d, stat.S_IRWXG | stat.S_IRWXU)
212
210
os.chmod(self._sd_image, stat.S_IRWXG | stat.S_IRWXU)
213
os.chmod(self._axf, stat.S_IRWXG | stat.S_IRWXU)
212
os.chmod(self._axf, stat.S_IRWXG | stat.S_IRWXU)
215
214
os.chmod(self._kernel, stat.S_IRWXG | stat.S_IRWXU)
216
os.chmod(self._initrd, stat.S_IRWXG | stat.S_IRWXU)
217
218
os.chmod(self._dtb, stat.S_IRWXG | stat.S_IRWXU)
219
os.chmod(self._initrd, stat.S_IRWXG | stat.S_IRWXU)
221
220
os.chmod(self._uefi, stat.S_IRWXG | stat.S_IRWXU)
223
222
#lmc ignores the parent directories group owner
225
os.chown(self._axf, st.st_uid, st.st_gid)
226
224
os.chown(self._sd_image, st.st_uid, st.st_gid)
226
os.chown(self._axf, st.st_uid, st.st_gid)
228
228
os.chown(self._kernel, st.st_uid, st.st_gid)
230
os.chown(self._initrd, st.st_uid, st.st_gid)
230
232
os.chown(self._dtb, st.st_uid, st.st_gid)
232
os.chown(self._initrd, st.st_uid, st.st_gid)
234
234
os.chown(self._uefi, st.st_uid, st.st_gid)
236
def _enter_bootloader(self):
237
if self.proc.expect(self.config.interrupt_boot_prompt) != 0:
238
raise Exception("Failed to enter bootloader")
239
self.proc.sendline(self.config.interrupt_boot_command)
236
241
def power_off(self, proc):
237
242
super(FastModelTarget, self).power_off(proc)
238
243
if self._sim_proc is not None: