Merge lp:~salgado/linaro-image-tools/config-class into lp:linaro-image-tools/11.11

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
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+46048@code.launchpad.net

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.
Revision history for this message
James Westby (james-w) wrote :

Looks good to me.

Thanks,

James

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'linaro-media-create'
--- linaro-media-create 2011-01-11 21:26:54 +0000
+++ linaro-media-create 2011-01-12 21:58:47 +0000
@@ -6,6 +6,10 @@
6import tempfile6import tempfile
7from subprocess import Popen7from subprocess import Popen
88
9from linaro_media_create.boards import (
10 board_configs,
11 ROOTFS_UUID,
12 )
9from linaro_media_create.check_device import (13from linaro_media_create.check_device import (
10 confirm_device_selection_and_ensure_it_is_ready)14 confirm_device_selection_and_ensure_it_is_ready)
11from linaro_media_create.ensure_command import ensure_command15from linaro_media_create.ensure_command import ensure_command
@@ -18,11 +22,7 @@
18from linaro_media_create.remove_binary_dir import remove_dir22from linaro_media_create.remove_binary_dir import remove_dir
19from linaro_media_create.rootfs import populate_rootfs23from linaro_media_create.rootfs import populate_rootfs
20from linaro_media_create.unpack_binary_tarball import unpack_binary_tarball24from linaro_media_create.unpack_binary_tarball import unpack_binary_tarball
21from linaro_media_create import (25from linaro_media_create import get_args_parser
22 get_args_parser,
23 get_board_config,
24 ROOTFS_UUID,
25 )
2626
2727
28TMP_DIR = tempfile.mkdtemp()28TMP_DIR = tempfile.mkdtemp()
@@ -71,8 +71,7 @@
71if __name__ == '__main__':71if __name__ == '__main__':
72 parser = get_args_parser()72 parser = get_args_parser()
73 args = parser.parse_args()73 args = parser.parse_args()
74 board_config = get_board_config(74 board_config = board_configs[args.board]
75 args.board, args.is_live, args.is_lowmem, args.consoles)
7675
77 media = Media(args.device)76 media = Media(args.device)
78 if media.is_block_device:77 if media.is_block_device:
@@ -94,7 +93,7 @@
94 install_hwpacks(ROOTFS_DIR, TMP_DIR, args.hwpack_force_yes, *hwpacks)93 install_hwpacks(ROOTFS_DIR, TMP_DIR, args.hwpack_force_yes, *hwpacks)
9594
96 boot_partition, root_partition = setup_partitions(95 boot_partition, root_partition = setup_partitions(
97 args.board, media, board_config['fat_size'], args.image_size,96 args.board, media, board_config.fat_size, args.image_size,
98 args.boot_label, args.rfs_label, args.rootfs, ROOTFS_UUID,97 args.boot_label, args.rfs_label, args.rootfs, ROOTFS_UUID,
99 args.should_create_partitions,98 args.should_create_partitions,
100 args.should_format_bootfs, args.should_format_rootfs)99 args.should_format_bootfs, args.should_format_rootfs)
@@ -102,7 +101,7 @@
102 if args.should_format_bootfs:101 if args.should_format_bootfs:
103 populate_boot(102 populate_boot(
104 args.board, board_config, ROOTFS_DIR, boot_partition, BOOT_DISK,103 args.board, board_config, ROOTFS_DIR, boot_partition, BOOT_DISK,
105 args.device, TMP_DIR, args.is_live)104 args.device, TMP_DIR, args.is_live, args.is_lowmem, args.consoles)
106105
107 if args.should_format_rootfs:106 if args.should_format_rootfs:
108 create_swap = False107 create_swap = False
@@ -110,6 +109,6 @@
110 create_swap = True109 create_swap = True
111 populate_rootfs(ROOTFS_DIR, ROOT_DISK, root_partition, args.rootfs,110 populate_rootfs(ROOTFS_DIR, ROOT_DISK, root_partition, args.rootfs,
112 ROOTFS_UUID, create_swap, str(args.swap_file),111 ROOTFS_UUID, create_swap, str(args.swap_file),
113 board_config['mmc_part_offset'])112 board_config.mmc_part_offset)
114113
115 print "Done creating Linaro image on %s" % args.device114 print "Done creating Linaro image on %s" % args.device
116115
=== modified file 'linaro_media_create/__init__.py'
--- linaro_media_create/__init__.py 2011-01-11 21:09:50 +0000
+++ linaro_media_create/__init__.py 2011-01-12 21:58:47 +0000
@@ -1,8 +1,9 @@
1import argparse1import argparse
2import uuid2
33from linaro_media_create.boards import board_configs
4ROOTFS_UUID = str(uuid.uuid4())4
5KNOWN_BOARDS = ['beagle', 'igep', 'mx51evk', 'panda', 'ux500', 'vexpress']5
6KNOWN_BOARDS = board_configs.keys()
67
78
8class Live256MegsAction(argparse.Action):9class Live256MegsAction(argparse.Action):
@@ -87,121 +88,3 @@
87 '--no-part', dest='should_create_partitions', action='store_false',88 '--no-part', dest='should_create_partitions', action='store_false',
88 help='Reuse existing partitions on the given media.')89 help='Reuse existing partitions on the given media.')
89 return parser90 return parser
90
91
92def get_board_config(board, is_live, is_lowmem, consoles):
93 """Return a dict containing the configs to create an image for a board.
94
95 :param args: An argparse.ArgumentParser object containing the arguments
96 passed to linaro-media-create.
97 """
98 mmc_part_offset = 0
99 mmc_option = '0:1'
100 boot_args_options = 'rootwait ro'
101 uboot_flavor = None
102 fat_size = 32
103 serial_opts = ''
104 if consoles is not None:
105 for console in consoles:
106 serial_opts += ' console=%s' % console
107
108 # XXX: I think this is not needed as we have board-specific
109 # serial options for when is_live is true.
110 if is_live:
111 serial_opts += ' serialtty=ttyS2'
112
113 if board in ('beagle', 'igep'):
114 if board == 'beagle':
115 uboot_flavor = 'omap3_beagle'
116 serial_opts += ' console=tty0 console=ttyS2,115200n8'
117 live_serial_opts = 'serialtty=ttyS2'
118 kernel_addr = '0x80000000'
119 initrd_addr = '0x81600000'
120 load_addr = '0x80008000'
121 sub_arch = 'linaro-omap'
122 boot_script = 'boot.scr'
123 boot_args_options += (
124 ' earlyprintk fixrtc nocompcache vram=12M omapfb.debug=y'
125 ' omapfb.mode=dvi:1280x720MR-16@60')
126
127 elif board == 'panda':
128 uboot_flavor = 'omap4_panda'
129 serial_opts += ' console = tty0 console = ttyO2,115200n8'
130 live_serial_opts = 'serialtty = ttyO2'
131 kernel_addr = '0x80200000'
132 initrd_addr = '0x81600000'
133 load_addr = '0x80008000'
134 sub_arch = 'omap4'
135 boot_script = 'boot.scr'
136 boot_args_options += (
137 ' earlyprintk fixrtc nocompcache vram = 32M omapfb.debug = y'
138 ' omapfb.vram = 0:8M mem = 463M ip = none')
139
140 elif board == 'ux500':
141 serial_opts += ' console = tty0 console = ttyAMA2,115200n8'
142 live_serial_opts = 'serialtty = ttyAMA2'
143 kernel_addr = '0x00100000'
144 initrd_addr = '0x08000000'
145 load_addr = '0x00008000'
146 sub_arch = 'ux500'
147 boot_script = 'flash.scr'
148 boot_args_options += (
149 ' earlyprintk rootdelay = 1 fixrtc nocompcache'
150 ' mem = 96M@0 mem_modem = 32M@96M mem = 44M@128M pmem = 22M@172M'
151 ' mem = 30M@194M mem_mali = 32M@224M pmem_hwb = 54M@256M'
152 ' hwmem = 48M@302M mem = 152M@360M')
153 mmc_option = '1:1'
154
155 elif board == 'mx51evk':
156 serial_opts += ' console = tty0 console = ttymxc0,115200n8'
157 live_serial_opts = 'serialtty = ttymxc0'
158 kernel_addr = '0x90000000'
159 initrd_addr = '0x90800000'
160 load_addr = '0x90008000'
161 sub_arch = 'linaro-mx51'
162 boot_script = 'boot.scr'
163 mmc_part_offset = 1
164 mmc_option = '0:2'
165
166 elif board == 'vexpress':
167 uboot_flavor = 'ca9x4_ct_vxp'
168 serial_opts += ' console = tty0 console = ttyAMA0,38400n8'
169 live_serial_opts = 'serialtty = ttyAMA0'
170 kernel_addr = '0x60008000'
171 initrd_addr = '0x81000000'
172 load_addr = kernel_addr
173 sub_arch = 'linaro-vexpress'
174 boot_script = None
175 # ARM Boot Monitor is used to load u-boot, uImage etc. into flash and
176 # only allows for FAT16
177 fat_size = 16
178
179 else:
180 raise ValueError("Unkown board: %s" % board)
181
182 lowmem_opt = ''
183 boot_snippet = 'root=UUID=%s' % ROOTFS_UUID
184 if is_live:
185 serial_opts += ' %s' % live_serial_opts
186 boot_snippet = 'boot=casper'
187 if is_lowmem:
188 lowmem_opt = 'only-ubiquity'
189
190 boot_cmd = (
191 "setenv bootcmd 'fatload mmc %(mmc_option)s %(kernel_addr)s "
192 "uImage; fatload mmc %(mmc_option)s %(initrd_addr)s uInitrd; "
193 "bootm %(kernel_addr)s %(initrd_addr)s'\n"
194 "setenv bootargs '%(serial_opts)s %(lowmem_opt)s "
195 "%(boot_snippet)s %(boot_args_options)s'\n"
196 "boot" % vars())
197
198 # Instead of constructing a dict here, we could create a separate class
199 # for the config of every board, with the varying bits stored as class
200 # variables. At this point I don't see much advantage in doing that,
201 # though.
202 return dict(
203 kernel_addr=kernel_addr, initrd_addr=initrd_addr, load_addr=load_addr,
204 sub_arch=sub_arch, boot_script=boot_script, fat_size=fat_size,
205 boot_args_options=boot_args_options, serial_opts=serial_opts,
206 uboot_flavor=uboot_flavor, mmc_part_offset=mmc_part_offset,
207 mmc_option=mmc_option, boot_cmd=boot_cmd)
20891
=== added file 'linaro_media_create/boards.py'
--- linaro_media_create/boards.py 1970-01-01 00:00:00 +0000
+++ linaro_media_create/boards.py 2011-01-12 21:58:47 +0000
@@ -0,0 +1,148 @@
1"""Configuration for boards supported by linaro-media-create.
2
3To add support for a new board, you just need to create a subclass of
4BoardConfig and set appropriate values for its variables.
5"""
6
7import uuid
8
9ROOTFS_UUID = str(uuid.uuid4())
10
11
12class BoardConfig(object):
13 """The configuration used when building an image for a board."""
14 uboot_flavor = None
15 mmc_option = '0:1'
16 mmc_part_offset = 0
17 extra_serial_opts = None
18 live_serial_opts = None
19 kernel_addr = None
20 initrd_addr = None
21 load_addr = None
22 sub_arch = None
23 boot_script = None
24 extra_boot_args_options = None
25 fat_size = 32
26
27 @classmethod
28 def get_boot_cmd(cls, is_live, is_lowmem, consoles):
29 """Get the boot command for this board."""
30 boot_args_options = 'rootwait ro'
31 if cls.extra_boot_args_options:
32 boot_args_options += " %s" % cls.extra_boot_args_options
33 serial_opts = ''
34 if consoles is not None:
35 for console in consoles:
36 serial_opts += ' console=%s' % console
37
38 # XXX: I think this is not needed as we have board-specific
39 # serial options for when is_live is true.
40 if is_live:
41 serial_opts += ' serialtty=ttyS2'
42
43 serial_opts += ' %s' % cls.extra_serial_opts
44
45 lowmem_opt = ''
46 boot_snippet = 'root=UUID=%s' % ROOTFS_UUID
47 if is_live:
48 serial_opts += ' %s' % cls.live_serial_opts
49 boot_snippet = 'boot=casper'
50 if is_lowmem:
51 lowmem_opt = 'only-ubiquity'
52
53 replacements = dict(
54 mmc_option=cls.mmc_option, kernel_addr=cls.kernel_addr,
55 initrd_addr=cls.initrd_addr, serial_opts=serial_opts,
56 lowmem_opt=lowmem_opt, boot_snippet=boot_snippet,
57 boot_args_options=boot_args_options)
58 return (
59 "setenv bootcmd 'fatload mmc %(mmc_option)s %(kernel_addr)s "
60 "uImage; fatload mmc %(mmc_option)s %(initrd_addr)s uInitrd; "
61 "bootm %(kernel_addr)s %(initrd_addr)s'\n"
62 "setenv bootargs '%(serial_opts)s %(lowmem_opt)s "
63 "%(boot_snippet)s %(boot_args_options)s'\n"
64 "boot" % replacements)
65
66
67class BeagleConfig(BoardConfig):
68 uboot_flavor = 'omap3_beagle'
69 extra_serial_opts = 'console=tty0 console=ttyS2,115200n8'
70 live_serial_opts = 'serialtty=ttyS2'
71 kernel_addr = '0x80000000'
72 initrd_addr = '0x81600000'
73 load_addr = '0x80008000'
74 sub_arch = 'linaro-omap'
75 boot_script = 'boot.scr'
76 extra_boot_args_options = (
77 'earlyprintk fixrtc nocompcache vram=12M omapfb.debug=y '
78 'omapfb.mode=dvi:1280x720MR-16@60')
79
80
81class PandaConfig(BoardConfig):
82 uboot_flavor = 'omap4_panda'
83 extra_serial_opts = 'console = tty0 console = ttyO2,115200n8'
84 live_serial_opts = 'serialtty = ttyO2'
85 kernel_addr = '0x80200000'
86 initrd_addr = '0x81600000'
87 load_addr = '0x80008000'
88 sub_arch = 'omap4'
89 boot_script = 'boot.scr'
90 extra_boot_args_options = (
91 'earlyprintk fixrtc nocompcache vram = 32M omapfb.debug = y '
92 'omapfb.vram = 0:8M mem = 463M ip = none')
93
94
95class IgepConfig(BeagleConfig):
96 uboot_flavor = None
97
98
99class Ux500Config(BoardConfig):
100 extra_serial_opts = 'console = tty0 console = ttyAMA2,115200n8'
101 live_serial_opts = 'serialtty = ttyAMA2'
102 kernel_addr = '0x00100000'
103 initrd_addr = '0x08000000'
104 load_addr = '0x00008000'
105 sub_arch = 'ux500'
106 boot_script = 'flash.scr'
107 extra_boot_args_options = (
108 'earlyprintk rootdelay = 1 fixrtc nocompcache '
109 'mem = 96M@0 mem_modem = 32M@96M mem = 44M@128M pmem = 22M@172M '
110 'mem = 30M@194M mem_mali = 32M@224M pmem_hwb = 54M@256M '
111 'hwmem = 48M@302M mem = 152M@360M')
112 mmc_option = '1:1'
113
114
115class Mx51evkConfig(BoardConfig):
116 extra_serial_opts = 'console = tty0 console = ttymxc0,115200n8'
117 live_serial_opts = 'serialtty = ttymxc0'
118 kernel_addr = '0x90000000'
119 initrd_addr = '0x90800000'
120 load_addr = '0x90008000'
121 sub_arch = 'linaro-mx51'
122 boot_script = 'boot.scr'
123 mmc_part_offset = 1
124 mmc_option = '0:2'
125
126
127class VexpressConfig(BoardConfig):
128 uboot_flavor = 'ca9x4_ct_vxp'
129 extra_serial_opts = 'console = tty0 console = ttyAMA0,38400n8'
130 live_serial_opts = 'serialtty = ttyAMA0'
131 kernel_addr = '0x60008000'
132 initrd_addr = '0x81000000'
133 load_addr = kernel_addr
134 sub_arch = 'linaro-vexpress'
135 boot_script = None
136 # ARM Boot Monitor is used to load u-boot, uImage etc. into flash and
137 # only allows for FAT16
138 fat_size = 16
139
140
141board_configs = {
142 'beagle': BeagleConfig,
143 'igep': IgepConfig,
144 'panda': PandaConfig,
145 'vexpress': VexpressConfig,
146 'ux500': Ux500Config,
147 'mx51evk': Mx51evkConfig,
148 }
0149
=== removed file 'linaro_media_create/boot_cmd.py'
=== modified file 'linaro_media_create/populate_boot.py'
--- linaro_media_create/populate_boot.py 2011-01-11 21:26:54 +0000
+++ linaro_media_create/populate_boot.py 2011-01-12 21:58:47 +0000
@@ -88,7 +88,7 @@
8888
8989
90def populate_boot(board, board_config, chroot_dir, boot_partition, boot_disk,90def populate_boot(board, board_config, chroot_dir, boot_partition, boot_disk,
91 boot_device_or_file, tmp_dir, is_live):91 boot_device_or_file, tmp_dir, is_live, is_lowmem, consoles):
9292
93 parts_dir = 'boot'93 parts_dir = 'boot'
94 if is_live:94 if is_live:
@@ -104,7 +104,7 @@
104 raise104 raise
105 cmd_runner.run(['mount', boot_partition, boot_disk], as_root=True).wait()105 cmd_runner.run(['mount', boot_partition, boot_disk], as_root=True).wait()
106106
107 uboot_flavor = board_config.get('uboot_flavor')107 uboot_flavor = board_config.uboot_flavor
108 if uboot_flavor is not None:108 if uboot_flavor is not None:
109 uboot_bin = os.path.join(109 uboot_bin = os.path.join(
110 chroot_dir, 'usr', 'lib', 'u-boot', uboot_flavor, 'u-boot.bin')110 chroot_dir, 'usr', 'lib', 'u-boot', uboot_flavor, 'u-boot.bin')
@@ -113,11 +113,11 @@
113113
114 boot_script = "%(boot_disk)s/%(boot_script_name)s" % (114 boot_script = "%(boot_disk)s/%(boot_script_name)s" % (
115 dict(boot_disk=boot_disk,115 dict(boot_disk=boot_disk,
116 boot_script_name=board_config['boot_script']))116 boot_script_name=board_config.boot_script))
117117
118 load_addr = board_config['load_addr']118 load_addr = board_config.load_addr
119 sub_arch = board_config['sub_arch']119 sub_arch = board_config.sub_arch
120 boot_cmd = board_config['boot_cmd']120 boot_cmd = board_config.get_boot_cmd(is_live, is_lowmem, consoles)
121121
122 # TODO: Once linaro-media-create is fully ported to python, we should122 # TODO: Once linaro-media-create is fully ported to python, we should
123 # split this into several board-specific functions that are defined123 # split this into several board-specific functions that are defined
124124
=== modified file 'linaro_media_create/tests/test_media_create.py'
--- linaro_media_create/tests/test_media_create.py 2011-01-11 21:26:54 +0000
+++ linaro_media_create/tests/test_media_create.py 2011-01-12 21:58:47 +0000
@@ -9,7 +9,6 @@
9import time9import time
1010
11from testtools import TestCase11from testtools import TestCase
12from testtools.matchers import Mismatch
1312
14from hwpack.testing import TestCaseWithFixtures13from hwpack.testing import TestCaseWithFixtures
1514
@@ -17,10 +16,12 @@
17 check_device,16 check_device,
18 cmd_runner,17 cmd_runner,
19 ensure_command,18 ensure_command,
20 get_board_config,
21 populate_boot,19 populate_boot,
22 partitions,20 partitions,
23 rootfs,21 rootfs,
22 )
23from linaro_media_create.boards import (
24 board_configs,
24 ROOTFS_UUID,25 ROOTFS_UUID,
25 )26 )
26from linaro_media_create.hwpack import (27from linaro_media_create.hwpack import (
@@ -92,110 +93,32 @@
92 ensure_command.apt_get_install = orig_func93 ensure_command.apt_get_install = orig_func
9394
9495
95class IsEqualToDict(object):96class TestGetBootCmd(TestCase):
96 """A testtools matcher to compare dicts.97
9798 def test_vexpress(self):
98 When there are differences, only the differing keys/values are shown.99 boot_cmd = board_configs['vexpress'].get_boot_cmd(
99 """100 is_live=False, is_lowmem=False, consoles=None)
100101 expected = (
101 def __init__(self, expected):102 "setenv bootcmd 'fatload mmc 0:1 0x60008000 uImage; fatload mmc "
102 self.expected = expected103 "0:1 0x81000000 uInitrd; bootm 0x60008000 0x81000000'\nsetenv "
103104 "bootargs ' console = tty0 console = ttyAMA0,38400n8 "
104 def match(self, actual):105 "root=UUID=%s rootwait ro'\nboot" % ROOTFS_UUID)
105 actual_keys = set(actual.keys())106 self.assertEqual(expected, boot_cmd)
106 expected_keys = set(self.expected.keys())107
107 instersection = actual_keys.intersection(expected_keys)108 def test_mx51evk(self):
108 expected_only_keys = expected_keys.difference(actual_keys)109 boot_cmd = board_configs['mx51evk'].get_boot_cmd(
109 actual_only_keys = actual_keys.difference(expected_keys)110 is_live=False, is_lowmem=False, consoles=None)
110 keys_with_differing_values = []111 expected = (
111 for key in instersection:112 "setenv bootcmd 'fatload mmc 0:2 0x90000000 uImage; fatload mmc "
112 if actual[key] != self.expected[key]:113 "0:2 0x90800000 uInitrd; bootm 0x90000000 0x90800000'\nsetenv "
113 keys_with_differing_values.append(key)114 "bootargs ' console = tty0 console = ttymxc0,115200n8 "
114115 "root=UUID=%s rootwait ro'\nboot" % ROOTFS_UUID)
115 if (len(expected_only_keys) == 0 and len(actual_only_keys) == 0116 self.assertEqual(expected, boot_cmd)
116 and len(keys_with_differing_values) == 0):117
117 return None118 def test_ux500(self):
118119 boot_cmd = board_configs['ux500'].get_boot_cmd(
119 expected_diffs = []120 is_live=False, is_lowmem=False, consoles=None)
120 for key in keys_with_differing_values + list(expected_only_keys):121 expected = (
121 expected_diffs.append("%s: %r" % (key, self.expected[key]))
122 expected_diffs = "\n".join(expected_diffs)
123
124 actual_diffs = []
125 for key in keys_with_differing_values + list(actual_only_keys):
126 actual_diffs.append("%s: %r" % (key, actual[key]))
127 actual_diffs = "\n".join(actual_diffs)
128
129 mismatch_string = "\na = %s\n" % expected_diffs
130 mismatch_string += "=" * 60 + "\n"
131 mismatch_string += "b = %s" % actual_diffs
132 return IsEqualToDictMismatch(self.expected, mismatch_string, actual)
133
134
135class IsEqualToDictMismatch(Mismatch):
136
137 def __init__(self, expected, mismatch_string, other):
138 self.expected = expected
139 self._mismatch_string = mismatch_string
140 self.other = other
141
142 def describe(self):
143 return self._mismatch_string
144
145
146class TestGetBoardConfig(TestCase):
147
148 expected_beagle_config = {
149 'boot_cmd': (
150 "setenv bootcmd 'fatload mmc 0:1 0x80000000 uImage; "
151 "fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80000000 "
152 "0x81600000'\nsetenv bootargs ' console=tty0 "
153 "console=ttyS2,115200n8 root=UUID=%s rootwait ro earlyprintk "
154 "fixrtc nocompcache vram=12M omapfb.debug=y "
155 "omapfb.mode=dvi:1280x720MR-16@60'\nboot" % ROOTFS_UUID),
156 'boot_args_options': (
157 'rootwait ro earlyprintk fixrtc nocompcache vram=12M '
158 'omapfb.debug=y omapfb.mode=dvi:1280x720MR-16@60'),
159 'boot_script': 'boot.scr',
160 'fat_size': 32,
161 'initrd_addr': '0x81600000',
162 'kernel_addr': '0x80000000',
163 'load_addr': '0x80008000',
164 'mmc_option': '0:1',
165 'mmc_part_offset': 0,
166 'serial_opts': ' console=tty0 console=ttyS2,115200n8',
167 'sub_arch': 'linaro-omap',
168 'uboot_flavor': 'omap3_beagle'}
169
170 expected_panda_config = {
171 'boot_cmd': (
172 "setenv bootcmd 'fatload mmc 0:1 0x80200000 uImage; fatload mmc "
173 "0:1 0x81600000 uInitrd; bootm 0x80200000 0x81600000'\nsetenv "
174 "bootargs ' console = tty0 console = ttyO2,115200n8 "
175 "root=UUID=%s rootwait ro earlyprintk fixrtc nocompcache "
176 "vram = 32M omapfb.debug = y omapfb.vram = 0:8M mem = 463M "
177 "ip = none'\nboot" % ROOTFS_UUID),
178 'boot_args_options': (
179 'rootwait ro earlyprintk fixrtc nocompcache vram = 32M '
180 'omapfb.debug = y omapfb.vram = 0:8M mem = 463M ip = none'),
181 'boot_script': 'boot.scr',
182 'fat_size': 32,
183 'initrd_addr': '0x81600000',
184 'kernel_addr': '0x80200000',
185 'load_addr': '0x80008000',
186 'mmc_option': '0:1',
187 'mmc_part_offset': 0,
188 'serial_opts': ' console = tty0 console = ttyO2,115200n8',
189 'sub_arch': 'omap4',
190 'uboot_flavor': 'omap4_panda'}
191
192 expected_ux500_config = {
193 'boot_args_options': (
194 'rootwait ro earlyprintk rootdelay = 1 fixrtc nocompcache '
195 'mem = 96M@0 mem_modem = 32M@96M mem = 44M@128M pmem = 22M@172M '
196 'mem = 30M@194M mem_mali = 32M@224M pmem_hwb = 54M@256M '
197 'hwmem = 48M@302M mem = 152M@360M'),
198 'boot_cmd': (
199 "setenv bootcmd 'fatload mmc 1:1 0x00100000 uImage; fatload mmc "122 "setenv bootcmd 'fatload mmc 1:1 0x00100000 uImage; fatload mmc "
200 "1:1 0x08000000 uInitrd; bootm 0x00100000 0x08000000'\nsetenv "123 "1:1 0x08000000 uInitrd; bootm 0x00100000 0x08000000'\nsetenv "
201 "bootargs ' console = tty0 console = ttyAMA2,115200n8 "124 "bootargs ' console = tty0 console = ttyAMA2,115200n8 "
@@ -203,160 +126,32 @@
203 "nocompcache mem = 96M@0 mem_modem = 32M@96M mem = 44M@128M "126 "nocompcache mem = 96M@0 mem_modem = 32M@96M mem = 44M@128M "
204 "pmem = 22M@172M mem = 30M@194M mem_mali = 32M@224M "127 "pmem = 22M@172M mem = 30M@194M mem_mali = 32M@224M "
205 "pmem_hwb = 54M@256M hwmem = 48M@302M mem = 152M@360M'\nboot"128 "pmem_hwb = 54M@256M hwmem = 48M@302M mem = 152M@360M'\nboot"
206 % ROOTFS_UUID),129 % ROOTFS_UUID)
207 'boot_script': 'flash.scr',130 self.assertEqual(expected, boot_cmd)
208 'fat_size': 32,
209 'initrd_addr': '0x08000000',
210 'kernel_addr': '0x00100000',
211 'load_addr': '0x00008000',
212 'mmc_option': '1:1',
213 'mmc_part_offset': 0,
214 'serial_opts': ' console = tty0 console = ttyAMA2,115200n8',
215 'sub_arch': 'ux500',
216 'uboot_flavor': None}
217
218 expected_vexpress_config = {
219 'boot_args_options': 'rootwait ro',
220 'boot_cmd': (
221 "setenv bootcmd 'fatload mmc 0:1 0x60008000 uImage; fatload mmc "
222 "0:1 0x81000000 uInitrd; bootm 0x60008000 0x81000000'\nsetenv "
223 "bootargs ' console = tty0 console = ttyAMA0,38400n8 "
224 "root=UUID=%s rootwait ro'\nboot" % ROOTFS_UUID),
225 'boot_script': None,
226 'fat_size': 16,
227 'initrd_addr': '0x81000000',
228 'kernel_addr': '0x60008000',
229 'load_addr': '0x60008000',
230 'mmc_option': '0:1',
231 'mmc_part_offset': 0,
232 'serial_opts': ' console = tty0 console = ttyAMA0,38400n8',
233 'sub_arch': 'linaro-vexpress',
234 'uboot_flavor': 'ca9x4_ct_vxp'}
235
236 expected_mx51evk_config = {
237 'boot_args_options': 'rootwait ro',
238 'boot_cmd': (
239 "setenv bootcmd 'fatload mmc 0:2 0x90000000 uImage; fatload mmc "
240 "0:2 0x90800000 uInitrd; bootm 0x90000000 0x90800000'\nsetenv "
241 "bootargs ' console = tty0 console = ttymxc0,115200n8 "
242 "root=UUID=%s rootwait ro'\nboot" % ROOTFS_UUID),
243 'boot_script': 'boot.scr',
244 'fat_size': 32,
245 'initrd_addr': '0x90800000',
246 'kernel_addr': '0x90000000',
247 'load_addr': '0x90008000',
248 'mmc_option': '0:2',
249 'mmc_part_offset': 1,
250 'serial_opts': ' console = tty0 console = ttymxc0,115200n8',
251 'sub_arch': 'linaro-mx51',
252 'uboot_flavor': None}
253
254 def test_unknown_board(self):
255 self.assertRaises(
256 ValueError, get_board_config, 'foobar', is_live=True,
257 is_lowmem=False, consoles=None)
258
259 def test_vexpress_live(self):
260 config = get_board_config(
261 'vexpress', is_live=True, is_lowmem=False, consoles=None)
262 expected = self.expected_vexpress_config.copy()
263 expected['boot_cmd'] = (
264 "setenv bootcmd 'fatload mmc 0:1 0x60008000 uImage; fatload mmc "
265 "0:1 0x81000000 uInitrd; bootm 0x60008000 0x81000000'\nsetenv "
266 "bootargs ' console = tty0 console = ttyAMA0,38400n8 "
267 "serialtty = ttyAMA0 boot=casper rootwait ro'\nboot")
268 expected['serial_opts'] = (
269 ' console = tty0 console = ttyAMA0,38400n8 serialtty = ttyAMA0')
270 self.assertThat(expected, IsEqualToDict(config))
271
272 def test_vexpress(self):
273 config = get_board_config(
274 'vexpress', is_live=False, is_lowmem=False, consoles=None)
275 self.assertThat(self.expected_vexpress_config, IsEqualToDict(config))
276
277 def test_mx51evk_live(self):
278 config = get_board_config(
279 'mx51evk', is_live=True, is_lowmem=False, consoles=None)
280 expected = self.expected_mx51evk_config.copy()
281 expected['boot_cmd'] = (
282 "setenv bootcmd 'fatload mmc 0:2 0x90000000 uImage; "
283 "fatload mmc 0:2 0x90800000 uInitrd; bootm 0x90000000 "
284 "0x90800000'\nsetenv bootargs ' console = tty0 "
285 "console = ttymxc0,115200n8 serialtty = ttymxc0 boot=casper "
286 "rootwait ro'\nboot")
287 expected['serial_opts'] = (
288 ' console = tty0 console = ttymxc0,115200n8 serialtty = ttymxc0')
289 self.assertThat(expected, IsEqualToDict(config))
290
291 def test_mx51evk(self):
292 config = get_board_config(
293 'mx51evk', is_live=False, is_lowmem=False, consoles=None)
294 self.assertThat(self.expected_mx51evk_config, IsEqualToDict(config))
295
296 def test_ux500_live(self):
297 config = get_board_config(
298 'ux500', is_live=True, is_lowmem=False, consoles=None)
299 boot_cmd = (
300 "setenv bootcmd 'fatload mmc 1:1 0x00100000 uImage; fatload "
301 "mmc 1:1 0x08000000 uInitrd; bootm 0x00100000 0x08000000'\n"
302 "setenv bootargs ' console = tty0 console = ttyAMA2,115200n8 "
303 "serialtty = ttyAMA2 boot=casper rootwait ro earlyprintk "
304 "rootdelay = 1 fixrtc nocompcache mem = 96M@0 "
305 "mem_modem = 32M@96M mem = 44M@128M pmem = 22M@172M "
306 "mem = 30M@194M mem_mali = 32M@224M pmem_hwb = 54M@256M "
307 "hwmem = 48M@302M mem = 152M@360M'\nboot")
308 expected = self.expected_ux500_config.copy()
309 expected['boot_cmd'] = boot_cmd
310 expected['serial_opts'] = (
311 ' console = tty0 console = ttyAMA2,115200n8 serialtty = ttyAMA2')
312 self.assertThat(expected, IsEqualToDict(config))
313
314 def test_ux500(self):
315 config = get_board_config(
316 'ux500', is_live=False, is_lowmem=False, consoles=None)
317 self.assertThat(self.expected_ux500_config, IsEqualToDict(config))
318131
319 def test_panda(self):132 def test_panda(self):
320 config = get_board_config(133 boot_cmd = board_configs['panda'].get_boot_cmd(
321 'panda', is_live=False, is_lowmem=False, consoles=None)134 is_live=False, is_lowmem=False, consoles=None)
322 self.assertThat(self.expected_panda_config, IsEqualToDict(config))135 expected = (
323136 "setenv bootcmd 'fatload mmc 0:1 0x80200000 uImage; fatload mmc "
324 def test_panda_live(self):137 "0:1 0x81600000 uInitrd; bootm 0x80200000 0x81600000'\nsetenv "
325 config = get_board_config(138 "bootargs ' console = tty0 console = ttyO2,115200n8 "
326 'panda', is_live=True, is_lowmem=False, consoles=None)139 "root=UUID=%s rootwait ro earlyprintk fixrtc nocompcache "
327 boot_cmd = (140 "vram = 32M omapfb.debug = y omapfb.vram = 0:8M mem = 463M "
328 "setenv bootcmd 'fatload mmc 0:1 0x80200000 uImage; "141 "ip = none'\nboot" % ROOTFS_UUID)
329 "fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80200000 "142 self.assertEqual(expected, boot_cmd)
330 "0x81600000'\nsetenv bootargs ' console = tty0 "
331 "console = ttyO2,115200n8 serialtty = ttyO2 boot=casper "
332 "rootwait ro earlyprintk fixrtc nocompcache vram = 32M "
333 "omapfb.debug = y omapfb.vram = 0:8M mem = 463M ip = none'\nboot")
334 expected = self.expected_panda_config.copy()
335 expected['boot_cmd'] = boot_cmd
336 expected['serial_opts'] = (
337 ' console = tty0 console = ttyO2,115200n8 serialtty = ttyO2')
338 self.assertThat(expected, IsEqualToDict(config))
339143
340 def test_beagle(self):144 def test_beagle(self):
341 config = get_board_config(145 boot_cmd = board_configs['beagle'].get_boot_cmd(
342 'beagle', is_live=False, is_lowmem=False, consoles=None)146 is_live=False, is_lowmem=False, consoles=None)
343 self.assertThat(self.expected_beagle_config, IsEqualToDict(config))147 expected = (
344
345 def test_beagle_live(self):
346 config = get_board_config(
347 'beagle', is_live=True, is_lowmem=False, consoles=None)
348 boot_cmd = (
349 "setenv bootcmd 'fatload mmc 0:1 0x80000000 uImage; "148 "setenv bootcmd 'fatload mmc 0:1 0x80000000 uImage; "
350 "fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80000000 "149 "fatload mmc 0:1 0x81600000 uInitrd; bootm 0x80000000 "
351 "0x81600000'\nsetenv bootargs ' console=tty0 "150 "0x81600000'\nsetenv bootargs ' console=tty0 "
352 "console=ttyS2,115200n8 serialtty=ttyS2 boot=casper rootwait ro "151 "console=ttyS2,115200n8 root=UUID=%s rootwait ro earlyprintk "
353 "earlyprintk fixrtc nocompcache vram=12M omapfb.debug=y "152 "fixrtc nocompcache vram=12M omapfb.debug=y "
354 "omapfb.mode=dvi:1280x720MR-16@60'\nboot")153 "omapfb.mode=dvi:1280x720MR-16@60'\nboot" % ROOTFS_UUID)
355 expected = self.expected_beagle_config.copy()154 self.assertEqual(expected, boot_cmd)
356 expected['boot_cmd'] = boot_cmd
357 expected['serial_opts'] = (
358 ' console=tty0 console=ttyS2,115200n8 serialtty=ttyS2')
359 self.assertThat(expected, IsEqualToDict(config))
360155
361156
362class TestRemoveBinaryDir(TestCaseWithFixtures):157class TestRemoveBinaryDir(TestCaseWithFixtures):

Subscribers

People subscribed via source and target branches