Merge lp:~terceiro/lava-dispatcher/fastmodels-semihosting-fix into lp:lava-dispatcher

Proposed by Antonio Terceiro
Status: Merged
Merged at revision: 618
Proposed branch: lp:~terceiro/lava-dispatcher/fastmodels-semihosting-fix
Merge into: lp:lava-dispatcher
Diff against target: 195 lines (+84/-19)
3 files modified
lava_dispatcher/config.py (+3/-0)
lava_dispatcher/default-config/lava-dispatcher/device-types/fastmodel_A15x4-A7x4.conf (+6/-0)
lava_dispatcher/device/fastmodel.py (+75/-19)
To merge this branch: bzr merge lp:~terceiro/lava-dispatcher/fastmodels-semihosting-fix
Reviewer Review Type Date Requested Status
Riku Voipio Pending
Fathi Boudra Pending
Linaro Validation Team Pending
Review via email: mp+161258@code.launchpad.net

Description of the change

This branch adds support for copying the needed files to boot the simulator in semihosting mode, used for big.LITTLE simulators.

I need a review specially of the assumptions I am making in the configuration about filenames for kernel/dtb/initrd.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_dispatcher/config.py'
2--- lava_dispatcher/config.py 2013-04-23 10:47:45 +0000
3+++ lava_dispatcher/config.py 2013-04-26 23:36:30 +0000
4@@ -79,6 +79,9 @@
5 simulator_version_command = schema.StringOption()
6 simulator_command = schema.StringOption()
7 simulator_axf_files = schema.ListOption()
8+ simulator_kernel = schema.StringOption(default=None)
9+ simulator_initrd = schema.StringOption(default=None)
10+ simulator_dtb = schema.StringOption(default=None)
11
12 android_disable_suspend = schema.BoolOption(default=True)
13 android_adb_over_usb = schema.BoolOption(default=False)
14
15=== modified file 'lava_dispatcher/default-config/lava-dispatcher/device-types/fastmodel_A15x4-A7x4.conf'
16--- lava_dispatcher/default-config/lava-dispatcher/device-types/fastmodel_A15x4-A7x4.conf 2013-04-24 05:15:37 +0000
17+++ lava_dispatcher/default-config/lava-dispatcher/device-types/fastmodel_A15x4-A7x4.conf 2013-04-26 23:36:30 +0000
18@@ -16,6 +16,11 @@
19 simulator_axf_files =
20 img.axf
21 linux-system-ISW.axf
22+ rtsm/linux-system-semi.axf
23+
24+simulator_kernel = uImage
25+simulator_dtb = rtsm/rtsm_ve-ca15x4-ca7x4.dtb
26+simulator_initrd = uInitrd
27
28 license_file = 8224@localhost
29 sim_bin = /opt/arm/RTSM_A15-A7x14_VE/Linux64_RTSM_VE_Cortex-A15x4-A7x4/RTSM_VE_Cortex-A15x4-A7x4
30@@ -53,3 +58,4 @@
31 allowed = 0,1
32
33 [coretile.cluster0.cpu0.semihosting-cmd_line]
34+default = "--kernel {KERNEL} --dtb {DTB} --initrd {INITRD} -- console=ttyAMA0,38400n8 root=/dev/mmcblk0p2 rootwait ro mem=1024M"
35
36=== modified file 'lava_dispatcher/device/fastmodel.py'
37--- lava_dispatcher/device/fastmodel.py 2013-03-25 20:23:35 +0000
38+++ lava_dispatcher/device/fastmodel.py 2013-04-26 23:36:30 +0000
39@@ -62,6 +62,11 @@
40
41 self._sim_proc = None
42
43+ self._axf = None
44+ self._kernel = None
45+ self._dtb = None
46+ self._initrd = None
47+
48 def _customize_android(self):
49 with image_partition_mounted(self._sd_image, self.DATA_PARTITION) as d:
50 wallpaper = '%s/%s' % (d, self.ANDROID_WALLPAPER)
51@@ -78,20 +83,58 @@
52
53 self.deployment_data = Target.android_deployment_data
54
55- def _copy_axf(self, partno, subdir):
56- self._axf = None
57+ def _copy_needed_files_from_partition(self, partno, subdir):
58 with image_partition_mounted(self._sd_image, partno) as mntdir:
59 subdir = os.path.join(mntdir, subdir)
60+ self._copy_needed_files_from_directory(subdir)
61+
62+ def _copy_needed_files_from_directory(self, subdir):
63+ odir = os.path.dirname(self._sd_image)
64+
65+ if self._axf is None:
66 for fname in self.config.simulator_axf_files:
67 src = os.path.join(subdir, fname)
68 if os.path.exists(src):
69- odir = os.path.dirname(self._sd_image)
70 self._axf = '%s/%s' % (odir, os.path.split(src)[1])
71- shutil.copyfile(src, self._axf)
72+ if src != self._axf:
73+ shutil.copyfile(src, self._axf)
74 break
75
76- if not self._axf:
77- raise RuntimeError('No AXF found, %r' % os.listdir(subdir))
78+ if self._kernel is None and self.config.simulator_kernel:
79+ kernel = os.path.join(subdir, self.config.simulator_kernel)
80+ if os.path.exists(kernel):
81+ self._kernel = os.path.join(odir, os.path.basename(kernel))
82+ shutil.copyfile(kernel, self._kernel)
83+
84+ if self._dtb is None and self.config.simulator_dtb:
85+ dtb = os.path.join(subdir, self.config.simulator_dtb)
86+ if os.path.exists(dtb):
87+ self._dtb = os.path.join(odir, os.path.basename(dtb))
88+ shutil.copyfile(dtb, self._dtb)
89+
90+ if self._initrd is None and self.config.simulator_initrd:
91+ initrd = os.path.join(subdir, self.config.simulator_initrd)
92+ if os.path.exists(initrd):
93+ self._initrd = os.path.join(odir, os.path.basename(initrd))
94+ shutil.copyfile(initrd, self._initrd)
95+
96+ def _check_needed_files(self):
97+ # AXF is needed in all cases
98+ if not self._axf:
99+ raise RuntimeError('No AXF found, %r' %
100+ self.config.simulator_axf_files)
101+
102+ if self.config.simulator_kernel and self._kernel is None:
103+ raise RuntimeError('No INITRD found, %s',
104+ self.config.simulator_kernel)
105+
106+ if self.config.simulator_dtb and self._dtb is None:
107+ raise RuntimeError('No DTB found, %s',
108+ self.config.simulator_dtb)
109+
110+ if self.config.simulator_initrd and self._initrd is None:
111+ raise RuntimeError('No KERNEL found, %s',
112+ self.config.simulator_initrd)
113
114 def deploy_android(self, boot, system, data):
115 logging.info("Deploying Android on %s" % self.config.hostname)
116@@ -106,7 +149,7 @@
117 self.context, 'vexpress-a9', self._boot, self._data, self._system, self._sd_image
118 )
119
120- self._copy_axf(self.config.boot_part, '')
121+ self._copy_needed_files_from_partition(self.config.boot_part, '')
122
123 self._customize_android()
124
125@@ -117,20 +160,18 @@
126
127 generate_fastmodel_image(self.context, hwpack, rootfs, odir, bootloader)
128 self._sd_image = '%s/sd.img' % odir
129- self._axf = None
130- for f in self.config.simulator_axf_files:
131- fname = os.path.join(odir, f)
132- if os.path.exists(fname):
133- self._axf = fname
134- break
135- if not self._axf:
136- raise RuntimeError('No AXF found, %r' % os.listdir(odir))
137+
138+ self._copy_needed_files_from_directory(odir)
139+ self._copy_needed_files_from_partition(self.config.boot_part, '')
140+ self._copy_needed_files_from_partition(self.config.root_part, 'boot')
141
142 self._customize_linux(self._sd_image)
143
144 def deploy_linaro_prebuilt(self, image):
145 self._sd_image = download_image(image, self.context)
146- self._copy_axf(self.config.root_part, 'boot')
147+
148+ self._copy_needed_files_from_partition(self.config.boot_part, '')
149+ self._copy_needed_files_from_partition(self.config.root_part, 'boot')
150
151 self._customize_linux(self._sd_image)
152
153@@ -158,11 +199,23 @@
154 os.chmod(d, stat.S_IRWXG | stat.S_IRWXU)
155 os.chmod(self._sd_image, stat.S_IRWXG | stat.S_IRWXU)
156 os.chmod(self._axf, stat.S_IRWXG | stat.S_IRWXU)
157+ if self._kernel:
158+ os.chmod(self._kernel, stat.S_IRWXG | stat.S_IRWXU)
159+ if self._dtb:
160+ os.chmod(self._dtb, stat.S_IRWXG | stat.S_IRWXU)
161+ if self._initrd:
162+ os.chmod(self._initrd, stat.S_IRWXG | stat.S_IRWXU)
163
164 #lmc ignores the parent directories group owner
165 st = os.stat(d)
166 os.chown(self._axf, st.st_uid, st.st_gid)
167 os.chown(self._sd_image, st.st_uid, st.st_gid)
168+ if self._kernel:
169+ os.chown(self._kernel, st.st_uid, st.st_gid)
170+ if self._dtb:
171+ os.chown(self._dtb, st.st_uid, st.st_gid)
172+ if self._initrd:
173+ os.chown(self._initrd, st.st_uid, st.st_gid)
174
175 def power_off(self, proc):
176 super(FastModelTarget, self).power_off(proc)
177@@ -189,12 +242,15 @@
178 logging.warning("device was still on, shutting down")
179 self.power_off(None)
180
181+ self._check_needed_files()
182+
183 self._fix_perms()
184
185 options = boot_options.as_string(self, join_pattern=' -C %s=%s')
186- sim_cmd = self.config.simulator_command.format(
187- AXF=self._axf, IMG=self._sd_image)
188- sim_cmd = '%s %s' % (sim_cmd, options)
189+ sim_cmd = '%s %s' % (self.config.simulator_command, options)
190+ sim_cmd = sim_cmd.format(
191+ AXF=self._axf, IMG=self._sd_image, KERNEL=self._kernel,
192+ DTB=self._dtb, INITRD=self._initrd)
193
194 # the simulator proc only has stdout/stderr about the simulator
195 # we hook up into a telnet port which emulates a serial console

Subscribers

People subscribed via source and target branches