Merge lp:~salgado/linaro-image-tools/config-class into lp:linaro-image-tools/11.11
- config-class
- Merge into trunk
Proposed by
Guilherme Salgado
Status: | Merged |
---|---|
Merged at revision: | 237 |
Proposed branch: | lp:~salgado/linaro-image-tools/config-class |
Merge into: | lp:linaro-image-tools/11.11 |
Diff against target: |
738 lines (+216/-391) 5 files modified
linaro-media-create (+9/-10) linaro_media_create/__init__.py (+5/-122) linaro_media_create/boards.py (+148/-0) linaro_media_create/populate_boot.py (+6/-6) linaro_media_create/tests/test_media_create.py (+48/-253) |
To merge this branch: | bzr merge lp:~salgado/linaro-image-tools/config-class |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Westby (community) | Approve | ||
Review via email: mp+46048@code.launchpad.net |
Commit message
Description of the change
Store board config in python classes. This will make it possible for us to
move the board-specific out of populate_boot.py and into boards.py, where all
board-specific stuff will live.
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 'linaro-media-create' |
2 | --- linaro-media-create 2011-01-11 21:26:54 +0000 |
3 | +++ linaro-media-create 2011-01-12 21:58:47 +0000 |
4 | @@ -6,6 +6,10 @@ |
5 | import tempfile |
6 | from subprocess import Popen |
7 | |
8 | +from linaro_media_create.boards import ( |
9 | + board_configs, |
10 | + ROOTFS_UUID, |
11 | + ) |
12 | from linaro_media_create.check_device import ( |
13 | confirm_device_selection_and_ensure_it_is_ready) |
14 | from linaro_media_create.ensure_command import ensure_command |
15 | @@ -18,11 +22,7 @@ |
16 | from linaro_media_create.remove_binary_dir import remove_dir |
17 | from linaro_media_create.rootfs import populate_rootfs |
18 | from linaro_media_create.unpack_binary_tarball import unpack_binary_tarball |
19 | -from linaro_media_create import ( |
20 | - get_args_parser, |
21 | - get_board_config, |
22 | - ROOTFS_UUID, |
23 | - ) |
24 | +from linaro_media_create import get_args_parser |
25 | |
26 | |
27 | TMP_DIR = tempfile.mkdtemp() |
28 | @@ -71,8 +71,7 @@ |
29 | if __name__ == '__main__': |
30 | parser = get_args_parser() |
31 | args = parser.parse_args() |
32 | - board_config = get_board_config( |
33 | - args.board, args.is_live, args.is_lowmem, args.consoles) |
34 | + board_config = board_configs[args.board] |
35 | |
36 | media = Media(args.device) |
37 | if media.is_block_device: |
38 | @@ -94,7 +93,7 @@ |
39 | install_hwpacks(ROOTFS_DIR, TMP_DIR, args.hwpack_force_yes, *hwpacks) |
40 | |
41 | boot_partition, root_partition = setup_partitions( |
42 | - args.board, media, board_config['fat_size'], args.image_size, |
43 | + args.board, media, board_config.fat_size, args.image_size, |
44 | args.boot_label, args.rfs_label, args.rootfs, ROOTFS_UUID, |
45 | args.should_create_partitions, |
46 | args.should_format_bootfs, args.should_format_rootfs) |
47 | @@ -102,7 +101,7 @@ |
48 | if args.should_format_bootfs: |
49 | populate_boot( |
50 | args.board, board_config, ROOTFS_DIR, boot_partition, BOOT_DISK, |
51 | - args.device, TMP_DIR, args.is_live) |
52 | + args.device, TMP_DIR, args.is_live, args.is_lowmem, args.consoles) |
53 | |
54 | if args.should_format_rootfs: |
55 | create_swap = False |
56 | @@ -110,6 +109,6 @@ |
57 | create_swap = True |
58 | populate_rootfs(ROOTFS_DIR, ROOT_DISK, root_partition, args.rootfs, |
59 | ROOTFS_UUID, create_swap, str(args.swap_file), |
60 | - board_config['mmc_part_offset']) |
61 | + board_config.mmc_part_offset) |
62 | |
63 | print "Done creating Linaro image on %s" % args.device |
64 | |
65 | === modified file 'linaro_media_create/__init__.py' |
66 | --- linaro_media_create/__init__.py 2011-01-11 21:09:50 +0000 |
67 | +++ linaro_media_create/__init__.py 2011-01-12 21:58:47 +0000 |
68 | @@ -1,8 +1,9 @@ |
69 | import argparse |
70 | -import uuid |
71 | - |
72 | -ROOTFS_UUID = str(uuid.uuid4()) |
73 | -KNOWN_BOARDS = ['beagle', 'igep', 'mx51evk', 'panda', 'ux500', 'vexpress'] |
74 | + |
75 | +from linaro_media_create.boards import board_configs |
76 | + |
77 | + |
78 | +KNOWN_BOARDS = board_configs.keys() |
79 | |
80 | |
81 | class Live256MegsAction(argparse.Action): |
82 | @@ -87,121 +88,3 @@ |
83 | '--no-part', dest='should_create_partitions', action='store_false', |
84 | help='Reuse existing partitions on the given media.') |
85 | return parser |
86 | - |
87 | - |
88 | -def get_board_config(board, is_live, is_lowmem, consoles): |
89 | - """Return a dict containing the configs to create an image for a board. |
90 | - |
91 | - :param args: An argparse.ArgumentParser object containing the arguments |
92 | - passed to linaro-media-create. |
93 | - """ |
94 | - mmc_part_offset = 0 |
95 | - mmc_option = '0:1' |
96 | - boot_args_options = 'rootwait ro' |
97 | - uboot_flavor = None |
98 | - fat_size = 32 |
99 | - serial_opts = '' |
100 | - if consoles is not None: |
101 | - for console in consoles: |
102 | - serial_opts += ' console=%s' % console |
103 | - |
104 | - # XXX: I think this is not needed as we have board-specific |
105 | - # serial options for when is_live is true. |
106 | - if is_live: |
107 | - serial_opts += ' serialtty=ttyS2' |
108 | - |
109 | - if board in ('beagle', 'igep'): |
110 | - if board == 'beagle': |
111 | - uboot_flavor = 'omap3_beagle' |
112 | - serial_opts += ' console=tty0 console=ttyS2,115200n8' |
113 | - live_serial_opts = 'serialtty=ttyS2' |
114 | - kernel_addr = '0x80000000' |
115 | - initrd_addr = '0x81600000' |
116 | - load_addr = '0x80008000' |
117 | - sub_arch = 'linaro-omap' |
118 | - boot_script = 'boot.scr' |
119 | - boot_args_options += ( |
120 | - ' earlyprintk fixrtc nocompcache vram=12M omapfb.debug=y' |
121 | - ' omapfb.mode=dvi:1280x720MR-16@60') |
122 | - |
123 | - elif board == 'panda': |
124 | - uboot_flavor = 'omap4_panda' |
125 | - serial_opts += ' console = tty0 console = ttyO2,115200n8' |
126 | - live_serial_opts = 'serialtty = ttyO2' |
127 | - kernel_addr = '0x80200000' |
128 | - initrd_addr = '0x81600000' |
129 | - load_addr = '0x80008000' |
130 | - sub_arch = 'omap4' |
131 | - boot_script = 'boot.scr' |
132 | - boot_args_options += ( |
133 | - ' earlyprintk fixrtc nocompcache vram = 32M omapfb.debug = y' |
134 | - ' omapfb.vram = 0:8M mem = 463M ip = none') |
135 | - |
136 | - elif board == 'ux500': |
137 | - serial_opts += ' console = tty0 console = ttyAMA2,115200n8' |
138 | - live_serial_opts = 'serialtty = ttyAMA2' |
139 | - kernel_addr = '0x00100000' |
140 | - initrd_addr = '0x08000000' |
141 | - load_addr = '0x00008000' |
142 | - sub_arch = 'ux500' |
143 | - boot_script = 'flash.scr' |
144 | - boot_args_options += ( |
145 | - ' earlyprintk rootdelay = 1 fixrtc nocompcache' |
146 | - ' mem = 96M@0 mem_modem = 32M@96M mem = 44M@128M pmem = 22M@172M' |
147 | - ' mem = 30M@194M mem_mali = 32M@224M pmem_hwb = 54M@256M' |
148 | - ' hwmem = 48M@302M mem = 152M@360M') |
149 | - mmc_option = '1:1' |
150 | - |
151 | - elif board == 'mx51evk': |
152 | - serial_opts += ' console = tty0 console = ttymxc0,115200n8' |
153 | - live_serial_opts = 'serialtty = ttymxc0' |
154 | - kernel_addr = '0x90000000' |
155 | - initrd_addr = '0x90800000' |
156 | - load_addr = '0x90008000' |
157 | - sub_arch = 'linaro-mx51' |
158 | - boot_script = 'boot.scr' |
159 | - mmc_part_offset = 1 |
160 | - mmc_option = '0:2' |
161 | - |
162 | - elif board == 'vexpress': |
163 | - uboot_flavor = 'ca9x4_ct_vxp' |
164 | - serial_opts += ' console = tty0 console = ttyAMA0,38400n8' |
165 | - live_serial_opts = 'serialtty = ttyAMA0' |
166 | - kernel_addr = '0x60008000' |
167 | - initrd_addr = '0x81000000' |
168 | - load_addr = kernel_addr |
169 | - sub_arch = 'linaro-vexpress' |
170 | - boot_script = None |
171 | - # ARM Boot Monitor is used to load u-boot, uImage etc. into flash and |
172 | - # only allows for FAT16 |
173 | - fat_size = 16 |
174 | - |
175 | - else: |
176 | - raise ValueError("Unkown board: %s" % board) |
177 | - |
178 | - lowmem_opt = '' |
179 | - boot_snippet = 'root=UUID=%s' % ROOTFS_UUID |
180 | - if is_live: |
181 | - serial_opts += ' %s' % live_serial_opts |
182 | - boot_snippet = 'boot=casper' |
183 | - if is_lowmem: |
184 | - lowmem_opt = 'only-ubiquity' |
185 | - |
186 | - boot_cmd = ( |
187 | - "setenv bootcmd 'fatload mmc %(mmc_option)s %(kernel_addr)s " |
188 | - "uImage; fatload mmc %(mmc_option)s %(initrd_addr)s uInitrd; " |
189 | - "bootm %(kernel_addr)s %(initrd_addr)s'\n" |
190 | - "setenv bootargs '%(serial_opts)s %(lowmem_opt)s " |
191 | - "%(boot_snippet)s %(boot_args_options)s'\n" |
192 | - "boot" % vars()) |
193 | - |
194 | - # Instead of constructing a dict here, we could create a separate class |
195 | - # for the config of every board, with the varying bits stored as class |
196 | - # variables. At this point I don't see much advantage in doing that, |
197 | - # though. |
198 | - return dict( |
199 | - kernel_addr=kernel_addr, initrd_addr=initrd_addr, load_addr=load_addr, |
200 | - sub_arch=sub_arch, boot_script=boot_script, fat_size=fat_size, |
201 | - boot_args_options=boot_args_options, serial_opts=serial_opts, |
202 | - uboot_flavor=uboot_flavor, mmc_part_offset=mmc_part_offset, |
203 | - mmc_option=mmc_option, boot_cmd=boot_cmd) |
204 | |
205 | === added file 'linaro_media_create/boards.py' |
206 | --- linaro_media_create/boards.py 1970-01-01 00:00:00 +0000 |
207 | +++ linaro_media_create/boards.py 2011-01-12 21:58:47 +0000 |
208 | @@ -0,0 +1,148 @@ |
209 | +"""Configuration for boards supported by linaro-media-create. |
210 | + |
211 | +To add support for a new board, you just need to create a subclass of |
212 | +BoardConfig and set appropriate values for its variables. |
213 | +""" |
214 | + |
215 | +import uuid |
216 | + |
217 | +ROOTFS_UUID = str(uuid.uuid4()) |
218 | + |
219 | + |
220 | +class BoardConfig(object): |
221 | + """The configuration used when building an image for a board.""" |
222 | + uboot_flavor = None |
223 | + mmc_option = '0:1' |
224 | + mmc_part_offset = 0 |
225 | + extra_serial_opts = None |
226 | + live_serial_opts = None |
227 | + kernel_addr = None |
228 | + initrd_addr = None |
229 | + load_addr = None |
230 | + sub_arch = None |
231 | + boot_script = None |
232 | + extra_boot_args_options = None |
233 | + fat_size = 32 |
234 | + |
235 | + @classmethod |
236 | + def get_boot_cmd(cls, is_live, is_lowmem, consoles): |
237 | + """Get the boot command for this board.""" |
238 | + boot_args_options = 'rootwait ro' |
239 | + if cls.extra_boot_args_options: |
240 | + boot_args_options += " %s" % cls.extra_boot_args_options |
241 | + serial_opts = '' |
242 | + if consoles is not None: |
243 | + for console in consoles: |
244 | + serial_opts += ' console=%s' % console |
245 | + |
246 | + # XXX: I think this is not needed as we have board-specific |
247 | + # serial options for when is_live is true. |
248 | + if is_live: |
249 | + serial_opts += ' serialtty=ttyS2' |
250 | + |
251 | + serial_opts += ' %s' % cls.extra_serial_opts |
252 | + |
253 | + lowmem_opt = '' |
254 | + boot_snippet = 'root=UUID=%s' % ROOTFS_UUID |
255 | + if is_live: |
256 | + serial_opts += ' %s' % cls.live_serial_opts |
257 | + boot_snippet = 'boot=casper' |
258 | + if is_lowmem: |
259 | + lowmem_opt = 'only-ubiquity' |
260 | + |
261 | + replacements = dict( |
262 | + mmc_option=cls.mmc_option, kernel_addr=cls.kernel_addr, |
263 | + initrd_addr=cls.initrd_addr, serial_opts=serial_opts, |
264 | + lowmem_opt=lowmem_opt, boot_snippet=boot_snippet, |
265 | + boot_args_options=boot_args_options) |
266 | + return ( |
267 | + "setenv bootcmd 'fatload mmc %(mmc_option)s %(kernel_addr)s " |
268 | + "uImage; fatload mmc %(mmc_option)s %(initrd_addr)s uInitrd; " |
269 | + "bootm %(kernel_addr)s %(initrd_addr)s'\n" |
270 | + "setenv bootargs '%(serial_opts)s %(lowmem_opt)s " |
271 | + "%(boot_snippet)s %(boot_args_options)s'\n" |
272 | + "boot" % replacements) |
273 | + |
274 | + |
275 | +class BeagleConfig(BoardConfig): |
276 | + uboot_flavor = 'omap3_beagle' |
277 | + extra_serial_opts = 'console=tty0 console=ttyS2,115200n8' |
278 | + live_serial_opts = 'serialtty=ttyS2' |
279 | + kernel_addr = '0x80000000' |
280 | + initrd_addr = '0x81600000' |
281 | + load_addr = '0x80008000' |
282 | + sub_arch = 'linaro-omap' |
283 | + boot_script = 'boot.scr' |
284 | + extra_boot_args_options = ( |
285 | + 'earlyprintk fixrtc nocompcache vram=12M omapfb.debug=y ' |
286 | + 'omapfb.mode=dvi:1280x720MR-16@60') |
287 | + |
288 | + |
289 | +class PandaConfig(BoardConfig): |
290 | + uboot_flavor = 'omap4_panda' |
291 | + extra_serial_opts = 'console = tty0 console = ttyO2,115200n8' |
292 | + live_serial_opts = 'serialtty = ttyO2' |
293 | + kernel_addr = '0x80200000' |
294 | + initrd_addr = '0x81600000' |
295 | + load_addr = '0x80008000' |
296 | + sub_arch = 'omap4' |
297 | + boot_script = 'boot.scr' |
298 | + extra_boot_args_options = ( |
299 | + 'earlyprintk fixrtc nocompcache vram = 32M omapfb.debug = y ' |
300 | + 'omapfb.vram = 0:8M mem = 463M ip = none') |
301 | + |
302 | + |
303 | +class IgepConfig(BeagleConfig): |
304 | + uboot_flavor = None |
305 | + |
306 | + |
307 | +class Ux500Config(BoardConfig): |
308 | + extra_serial_opts = 'console = tty0 console = ttyAMA2,115200n8' |
309 | + live_serial_opts = 'serialtty = ttyAMA2' |
310 | + kernel_addr = '0x00100000' |
311 | + initrd_addr = '0x08000000' |
312 | + load_addr = '0x00008000' |
313 | + sub_arch = 'ux500' |
314 | + boot_script = 'flash.scr' |
315 | + extra_boot_args_options = ( |
316 | + 'earlyprintk rootdelay = 1 fixrtc nocompcache ' |
317 | + 'mem = 96M@0 mem_modem = 32M@96M mem = 44M@128M pmem = 22M@172M ' |
318 | + 'mem = 30M@194M mem_mali = 32M@224M pmem_hwb = 54M@256M ' |
319 | + 'hwmem = 48M@302M mem = 152M@360M') |
320 | + mmc_option = '1:1' |
321 | + |
322 | + |
323 | +class Mx51evkConfig(BoardConfig): |
324 | + extra_serial_opts = 'console = tty0 console = ttymxc0,115200n8' |
325 | + live_serial_opts = 'serialtty = ttymxc0' |
326 | + kernel_addr = '0x90000000' |
327 | + initrd_addr = '0x90800000' |
328 | + load_addr = '0x90008000' |
329 | + sub_arch = 'linaro-mx51' |
330 | + boot_script = 'boot.scr' |
331 | + mmc_part_offset = 1 |
332 | + mmc_option = '0:2' |
333 | + |
334 | + |
335 | +class VexpressConfig(BoardConfig): |
336 | + uboot_flavor = 'ca9x4_ct_vxp' |
337 | + extra_serial_opts = 'console = tty0 console = ttyAMA0,38400n8' |
338 | + live_serial_opts = 'serialtty = ttyAMA0' |
339 | + kernel_addr = '0x60008000' |
340 | + initrd_addr = '0x81000000' |
341 | + load_addr = kernel_addr |
342 | + sub_arch = 'linaro-vexpress' |
343 | + boot_script = None |
344 | + # ARM Boot Monitor is used to load u-boot, uImage etc. into flash and |
345 | + # only allows for FAT16 |
346 | + fat_size = 16 |
347 | + |
348 | + |
349 | +board_configs = { |
350 | + 'beagle': BeagleConfig, |
351 | + 'igep': IgepConfig, |
352 | + 'panda': PandaConfig, |
353 | + 'vexpress': VexpressConfig, |
354 | + 'ux500': Ux500Config, |
355 | + 'mx51evk': Mx51evkConfig, |
356 | + } |
357 | |
358 | === removed file 'linaro_media_create/boot_cmd.py' |
359 | === modified file 'linaro_media_create/populate_boot.py' |
360 | --- linaro_media_create/populate_boot.py 2011-01-11 21:26:54 +0000 |
361 | +++ linaro_media_create/populate_boot.py 2011-01-12 21:58:47 +0000 |
362 | @@ -88,7 +88,7 @@ |
363 | |
364 | |
365 | def populate_boot(board, board_config, chroot_dir, boot_partition, boot_disk, |
366 | - boot_device_or_file, tmp_dir, is_live): |
367 | + boot_device_or_file, tmp_dir, is_live, is_lowmem, consoles): |
368 | |
369 | parts_dir = 'boot' |
370 | if is_live: |
371 | @@ -104,7 +104,7 @@ |
372 | raise |
373 | cmd_runner.run(['mount', boot_partition, boot_disk], as_root=True).wait() |
374 | |
375 | - uboot_flavor = board_config.get('uboot_flavor') |
376 | + uboot_flavor = board_config.uboot_flavor |
377 | if uboot_flavor is not None: |
378 | uboot_bin = os.path.join( |
379 | chroot_dir, 'usr', 'lib', 'u-boot', uboot_flavor, 'u-boot.bin') |
380 | @@ -113,11 +113,11 @@ |
381 | |
382 | boot_script = "%(boot_disk)s/%(boot_script_name)s" % ( |
383 | dict(boot_disk=boot_disk, |
384 | - boot_script_name=board_config['boot_script'])) |
385 | + boot_script_name=board_config.boot_script)) |
386 | |
387 | - load_addr = board_config['load_addr'] |
388 | - sub_arch = board_config['sub_arch'] |
389 | - boot_cmd = board_config['boot_cmd'] |
390 | + load_addr = board_config.load_addr |
391 | + sub_arch = board_config.sub_arch |
392 | + boot_cmd = board_config.get_boot_cmd(is_live, is_lowmem, consoles) |
393 | |
394 | # TODO: Once linaro-media-create is fully ported to python, we should |
395 | # split this into several board-specific functions that are defined |
396 | |
397 | === modified file 'linaro_media_create/tests/test_media_create.py' |
398 | --- linaro_media_create/tests/test_media_create.py 2011-01-11 21:26:54 +0000 |
399 | +++ linaro_media_create/tests/test_media_create.py 2011-01-12 21:58:47 +0000 |
400 | @@ -9,7 +9,6 @@ |
401 | import time |
402 | |
403 | from testtools import TestCase |
404 | -from testtools.matchers import Mismatch |
405 | |
406 | from hwpack.testing import TestCaseWithFixtures |
407 | |
408 | @@ -17,10 +16,12 @@ |
409 | check_device, |
410 | cmd_runner, |
411 | ensure_command, |
412 | - get_board_config, |
413 | populate_boot, |
414 | partitions, |
415 | rootfs, |
416 | + ) |
417 | +from linaro_media_create.boards import ( |
418 | + board_configs, |
419 | ROOTFS_UUID, |
420 | ) |
421 | from linaro_media_create.hwpack import ( |
422 | @@ -92,110 +93,32 @@ |
423 | ensure_command.apt_get_install = orig_func |
424 | |
425 | |
426 | -class IsEqualToDict(object): |
427 | - """A testtools matcher to compare dicts. |
428 | - |
429 | - When there are differences, only the differing keys/values are shown. |
430 | - """ |
431 | - |
432 | - def __init__(self, expected): |
433 | - self.expected = expected |
434 | - |
435 | - def match(self, actual): |
436 | - actual_keys = set(actual.keys()) |
437 | - expected_keys = set(self.expected.keys()) |
438 | - instersection = actual_keys.intersection(expected_keys) |
439 | - expected_only_keys = expected_keys.difference(actual_keys) |
440 | - actual_only_keys = actual_keys.difference(expected_keys) |
441 | - keys_with_differing_values = [] |
442 | - for key in instersection: |
443 | - if actual[key] != self.expected[key]: |
444 | - keys_with_differing_values.append(key) |
445 | - |
446 | - if (len(expected_only_keys) == 0 and len(actual_only_keys) == 0 |
447 | - and len(keys_with_differing_values) == 0): |
448 | - return None |
449 | - |
450 | - expected_diffs = [] |
451 | - for key in keys_with_differing_values + list(expected_only_keys): |
452 | - expected_diffs.append("%s: %r" % (key, self.expected[key])) |
453 | - expected_diffs = "\n".join(expected_diffs) |
454 | - |
455 | - actual_diffs = [] |
456 | - for key in keys_with_differing_values + list(actual_only_keys): |
457 | - actual_diffs.append("%s: %r" % (key, actual[key])) |
458 | - actual_diffs = "\n".join(actual_diffs) |
459 | - |
460 | - mismatch_string = "\na = %s\n" % expected_diffs |
461 | - mismatch_string += "=" * 60 + "\n" |
462 | - mismatch_string += "b = %s" % actual_diffs |
463 | - return IsEqualToDictMismatch(self.expected, mismatch_string, actual) |
464 | - |
465 | - |
466 | -class IsEqualToDictMismatch(Mismatch): |
467 | - |
468 | - def __init__(self, expected, mismatch_string, other): |
469 | - self.expected = expected |
470 | - self._mismatch_string = mismatch_string |
471 | - self.other = other |
472 | - |
473 | - def describe(self): |
474 | - return self._mismatch_string |
475 | - |
476 | - |
477 | -class TestGetBoardConfig(TestCase): |
478 | - |
479 | - expected_beagle_config = { |
480 | - 'boot_cmd': ( |
481 | - "setenv bootcmd 'fatload mmc 0:1 0x80000000 uImage; " |
482 | - "fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80000000 " |
483 | - "0x81600000'\nsetenv bootargs ' console=tty0 " |
484 | - "console=ttyS2,115200n8 root=UUID=%s rootwait ro earlyprintk " |
485 | - "fixrtc nocompcache vram=12M omapfb.debug=y " |
486 | - "omapfb.mode=dvi:1280x720MR-16@60'\nboot" % ROOTFS_UUID), |
487 | - 'boot_args_options': ( |
488 | - 'rootwait ro earlyprintk fixrtc nocompcache vram=12M ' |
489 | - 'omapfb.debug=y omapfb.mode=dvi:1280x720MR-16@60'), |
490 | - 'boot_script': 'boot.scr', |
491 | - 'fat_size': 32, |
492 | - 'initrd_addr': '0x81600000', |
493 | - 'kernel_addr': '0x80000000', |
494 | - 'load_addr': '0x80008000', |
495 | - 'mmc_option': '0:1', |
496 | - 'mmc_part_offset': 0, |
497 | - 'serial_opts': ' console=tty0 console=ttyS2,115200n8', |
498 | - 'sub_arch': 'linaro-omap', |
499 | - 'uboot_flavor': 'omap3_beagle'} |
500 | - |
501 | - expected_panda_config = { |
502 | - 'boot_cmd': ( |
503 | - "setenv bootcmd 'fatload mmc 0:1 0x80200000 uImage; fatload mmc " |
504 | - "0:1 0x81600000 uInitrd; bootm 0x80200000 0x81600000'\nsetenv " |
505 | - "bootargs ' console = tty0 console = ttyO2,115200n8 " |
506 | - "root=UUID=%s rootwait ro earlyprintk fixrtc nocompcache " |
507 | - "vram = 32M omapfb.debug = y omapfb.vram = 0:8M mem = 463M " |
508 | - "ip = none'\nboot" % ROOTFS_UUID), |
509 | - 'boot_args_options': ( |
510 | - 'rootwait ro earlyprintk fixrtc nocompcache vram = 32M ' |
511 | - 'omapfb.debug = y omapfb.vram = 0:8M mem = 463M ip = none'), |
512 | - 'boot_script': 'boot.scr', |
513 | - 'fat_size': 32, |
514 | - 'initrd_addr': '0x81600000', |
515 | - 'kernel_addr': '0x80200000', |
516 | - 'load_addr': '0x80008000', |
517 | - 'mmc_option': '0:1', |
518 | - 'mmc_part_offset': 0, |
519 | - 'serial_opts': ' console = tty0 console = ttyO2,115200n8', |
520 | - 'sub_arch': 'omap4', |
521 | - 'uboot_flavor': 'omap4_panda'} |
522 | - |
523 | - expected_ux500_config = { |
524 | - 'boot_args_options': ( |
525 | - 'rootwait ro earlyprintk rootdelay = 1 fixrtc nocompcache ' |
526 | - 'mem = 96M@0 mem_modem = 32M@96M mem = 44M@128M pmem = 22M@172M ' |
527 | - 'mem = 30M@194M mem_mali = 32M@224M pmem_hwb = 54M@256M ' |
528 | - 'hwmem = 48M@302M mem = 152M@360M'), |
529 | - 'boot_cmd': ( |
530 | +class TestGetBootCmd(TestCase): |
531 | + |
532 | + def test_vexpress(self): |
533 | + boot_cmd = board_configs['vexpress'].get_boot_cmd( |
534 | + is_live=False, is_lowmem=False, consoles=None) |
535 | + expected = ( |
536 | + "setenv bootcmd 'fatload mmc 0:1 0x60008000 uImage; fatload mmc " |
537 | + "0:1 0x81000000 uInitrd; bootm 0x60008000 0x81000000'\nsetenv " |
538 | + "bootargs ' console = tty0 console = ttyAMA0,38400n8 " |
539 | + "root=UUID=%s rootwait ro'\nboot" % ROOTFS_UUID) |
540 | + self.assertEqual(expected, boot_cmd) |
541 | + |
542 | + def test_mx51evk(self): |
543 | + boot_cmd = board_configs['mx51evk'].get_boot_cmd( |
544 | + is_live=False, is_lowmem=False, consoles=None) |
545 | + expected = ( |
546 | + "setenv bootcmd 'fatload mmc 0:2 0x90000000 uImage; fatload mmc " |
547 | + "0:2 0x90800000 uInitrd; bootm 0x90000000 0x90800000'\nsetenv " |
548 | + "bootargs ' console = tty0 console = ttymxc0,115200n8 " |
549 | + "root=UUID=%s rootwait ro'\nboot" % ROOTFS_UUID) |
550 | + self.assertEqual(expected, boot_cmd) |
551 | + |
552 | + def test_ux500(self): |
553 | + boot_cmd = board_configs['ux500'].get_boot_cmd( |
554 | + is_live=False, is_lowmem=False, consoles=None) |
555 | + expected = ( |
556 | "setenv bootcmd 'fatload mmc 1:1 0x00100000 uImage; fatload mmc " |
557 | "1:1 0x08000000 uInitrd; bootm 0x00100000 0x08000000'\nsetenv " |
558 | "bootargs ' console = tty0 console = ttyAMA2,115200n8 " |
559 | @@ -203,160 +126,32 @@ |
560 | "nocompcache mem = 96M@0 mem_modem = 32M@96M mem = 44M@128M " |
561 | "pmem = 22M@172M mem = 30M@194M mem_mali = 32M@224M " |
562 | "pmem_hwb = 54M@256M hwmem = 48M@302M mem = 152M@360M'\nboot" |
563 | - % ROOTFS_UUID), |
564 | - 'boot_script': 'flash.scr', |
565 | - 'fat_size': 32, |
566 | - 'initrd_addr': '0x08000000', |
567 | - 'kernel_addr': '0x00100000', |
568 | - 'load_addr': '0x00008000', |
569 | - 'mmc_option': '1:1', |
570 | - 'mmc_part_offset': 0, |
571 | - 'serial_opts': ' console = tty0 console = ttyAMA2,115200n8', |
572 | - 'sub_arch': 'ux500', |
573 | - 'uboot_flavor': None} |
574 | - |
575 | - expected_vexpress_config = { |
576 | - 'boot_args_options': 'rootwait ro', |
577 | - 'boot_cmd': ( |
578 | - "setenv bootcmd 'fatload mmc 0:1 0x60008000 uImage; fatload mmc " |
579 | - "0:1 0x81000000 uInitrd; bootm 0x60008000 0x81000000'\nsetenv " |
580 | - "bootargs ' console = tty0 console = ttyAMA0,38400n8 " |
581 | - "root=UUID=%s rootwait ro'\nboot" % ROOTFS_UUID), |
582 | - 'boot_script': None, |
583 | - 'fat_size': 16, |
584 | - 'initrd_addr': '0x81000000', |
585 | - 'kernel_addr': '0x60008000', |
586 | - 'load_addr': '0x60008000', |
587 | - 'mmc_option': '0:1', |
588 | - 'mmc_part_offset': 0, |
589 | - 'serial_opts': ' console = tty0 console = ttyAMA0,38400n8', |
590 | - 'sub_arch': 'linaro-vexpress', |
591 | - 'uboot_flavor': 'ca9x4_ct_vxp'} |
592 | - |
593 | - expected_mx51evk_config = { |
594 | - 'boot_args_options': 'rootwait ro', |
595 | - 'boot_cmd': ( |
596 | - "setenv bootcmd 'fatload mmc 0:2 0x90000000 uImage; fatload mmc " |
597 | - "0:2 0x90800000 uInitrd; bootm 0x90000000 0x90800000'\nsetenv " |
598 | - "bootargs ' console = tty0 console = ttymxc0,115200n8 " |
599 | - "root=UUID=%s rootwait ro'\nboot" % ROOTFS_UUID), |
600 | - 'boot_script': 'boot.scr', |
601 | - 'fat_size': 32, |
602 | - 'initrd_addr': '0x90800000', |
603 | - 'kernel_addr': '0x90000000', |
604 | - 'load_addr': '0x90008000', |
605 | - 'mmc_option': '0:2', |
606 | - 'mmc_part_offset': 1, |
607 | - 'serial_opts': ' console = tty0 console = ttymxc0,115200n8', |
608 | - 'sub_arch': 'linaro-mx51', |
609 | - 'uboot_flavor': None} |
610 | - |
611 | - def test_unknown_board(self): |
612 | - self.assertRaises( |
613 | - ValueError, get_board_config, 'foobar', is_live=True, |
614 | - is_lowmem=False, consoles=None) |
615 | - |
616 | - def test_vexpress_live(self): |
617 | - config = get_board_config( |
618 | - 'vexpress', is_live=True, is_lowmem=False, consoles=None) |
619 | - expected = self.expected_vexpress_config.copy() |
620 | - expected['boot_cmd'] = ( |
621 | - "setenv bootcmd 'fatload mmc 0:1 0x60008000 uImage; fatload mmc " |
622 | - "0:1 0x81000000 uInitrd; bootm 0x60008000 0x81000000'\nsetenv " |
623 | - "bootargs ' console = tty0 console = ttyAMA0,38400n8 " |
624 | - "serialtty = ttyAMA0 boot=casper rootwait ro'\nboot") |
625 | - expected['serial_opts'] = ( |
626 | - ' console = tty0 console = ttyAMA0,38400n8 serialtty = ttyAMA0') |
627 | - self.assertThat(expected, IsEqualToDict(config)) |
628 | - |
629 | - def test_vexpress(self): |
630 | - config = get_board_config( |
631 | - 'vexpress', is_live=False, is_lowmem=False, consoles=None) |
632 | - self.assertThat(self.expected_vexpress_config, IsEqualToDict(config)) |
633 | - |
634 | - def test_mx51evk_live(self): |
635 | - config = get_board_config( |
636 | - 'mx51evk', is_live=True, is_lowmem=False, consoles=None) |
637 | - expected = self.expected_mx51evk_config.copy() |
638 | - expected['boot_cmd'] = ( |
639 | - "setenv bootcmd 'fatload mmc 0:2 0x90000000 uImage; " |
640 | - "fatload mmc 0:2 0x90800000 uInitrd; bootm 0x90000000 " |
641 | - "0x90800000'\nsetenv bootargs ' console = tty0 " |
642 | - "console = ttymxc0,115200n8 serialtty = ttymxc0 boot=casper " |
643 | - "rootwait ro'\nboot") |
644 | - expected['serial_opts'] = ( |
645 | - ' console = tty0 console = ttymxc0,115200n8 serialtty = ttymxc0') |
646 | - self.assertThat(expected, IsEqualToDict(config)) |
647 | - |
648 | - def test_mx51evk(self): |
649 | - config = get_board_config( |
650 | - 'mx51evk', is_live=False, is_lowmem=False, consoles=None) |
651 | - self.assertThat(self.expected_mx51evk_config, IsEqualToDict(config)) |
652 | - |
653 | - def test_ux500_live(self): |
654 | - config = get_board_config( |
655 | - 'ux500', is_live=True, is_lowmem=False, consoles=None) |
656 | - boot_cmd = ( |
657 | - "setenv bootcmd 'fatload mmc 1:1 0x00100000 uImage; fatload " |
658 | - "mmc 1:1 0x08000000 uInitrd; bootm 0x00100000 0x08000000'\n" |
659 | - "setenv bootargs ' console = tty0 console = ttyAMA2,115200n8 " |
660 | - "serialtty = ttyAMA2 boot=casper rootwait ro earlyprintk " |
661 | - "rootdelay = 1 fixrtc nocompcache mem = 96M@0 " |
662 | - "mem_modem = 32M@96M mem = 44M@128M pmem = 22M@172M " |
663 | - "mem = 30M@194M mem_mali = 32M@224M pmem_hwb = 54M@256M " |
664 | - "hwmem = 48M@302M mem = 152M@360M'\nboot") |
665 | - expected = self.expected_ux500_config.copy() |
666 | - expected['boot_cmd'] = boot_cmd |
667 | - expected['serial_opts'] = ( |
668 | - ' console = tty0 console = ttyAMA2,115200n8 serialtty = ttyAMA2') |
669 | - self.assertThat(expected, IsEqualToDict(config)) |
670 | - |
671 | - def test_ux500(self): |
672 | - config = get_board_config( |
673 | - 'ux500', is_live=False, is_lowmem=False, consoles=None) |
674 | - self.assertThat(self.expected_ux500_config, IsEqualToDict(config)) |
675 | + % ROOTFS_UUID) |
676 | + self.assertEqual(expected, boot_cmd) |
677 | |
678 | def test_panda(self): |
679 | - config = get_board_config( |
680 | - 'panda', is_live=False, is_lowmem=False, consoles=None) |
681 | - self.assertThat(self.expected_panda_config, IsEqualToDict(config)) |
682 | - |
683 | - def test_panda_live(self): |
684 | - config = get_board_config( |
685 | - 'panda', is_live=True, is_lowmem=False, consoles=None) |
686 | - boot_cmd = ( |
687 | - "setenv bootcmd 'fatload mmc 0:1 0x80200000 uImage; " |
688 | - "fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80200000 " |
689 | - "0x81600000'\nsetenv bootargs ' console = tty0 " |
690 | - "console = ttyO2,115200n8 serialtty = ttyO2 boot=casper " |
691 | - "rootwait ro earlyprintk fixrtc nocompcache vram = 32M " |
692 | - "omapfb.debug = y omapfb.vram = 0:8M mem = 463M ip = none'\nboot") |
693 | - expected = self.expected_panda_config.copy() |
694 | - expected['boot_cmd'] = boot_cmd |
695 | - expected['serial_opts'] = ( |
696 | - ' console = tty0 console = ttyO2,115200n8 serialtty = ttyO2') |
697 | - self.assertThat(expected, IsEqualToDict(config)) |
698 | + boot_cmd = board_configs['panda'].get_boot_cmd( |
699 | + is_live=False, is_lowmem=False, consoles=None) |
700 | + expected = ( |
701 | + "setenv bootcmd 'fatload mmc 0:1 0x80200000 uImage; fatload mmc " |
702 | + "0:1 0x81600000 uInitrd; bootm 0x80200000 0x81600000'\nsetenv " |
703 | + "bootargs ' console = tty0 console = ttyO2,115200n8 " |
704 | + "root=UUID=%s rootwait ro earlyprintk fixrtc nocompcache " |
705 | + "vram = 32M omapfb.debug = y omapfb.vram = 0:8M mem = 463M " |
706 | + "ip = none'\nboot" % ROOTFS_UUID) |
707 | + self.assertEqual(expected, boot_cmd) |
708 | |
709 | def test_beagle(self): |
710 | - config = get_board_config( |
711 | - 'beagle', is_live=False, is_lowmem=False, consoles=None) |
712 | - self.assertThat(self.expected_beagle_config, IsEqualToDict(config)) |
713 | - |
714 | - def test_beagle_live(self): |
715 | - config = get_board_config( |
716 | - 'beagle', is_live=True, is_lowmem=False, consoles=None) |
717 | - boot_cmd = ( |
718 | + boot_cmd = board_configs['beagle'].get_boot_cmd( |
719 | + is_live=False, is_lowmem=False, consoles=None) |
720 | + expected = ( |
721 | "setenv bootcmd 'fatload mmc 0:1 0x80000000 uImage; " |
722 | "fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80000000 " |
723 | "0x81600000'\nsetenv bootargs ' console=tty0 " |
724 | - "console=ttyS2,115200n8 serialtty=ttyS2 boot=casper rootwait ro " |
725 | - "earlyprintk fixrtc nocompcache vram=12M omapfb.debug=y " |
726 | - "omapfb.mode=dvi:1280x720MR-16@60'\nboot") |
727 | - expected = self.expected_beagle_config.copy() |
728 | - expected['boot_cmd'] = boot_cmd |
729 | - expected['serial_opts'] = ( |
730 | - ' console=tty0 console=ttyS2,115200n8 serialtty=ttyS2') |
731 | - self.assertThat(expected, IsEqualToDict(config)) |
732 | + "console=ttyS2,115200n8 root=UUID=%s rootwait ro earlyprintk " |
733 | + "fixrtc nocompcache vram=12M omapfb.debug=y " |
734 | + "omapfb.mode=dvi:1280x720MR-16@60'\nboot" % ROOTFS_UUID) |
735 | + self.assertEqual(expected, boot_cmd) |
736 | |
737 | |
738 | class TestRemoveBinaryDir(TestCaseWithFixtures): |
Looks good to me.
Thanks,
James