Merge lp:~tyler-baker/lava-dispatcher/bootloader-next into lp:lava-dispatcher

Proposed by Tyler Baker
Status: Merged
Approved by: Senthil Kumaran S
Approved revision: 669
Merged at revision: 645
Proposed branch: lp:~tyler-baker/lava-dispatcher/bootloader-next
Merge into: lp:lava-dispatcher
Diff against target: 628 lines (+307/-51)
19 files modified
lava_dispatcher/actions/boot_control.py (+1/-3)
lava_dispatcher/actions/deploy.py (+27/-0)
lava_dispatcher/client/targetdevice.py (+5/-0)
lava_dispatcher/config.py (+1/-0)
lava_dispatcher/default-config/lava-dispatcher/device-types/arndale.conf (+20/-1)
lava_dispatcher/default-config/lava-dispatcher/device-types/beagle-xm.conf (+1/-0)
lava_dispatcher/default-config/lava-dispatcher/device-types/beaglebone-black.conf (+18/-0)
lava_dispatcher/default-config/lava-dispatcher/device-types/beaglebone.conf (+17/-0)
lava_dispatcher/default-config/lava-dispatcher/device-types/mx51evk.conf (+1/-0)
lava_dispatcher/default-config/lava-dispatcher/device-types/mx53loco.conf (+1/-0)
lava_dispatcher/default-config/lava-dispatcher/device-types/origen.conf (+1/-0)
lava_dispatcher/default-config/lava-dispatcher/device-types/panda.conf (+23/-0)
lava_dispatcher/default-config/lava-dispatcher/device-types/snowball.conf (+1/-0)
lava_dispatcher/device/bootloader.py (+130/-0)
lava_dispatcher/device/capri.py (+2/-2)
lava_dispatcher/device/fastmodel.py (+7/-7)
lava_dispatcher/device/master.py (+30/-24)
lava_dispatcher/device/target.py (+19/-12)
lava_dispatcher/device/vexpress.py (+2/-2)
To merge this branch: bzr merge lp:~tyler-baker/lava-dispatcher/bootloader-next
Reviewer Review Type Date Requested Status
Senthil Kumaran S Approve
Review via email: mp+179825@code.launchpad.net

Description of the change

Introducing the BootloaderTarget class an extension of MasterImageTarget. This will allow all exisiting master image devices to function as they do today, however adds the ability to tftp boot binaries directly from the bootloader.

There is quite a few changes here..

* Add deploy_linaro_kernel
  - New schema for dealing with binaries that are not in an image, or hwpack.
  - Only required property is "kernel"
  - Allows us to seperate the deployment/boot logic for raw kernel booting.

* BootloaderTarget Class
  - Documentation MP is here https://code.launchpad.net/~tyler-baker/lava-project/bootloader/+merge/179796
  - This class inherits from MasterImageTarget and implements deploy_linaro_kernel.
  - Sets lava_server_ip, lava_kernel, lava_ramdisk, and lava_dtb as bootloader enviroment variables.
  - It is up to the user to utilize these in their boot_cmds.

* Added a wrapper for wait_for_prompt as _wait_for_prompt in target.py
  - This is a very common function, encouraging reuse without an import.

* _enter_bootloader added to target.py
  - Refactored all the device types to use this single function.

* _customize_bootloader
  - Fixed the pep8 issue with self.proc.
  - Added _wait_for_prompt logic.

* Job defined boot_cmds
  - Tested and is working on the following:
     - Master Image Targets
     - Bootloader Targets
     - ARMv7 Fastmodels

* Refactored _boot_linaro_image in master.py
  - The boot_cmds logic was a mess and was broken.
     - https://bugs.launchpad.net/lava-dispatcher/+bug/1211406
  - Confirmed this as a fix for 1211406

* Added client_type = bootloader to all Master Image devices
  - This has been tested, and all devices function as they do today.

* Testing
    - All test jobs passed.
        - https://code.launchpad.net/~tyler-baker/+junk/bootloader-job-def-tests

To post a comment you must log in.
Revision history for this message
Senthil Kumaran S (stylesen) wrote :

Reading boot commands from images is something which I haven't tested with this patch exhaustively. But as it is it is good to me with my simple testing.

review: Approve
670. By Tyler Baker

Add the boot_cmds_tftp for arndale, bbb, beaglebone, and panda

671. By Tyler Baker

Merge lava-lab device-configs for Arndale and Panda

Revision history for this message
Antonio Terceiro (terceiro) wrote :
Download full text (13.1 KiB)

I know this already got merged, but I still have some comments.

On Mon, Aug 12, 2013 at 10:19:30PM -0000, Tyler Baker wrote:
> Tyler Baker has proposed merging lp:~tyler-baker/lava-dispatcher/bootloader-next into lp:lava-dispatcher.
>
> Requested reviews:
> Linaro Validation Team (linaro-validation)
> Related bugs:
> Bug #1211406 in LAVA Dispatcher: "Dispatcher not reading boot_cmds from image"
> https://bugs.launchpad.net/lava-dispatcher/+bug/1211406
>
> For more details, see:
> https://code.launchpad.net/~tyler-baker/lava-dispatcher/bootloader-next/+merge/179825
>
> Introducing the BootloaderTarget class an extension of MasterImageTarget. This will allow all exisiting master image devices to function as they do today, however adds the ability to tftp boot binaries directly from the bootloader.
>
> There is quite a few changes here..
>
> * Add deploy_linaro_kernel
> - New schema for dealing with binaries that are not in an image, or hwpack.
> - Only required property is "kernel"
> - Allows us to seperate the deployment/boot logic for raw kernel booting.
>
> * BootloaderTarget Class
> - Documentation MP is here https://code.launchpad.net/~tyler-baker/lava-project/bootloader/+merge/179796
> - This class inherits from MasterImageTarget and implements deploy_linaro_kernel.
> - Sets lava_server_ip, lava_kernel, lava_ramdisk, and lava_dtb as bootloader enviroment variables.
> - It is up to the user to utilize these in their boot_cmds.
>
> * Added a wrapper for wait_for_prompt as _wait_for_prompt in target.py
> - This is a very common function, encouraging reuse without an import.
>
> * _enter_bootloader added to target.py
> - Refactored all the device types to use this single function.
>
> * _customize_bootloader
> - Fixed the pep8 issue with self.proc.
> - Added _wait_for_prompt logic.
>
> * Job defined boot_cmds
> - Tested and is working on the following:
> - Master Image Targets
> - Bootloader Targets
> - ARMv7 Fastmodels
>
> * Refactored _boot_linaro_image in master.py
> - The boot_cmds logic was a mess and was broken.
> - https://bugs.launchpad.net/lava-dispatcher/+bug/1211406
> - Confirmed this as a fix for 1211406
>
> * Added client_type = bootloader to all Master Image devices
> - This has been tested, and all devices function as they do today.
>
> * Testing
> - All test jobs passed.
> - https://code.launchpad.net/~tyler-baker/+junk/bootloader-job-def-tests
> --
> https://code.launchpad.net/~tyler-baker/lava-dispatcher/bootloader-next/+merge/179825
> Your team Linaro Validation Team is requested to review the proposed merge of lp:~tyler-baker/lava-dispatcher/bootloader-next into lp:lava-dispatcher.

> === added file 'lava_dispatcher/device/bootloader.py'
> --- lava_dispatcher/device/bootloader.py 1970-01-01 00:00:00 +0000
> +++ lava_dispatcher/device/bootloader.py 2013-08-12 22:19:12 +0000
> @@ -0,0 +1,130 @@
> +# Copyright (C) 2013 Linaro Limited
> +#
> +# Author: Tyler Baker <email address hidden>
> +#
> +# This file is part of LAVA Dispatcher.
> +#
> +# LAVA Dispatcher is free software; you can redistribute it and/or modify
> +# it under the terms of th...

Revision history for this message
Tyler Baker (tyler-baker) wrote :

Hey Antonio,

These are great suggestions, thanks for having a look at these after the fact. I'll draft up your requested changes and submit for MP.

Cheers

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_dispatcher/actions/boot_control.py'
2--- lava_dispatcher/actions/boot_control.py 2013-07-16 15:59:32 +0000
3+++ lava_dispatcher/actions/boot_control.py 2013-08-14 20:57:19 +0000
4@@ -77,9 +77,7 @@
5 'default': False, 'optional': True
6 }
7
8- def run(self, options=None, interactive_boot_cmds=False):
9- if not options:
10- options = []
11+ def run(self, options=[], interactive_boot_cmds=False):
12 client = self.client
13 if interactive_boot_cmds:
14 client.config.boot_cmds = options
15
16=== modified file 'lava_dispatcher/actions/deploy.py'
17--- lava_dispatcher/actions/deploy.py 2013-07-16 16:01:18 +0000
18+++ lava_dispatcher/actions/deploy.py 2013-08-14 20:57:19 +0000
19@@ -91,6 +91,33 @@
20 def run(self, boot, system, data, rootfstype='ext4'):
21 self.client.deploy_linaro_android(boot, system, data, rootfstype)
22
23+class cmd_deploy_linaro_kernel(BaseAction):
24+
25+ parameters_schema = {
26+ 'type': 'object',
27+ 'properties': {
28+ 'kernel': {'type': 'string', 'optional': False},
29+ 'ramdisk': {'type': 'string', 'optional': True},
30+ 'dtb': {'type': 'string', 'optional': True},
31+ 'rootfs': {'type': 'string', 'optional': True},
32+ 'rootfstype': {'type': 'string', 'optional': True},
33+ 'bootloader': {'type': 'string', 'optional': True, 'default': 'u_boot'},
34+ },
35+ 'additionalProperties': False,
36+ }
37+
38+ @classmethod
39+ def validate_parameters(cls, parameters):
40+ super(cmd_deploy_linaro_kernel, cls).validate_parameters(parameters)
41+ if 'kernel' not in parameters:
42+ raise ValueError('must specify a kernel')
43+
44+ def run(self, kernel=None, ramdisk=None, dtb=None, rootfs=None, rootfstype='ext4',
45+ bootloader='u_boot'):
46+ self.client.deploy_linaro_kernel(
47+ kernel=kernel, ramdisk=ramdisk, dtb=dtb, rootfs=rootfs,
48+ rootfstype=rootfstype, bootloader=bootloader)
49+
50
51 class cmd_dummy_deploy(BaseAction):
52
53
54=== modified file 'lava_dispatcher/client/targetdevice.py'
55--- lava_dispatcher/client/targetdevice.py 2013-07-24 16:56:18 +0000
56+++ lava_dispatcher/client/targetdevice.py 2013-08-14 20:57:19 +0000
57@@ -64,6 +64,11 @@
58 else:
59 self.target_device.deploy_linaro_prebuilt(image)
60
61+ def deploy_linaro_kernel(self, kernel, ramdisk=None, dtb=None, rootfs=None,
62+ rootfstype='ext4', bootloader='u_boot'):
63+ self.target_device.deploy_linaro_kernel(kernel, ramdisk, dtb, rootfs,
64+ bootloader)
65+
66 def _boot_linaro_image(self):
67 if self.proc:
68 logging.warning('device already powered on, powering off first')
69
70=== modified file 'lava_dispatcher/config.py'
71--- lava_dispatcher/config.py 2013-07-22 21:18:32 +0000
72+++ lava_dispatcher/config.py 2013-08-14 20:57:19 +0000
73@@ -32,6 +32,7 @@
74 boot_cmds = schema.StringOption(fatal=True) # Can do better here
75 boot_cmds_android = schema.StringOption(fatal=True) # And here
76 boot_cmds_oe = schema.StringOption(fatal=True) # And here?
77+ boot_cmds_tftp = schema.StringOption()
78 read_boot_cmds_from_image = schema.BoolOption(default=True)
79 boot_options = schema.ListOption()
80 boot_linaro_timeout = schema.IntOption(default=300)
81
82=== modified file 'lava_dispatcher/default-config/lava-dispatcher/device-types/arndale.conf'
83--- lava_dispatcher/default-config/lava-dispatcher/device-types/arndale.conf 2013-07-02 18:04:30 +0000
84+++ lava_dispatcher/default-config/lava-dispatcher/device-types/arndale.conf 2013-08-14 20:57:19 +0000
85@@ -1,5 +1,8 @@
86+client_type = bootloader
87 boot_part = 2
88 root_part = 3
89+testboot_offset = 3
90+
91 boot_cmds = mmc rescan,
92 mmc part 1,
93 setenv bootcmd "'fatload mmc 0:5 0x40007000 uImage; fatload mmc 0:5 0x42000000 uInitrd; fatload mmc 0:5 0x41f00000 board.dtb; bootm 0x40007000 0x42000000 0x41f00000'",
94@@ -18,11 +21,27 @@
95 sdcard_part_android = 7
96 data_part_android = 7
97
98+image_boot_msg = Starting kernel
99+
100 boot_cmds_android = mmc init,
101 mmc part 0,
102 setenv bootcmd "'fatload mmc 0:5 0x40007000 uImage; fatload mmc 0:5 0x41000000 uInitrd; fatload mmc 0:5 0x41f00000 board.dtb; bootm 0x40007000 0x41000000 0x41f00000'",
103 setenv bootargs "'console=tty0 console=ttySAC2,115200n8 androidboot.hardware=exynos5250-arndale rootwait ro rootdelay=3 init=/init androidboot.console=ttySAC2 console=ttySAC2'",
104 boot
105
106-bootloader_prompt = #
107+boot_cmds_tftp =
108+ setenv autoload no,
109+ setenv usbethaddr 00:40:5c:26:0a:5b,
110+ setenv pxefile_addr_r "'0x50000000'",
111+ setenv kernel_addr_r "'0x40007000'",
112+ setenv initrd_addr_r "'0x42000000'",
113+ setenv fdt_addr_r "'0x41f00000'",
114+ setenv loadkernel "'tftp ${kernel_addr_r} ${lava_kernel}'",
115+ setenv loadinitrd "'tftp ${initrd_addr_r} ${lava_ramdisk}; setenv initrd_size ${filesize}'",
116+ setenv loadfdt "'tftp ${fdt_addr_r} ${lava_dtb}'",
117+ setenv bootargs "'root=/dev/ram0 console=ttySAC2,115200n8 init --no-log ip=:::::eth0:dhcp'",
118+ setenv bootcmd "'usb start; dhcp; setenv serverip ${lava_server_ip}; run loadkernel; run loadinitrd; run loadfdt; bootm ${kernel_addr_r} ${initrd_addr_r} ${fdt_addr_r}'",
119+ boot
120+
121+bootloader_prompt = ARNDALE5250
122
123
124=== modified file 'lava_dispatcher/default-config/lava-dispatcher/device-types/beagle-xm.conf'
125--- lava_dispatcher/default-config/lava-dispatcher/device-types/beagle-xm.conf 2012-03-27 19:31:12 +0000
126+++ lava_dispatcher/default-config/lava-dispatcher/device-types/beagle-xm.conf 2013-08-14 20:57:19 +0000
127@@ -1,3 +1,4 @@
128+client_type = bootloader
129 boot_cmds = mmc init,
130 mmc part 0,
131 setenv bootcmd "'fatload mmc 0:3 0x80000000 uImage;
132
133=== modified file 'lava_dispatcher/default-config/lava-dispatcher/device-types/beaglebone-black.conf'
134--- lava_dispatcher/default-config/lava-dispatcher/device-types/beaglebone-black.conf 2013-06-05 00:39:23 +0000
135+++ lava_dispatcher/default-config/lava-dispatcher/device-types/beaglebone-black.conf 2013-08-14 20:57:19 +0000
136@@ -1,3 +1,21 @@
137+client_type = bootloader
138+
139+boot_cmds_tftp =
140+ setenv autoload no,
141+ setenv usbethaddr 00:40:5c:26:0a:6c,
142+ setenv pxefile_addr_r "'0x50000000'",
143+ setenv kernel_addr_r "'0x80200000'",
144+ setenv initrd_addr_r "'0x81000000'",
145+ setenv fdt_addr_r "'0x815f0000'",
146+ setenv initrd_high "'0xffffffff'",
147+ setenv fdt_high "'0xffffffff'",
148+ setenv loadkernel "'tftp ${kernel_addr_r} ${lava_kernel}'",
149+ setenv loadinitrd "'tftp ${initrd_addr_r} ${lava_ramdisk}; setenv initrd_size ${filesize}'",
150+ setenv loadfdt "'tftp ${fdt_addr_r} ${lava_dtb}'",
151+ setenv bootargs "'console=ttyO0,115200n8 root=/dev/ram0 earlyprintk ip=:::::eth0:dhcp'",
152+ setenv bootcmd "'dhcp; setenv serverip ${lava_server_ip}; run loadkernel; run loadinitrd; run loadfdt; bootz ${kernel_addr_r} ${initrd_addr_r} ${fdt_addr_r}'",
153+ boot
154+
155 boot_cmds_oe =
156 setenv initrd_high "'0xffffffff'",
157 setenv fdt_high "'0xffffffff'",
158
159=== modified file 'lava_dispatcher/default-config/lava-dispatcher/device-types/beaglebone.conf'
160--- lava_dispatcher/default-config/lava-dispatcher/device-types/beaglebone.conf 2013-06-05 00:39:23 +0000
161+++ lava_dispatcher/default-config/lava-dispatcher/device-types/beaglebone.conf 2013-08-14 20:57:19 +0000
162@@ -1,3 +1,4 @@
163+client_type = bootloader
164 boot_cmds_oe =
165 setenv initrd_high "'0xffffffff'",
166 setenv fdt_high "'0xffffffff'",
167@@ -12,6 +13,22 @@
168 setenv bootargs "'console=ttyO0,115200n8 root=LABEL=testrootfs rootwait ro'",
169 boot
170
171+boot_cmds_tftp =
172+ setenv autoload no,
173+ setenv usbethaddr 00:40:5c:26:0a:6c,
174+ setenv pxefile_addr_r "'0x50000000'",
175+ setenv kernel_addr_r "'0x80200000'",
176+ setenv initrd_addr_r "'0x81000000'",
177+ setenv fdt_addr_r "'0x815f0000'",
178+ setenv initrd_high "'0xffffffff'",
179+ setenv fdt_high "'0xffffffff'",
180+ setenv loadkernel "'tftp ${kernel_addr_r} ${lava_kernel}'",
181+ setenv loadinitrd "'tftp ${initrd_addr_r} ${lava_ramdisk}; setenv initrd_size ${filesize}'",
182+ setenv loadfdt "'tftp ${fdt_addr_r} ${lava_dtb}'",
183+ setenv bootargs "'console=ttyO0,115200n8 root=/dev/ram0 earlyprintk ip=:::::eth0:dhcp'",
184+ setenv bootcmd "'dhcp; setenv serverip ${lava_server_ip}; run loadkernel; run loadinitrd; run loadfdt; bootz ${kernel_addr_r} ${initrd_addr_r} ${fdt_addr_r}'",
185+ boot,
186+
187 lmc_dev_arg = beaglebone
188
189 boot_options =
190
191=== modified file 'lava_dispatcher/default-config/lava-dispatcher/device-types/mx51evk.conf'
192--- lava_dispatcher/default-config/lava-dispatcher/device-types/mx51evk.conf 2011-10-20 04:09:15 +0000
193+++ lava_dispatcher/default-config/lava-dispatcher/device-types/mx51evk.conf 2013-08-14 20:57:19 +0000
194@@ -1,3 +1,4 @@
195+client_type = bootloader
196 boot_part = 2
197 root_part = 3
198 boot_cmds = mmc init,
199
200=== modified file 'lava_dispatcher/default-config/lava-dispatcher/device-types/mx53loco.conf'
201--- lava_dispatcher/default-config/lava-dispatcher/device-types/mx53loco.conf 2012-06-29 08:42:13 +0000
202+++ lava_dispatcher/default-config/lava-dispatcher/device-types/mx53loco.conf 2013-08-14 20:57:19 +0000
203@@ -1,3 +1,4 @@
204+client_type = bootloader
205 boot_part = 2
206 root_part = 3
207 boot_cmds = mmc init,
208
209=== modified file 'lava_dispatcher/default-config/lava-dispatcher/device-types/origen.conf'
210--- lava_dispatcher/default-config/lava-dispatcher/device-types/origen.conf 2012-12-13 22:04:36 +0000
211+++ lava_dispatcher/default-config/lava-dispatcher/device-types/origen.conf 2013-08-14 20:57:19 +0000
212@@ -1,3 +1,4 @@
213+client_type = bootloader
214 boot_part = 2
215 root_part = 3
216 boot_cmds = mmc init,
217
218=== modified file 'lava_dispatcher/default-config/lava-dispatcher/device-types/panda.conf'
219--- lava_dispatcher/default-config/lava-dispatcher/device-types/panda.conf 2013-01-08 03:31:23 +0000
220+++ lava_dispatcher/default-config/lava-dispatcher/device-types/panda.conf 2013-08-14 20:57:19 +0000
221@@ -1,3 +1,4 @@
222+client_type = bootloader
223 boot_cmds = mmc init,
224 mmc part 0,
225 setenv bootcmd "'fatload mmc 0:3 0x80200000 uImage; fatload mmc
226@@ -27,6 +28,28 @@
227 vram=48M omapfb.vram=0:24M'",
228 boot
229
230+boot_cmds_fdt = mmc init,
231+ mmc part 0,
232+ setenv bootcmd "'fatload mmc 0:3 0x80200000 uImage; fatload mmc 0:3 0x81600000 uInitrd; fatload mmc 0:3 0x815f0000 board.dtb; bootm 0x80200000 0x81600000 0x815f0000'",
233+ setenv bootargs "'console=tty0 console=ttyO2,115200n8 root=LABEL=testrootfs rootwait ro earlyprintk fixrtc nocompcache vram=48M omapfb.vram=0:24M mem=456M@0x80000000 mem=512M@0xA0000000'",
234+ boot
235+
236+boot_cmds_tftp =
237+ setenv autoload no,
238+ setenv usbethaddr 00:40:5c:26:0a:5c,
239+ setenv pxefile_addr_r "'0x50000000'",
240+ setenv kernel_addr_r "'0x80200000'",
241+ setenv initrd_addr_r "'0x81600000'",
242+ setenv fdt_addr_r "'0x815f0000'",
243+ setenv initrd_high "'0xffffffff'",
244+ setenv fdt_high "'0xffffffff'",
245+ setenv loadkernel "'tftp ${kernel_addr_r} ${lava_kernel}'",
246+ setenv loadinitrd "'tftp ${initrd_addr_r} ${lava_ramdisk}; setenv initrd_size ${filesize}'",
247+ setenv loadfdt "'tftp ${fdt_addr_r} ${lava_dtb}'",
248+ setenv bootargs "'console=ttyO2,115200n8 root=/dev/ram0 fixrtc nocompcache vram=48M omapfb.vram=0:24M mem=456M@0x80000000 mem=512M@0xA0000000 ip=:::::eth0:dhcp init=init'",
249+ setenv bootcmd "'usb start; dhcp; setenv serverip ${lava_server_ip}; run loadkernel; run loadinitrd; run loadfdt; bootm ${kernel_addr_r} ${initrd_addr_r} ${fdt_addr_r}'",
250+ boot
251+
252 android_binary_drivers = http://192.168.1.21/LAVA_HTTP/android-binaries/panda-drivers.tgz
253 possible_partitions_files =
254 init.partitions.rc
255
256=== modified file 'lava_dispatcher/default-config/lava-dispatcher/device-types/snowball.conf'
257--- lava_dispatcher/default-config/lava-dispatcher/device-types/snowball.conf 2013-04-18 14:11:37 +0000
258+++ lava_dispatcher/default-config/lava-dispatcher/device-types/snowball.conf 2013-08-14 20:57:19 +0000
259@@ -1,3 +1,4 @@
260+client_type = bootloader
261 boot_cmds = mmc rescan 0,
262 setenv bootcmd "'fatload mmc 0:3 0x00100000 /uImage;
263 bootm 0x00100000'",
264
265=== added file 'lava_dispatcher/device/bootloader.py'
266--- lava_dispatcher/device/bootloader.py 1970-01-01 00:00:00 +0000
267+++ lava_dispatcher/device/bootloader.py 2013-08-14 20:57:19 +0000
268@@ -0,0 +1,130 @@
269+# Copyright (C) 2013 Linaro Limited
270+#
271+# Author: Tyler Baker <tyler.baker@linaro.org>
272+#
273+# This file is part of LAVA Dispatcher.
274+#
275+# LAVA Dispatcher is free software; you can redistribute it and/or modify
276+# it under the terms of the GNU General Public License as published by
277+# the Free Software Foundation; either version 2 of the License, or
278+# (at your option) any later version.
279+#
280+# LAVA Dispatcher is distributed in the hope that it will be useful,
281+# but WITHOUT ANY WARRANTY; without even the implied warranty of
282+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
283+# GNU General Public License for more details.
284+#
285+# You should have received a copy of the GNU General Public License
286+# along
287+# with this program; if not, see <http://www.gnu.org/licenses>.
288+
289+import logging
290+import contextlib
291+import time
292+import os
293+import pexpect
294+
295+from lava_dispatcher.device.master import (
296+ MasterImageTarget
297+)
298+from lava_dispatcher.utils import (
299+ string_to_list
300+)
301+from lava_dispatcher.errors import (
302+ CriticalError
303+)
304+from lava_dispatcher.downloader import (
305+ download_image
306+)
307+
308+class BootloaderTarget(MasterImageTarget):
309+
310+ def __init__(self, context, config):
311+ super(BootloaderTarget, self).__init__(context, config)
312+ self._booted = False
313+ self._boot_cmds = None
314+ self._lava_cmds = None
315+ self._uboot_boot = False
316+ # This is the offset into the path, used to reference bootfiles
317+ self._offset = self.scratch_dir.index('images')
318+
319+ def power_off(self, proc):
320+ if self._uboot_boot:
321+ if self.config.power_off_cmd:
322+ self.context.run_command(self.config.power_off_cmd)
323+ else:
324+ super(BootloaderTarget, self).power_off(proc)
325+
326+ def deploy_linaro_kernel(self, kernel, ramdisk, dtb, rootfs, bootloader):
327+ if bootloader == "u_boot":
328+ # We assume we will be controlling u-boot
329+ if kernel is not None:
330+ # We have been passed kernel image, setup TFTP boot
331+ self._uboot_boot = True
332+ # Set the TFTP server IP (Dispatcher)
333+ self._lava_cmds = "lava_server_ip=" + self.context.config.lava_server_ip + ","
334+ kernel = download_image(kernel, self.context, self.scratch_dir, decompress=False)
335+ # Set the TFTP bootfile path for the kernel
336+ self._lava_cmds += "lava_kernel=" + kernel[self._offset::] + ","
337+ if ramdisk is not None:
338+ # We have been passed a ramdisk
339+ ramdisk = download_image(ramdisk, self.context, self.scratch_dir, decompress=False)
340+ # Set the TFTP bootfile path for the ramdisk
341+ self._lava_cmds += "lava_ramdisk=" + ramdisk[self._offset::] + ","
342+ if dtb is not None:
343+ # We have been passed a device tree blob
344+ dtb = download_image(dtb, self.context, self.scratch_dir, decompress=False)
345+ # Set the bootfile path for the ramdisk
346+ self._lava_cmds += "lava_dtb=" + dtb[self._offset::] + ","
347+ if rootfs is not None:
348+ # We have been passed a rootfs
349+ rootfs = download_image(rootfs, self.context, self.scratch_dir, decompress=True)
350+ self._lava_cmds += "lava_rootfs=" + dtb[self._offset::] + ","
351+ else:
352+ # TODO: Faking the deployment data - Ubuntu
353+ self.deployment_data = self.target_map['ubuntu']
354+ else:
355+ # This *should* never happen
356+ raise CriticalError("No kernel images to boot")
357+ else:
358+ # Define other "types" of bootloaders here. UEFI? Grub?
359+ raise CriticalError("U-Boot is the only supported bootloader at this time")
360+
361+ def deploy_linaro(self, hwpack, rfs, bootloader):
362+ self._uboot_boot = False
363+ super(BootloaderTarget, self).deploy_linaro(hwpack, rfs, bootloader)
364+
365+ def deploy_linaro_prebuilt(self, image):
366+ self._uboot_boot = False
367+ super(BootloaderTarget, self).deploy_linaro_prebuilt(image)
368+
369+ def _inject_boot_cmds(self):
370+ if isinstance(self.config.boot_cmds, basestring):
371+ if self.config.boot_cmds_tftp is None:
372+ raise CriticalError("No TFTP boot commands defined")
373+ else:
374+ self._boot_cmds = self._lava_cmds + self.config.boot_cmds_tftp
375+ self._boot_cmds = string_to_list(self._boot_cmds.encode('ascii'))
376+ else:
377+ self._boot_cmds = string_to_list(self._lava_cmds.encode('ascii')) + self.config.boot_cmds
378+
379+ def _run_boot(self):
380+ self._enter_bootloader(self.proc)
381+ self._inject_boot_cmds()
382+ self._customize_bootloader(self.proc, self._boot_cmds)
383+ self._wait_for_prompt(self.proc, ['\(initramfs\)', self.config.master_str],
384+ self.config.boot_linaro_timeout)
385+
386+ def _boot_linaro_image(self):
387+ if self._uboot_boot:
388+ if self.config.hard_reset_command:
389+ self._hard_reboot()
390+ else:
391+ raise CriticalError("No hard reset command defined")
392+ self._run_boot()
393+ self.proc.sendline('export PS1="%s"' % self.deployment_data['TESTER_PS1'])
394+ self._booted = True
395+ else:
396+ super(BootloaderTarget, self)._boot_linaro_image()
397+
398+target_class = BootloaderTarget
399
400=== modified file 'lava_dispatcher/device/capri.py'
401--- lava_dispatcher/device/capri.py 2013-07-16 16:04:57 +0000
402+++ lava_dispatcher/device/capri.py 2013-08-14 20:57:19 +0000
403@@ -44,11 +44,11 @@
404 return
405 try:
406 self._soft_reboot()
407- self._enter_bootloader()
408+ self._enter_bootloader(self.proc)
409 except:
410 logging.exception("_enter_bootloader failed")
411 self._hard_reboot()
412- self._enter_bootloader()
413+ self._enter_bootloader(self.proc)
414 self.proc.sendline("fastboot")
415
416 def deploy_android(self, boot, system, userdata):
417
418=== modified file 'lava_dispatcher/device/fastmodel.py'
419--- lava_dispatcher/device/fastmodel.py 2013-07-24 14:04:25 +0000
420+++ lava_dispatcher/device/fastmodel.py 2013-08-14 20:57:19 +0000
421@@ -47,6 +47,7 @@
422 extract_targz,
423 DrainConsoleOutput,
424 finalize_process,
425+ string_to_list,
426 )
427
428
429@@ -238,11 +239,6 @@
430 if self._uefi:
431 os.chown(self._uefi, st.st_uid, st.st_gid)
432
433- def _enter_bootloader(self):
434- if self.proc.expect(self.config.interrupt_boot_prompt) != 0:
435- raise Exception("Failed to enter bootloader")
436- self.proc.sendline(self.config.interrupt_boot_command)
437-
438 def power_off(self, proc):
439 super(FastModelTarget, self).power_off(proc)
440 finalize_process(self._sim_proc)
441@@ -304,8 +300,12 @@
442 self.proc.logfile_read)
443
444 if self._uefi:
445- self._enter_bootloader()
446- self._customize_bootloader()
447+ self._enter_bootloader(self.proc)
448+ if isinstance(self.config.boot_cmds, basestring):
449+ boot_cmds = string_to_list(self.config.boot_cmds.encode('ascii'))
450+ else:
451+ boot_cmds = self.config.boot_cmds
452+ self._customize_bootloader(self.proc, boot_cmds)
453
454 return self.proc
455
456
457=== modified file 'lava_dispatcher/device/master.py'
458--- lava_dispatcher/device/master.py 2013-07-17 09:16:46 +0000
459+++ lava_dispatcher/device/master.py 2013-08-14 20:57:19 +0000
460@@ -99,12 +99,14 @@
461 return self.device_version
462
463 def power_on(self):
464+ if self.config.power_on_cmd:
465+ self.context.run_command(self.config.power_on_cmd)
466 self._boot_linaro_image()
467 return self.proc
468
469 def power_off(self, proc):
470- # we always leave master image devices powered on
471- pass
472+ if self.config.power_off_cmd:
473+ self.context.run_command(self.config.power_off_cmd)
474
475 def deploy_linaro(self, hwpack, rfs, bootloader):
476 self.boot_master_image()
477@@ -482,47 +484,51 @@
478 self.proc.sendline("hardreset")
479 self.proc.empty_buffer()
480
481- def _enter_bootloader(self):
482- if self.proc.expect(self.config.interrupt_boot_prompt) != 0:
483- raise Exception("Failed to enter bootloader")
484- self.proc.sendline(self.config.interrupt_boot_command)
485-
486 def _boot_linaro_image(self):
487 boot_cmds = self.deployment_data['boot_cmds']
488- boot_cmds_override = False
489-
490 options = boot_options.as_dict(self, defaults={'boot_cmds': boot_cmds})
491- if 'boot_cmds' in options:
492+
493+ # Interactive boot_cmds from the job file are a list.
494+ # We check for them first, if they are present, we use
495+ # them and ignore the other cases.
496+ if not isinstance(self.config.boot_cmds, basestring):
497+ logging.info('Overriding boot_cmds from job file')
498 boot_cmds_override = True
499+ boot_cmds = self.config.boot_cmds
500+ # If there were no interactive boot_cmds, next we check
501+ # for boot_option overrides. If one exists, we use them
502+ # and ignore all other cases.
503+ elif options['boot_cmds'].value != 'boot_cmds':
504+ logging.info('Overriding boot_cmds from boot_options')
505 boot_cmds = options['boot_cmds'].value
506-
507- logging.info('boot_cmds attribute: %s', boot_cmds)
508-
509- # Check if we have already got some values from image's boot file.
510- if self.deployment_data.get('boot_cmds_dynamic') \
511- and not boot_cmds_override:
512+ boot_cmds = self.config.cp.get('__main__', boot_cmds)
513+ boot_cmds = string_to_list(boot_cmds.encode('ascii'))
514+ # No interactive or boot_option overrides are present,
515+ # we prefer to get the boot_cmds for the image if they are
516+ # present.
517+ elif self.deployment_data.get('boot_cmds_dynamic'):
518 logging.info('Loading boot_cmds from image')
519 boot_cmds = self.deployment_data['boot_cmds_dynamic']
520- else:
521+ # This is the catch all case. Where we get the default boot_cmds
522+ # from the deployment data.
523+ else:
524 logging.info('Loading boot_cmds from device configuration')
525 boot_cmds = self.config.cp.get('__main__', boot_cmds)
526 boot_cmds = string_to_list(boot_cmds.encode('ascii'))
527
528+ logging.info('boot_cmds: %s', boot_cmds)
529+
530 self._boot(boot_cmds)
531
532 def _boot(self, boot_cmds):
533 try:
534 self._soft_reboot()
535- self._enter_bootloader()
536+ self._enter_bootloader(self.proc)
537 except:
538 logging.exception("_enter_bootloader failed")
539 self._hard_reboot()
540- self._enter_bootloader()
541- self.proc.sendline(boot_cmds[0])
542- for line in range(1, len(boot_cmds)):
543- self.proc.expect(self.config.bootloader_prompt, timeout=300)
544- self.proc.sendline(boot_cmds[line])
545-
546+ self._enter_bootloader(self.proc)
547+ self._customize_bootloader(self.proc, boot_cmds)
548
549 target_class = MasterImageTarget
550
551
552=== modified file 'lava_dispatcher/device/target.py'
553--- lava_dispatcher/device/target.py 2013-07-17 09:16:46 +0000
554+++ lava_dispatcher/device/target.py 2013-08-14 20:57:19 +0000
555@@ -23,8 +23,12 @@
556 import shutil
557 import re
558
559+from lava_dispatcher.client.base import (
560+ wait_for_prompt
561+)
562 from lava_dispatcher.client.lmc_utils import (
563- image_partition_mounted)
564+ image_partition_mounted
565+)
566 import lava_dispatcher.utils as utils
567
568
569@@ -171,13 +175,15 @@
570 return dest
571 return dest
572
573- def _customize_bootloader(self):
574- # FIXME: proc is unresolved - is this the same as the proc from runner?
575- self.proc.expect(self.config.bootloader_prompt, timeout=300)
576- if isinstance(self.config.boot_cmds, basestring):
577- boot_cmds = utils.string_to_list(self.config.boot_cmds.encode('ascii'))
578- else:
579- boot_cmds = self.config.boot_cmds
580+ def _wait_for_prompt(self, connection, prompt_pattern, timeout):
581+ wait_for_prompt(connection, prompt_pattern, timeout)
582+
583+ def _enter_bootloader(self, connection):
584+ if connection.expect(self.config.interrupt_boot_prompt) != 0:
585+ raise Exception("Failed to enter bootloader")
586+ connection.sendline(self.config.interrupt_boot_command)
587+
588+ def _customize_bootloader(self, connection, boot_cmds):
589 for line in boot_cmds:
590 parts = re.match('^(?P<action>sendline|expect)\s*(?P<command>.*)', line)
591 if parts:
592@@ -187,13 +193,14 @@
593 except AttributeError as e:
594 raise Exception("Badly formatted command in boot_cmds %s" % e)
595 if action == "sendline":
596- self.proc.send(command)
597- self.proc.sendline('')
598+ connection.send(command)
599+ connection.sendline('')
600 elif action == "expect":
601 command = re.escape(command)
602- self.proc.expect(command, timeout=300)
603+ connection.expect(command, timeout=300)
604 else:
605- self.proc.sendline(line)
606+ self._wait_for_prompt(connection, self.config.bootloader_prompt, timeout=300)
607+ connection.sendline(line)
608
609 def _customize_ubuntu(self, rootdir):
610 self.deployment_data = Target.ubuntu_deployment_data
611
612=== modified file 'lava_dispatcher/device/vexpress.py'
613--- lava_dispatcher/device/vexpress.py 2013-07-17 09:16:46 +0000
614+++ lava_dispatcher/device/vexpress.py 2013-08-14 20:57:19 +0000
615@@ -66,11 +66,11 @@
616
617 self._hard_reboot()
618
619- def _enter_bootloader(self):
620+ def _enter_bootloader(self, connection):
621 with self._mcc_setup() as mount_point:
622 self._install_test_uefi(mount_point)
623
624- super(VexpressTarget, self)._enter_bootloader()
625+ super(VexpressTarget, self)._enter_bootloader(connection)
626
627 def _wait_for_master_boot(self):
628 with self._mcc_setup() as mount_point:

Subscribers

People subscribed via source and target branches