Merge lp:~milo/linaro-image-tools/android-hwpack into lp:linaro-image-tools/11.11
- android-hwpack
- Merge into trunk
Status: | Rejected |
---|---|
Rejected by: | Milo Casagrande |
Proposed branch: | lp:~milo/linaro-image-tools/android-hwpack |
Merge into: | lp:linaro-image-tools/11.11 |
Diff against target: |
5512 lines (+1928/-1614) 12 files modified
linaro-android-media-create (+15/-9) linaro-media-create (+3/-3) linaro_image_tools/hwpack/handler.py (+292/-0) linaro_image_tools/hwpack/hwpack_fields.py (+7/-3) linaro_image_tools/hwpack/hwpack_reader.py (+1/-1) linaro_image_tools/media_create/__init__.py (+4/-3) linaro_image_tools/media_create/android_boards.py (+219/-157) linaro_image_tools/media_create/boards.py (+787/-1017) linaro_image_tools/media_create/chroot_utils.py (+1/-1) linaro_image_tools/media_create/tests/__init__.py (+4/-2) linaro_image_tools/media_create/tests/test_android_boards.py (+249/-0) linaro_image_tools/media_create/tests/test_media_create.py (+346/-418) |
To merge this branch: | bzr merge lp:~milo/linaro-image-tools/android-hwpack |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Данило Шеган (community) | Disapprove | ||
Review via email: mp+135109@code.launchpad.net |
Commit message
Description of the change
Данило Шеган (danilo) wrote : | # |
Oh, and we should keep all the android_boards.py settings in: when no hwpack-like files are used, we should still be able to build older android images and similar.
Milo Casagrande (milo) wrote : | # |
On Thu, Nov 22, 2012 at 2:44 PM, Данило Шеган <email address hidden> wrote:
> Review: Disapprove
>
> A few things on this branch:
>
> * it needs to be split up into more manageable branches (I said this a few times already)—take the "mechanical" changes out and put them into a branch of it's own (moving code around and enabling use of instances instead of classes all belongs in either one or two separate branches).
> * land bits and pieces that can land asap.
Indeed, it was not my intention to propose that branch for review, I
wanted to have a place where to store all for the moment, since I
wouldn't be able to complete it all in time.
I will split out the changes and start with the ones that should not
introduce errors or problems to other parts.
> * extracted configs contain only the 'final' class elements, not anything out of parent classes.
Yes, I'm not sure about this point though. I need to pick-up again
disucssions with Vishal if they want to have the full blown
configuration, or just a small subset and rely on the other
"defaults".
Ciao.
--
Milo Casagrande
Infrastructure Engineer
Linaro.org <www.linaro.org> │ Open source software for ARM SoCs
Unmerged revisions
- 617. By Milo Casagrande
-
Added new tests.
- 616. By Milo Casagrande
-
Fixed more tests.
- 615. By Milo Casagrande
-
Fixed more tests, 50 to go.
- 614. By Milo Casagrande
-
Fixed even more tests.
- 613. By Milo Casagrande
-
Fixed more tests.
- 612. By Milo Casagrande
-
Added fields.
- 611. By Milo Casagrande
-
Continued refactoring.
- 610. By Milo Casagrande
-
Started to fix tests.
- 609. By Milo Casagrande
-
Continue refactoring.
- 608. By Milo Casagrande
-
Continue refactoring, added TODOs.
Preview Diff
1 | === modified file 'linaro-android-media-create' | |||
2 | --- linaro-android-media-create 2012-07-26 08:48:15 +0000 | |||
3 | +++ linaro-android-media-create 2012-11-20 10:49:03 +0000 | |||
4 | @@ -26,7 +26,7 @@ | |||
5 | 26 | from linaro_image_tools import cmd_runner | 26 | from linaro_image_tools import cmd_runner |
6 | 27 | 27 | ||
7 | 28 | from linaro_image_tools.media_create.android_boards import ( | 28 | from linaro_image_tools.media_create.android_boards import ( |
9 | 29 | android_board_configs, | 29 | get_board_config, |
10 | 30 | ) | 30 | ) |
11 | 31 | from linaro_image_tools.media_create.check_device import ( | 31 | from linaro_image_tools.media_create.check_device import ( |
12 | 32 | confirm_device_selection_and_ensure_it_is_ready) | 32 | confirm_device_selection_and_ensure_it_is_ready) |
13 | @@ -40,8 +40,10 @@ | |||
14 | 40 | unpack_android_binary_tarball | 40 | unpack_android_binary_tarball |
15 | 41 | ) | 41 | ) |
16 | 42 | from linaro_image_tools.media_create import get_android_args_parser | 42 | from linaro_image_tools.media_create import get_android_args_parser |
19 | 43 | from linaro_image_tools.utils import ensure_command | 43 | from linaro_image_tools.utils import ( |
20 | 44 | 44 | ensure_command, | |
21 | 45 | get_logger | ||
22 | 46 | ) | ||
23 | 45 | 47 | ||
24 | 46 | 48 | ||
25 | 47 | # Just define the global variables | 49 | # Just define the global variables |
26 | @@ -89,6 +91,8 @@ | |||
27 | 89 | parser = get_android_args_parser() | 91 | parser = get_android_args_parser() |
28 | 90 | args = parser.parse_args() | 92 | args = parser.parse_args() |
29 | 91 | 93 | ||
30 | 94 | logger = get_logger(debug=args.debug) | ||
31 | 95 | |||
32 | 92 | # If --help was specified this won't execute. | 96 | # If --help was specified this won't execute. |
33 | 93 | # Create temp dir and initialize rest of path vars. | 97 | # Create temp dir and initialize rest of path vars. |
34 | 94 | TMP_DIR = tempfile.mkdtemp() | 98 | TMP_DIR = tempfile.mkdtemp() |
35 | @@ -102,13 +106,15 @@ | |||
36 | 102 | DATA_DISK = os.path.join(TMP_DIR, 'userdata-disc') | 106 | DATA_DISK = os.path.join(TMP_DIR, 'userdata-disc') |
37 | 103 | SDCARD_DISK = os.path.join(TMP_DIR, 'sdcard-disc') | 107 | SDCARD_DISK = os.path.join(TMP_DIR, 'sdcard-disc') |
38 | 104 | 108 | ||
40 | 105 | board_config = android_board_configs[args.dev] | 109 | board_config = get_board_config(args.dev) |
41 | 110 | board_config.from_file(args.hwpack) | ||
42 | 106 | board_config.add_boot_args(args.extra_boot_args) | 111 | board_config.add_boot_args(args.extra_boot_args) |
43 | 107 | board_config.add_boot_args_from_file(args.extra_boot_args_file) | 112 | board_config.add_boot_args_from_file(args.extra_boot_args_file) |
44 | 108 | 113 | ||
45 | 109 | if args.dev == 'iMX53': | 114 | if args.dev == 'iMX53': |
46 | 110 | # XXX: remove this and the corresponding entry in android_board_configs | 115 | # XXX: remove this and the corresponding entry in android_board_configs |
48 | 111 | print "DEPRECATION WARNING: iMX53 is deprecated, please use mx53loco." | 116 | logger.warning("DEPRECATION WARNING: iMX53 is deprecated, please " |
49 | 117 | "use mx53loco.") | ||
50 | 112 | 118 | ||
51 | 113 | ensure_required_commands(args) | 119 | ensure_required_commands(args) |
52 | 114 | 120 | ||
53 | @@ -117,11 +123,11 @@ | |||
54 | 117 | if not confirm_device_selection_and_ensure_it_is_ready(args.device): | 123 | if not confirm_device_selection_and_ensure_it_is_ready(args.device): |
55 | 118 | sys.exit(1) | 124 | sys.exit(1) |
56 | 119 | elif not args.should_create_partitions: | 125 | elif not args.should_create_partitions: |
58 | 120 | print ("Do not use --no-part in conjunction with --image_file.") | 126 | logger.error("Do not use --no-part in conjunction with --image_file.") |
59 | 121 | sys.exit(1) | 127 | sys.exit(1) |
63 | 122 | else: | 128 | # else: |
64 | 123 | # All good, move on. | 129 | # # All good, move on. |
65 | 124 | pass | 130 | # pass |
66 | 125 | 131 | ||
67 | 126 | cmd_runner.run(['mkdir', '-p', BOOT_DIR]).wait() | 132 | cmd_runner.run(['mkdir', '-p', BOOT_DIR]).wait() |
68 | 127 | cmd_runner.run(['mkdir', '-p', SYSTEM_DIR]).wait() | 133 | cmd_runner.run(['mkdir', '-p', SYSTEM_DIR]).wait() |
69 | 128 | 134 | ||
70 | === modified file 'linaro-media-create' | |||
71 | --- linaro-media-create 2012-10-22 06:57:20 +0000 | |||
72 | +++ linaro-media-create 2012-11-20 10:49:03 +0000 | |||
73 | @@ -25,7 +25,7 @@ | |||
74 | 25 | 25 | ||
75 | 26 | from linaro_image_tools import cmd_runner | 26 | from linaro_image_tools import cmd_runner |
76 | 27 | 27 | ||
78 | 28 | from linaro_image_tools.media_create.boards import board_configs | 28 | from linaro_image_tools.media_create.boards import get_board_config |
79 | 29 | from linaro_image_tools.media_create.check_device import ( | 29 | from linaro_image_tools.media_create.check_device import ( |
80 | 30 | confirm_device_selection_and_ensure_it_is_ready) | 30 | confirm_device_selection_and_ensure_it_is_ready) |
81 | 31 | from linaro_image_tools.media_create.chroot_utils import ( | 31 | from linaro_image_tools.media_create.chroot_utils import ( |
82 | @@ -131,9 +131,9 @@ | |||
83 | 131 | logger.error(e.value) | 131 | logger.error(e.value) |
84 | 132 | sys.exit(1) | 132 | sys.exit(1) |
85 | 133 | 133 | ||
87 | 134 | board_config = board_configs[args.dev] | 134 | board_config = get_board_config(args.dev) |
88 | 135 | board_config.set_metadata(args.hwpacks, args.bootloader, args.dev) | 135 | board_config.set_metadata(args.hwpacks, args.bootloader, args.dev) |
90 | 136 | board_config.set_board(args.dev) | 136 | board_config.board(args.dev) |
91 | 137 | board_config.add_boot_args(args.extra_boot_args) | 137 | board_config.add_boot_args(args.extra_boot_args) |
92 | 138 | board_config.add_boot_args_from_file(args.extra_boot_args_file) | 138 | board_config.add_boot_args_from_file(args.extra_boot_args_file) |
93 | 139 | 139 | ||
94 | 140 | 140 | ||
95 | === added file 'linaro_image_tools/hwpack/handler.py' | |||
96 | --- linaro_image_tools/hwpack/handler.py 1970-01-01 00:00:00 +0000 | |||
97 | +++ linaro_image_tools/hwpack/handler.py 2012-11-20 10:49:03 +0000 | |||
98 | @@ -0,0 +1,292 @@ | |||
99 | 1 | # Copyright (C) 2010, 2011 Linaro | ||
100 | 2 | # | ||
101 | 3 | # Author: Guilherme Salgado <guilherme.salgado@linaro.org> | ||
102 | 4 | # | ||
103 | 5 | # This file is part of Linaro Image Tools. | ||
104 | 6 | # | ||
105 | 7 | # Linaro Image Tools is free software: you can redistribute it and/or modify | ||
106 | 8 | # it under the terms of the GNU General Public License as published by | ||
107 | 9 | # the Free Software Foundation, either version 3 of the License, or | ||
108 | 10 | # (at your option) any later version. | ||
109 | 11 | # | ||
110 | 12 | # Linaro Image Tools is distributed in the hope that it will be useful, | ||
111 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
112 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
113 | 15 | # GNU General Public License for more details. | ||
114 | 16 | # | ||
115 | 17 | # You should have received a copy of the GNU General Public License | ||
116 | 18 | # along with Linaro Image Tools. If not, see <http://www.gnu.org/licenses/>. | ||
117 | 19 | |||
118 | 20 | from StringIO import StringIO | ||
119 | 21 | import ConfigParser | ||
120 | 22 | import logging | ||
121 | 23 | import os | ||
122 | 24 | import re | ||
123 | 25 | import shutil | ||
124 | 26 | import tarfile | ||
125 | 27 | import tempfile | ||
126 | 28 | |||
127 | 29 | from linaro_image_tools.hwpack.config import Config | ||
128 | 30 | from linaro_image_tools.hwpack.builder import PackageUnpacker | ||
129 | 31 | from linaro_image_tools.utils import DEFAULT_LOGGER_NAME | ||
130 | 32 | |||
131 | 33 | |||
132 | 34 | logger = logging.getLogger(DEFAULT_LOGGER_NAME) | ||
133 | 35 | |||
134 | 36 | |||
135 | 37 | class HardwarepackHandler(object): | ||
136 | 38 | FORMAT_1 = '1.0' | ||
137 | 39 | FORMAT_2 = '2.0' | ||
138 | 40 | FORMAT_3 = '3.0' | ||
139 | 41 | FORMAT_MIXED = '1.0and2.0' | ||
140 | 42 | metadata_filename = 'metadata' | ||
141 | 43 | format_filename = 'FORMAT' | ||
142 | 44 | main_section = 'main' | ||
143 | 45 | hwpack_tarfiles = [] | ||
144 | 46 | tempdir = None | ||
145 | 47 | |||
146 | 48 | def __init__(self, hwpacks, bootloader=None, board=None): | ||
147 | 49 | self.hwpacks = hwpacks | ||
148 | 50 | self.hwpack_tarfiles = [] | ||
149 | 51 | self.bootloader = bootloader | ||
150 | 52 | self.board = board | ||
151 | 53 | self.tempdirs = {} | ||
152 | 54 | # Used to store the config created from the metadata. | ||
153 | 55 | self.config = None | ||
154 | 56 | |||
155 | 57 | class FakeSecHead(object): | ||
156 | 58 | """ Add a fake section header to the metadata file. | ||
157 | 59 | |||
158 | 60 | This is done so we can use ConfigParser to parse the file. | ||
159 | 61 | """ | ||
160 | 62 | def __init__(self, fp): | ||
161 | 63 | self.fp = fp | ||
162 | 64 | self.sechead = '[%s]\n' % HardwarepackHandler.main_section | ||
163 | 65 | |||
164 | 66 | def readline(self): | ||
165 | 67 | if self.sechead: | ||
166 | 68 | try: | ||
167 | 69 | return self.sechead | ||
168 | 70 | finally: | ||
169 | 71 | self.sechead = None | ||
170 | 72 | else: | ||
171 | 73 | return self.fp.readline() | ||
172 | 74 | |||
173 | 75 | def __enter__(self): | ||
174 | 76 | self.tempdir = tempfile.mkdtemp() | ||
175 | 77 | for hwpack in self.hwpacks: | ||
176 | 78 | hwpack_tarfile = tarfile.open(hwpack, mode='r:gz') | ||
177 | 79 | self.hwpack_tarfiles.append(hwpack_tarfile) | ||
178 | 80 | return self | ||
179 | 81 | |||
180 | 82 | def __exit__(self, type, value, traceback): | ||
181 | 83 | for hwpack_tarfile in self.hwpack_tarfiles: | ||
182 | 84 | if hwpack_tarfile is not None: | ||
183 | 85 | hwpack_tarfile.close() | ||
184 | 86 | self.hwpack_tarfiles = [] | ||
185 | 87 | if self.tempdir is not None and os.path.exists(self.tempdir): | ||
186 | 88 | shutil.rmtree(self.tempdir) | ||
187 | 89 | |||
188 | 90 | for name in self.tempdirs: | ||
189 | 91 | tempdir = self.tempdirs[name] | ||
190 | 92 | if tempdir is not None and os.path.exists(tempdir): | ||
191 | 93 | shutil.rmtree(tempdir) | ||
192 | 94 | |||
193 | 95 | def _get_config_from_metadata(self, metadata): | ||
194 | 96 | """ | ||
195 | 97 | Retrieves a Config object associated with the metadata. | ||
196 | 98 | |||
197 | 99 | :param metadata: The metadata to parse. | ||
198 | 100 | :return: A Config instance. | ||
199 | 101 | """ | ||
200 | 102 | if not self.config: | ||
201 | 103 | lines = metadata.readlines() | ||
202 | 104 | if re.search("=", lines[0]) and not re.search(":", lines[0]): | ||
203 | 105 | # Probably V2 hardware pack without [hwpack] on the first line | ||
204 | 106 | lines = ["[hwpack]\n"] + lines | ||
205 | 107 | self.config = Config(StringIO("".join(lines))) | ||
206 | 108 | self.config.set_board(self.board) | ||
207 | 109 | self.config.set_bootloader(self.bootloader) | ||
208 | 110 | return self.config | ||
209 | 111 | |||
210 | 112 | def get_field(self, field, return_keys=False): | ||
211 | 113 | data = None | ||
212 | 114 | hwpack_with_data = None | ||
213 | 115 | keys = None | ||
214 | 116 | for hwpack_tarfile in self.hwpack_tarfiles: | ||
215 | 117 | metadata = hwpack_tarfile.extractfile(self.metadata_filename) | ||
216 | 118 | parser = self._get_config_from_metadata(metadata) | ||
217 | 119 | try: | ||
218 | 120 | new_data = parser.get_option(field) | ||
219 | 121 | if new_data is not None: | ||
220 | 122 | assert data is None, "The metadata field '%s' is set to " \ | ||
221 | 123 | "'%s' and new value '%s' is found" % (field, data, | ||
222 | 124 | new_data) | ||
223 | 125 | data = new_data | ||
224 | 126 | hwpack_with_data = hwpack_tarfile | ||
225 | 127 | if return_keys: | ||
226 | 128 | keys = parser.get_last_used_keys() | ||
227 | 129 | except ConfigParser.NoOptionError: | ||
228 | 130 | continue | ||
229 | 131 | |||
230 | 132 | if return_keys: | ||
231 | 133 | return data, hwpack_with_data, keys | ||
232 | 134 | return data, hwpack_with_data | ||
233 | 135 | |||
234 | 136 | def get_format(self): | ||
235 | 137 | format = None | ||
236 | 138 | supported_formats = [self.FORMAT_1, self.FORMAT_2, self.FORMAT_3] | ||
237 | 139 | for hwpack_tarfile in self.hwpack_tarfiles: | ||
238 | 140 | format_file = hwpack_tarfile.extractfile(self.format_filename) | ||
239 | 141 | format_string = format_file.read().strip() | ||
240 | 142 | if not format_string in supported_formats: | ||
241 | 143 | raise AssertionError( | ||
242 | 144 | "Format version '%s' is not supported." % format_string) | ||
243 | 145 | if format is None: | ||
244 | 146 | format = format_string | ||
245 | 147 | elif format != format_string: | ||
246 | 148 | return self.FORMAT_MIXED | ||
247 | 149 | return format | ||
248 | 150 | |||
249 | 151 | def get_file(self, file_alias): | ||
250 | 152 | """Get file(s) from a hwpack. | ||
251 | 153 | :param file_alias: Property name (not field name) which contains | ||
252 | 154 | file reference(s) | ||
253 | 155 | :return: path to a file or list of paths to files | ||
254 | 156 | """ | ||
255 | 157 | file_names, hwpack_tarfile, keys = self.get_field(file_alias, | ||
256 | 158 | return_keys=True) | ||
257 | 159 | if not file_names: | ||
258 | 160 | return file_names | ||
259 | 161 | single = False | ||
260 | 162 | if not isinstance(file_names, list): | ||
261 | 163 | single = True | ||
262 | 164 | file_names = [file_names] | ||
263 | 165 | out_files = [] | ||
264 | 166 | |||
265 | 167 | # Depending on if board and/or bootloader were used to look up the | ||
266 | 168 | # file we are getting, we need to prepend those names to the path | ||
267 | 169 | # to get the correct extracted file from the hardware pack. | ||
268 | 170 | config_names = [("board", "boards"), ("bootloader", "bootloaders")] | ||
269 | 171 | base_path = "" | ||
270 | 172 | if keys: | ||
271 | 173 | # If keys is non-empty, we have a V3 config option that was | ||
272 | 174 | # modified by the bootloader and/or boot option... | ||
273 | 175 | for name, key in config_names: | ||
274 | 176 | if self.get_field(name): | ||
275 | 177 | value = self.get_field(name)[0] | ||
276 | 178 | if keys[0] == key: | ||
277 | 179 | base_path = os.path.join(base_path, value) | ||
278 | 180 | keys = keys[1:] | ||
279 | 181 | |||
280 | 182 | for f in file_names: | ||
281 | 183 | # Check that the base path is needed. If the file doesn't exist, | ||
282 | 184 | # try without it (this provides fallback to V2 style directory | ||
283 | 185 | # layouts with a V3 config). | ||
284 | 186 | path_inc_board_and_bootloader = os.path.join(base_path, f) | ||
285 | 187 | if path_inc_board_and_bootloader in hwpack_tarfile.getnames(): | ||
286 | 188 | f = path_inc_board_and_bootloader | ||
287 | 189 | hwpack_tarfile.extract(f, self.tempdir) | ||
288 | 190 | f = os.path.join(self.tempdir, f) | ||
289 | 191 | out_files.append(f) | ||
290 | 192 | if single: | ||
291 | 193 | return out_files[0] | ||
292 | 194 | return out_files | ||
293 | 195 | |||
294 | 196 | def list_packages(self): | ||
295 | 197 | """Return list of (package names, TarFile object containing them)""" | ||
296 | 198 | packages = [] | ||
297 | 199 | for tf in self.hwpack_tarfiles: | ||
298 | 200 | for name in tf.getnames(): | ||
299 | 201 | if name.startswith("pkgs/") and name.endswith(".deb"): | ||
300 | 202 | packages.append((tf, name)) | ||
301 | 203 | return packages | ||
302 | 204 | |||
303 | 205 | def find_package_for(self, name, version=None, revision=None, | ||
304 | 206 | architecture=None): | ||
305 | 207 | """Find a package that matches the name, version, rev and arch given. | ||
306 | 208 | |||
307 | 209 | Packages are named according to the debian specification: | ||
308 | 210 | http://www.debian.org/doc/manuals/debian-faq/ch-pkg_basics.en.html | ||
309 | 211 | <name>_<Version>-<DebianRevisionNumber>_<DebianArchitecture>.deb | ||
310 | 212 | DebianRevisionNumber seems to be optional. | ||
311 | 213 | Use this spec to return a package matching the requirements given. | ||
312 | 214 | """ | ||
313 | 215 | for tar_file, package in self.list_packages(): | ||
314 | 216 | file_name = os.path.basename(package) | ||
315 | 217 | dpkg_chunks = re.search("^(.+)_(.+)_(.+)\.deb$", | ||
316 | 218 | file_name) | ||
317 | 219 | assert dpkg_chunks, "Could not split package file name into"\ | ||
318 | 220 | "<name>_<Version>_<DebianArchitecture>.deb" | ||
319 | 221 | |||
320 | 222 | pkg_name = dpkg_chunks.group(1) | ||
321 | 223 | pkg_version = dpkg_chunks.group(2) | ||
322 | 224 | pkg_architecture = dpkg_chunks.group(3) | ||
323 | 225 | |||
324 | 226 | ver_chunks = re.search("^(.+)-(.+)$", pkg_version) | ||
325 | 227 | if ver_chunks: | ||
326 | 228 | pkg_version = ver_chunks.group(1) | ||
327 | 229 | pkg_revision = ver_chunks.group(2) | ||
328 | 230 | else: | ||
329 | 231 | pkg_revision = None | ||
330 | 232 | |||
331 | 233 | if name != pkg_name: | ||
332 | 234 | continue | ||
333 | 235 | if version != None and str(version) != pkg_version: | ||
334 | 236 | continue | ||
335 | 237 | if revision != None and str(revision) != pkg_revision: | ||
336 | 238 | continue | ||
337 | 239 | if (architecture != None and | ||
338 | 240 | str(architecture) != pkg_architecture): | ||
339 | 241 | continue | ||
340 | 242 | |||
341 | 243 | # Got a matching package - return its path inside the tarball | ||
342 | 244 | return tar_file, package | ||
343 | 245 | |||
344 | 246 | # Failed to find a matching package - return None | ||
345 | 247 | return None | ||
346 | 248 | |||
347 | 249 | def get_file_from_package(self, file_path, package_name, | ||
348 | 250 | package_version=None, package_revision=None, | ||
349 | 251 | package_architecture=None): | ||
350 | 252 | """Extract named file from package specified by name, ver, rev, arch. | ||
351 | 253 | |||
352 | 254 | File is extracted from the package matching the given specification | ||
353 | 255 | to a temporary directory. The absolute path to the extracted file is | ||
354 | 256 | returned. | ||
355 | 257 | """ | ||
356 | 258 | |||
357 | 259 | package_info = self.find_package_for(package_name, | ||
358 | 260 | package_version, | ||
359 | 261 | package_revision, | ||
360 | 262 | package_architecture) | ||
361 | 263 | if package_info is None: | ||
362 | 264 | return None | ||
363 | 265 | tar_file, package = package_info | ||
364 | 266 | |||
365 | 267 | # Avoid unpacking hardware pack more than once by assigning each one | ||
366 | 268 | # its own tempdir to unpack into. | ||
367 | 269 | # TODO: update logic that uses self.tempdir so we can get rid of this | ||
368 | 270 | # by sharing nicely. | ||
369 | 271 | if not package in self.tempdirs: | ||
370 | 272 | self.tempdirs[package] = tempfile.mkdtemp() | ||
371 | 273 | tempdir = self.tempdirs[package] | ||
372 | 274 | |||
373 | 275 | # We extract everything in the hardware pack so we don't have to worry | ||
374 | 276 | # about chasing links (extract a link, find where it points to, extract | ||
375 | 277 | # that...). This is slower, but more reliable. | ||
376 | 278 | tar_file.extractall(tempdir) | ||
377 | 279 | package_path = os.path.join(tempdir, package) | ||
378 | 280 | |||
379 | 281 | with PackageUnpacker() as self.package_unpacker: | ||
380 | 282 | extracted_file = self.package_unpacker.get_file(package_path, | ||
381 | 283 | file_path) | ||
382 | 284 | after_tmp = re.sub(self.package_unpacker.tempdir, "", | ||
383 | 285 | extracted_file).lstrip("/\\") | ||
384 | 286 | extract_dir = os.path.join(tempdir, "extracted", | ||
385 | 287 | os.path.dirname(after_tmp)) | ||
386 | 288 | os.makedirs(extract_dir) | ||
387 | 289 | shutil.move(extracted_file, extract_dir) | ||
388 | 290 | extracted_file = os.path.join(extract_dir, | ||
389 | 291 | os.path.basename(extracted_file)) | ||
390 | 292 | return extracted_file | ||
391 | 0 | 293 | ||
392 | === modified file 'linaro_image_tools/hwpack/hwpack_fields.py' | |||
393 | --- linaro_image_tools/hwpack/hwpack_fields.py 2012-10-02 14:53:56 +0000 | |||
394 | +++ linaro_image_tools/hwpack/hwpack_fields.py 2012-11-20 10:49:03 +0000 | |||
395 | @@ -86,10 +86,14 @@ | |||
396 | 86 | METADATA_VERSION_FIELD = 'version' | 86 | METADATA_VERSION_FIELD = 'version' |
397 | 87 | 87 | ||
398 | 88 | # The allowed partition layouts. | 88 | # The allowed partition layouts. |
399 | 89 | BOOTFS16 = 'bootfs16_rootfs' | ||
400 | 90 | BOOTFS = 'bootfs_rootfs' | ||
401 | 91 | RESERVED_BOOTFS = 'reserved_bootfs_rootfs' | ||
402 | 92 | |||
403 | 89 | DEFINED_PARTITION_LAYOUTS = [ | 93 | DEFINED_PARTITION_LAYOUTS = [ |
407 | 90 | 'bootfs16_rootfs', | 94 | BOOTFS16, |
408 | 91 | 'bootfs_rootfs', | 95 | BOOTFS, |
409 | 92 | 'reserved_bootfs_rootfs', ] | 96 | RESERVED_BOOTFS, ] |
410 | 93 | 97 | ||
411 | 94 | # Supported bootloaders | 98 | # Supported bootloaders |
412 | 95 | U_BOOT = 'u_boot' | 99 | U_BOOT = 'u_boot' |
413 | 96 | 100 | ||
414 | === modified file 'linaro_image_tools/hwpack/hwpack_reader.py' | |||
415 | --- linaro_image_tools/hwpack/hwpack_reader.py 2012-07-25 13:05:16 +0000 | |||
416 | +++ linaro_image_tools/hwpack/hwpack_reader.py 2012-11-20 10:49:03 +0000 | |||
417 | @@ -17,7 +17,7 @@ | |||
418 | 17 | # You should have received a copy of the GNU General Public License | 17 | # You should have received a copy of the GNU General Public License |
419 | 18 | # along with Linaro Image Tools. If not, see <http://www.gnu.org/licenses/>. | 18 | # along with Linaro Image Tools. If not, see <http://www.gnu.org/licenses/>. |
420 | 19 | 19 | ||
422 | 20 | from linaro_image_tools.media_create.boards import HardwarepackHandler | 20 | from linaro_image_tools.hwpack.handler import HardwarepackHandler |
423 | 21 | from linaro_image_tools.hwpack.hwpack_fields import ( | 21 | from linaro_image_tools.hwpack.hwpack_fields import ( |
424 | 22 | FORMAT_FIELD, | 22 | FORMAT_FIELD, |
425 | 23 | NAME_FIELD, | 23 | NAME_FIELD, |
426 | 24 | 24 | ||
427 | === modified file 'linaro_image_tools/media_create/__init__.py' | |||
428 | --- linaro_image_tools/media_create/__init__.py 2012-10-22 06:57:20 +0000 | |||
429 | +++ linaro_image_tools/media_create/__init__.py 2012-11-20 10:49:03 +0000 | |||
430 | @@ -78,6 +78,7 @@ | |||
431 | 78 | parser.add_argument( | 78 | parser.add_argument( |
432 | 79 | '--extra-boot-args-file', dest='extra_boot_args_file', | 79 | '--extra-boot-args-file', dest='extra_boot_args_file', |
433 | 80 | required=False, help=('File containing extra boot arguments.')) | 80 | required=False, help=('File containing extra boot arguments.')) |
434 | 81 | parser.add_argument("--debug", action="store_true") | ||
435 | 81 | 82 | ||
436 | 82 | 83 | ||
437 | 83 | def get_args_parser(): | 84 | def get_args_parser(): |
438 | @@ -173,7 +174,6 @@ | |||
439 | 173 | help="Select a bootloader from a hardware pack that contains more " | 174 | help="Select a bootloader from a hardware pack that contains more " |
440 | 174 | "than one. If not specified, it will default to '%s'." % | 175 | "than one. If not specified, it will default to '%s'." % |
441 | 175 | DEFAULT_BOOTLOADER) | 176 | DEFAULT_BOOTLOADER) |
442 | 176 | parser.add_argument("--debug", action="store_true") | ||
443 | 177 | 177 | ||
444 | 178 | add_common_options(parser) | 178 | add_common_options(parser) |
445 | 179 | return parser | 179 | return parser |
446 | @@ -189,6 +189,9 @@ | |||
447 | 189 | '--image-file', '--image_file', dest='device', | 189 | '--image-file', '--image_file', dest='device', |
448 | 190 | help='File where we should write the image file.') | 190 | help='File where we should write the image file.') |
449 | 191 | parser.add_argument( | 191 | parser.add_argument( |
450 | 192 | '--hwpack', required=True, | ||
451 | 193 | help=('An Android hardware pack file with the board configuration.')) | ||
452 | 194 | parser.add_argument( | ||
453 | 192 | '--image-size', '--image_size', default='2G', | 195 | '--image-size', '--image_size', default='2G', |
454 | 193 | help=('The image size, specified in mega/giga bytes (e.g. 3000M or ' | 196 | help=('The image size, specified in mega/giga bytes (e.g. 3000M or ' |
455 | 194 | '3G); use with --image_file only')) | 197 | '3G); use with --image_file only')) |
456 | @@ -202,7 +205,6 @@ | |||
457 | 202 | '--console', action='append', dest='consoles', default=[], | 205 | '--console', action='append', dest='consoles', default=[], |
458 | 203 | help=('Add a console to kernel boot parameter; this parameter can be ' | 206 | help=('Add a console to kernel boot parameter; this parameter can be ' |
459 | 204 | 'defined multiple times.')) | 207 | 'defined multiple times.')) |
460 | 205 | |||
461 | 206 | parser.add_argument( | 208 | parser.add_argument( |
462 | 207 | '--system', default='system.tar.bz2', required=True, | 209 | '--system', default='system.tar.bz2', required=True, |
463 | 208 | help=('The tarball containing the Android system paritition')) | 210 | help=('The tarball containing the Android system paritition')) |
464 | @@ -212,7 +214,6 @@ | |||
465 | 212 | parser.add_argument( | 214 | parser.add_argument( |
466 | 213 | '--boot', default='boot.tar.bz2', required=True, | 215 | '--boot', default='boot.tar.bz2', required=True, |
467 | 214 | help=('The tarball containing the Android root partition')) | 216 | help=('The tarball containing the Android root partition')) |
468 | 215 | |||
469 | 216 | parser.add_argument( | 217 | parser.add_argument( |
470 | 217 | '--no-part', dest='should_create_partitions', action='store_false', | 218 | '--no-part', dest='should_create_partitions', action='store_false', |
471 | 218 | help='Reuse existing partitions on the given media.') | 219 | help='Reuse existing partitions on the given media.') |
472 | 219 | 220 | ||
473 | === modified file 'linaro_image_tools/media_create/android_boards.py' | |||
474 | --- linaro_image_tools/media_create/android_boards.py 2012-10-17 10:48:49 +0000 | |||
475 | +++ linaro_image_tools/media_create/android_boards.py 2012-11-20 10:49:03 +0000 | |||
476 | @@ -20,44 +20,131 @@ | |||
477 | 20 | """Configuration for boards supported by linaro-android-media-create. | 20 | """Configuration for boards supported by linaro-android-media-create. |
478 | 21 | 21 | ||
479 | 22 | To add support for a new board, you need to create a subclass of | 22 | To add support for a new board, you need to create a subclass of |
482 | 23 | AndroidBoardConfig, set appropriate values for its variables and add it to | 23 | AndroidBoardConfig, create an Android hwpack as explained here: |
483 | 24 | android_board_configs at the bottom of this file. | 24 | |
484 | 25 | https://wiki.linaro.org/AndroidHardwarePacksV3 | ||
485 | 26 | |||
486 | 27 | and add the board to 'android_board_configs' at the end of this file. | ||
487 | 25 | """ | 28 | """ |
488 | 26 | 29 | ||
489 | 30 | import os | ||
490 | 31 | import yaml | ||
491 | 32 | import logging | ||
492 | 33 | |||
493 | 34 | from linaro_image_tools import cmd_runner | ||
494 | 27 | from linaro_image_tools.media_create.partitions import SECTOR_SIZE | 35 | from linaro_image_tools.media_create.partitions import SECTOR_SIZE |
495 | 28 | from linaro_image_tools.media_create.boards import PART_ALIGN_S | ||
496 | 29 | from linaro_image_tools.media_create.boards import BeagleConfig | ||
497 | 30 | from linaro_image_tools.media_create.boards import PandaConfig | ||
498 | 31 | from linaro_image_tools.media_create.boards import Mx53LoCoConfig | ||
499 | 32 | from linaro_image_tools.media_create.boards import SnowballSdConfig | ||
500 | 33 | from linaro_image_tools.media_create.boards import SnowballEmmcConfig | ||
501 | 34 | from linaro_image_tools.media_create.boards import SMDKV310Config | ||
502 | 35 | from linaro_image_tools.media_create.boards import OrigenConfig | ||
503 | 36 | from linaro_image_tools.media_create.boards import VexpressConfig | ||
504 | 37 | from linaro_image_tools.media_create.boards import ( | 36 | from linaro_image_tools.media_create.boards import ( |
505 | 37 | BeagleConfig, | ||
506 | 38 | BoardConfig, | ||
507 | 39 | BoardConfigException, | ||
508 | 40 | Mx53LoCoConfig, | ||
509 | 41 | OrigenConfig, | ||
510 | 42 | PART_ALIGN_S, | ||
511 | 43 | PandaConfig, | ||
512 | 44 | SMDKV310Config, | ||
513 | 45 | SnowballEmmcConfig, | ||
514 | 46 | SnowballSdConfig, | ||
515 | 47 | VexpressConfig, | ||
516 | 48 | align_partition, | ||
517 | 38 | align_up, | 49 | align_up, |
520 | 39 | align_partition, | 50 | install_mx5_boot_loader, |
519 | 40 | classproperty, | ||
521 | 41 | make_boot_script, | 51 | make_boot_script, |
522 | 42 | install_mx5_boot_loader, | ||
523 | 43 | ) | 52 | ) |
532 | 44 | 53 | from linaro_image_tools.utils import DEFAULT_LOGGER_NAME | |
533 | 45 | from linaro_image_tools import cmd_runner | 54 | |
534 | 46 | import os | 55 | logger = logging.getLogger(DEFAULT_LOGGER_NAME) |
535 | 47 | 56 | ||
536 | 48 | 57 | BOOT_MIN_SIZE_S = align_up(128 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE | |
537 | 49 | class AndroidBoardConfig(object): | 58 | SYSTEM_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE |
538 | 50 | @classmethod | 59 | CACHE_MIN_SIZE_S = align_up(256 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE |
539 | 51 | def _get_bootargs(cls, consoles): | 60 | USERDATA_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE |
540 | 61 | SDCARD_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE | ||
541 | 62 | LOADER_MIN_SIZE_S = align_up(1 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE | ||
542 | 63 | |||
543 | 64 | |||
544 | 65 | class AndroidBoardConfig(BoardConfig): | ||
545 | 66 | |||
546 | 67 | def __init__(self): | ||
547 | 68 | super(AndroidBoardConfig, self).__init__() | ||
548 | 69 | self._dtb_name = None | ||
549 | 70 | self._extra_serial_options = [] | ||
550 | 71 | self._android_specific_args = [] | ||
551 | 72 | self._extra_boot_args_options = [] | ||
552 | 73 | |||
553 | 74 | def _get_android_specific_args(self): | ||
554 | 75 | return ' '.join(self._android_specific_args) | ||
555 | 76 | |||
556 | 77 | def _set_android_specific_args(self, value): | ||
557 | 78 | self._android_specific_args = value | ||
558 | 79 | |||
559 | 80 | android_specific_args = property(_get_android_specific_args, | ||
560 | 81 | _set_android_specific_args) | ||
561 | 82 | |||
562 | 83 | def _get_extra_boot_args_options(self): | ||
563 | 84 | return ' '.join(self._extra_boot_args_options) | ||
564 | 85 | |||
565 | 86 | def _set_extra_boot_args_options(self, value): | ||
566 | 87 | self._extra_boot_args_options = value | ||
567 | 88 | |||
568 | 89 | extra_boot_args_options = property(_get_extra_boot_args_options, | ||
569 | 90 | _set_extra_boot_args_options) | ||
570 | 91 | |||
571 | 92 | def _get_extra_serial_options(self): | ||
572 | 93 | return ' '.join(self._extra_serial_options) | ||
573 | 94 | |||
574 | 95 | def _set_extra_serial_options(self, value): | ||
575 | 96 | self._extra_serial_options = value | ||
576 | 97 | |||
577 | 98 | extra_serial_options = property(_get_extra_serial_options, | ||
578 | 99 | _set_extra_serial_options) | ||
579 | 100 | |||
580 | 101 | def _get_dtb_name(self): | ||
581 | 102 | return self._dtb_name | ||
582 | 103 | |||
583 | 104 | def _set_dtb_name(self, value): | ||
584 | 105 | self._dtb_name = value | ||
585 | 106 | |||
586 | 107 | dtb_name = property(_get_dtb_name, _set_dtb_name) | ||
587 | 108 | |||
588 | 109 | def from_file(self, hwpack): | ||
589 | 110 | """Loads the Android board configuration from an Android hardware pack | ||
590 | 111 | configuration file and sets the config attributes with their values. | ||
591 | 112 | |||
592 | 113 | :param hwpack: The Android hwpack configuration file. | ||
593 | 114 | :return The configuration read from the file as a dictionary. | ||
594 | 115 | """ | ||
595 | 116 | try: | ||
596 | 117 | config = yaml.safe_load(hwpack) | ||
597 | 118 | self._set_attributes(config) | ||
598 | 119 | return config | ||
599 | 120 | except yaml.YAMLError, ex: | ||
600 | 121 | logger.debug("Error loading YAML file %s" % hwpack, ex) | ||
601 | 122 | raise BoardConfigException("Error reading Android hwpack %s" | ||
602 | 123 | % hwpack) | ||
603 | 124 | |||
604 | 125 | def _set_attributes(self, config): | ||
605 | 126 | """Initialize the class attributes with the values read from the | ||
606 | 127 | Android hardware pack configuration file. | ||
607 | 128 | |||
608 | 129 | :param config: The config read from the Android hwpack. | ||
609 | 130 | """ | ||
610 | 131 | for name, value in config.iteritems(): | ||
611 | 132 | if hasattr(self, name): | ||
612 | 133 | setattr(self, name, value) | ||
613 | 134 | else: | ||
614 | 135 | logger.warning("Attribute '%s' does not belong to this " | ||
615 | 136 | "instance of '%s'." % (name, self.__class__)) | ||
616 | 137 | |||
617 | 138 | def _get_bootargs(self, consoles): | ||
618 | 52 | """Get the bootargs for this board. | 139 | """Get the bootargs for this board. |
619 | 53 | 140 | ||
620 | 54 | In general subclasses should not have to override this. | 141 | In general subclasses should not have to override this. |
621 | 55 | """ | 142 | """ |
622 | 56 | boot_args_options = 'rootwait ro' | 143 | boot_args_options = 'rootwait ro' |
627 | 57 | if cls.extra_boot_args_options is not None: | 144 | if self.extra_boot_args_options: |
628 | 58 | boot_args_options += ' %s' % cls.extra_boot_args_options | 145 | boot_args_options += ' %s' % self.extra_boot_args_options |
629 | 59 | boot_args_options += ' %s' % cls.android_specific_args | 146 | boot_args_options += ' %s' % self.android_specific_args |
630 | 60 | serial_opts = cls._extra_serial_opts | 147 | serial_opts = self.extra_serial_options |
631 | 61 | for console in consoles: | 148 | for console in consoles: |
632 | 62 | serial_opts += ' console=%s' % console | 149 | serial_opts += ' console=%s' % console |
633 | 63 | 150 | ||
634 | @@ -69,34 +156,32 @@ | |||
635 | 69 | "%(boot_args_options)s" | 156 | "%(boot_args_options)s" |
636 | 70 | % replacements) | 157 | % replacements) |
637 | 71 | 158 | ||
640 | 72 | @classmethod | 159 | def _get_boot_env(self, consoles): |
639 | 73 | def _get_boot_env(cls, consoles): | ||
641 | 74 | """Get the boot environment for this board. | 160 | """Get the boot environment for this board. |
642 | 75 | 161 | ||
643 | 76 | In general subclasses should not have to override this. | 162 | In general subclasses should not have to override this. |
644 | 77 | """ | 163 | """ |
645 | 78 | boot_env = {} | 164 | boot_env = {} |
647 | 79 | boot_env["bootargs"] = cls._get_bootargs(consoles) | 165 | boot_env["bootargs"] = self._get_bootargs(consoles) |
648 | 80 | initrd = False | 166 | initrd = False |
650 | 81 | if cls.initrd_addr: | 167 | if self.initrd_addr: |
651 | 82 | initrd = True | 168 | initrd = True |
652 | 83 | # On Android, the DTB file is always built as part of the kernel it | 169 | # On Android, the DTB file is always built as part of the kernel it |
653 | 84 | # comes from - and lives in the same directory in the boot tarball, so | 170 | # comes from - and lives in the same directory in the boot tarball, so |
654 | 85 | # here we don't need to pass the whole path to it. | 171 | # here we don't need to pass the whole path to it. |
658 | 86 | boot_env["bootcmd"] = cls._get_bootcmd(initrd, cls.dtb_name) | 172 | boot_env["bootcmd"] = self._get_bootcmd(initrd, self.dtb_name) |
659 | 87 | boot_env["initrd_high"] = cls.initrd_high | 173 | boot_env["initrd_high"] = self.initrd_high |
660 | 88 | boot_env["fdt_high"] = cls.fdt_high | 174 | boot_env["fdt_high"] = self.fdt_high |
661 | 89 | return boot_env | 175 | return boot_env |
662 | 90 | 176 | ||
665 | 91 | @classmethod | 177 | def populate_boot_script(self, boot_partition, boot_disk, consoles): |
664 | 92 | def populate_boot_script(cls, boot_partition, boot_disk, consoles): | ||
666 | 93 | cmd_runner.run(['mkdir', '-p', boot_disk]).wait() | 178 | cmd_runner.run(['mkdir', '-p', boot_disk]).wait() |
667 | 94 | # TODO: Use partition_mounted() here to make sure the partition is | 179 | # TODO: Use partition_mounted() here to make sure the partition is |
668 | 95 | # always umounted after we're done. | 180 | # always umounted after we're done. |
669 | 96 | cmd_runner.run(['mount', boot_partition, boot_disk], | 181 | cmd_runner.run(['mount', boot_partition, boot_disk], |
670 | 97 | as_root=True).wait() | 182 | as_root=True).wait() |
671 | 98 | 183 | ||
673 | 99 | boot_env = cls._get_boot_env(consoles) | 184 | boot_env = self._get_boot_env(consoles) |
674 | 100 | cmdline_filepath = os.path.join(boot_disk, "cmdline") | 185 | cmdline_filepath = os.path.join(boot_disk, "cmdline") |
675 | 101 | cmdline_file = open(cmdline_filepath, 'r') | 186 | cmdline_file = open(cmdline_filepath, 'r') |
676 | 102 | android_kernel_cmdline = cmdline_file.read() | 187 | android_kernel_cmdline = cmdline_file.read() |
677 | @@ -105,7 +190,7 @@ | |||
678 | 105 | cmdline_file.close() | 190 | cmdline_file.close() |
679 | 106 | 191 | ||
680 | 107 | boot_dir = boot_disk | 192 | boot_dir = boot_disk |
682 | 108 | boot_script_path = os.path.join(boot_dir, cls.boot_script) | 193 | boot_script_path = os.path.join(boot_dir, self.boot_script) |
683 | 109 | make_boot_script(boot_env, boot_script_path) | 194 | make_boot_script(boot_env, boot_script_path) |
684 | 110 | 195 | ||
685 | 111 | cmd_runner.run(['sync']).wait() | 196 | cmd_runner.run(['sync']).wait() |
686 | @@ -114,25 +199,13 @@ | |||
687 | 114 | except cmd_runner.SubcommandNonZeroReturnValue: | 199 | except cmd_runner.SubcommandNonZeroReturnValue: |
688 | 115 | pass | 200 | pass |
689 | 116 | 201 | ||
692 | 117 | @classmethod | 202 | def get_sfdisk_cmd(self, should_align_boot_part=False, |
691 | 118 | def get_sfdisk_cmd(cls, should_align_boot_part=False, | ||
693 | 119 | start_addr=0, extra_part=False): | 203 | start_addr=0, extra_part=False): |
695 | 120 | if cls.fat_size == 32: | 204 | if self.fat_size == 32: |
696 | 121 | partition_type = '0x0C' | 205 | partition_type = '0x0C' |
697 | 122 | else: | 206 | else: |
698 | 123 | partition_type = '0x0E' | 207 | partition_type = '0x0E' |
699 | 124 | 208 | ||
700 | 125 | BOOT_MIN_SIZE_S = align_up( | ||
701 | 126 | 128 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE | ||
702 | 127 | SYSTEM_MIN_SIZE_S = align_up( | ||
703 | 128 | 512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE | ||
704 | 129 | CACHE_MIN_SIZE_S = align_up( | ||
705 | 130 | 256 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE | ||
706 | 131 | USERDATA_MIN_SIZE_S = align_up( | ||
707 | 132 | 512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE | ||
708 | 133 | SDCARD_MIN_SIZE_S = align_up( | ||
709 | 134 | 512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE | ||
710 | 135 | |||
711 | 136 | # align on sector 63 for compatibility with broken versions of x-loader | 209 | # align on sector 63 for compatibility with broken versions of x-loader |
712 | 137 | # unless align_boot_part is set | 210 | # unless align_boot_part is set |
713 | 138 | boot_align = 63 | 211 | boot_align = 63 |
714 | @@ -174,86 +247,48 @@ | |||
715 | 174 | cache_start, _cache_len, userdata_start, userdata_start, | 247 | cache_start, _cache_len, userdata_start, userdata_start, |
716 | 175 | _userdata_len, sdcard_start) | 248 | _userdata_len, sdcard_start) |
717 | 176 | 249 | ||
721 | 177 | @classmethod | 250 | def populate_raw_partition(self, media, boot_dir): |
722 | 178 | def populate_raw_partition(cls, media, boot_dir): | 251 | super(AndroidBoardConfig, self).populate_raw_partition(media, boot_dir) |
720 | 179 | super(AndroidBoardConfig, cls).populate_raw_partition(media, boot_dir) | ||
723 | 180 | 252 | ||
726 | 181 | @classmethod | 253 | def install_boot_loader(self, boot_partition, boot_device_or_file): |
725 | 182 | def install_boot_loader(cls, boot_partition, boot_device_or_file): | ||
727 | 183 | pass | 254 | pass |
728 | 184 | 255 | ||
729 | 185 | 256 | ||
730 | 186 | class AndroidOmapConfig(AndroidBoardConfig): | 257 | class AndroidOmapConfig(AndroidBoardConfig): |
749 | 187 | dtb_name = None | 258 | """Placeholder class for OMAP configuration inheritance.""" |
750 | 188 | 259 | ||
751 | 189 | 260 | ||
752 | 190 | class AndroidBeagleConfig(AndroidOmapConfig, BeagleConfig): | 261 | class AndroidBeagleConfig(AndroidBoardConfig, BeagleConfig): |
753 | 191 | _extra_serial_opts = 'console=tty0 console=ttyO2,115200n8' | 262 | """Placeholder class for Beagle configuration inheritance.""" |
754 | 192 | android_specific_args = 'init=/init androidboot.console=ttyO2' | 263 | |
755 | 193 | dtb_name = None | 264 | |
756 | 194 | 265 | class AndroidPandaConfig(AndroidBoardConfig, PandaConfig): | |
757 | 195 | 266 | """Placeholder class for Panda configuration inheritance.""" | |
740 | 196 | class AndroidPandaConfig(AndroidOmapConfig, PandaConfig): | ||
741 | 197 | bootloader_flavor = 'omap4_panda' | ||
742 | 198 | dtb_addr = '0x815f0000' | ||
743 | 199 | dtb_name = 'board.dtb' | ||
744 | 200 | _extra_serial_opts = 'console=ttyO2,115200n8' | ||
745 | 201 | extra_boot_args_options = ( | ||
746 | 202 | 'earlyprintk fixrtc nocompcache vram=48M ' | ||
747 | 203 | 'omapfb.vram=0:24M,1:24M mem=456M@0x80000000 mem=512M@0xA0000000') | ||
748 | 204 | android_specific_args = 'init=/init androidboot.console=ttyO2' | ||
758 | 205 | 267 | ||
759 | 206 | 268 | ||
760 | 207 | class AndroidSnowballSdConfig(AndroidBoardConfig, SnowballSdConfig): | 269 | class AndroidSnowballSdConfig(AndroidBoardConfig, SnowballSdConfig): |
772 | 208 | boot_script = 'boot.scr' | 270 | """Placeholder class for Snowball SD configuration inheritance.""" |
762 | 209 | fdt_high = '0x05000000' | ||
763 | 210 | initrd_addr = '0x05000000' | ||
764 | 211 | initrd_high = '0x06000000' | ||
765 | 212 | extra_boot_args_options = ( | ||
766 | 213 | 'earlyprintk mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M ' | ||
767 | 214 | 'mem=22M@360M mem_issw=1M@383M mem=640M@384M vmalloc=500M') | ||
768 | 215 | _extra_serial_opts = 'console=ttyAMA2,115200n8' | ||
769 | 216 | android_specific_args = 'init=/init androidboot.console=ttyAMA2' | ||
770 | 217 | dtb_name = 'board.dtb' | ||
771 | 218 | dtb_addr = '0x8000000' | ||
773 | 219 | 271 | ||
774 | 220 | 272 | ||
775 | 221 | class AndroidSnowballEmmcConfig(AndroidBoardConfig, SnowballEmmcConfig): | 273 | class AndroidSnowballEmmcConfig(AndroidBoardConfig, SnowballEmmcConfig): |
795 | 222 | boot_script = 'boot.scr' | 274 | """Snowball EMMC configuration inheritance.""" |
796 | 223 | fdt_high = '0x05000000' | 275 | |
797 | 224 | initrd_addr = '0x05000000' | 276 | def get_sfdisk_cmd(self, should_align_boot_part=False): |
779 | 225 | initrd_high = '0x06000000' | ||
780 | 226 | extra_boot_args_options = ( | ||
781 | 227 | 'earlyprintk mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M ' | ||
782 | 228 | 'mem=22M@360M mem_issw=1M@383M mem=640M@384M vmalloc=500M') | ||
783 | 229 | _extra_serial_opts = 'console=ttyAMA2,115200n8' | ||
784 | 230 | android_specific_args = 'init=/init androidboot.console=ttyAMA2' | ||
785 | 231 | mmc_option = '0:2' | ||
786 | 232 | dtb_name = 'board.dtb' | ||
787 | 233 | dtb_addr = '0x8000000' | ||
788 | 234 | |||
789 | 235 | @classmethod | ||
790 | 236 | def get_sfdisk_cmd(cls, should_align_boot_part=False): | ||
791 | 237 | |||
792 | 238 | LOADER_MIN_SIZE_S = align_up( | ||
793 | 239 | 1 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE | ||
794 | 240 | |||
798 | 241 | loader_start, loader_end, loader_len = align_partition( | 277 | loader_start, loader_end, loader_len = align_partition( |
799 | 242 | SnowballEmmcConfig.SNOWBALL_LOADER_START_S, | 278 | SnowballEmmcConfig.SNOWBALL_LOADER_START_S, |
800 | 243 | LOADER_MIN_SIZE_S, 1, PART_ALIGN_S) | 279 | LOADER_MIN_SIZE_S, 1, PART_ALIGN_S) |
801 | 244 | 280 | ||
803 | 245 | command = super(AndroidSnowballEmmcConfig, cls).get_sfdisk_cmd( | 281 | command = super(AndroidSnowballEmmcConfig, self).get_sfdisk_cmd( |
804 | 246 | should_align_boot_part=True, start_addr=loader_end, | 282 | should_align_boot_part=True, start_addr=loader_end, |
805 | 247 | extra_part=True) | 283 | extra_part=True) |
806 | 248 | 284 | ||
807 | 249 | return '%s,%s,0xDA\n%s' % ( | 285 | return '%s,%s,0xDA\n%s' % ( |
808 | 250 | loader_start, loader_len, command) | 286 | loader_start, loader_len, command) |
809 | 251 | 287 | ||
812 | 252 | @classmethod | 288 | def populate_raw_partition(self, media, boot_dir): |
811 | 253 | def populate_raw_partition(cls, media, boot_dir): | ||
813 | 254 | # To avoid adding a Snowball specific command line option, we assume | 289 | # To avoid adding a Snowball specific command line option, we assume |
814 | 255 | # that the user already has unpacked the startfiles to ./startupfiles | 290 | # that the user already has unpacked the startfiles to ./startupfiles |
816 | 256 | config_files_dir = cls.snowball_config(boot_dir) | 291 | config_files_dir = self.snowball_config(boot_dir) |
817 | 257 | assert os.path.exists(config_files_dir), ( | 292 | assert os.path.exists(config_files_dir), ( |
818 | 258 | "You need to unpack the Snowball startupfiles to the directory " | 293 | "You need to unpack the Snowball startupfiles to the directory " |
819 | 259 | "'startupfiles' in your current working directory. See " | 294 | "'startupfiles' in your current working directory. See " |
820 | @@ -264,72 +299,85 @@ | |||
821 | 264 | for boot_file in boot_files: | 299 | for boot_file in boot_files: |
822 | 265 | cmd_runner.run(['cp', os.path.join(boot_dir, 'boot', boot_file), | 300 | cmd_runner.run(['cp', os.path.join(boot_dir, 'boot', boot_file), |
823 | 266 | config_files_dir], as_root=True).wait() | 301 | config_files_dir], as_root=True).wait() |
825 | 267 | super(AndroidSnowballEmmcConfig, cls).populate_raw_partition( | 302 | super(AndroidSnowballEmmcConfig, self).populate_raw_partition( |
826 | 268 | media, boot_dir) | 303 | media, boot_dir) |
827 | 269 | 304 | ||
830 | 270 | @classmethod | 305 | def snowball_config(self, chroot_dir): |
829 | 271 | def snowball_config(cls, chroot_dir): | ||
831 | 272 | # The user is expected to have unpacked the startupfiles to this subdir | 306 | # The user is expected to have unpacked the startupfiles to this subdir |
832 | 273 | # of their working dir. | 307 | # of their working dir. |
833 | 274 | return os.path.join('.', 'startupfiles') | 308 | return os.path.join('.', 'startupfiles') |
834 | 275 | 309 | ||
837 | 276 | @classproperty | 310 | @property |
838 | 277 | def delete_startupfiles(cls): | 311 | def delete_startupfiles(self): |
839 | 278 | # The startupfiles will have been unpacked to the user's working dir | 312 | # The startupfiles will have been unpacked to the user's working dir |
840 | 279 | # and should not be deleted after they have been installed. | 313 | # and should not be deleted after they have been installed. |
841 | 280 | return False | 314 | return False |
842 | 281 | 315 | ||
843 | 282 | 316 | ||
844 | 283 | class AndroidMx53LoCoConfig(AndroidBoardConfig, Mx53LoCoConfig): | 317 | class AndroidMx53LoCoConfig(AndroidBoardConfig, Mx53LoCoConfig): |
855 | 284 | extra_boot_args_options = ( | 318 | """Mx53LoCo configuration inheritance.""" |
856 | 285 | 'earlyprintk rootdelay=1 fixrtc nocompcache di1_primary tve') | 319 | |
857 | 286 | _extra_serial_opts = 'console=%s,115200n8' % ( | 320 | def _get_extra_serial_options(self): |
858 | 287 | Mx53LoCoConfig.serial_tty) | 321 | serial_opts = self._extra_serial_options |
859 | 288 | android_specific_args = 'init=/init androidboot.console=%s' % ( | 322 | if serial_opts: |
860 | 289 | Mx53LoCoConfig.serial_tty) | 323 | if isinstance(serial_opts, list): |
861 | 290 | dtb_name = None | 324 | serial_opts = ' '.join(serial_opts) |
862 | 291 | 325 | if self._check_placeholder_presence(serial_opts, '%s'): | |
863 | 292 | @classmethod | 326 | serial_opts = serial_opts % self.serial_tty |
864 | 293 | def get_sfdisk_cmd(cls, should_align_boot_part=False): | 327 | return serial_opts |
865 | 328 | |||
866 | 329 | def _set_extra_serial_options(self, value): | ||
867 | 330 | self._extra_serial_options = value | ||
868 | 331 | |||
869 | 332 | extra_serial_options = property(_get_extra_serial_options, | ||
870 | 333 | _set_extra_serial_options) | ||
871 | 334 | |||
872 | 335 | def _get_android_specific_args(self): | ||
873 | 336 | android_args = self._android_specific_args | ||
874 | 337 | if android_args: | ||
875 | 338 | if isinstance(android_args, list): | ||
876 | 339 | android_args = ' '.join(android_args) | ||
877 | 340 | if self._check_placeholder_presence(android_args, '%s'): | ||
878 | 341 | android_args = android_args % self.serial_tty | ||
879 | 342 | return android_args | ||
880 | 343 | |||
881 | 344 | def _set_android_specific_args(self, value): | ||
882 | 345 | self._android_specific_args = value | ||
883 | 346 | |||
884 | 347 | android_specific_args = property(_get_android_specific_args, | ||
885 | 348 | _set_android_specific_args) | ||
886 | 349 | |||
887 | 350 | def get_sfdisk_cmd(self, should_align_boot_part=False): | ||
888 | 294 | loader_start, loader_end, loader_len = align_partition( | 351 | loader_start, loader_end, loader_len = align_partition( |
890 | 295 | 1, cls.LOADER_MIN_SIZE_S, 1, PART_ALIGN_S) | 352 | 1, self.LOADER_MIN_SIZE_S, 1, PART_ALIGN_S) |
891 | 296 | 353 | ||
893 | 297 | command = super(AndroidMx53LoCoConfig, cls).get_sfdisk_cmd( | 354 | command = super(AndroidMx53LoCoConfig, self).get_sfdisk_cmd( |
894 | 298 | should_align_boot_part=True, start_addr=loader_end, | 355 | should_align_boot_part=True, start_addr=loader_end, |
895 | 299 | extra_part=True) | 356 | extra_part=True) |
896 | 300 | 357 | ||
897 | 301 | return '%s,%s,0xDA\n%s' % ( | 358 | return '%s,%s,0xDA\n%s' % ( |
898 | 302 | loader_start, loader_len, command) | 359 | loader_start, loader_len, command) |
899 | 303 | 360 | ||
902 | 304 | @classmethod | 361 | def install_boot_loader(self, boot_partition, boot_device_or_file): |
901 | 305 | def install_boot_loader(cls, boot_partition, boot_device_or_file): | ||
903 | 306 | install_mx5_boot_loader( | 362 | install_mx5_boot_loader( |
904 | 307 | os.path.join(boot_device_or_file, "u-boot.imx"), | 363 | os.path.join(boot_device_or_file, "u-boot.imx"), |
906 | 308 | boot_partition, cls.LOADER_MIN_SIZE_S) | 364 | boot_partition, self.LOADER_MIN_SIZE_S) |
907 | 309 | 365 | ||
908 | 310 | 366 | ||
909 | 311 | class AndroidMx6QSabreliteConfig(AndroidMx53LoCoConfig): | 367 | class AndroidMx6QSabreliteConfig(AndroidMx53LoCoConfig): |
916 | 312 | bootloader_flavor = 'mx6qsabrelite' | 368 | """Placeholder class for Mx6Q Sabrelite configuration inheritance.""" |
911 | 313 | kernel_addr = '0x10000000' | ||
912 | 314 | initrd_addr = '0x12000000' | ||
913 | 315 | load_addr = '0x10008000' | ||
914 | 316 | dtb_addr = '0x11ff0000' | ||
915 | 317 | dtb_name = 'board.dtb' | ||
917 | 318 | 369 | ||
918 | 319 | 370 | ||
919 | 320 | class AndroidSamsungConfig(AndroidBoardConfig): | 371 | class AndroidSamsungConfig(AndroidBoardConfig): |
924 | 321 | dtb_name = None | 372 | def get_sfdisk_cmd(self, should_align_boot_part=False): |
921 | 322 | |||
922 | 323 | @classmethod | ||
923 | 324 | def get_sfdisk_cmd(cls, should_align_boot_part=False): | ||
925 | 325 | loaders_min_len = ( | 373 | loaders_min_len = ( |
928 | 326 | cls.SAMSUNG_V310_BL2_START + cls.SAMSUNG_V310_BL2_LEN - | 374 | self.samsung_v310_bl2_start + self.samsung_v310_bl2_len - |
929 | 327 | cls.SAMSUNG_V310_BL1_START) | 375 | self.samsung_v310_bl1_start) |
930 | 328 | 376 | ||
931 | 329 | loader_start, loader_end, loader_len = align_partition( | 377 | loader_start, loader_end, loader_len = align_partition( |
932 | 330 | 1, loaders_min_len, 1, PART_ALIGN_S) | 378 | 1, loaders_min_len, 1, PART_ALIGN_S) |
933 | 331 | 379 | ||
935 | 332 | command = super(AndroidSamsungConfig, cls).get_sfdisk_cmd( | 380 | command = super(AndroidSamsungConfig, self).get_sfdisk_cmd( |
936 | 333 | should_align_boot_part=False, start_addr=loader_end, | 381 | should_align_boot_part=False, start_addr=loader_end, |
937 | 334 | extra_part=True) | 382 | extra_part=True) |
938 | 335 | 383 | ||
939 | @@ -338,33 +386,47 @@ | |||
940 | 338 | 386 | ||
941 | 339 | 387 | ||
942 | 340 | class AndroidSMDKV310Config(AndroidSamsungConfig, SMDKV310Config): | 388 | class AndroidSMDKV310Config(AndroidSamsungConfig, SMDKV310Config): |
946 | 341 | _extra_serial_opts = 'console=tty0 console=ttySAC1,115200n8' | 389 | """Placeholder class for SMDKV310 configuration inheritance.""" |
944 | 342 | android_specific_args = 'init=/init androidboot.console=ttySAC1' | ||
945 | 343 | dtb_name = None | ||
947 | 344 | 390 | ||
948 | 345 | 391 | ||
949 | 346 | class AndroidOrigenConfig(AndroidSamsungConfig, OrigenConfig): | 392 | class AndroidOrigenConfig(AndroidSamsungConfig, OrigenConfig): |
953 | 347 | _extra_serial_opts = 'console=tty0 console=ttySAC2,115200n8' | 393 | """Placeholder class for Origen configuration inheritance.""" |
951 | 348 | android_specific_args = 'init=/init androidboot.console=ttySAC2' | ||
952 | 349 | dtb_name = None | ||
954 | 350 | 394 | ||
955 | 351 | 395 | ||
956 | 352 | class AndroidVexpressConfig(AndroidBoardConfig, VexpressConfig): | 396 | class AndroidVexpressConfig(AndroidBoardConfig, VexpressConfig): |
962 | 353 | _extra_serial_opts = 'console=tty0 console=ttyAMA0,38400n8' | 397 | """Placeholder class for Vexpress configuration inheritance.""" |
963 | 354 | android_specific_args = 'init=/init androidboot.console=ttyAMA0' | 398 | |
964 | 355 | dtb_name = None | 399 | |
965 | 356 | 400 | # This dictionary is composed as follows: | |
966 | 357 | 401 | # <device_name>: <class> | |
967 | 402 | # The <device_name> is the command line argument passed to l-a-m-c, the | ||
968 | 403 | # <class> is the corresponding config class in this file (not the instance). | ||
969 | 404 | # If a new device does not have special needs, it is possible to use the | ||
970 | 405 | # general AndroidBoardConfig class. | ||
971 | 358 | android_board_configs = { | 406 | android_board_configs = { |
972 | 359 | 'beagle': AndroidBeagleConfig, | 407 | 'beagle': AndroidBeagleConfig, |
977 | 360 | 'panda': AndroidPandaConfig, | 408 | 'iMX53': AndroidMx53LoCoConfig, |
974 | 361 | 'snowball_sd': AndroidSnowballSdConfig, | ||
975 | 362 | 'snowball_emmc': AndroidSnowballEmmcConfig, | ||
976 | 363 | 'smdkv310': AndroidSMDKV310Config, | ||
978 | 364 | 'mx53loco': AndroidMx53LoCoConfig, | 409 | 'mx53loco': AndroidMx53LoCoConfig, |
979 | 365 | 'iMX53': AndroidMx53LoCoConfig, | ||
980 | 366 | 'mx6qsabrelite': AndroidMx6QSabreliteConfig, | 410 | 'mx6qsabrelite': AndroidMx6QSabreliteConfig, |
981 | 367 | 'origen': AndroidOrigenConfig, | 411 | 'origen': AndroidOrigenConfig, |
982 | 412 | 'panda': AndroidPandaConfig, | ||
983 | 413 | 'smdkv310': AndroidSMDKV310Config, | ||
984 | 414 | 'snowball_emmc': AndroidSnowballEmmcConfig, | ||
985 | 415 | 'snowball_sd': AndroidSnowballSdConfig, | ||
986 | 368 | 'vexpress': AndroidVexpressConfig, | 416 | 'vexpress': AndroidVexpressConfig, |
987 | 369 | 'vexpress-a9': AndroidVexpressConfig, | 417 | 'vexpress-a9': AndroidVexpressConfig, |
988 | 370 | } | 418 | } |
989 | 419 | |||
990 | 420 | |||
991 | 421 | def get_board_config(board): | ||
992 | 422 | """Get the board configuration for the specified board. | ||
993 | 423 | |||
994 | 424 | :param board: The name of the board to get the configuration of. | ||
995 | 425 | :type board: str | ||
996 | 426 | """ | ||
997 | 427 | clazz = android_board_configs.get(board, None) | ||
998 | 428 | if clazz: | ||
999 | 429 | return clazz() | ||
1000 | 430 | else: | ||
1001 | 431 | raise BoardConfigException("Board name '%s' has no configuration " | ||
1002 | 432 | "available." % board) | ||
1003 | 371 | 433 | ||
1004 | === modified file 'linaro_image_tools/media_create/boards.py' | |||
1005 | --- linaro_image_tools/media_create/boards.py 2012-10-22 06:57:20 +0000 | |||
1006 | +++ linaro_image_tools/media_create/boards.py 2012-11-20 10:49:03 +0000 | |||
1007 | @@ -24,28 +24,58 @@ | |||
1008 | 24 | board_configs at the bottom of this file. | 24 | board_configs at the bottom of this file. |
1009 | 25 | """ | 25 | """ |
1010 | 26 | 26 | ||
1011 | 27 | from binascii import crc32 | ||
1012 | 28 | from parted import Device | ||
1013 | 27 | import atexit | 29 | import atexit |
1014 | 28 | import glob | 30 | import glob |
1015 | 31 | import logging | ||
1016 | 29 | import os | 32 | import os |
1017 | 30 | import re | 33 | import re |
1018 | 34 | import string | ||
1019 | 35 | import struct | ||
1020 | 31 | import tempfile | 36 | import tempfile |
1021 | 32 | import struct | ||
1022 | 33 | from binascii import crc32 | ||
1023 | 34 | import tarfile | ||
1024 | 35 | import ConfigParser | ||
1025 | 36 | import shutil | ||
1026 | 37 | import string | ||
1027 | 38 | import logging | ||
1028 | 39 | from linaro_image_tools.hwpack.config import Config | ||
1029 | 40 | from linaro_image_tools.hwpack.builder import PackageUnpacker | ||
1030 | 41 | |||
1031 | 42 | from parted import Device | ||
1032 | 43 | 37 | ||
1033 | 44 | from linaro_image_tools import cmd_runner | 38 | from linaro_image_tools import cmd_runner |
1034 | 45 | 39 | ||
1035 | 46 | from linaro_image_tools.media_create.partitions import ( | 40 | from linaro_image_tools.media_create.partitions import ( |
1038 | 47 | partition_mounted, SECTOR_SIZE, register_loopback) | 41 | SECTOR_SIZE, |
1039 | 48 | from StringIO import StringIO | 42 | partition_mounted, |
1040 | 43 | register_loopback, | ||
1041 | 44 | ) | ||
1042 | 45 | |||
1043 | 46 | from linaro_image_tools.hwpack.handler import HardwarepackHandler | ||
1044 | 47 | |||
1045 | 48 | from linaro_image_tools.hwpack.hwpack_fields import ( | ||
1046 | 49 | BOOTFS, | ||
1047 | 50 | BOOTFS16, | ||
1048 | 51 | BOOT_MIN_SIZE_FIELD, | ||
1049 | 52 | BOOT_SCRIPT_FIELD, | ||
1050 | 53 | DTB_ADDR_FIELD, | ||
1051 | 54 | DTB_FILES_FIELD, | ||
1052 | 55 | DTB_FILE_FIELD, | ||
1053 | 56 | ENV_DD_FIELD, | ||
1054 | 57 | EXTRA_BOOT_OPTIONS_FIELD, | ||
1055 | 58 | EXTRA_SERIAL_OPTIONS_FIELD, | ||
1056 | 59 | INITRD_ADDR_FIELD, | ||
1057 | 60 | KERNEL_ADDR_FIELD, | ||
1058 | 61 | LOADER_MIN_SIZE_FIELD, | ||
1059 | 62 | LOADER_START_FIELD, | ||
1060 | 63 | LOAD_ADDR_FIELD, | ||
1061 | 64 | MMC_ID_FIELD, | ||
1062 | 65 | PARTITION_LAYOUT_FIELD, | ||
1063 | 66 | RESERVED_BOOTFS, | ||
1064 | 67 | ROOT_MIN_SIZE_FIELD, | ||
1065 | 68 | SAMSUNG_BL1_LEN_FIELD, | ||
1066 | 69 | SAMSUNG_BL1_START_FIELD, | ||
1067 | 70 | SAMSUNG_BL2_LEN_FIELD, | ||
1068 | 71 | SAMSUNG_ENV_LEN_FIELD, | ||
1069 | 72 | SERIAL_TTY_FIELD, | ||
1070 | 73 | SNOWBALL_STARTUP_FILES_CONFIG_FIELD, | ||
1071 | 74 | SPL_DD_FIELD, | ||
1072 | 75 | SPL_IN_BOOT_PART_FIELD, | ||
1073 | 76 | WIRED_INTERFACES_FIELD, | ||
1074 | 77 | WIRELESS_INTERFACES_FIELD, | ||
1075 | 78 | ) | ||
1076 | 49 | 79 | ||
1077 | 50 | logger = logging.getLogger(__name__) | 80 | logger = logging.getLogger(__name__) |
1078 | 51 | 81 | ||
1079 | @@ -106,580 +136,336 @@ | |||
1080 | 106 | cmd_runner.run(cmd, as_root=True).wait() | 136 | cmd_runner.run(cmd, as_root=True).wait() |
1081 | 107 | 137 | ||
1082 | 108 | 138 | ||
1083 | 109 | class classproperty(object): | ||
1084 | 110 | """A descriptor that provides @property behavior on class methods.""" | ||
1085 | 111 | def __init__(self, getter): | ||
1086 | 112 | self.getter = getter | ||
1087 | 113 | |||
1088 | 114 | def __get__(self, instance, cls): | ||
1089 | 115 | return self.getter(cls) | ||
1090 | 116 | |||
1091 | 117 | |||
1092 | 118 | class HardwarepackHandler(object): | ||
1093 | 119 | FORMAT_1 = '1.0' | ||
1094 | 120 | FORMAT_2 = '2.0' | ||
1095 | 121 | FORMAT_3 = '3.0' | ||
1096 | 122 | FORMAT_MIXED = '1.0and2.0' | ||
1097 | 123 | metadata_filename = 'metadata' | ||
1098 | 124 | format_filename = 'FORMAT' | ||
1099 | 125 | main_section = 'main' | ||
1100 | 126 | hwpack_tarfiles = [] | ||
1101 | 127 | tempdir = None | ||
1102 | 128 | |||
1103 | 129 | def __init__(self, hwpacks, bootloader=None, board=None): | ||
1104 | 130 | self.hwpacks = hwpacks | ||
1105 | 131 | self.hwpack_tarfiles = [] | ||
1106 | 132 | self.bootloader = bootloader | ||
1107 | 133 | self.board = board | ||
1108 | 134 | self.tempdirs = {} | ||
1109 | 135 | # Used to store the config created from the metadata. | ||
1110 | 136 | self.config = None | ||
1111 | 137 | |||
1112 | 138 | class FakeSecHead(object): | ||
1113 | 139 | """ Add a fake section header to the metadata file. | ||
1114 | 140 | |||
1115 | 141 | This is done so we can use ConfigParser to parse the file. | ||
1116 | 142 | """ | ||
1117 | 143 | def __init__(self, fp): | ||
1118 | 144 | self.fp = fp | ||
1119 | 145 | self.sechead = '[%s]\n' % HardwarepackHandler.main_section | ||
1120 | 146 | |||
1121 | 147 | def readline(self): | ||
1122 | 148 | if self.sechead: | ||
1123 | 149 | try: | ||
1124 | 150 | return self.sechead | ||
1125 | 151 | finally: | ||
1126 | 152 | self.sechead = None | ||
1127 | 153 | else: | ||
1128 | 154 | return self.fp.readline() | ||
1129 | 155 | |||
1130 | 156 | def __enter__(self): | ||
1131 | 157 | self.tempdir = tempfile.mkdtemp() | ||
1132 | 158 | for hwpack in self.hwpacks: | ||
1133 | 159 | hwpack_tarfile = tarfile.open(hwpack, mode='r:gz') | ||
1134 | 160 | self.hwpack_tarfiles.append(hwpack_tarfile) | ||
1135 | 161 | return self | ||
1136 | 162 | |||
1137 | 163 | def __exit__(self, type, value, traceback): | ||
1138 | 164 | for hwpack_tarfile in self.hwpack_tarfiles: | ||
1139 | 165 | if hwpack_tarfile is not None: | ||
1140 | 166 | hwpack_tarfile.close() | ||
1141 | 167 | self.hwpack_tarfiles = [] | ||
1142 | 168 | if self.tempdir is not None and os.path.exists(self.tempdir): | ||
1143 | 169 | shutil.rmtree(self.tempdir) | ||
1144 | 170 | |||
1145 | 171 | for name in self.tempdirs: | ||
1146 | 172 | tempdir = self.tempdirs[name] | ||
1147 | 173 | if tempdir is not None and os.path.exists(tempdir): | ||
1148 | 174 | shutil.rmtree(tempdir) | ||
1149 | 175 | |||
1150 | 176 | def _get_config_from_metadata(self, metadata): | ||
1151 | 177 | """ | ||
1152 | 178 | Retrieves a Config object associated with the metadata. | ||
1153 | 179 | |||
1154 | 180 | :param metadata: The metadata to parse. | ||
1155 | 181 | :return: A Config instance. | ||
1156 | 182 | """ | ||
1157 | 183 | if not self.config: | ||
1158 | 184 | lines = metadata.readlines() | ||
1159 | 185 | if re.search("=", lines[0]) and not re.search(":", lines[0]): | ||
1160 | 186 | # Probably V2 hardware pack without [hwpack] on the first line | ||
1161 | 187 | lines = ["[hwpack]\n"] + lines | ||
1162 | 188 | self.config = Config(StringIO("".join(lines))) | ||
1163 | 189 | self.config.set_board(self.board) | ||
1164 | 190 | self.config.set_bootloader(self.bootloader) | ||
1165 | 191 | return self.config | ||
1166 | 192 | |||
1167 | 193 | def get_field(self, field, return_keys=False): | ||
1168 | 194 | data = None | ||
1169 | 195 | hwpack_with_data = None | ||
1170 | 196 | keys = None | ||
1171 | 197 | for hwpack_tarfile in self.hwpack_tarfiles: | ||
1172 | 198 | metadata = hwpack_tarfile.extractfile(self.metadata_filename) | ||
1173 | 199 | parser = self._get_config_from_metadata(metadata) | ||
1174 | 200 | try: | ||
1175 | 201 | new_data = parser.get_option(field) | ||
1176 | 202 | if new_data is not None: | ||
1177 | 203 | assert data is None, "The metadata field '%s' is set to " \ | ||
1178 | 204 | "'%s' and new value '%s' is found" % (field, data, | ||
1179 | 205 | new_data) | ||
1180 | 206 | data = new_data | ||
1181 | 207 | hwpack_with_data = hwpack_tarfile | ||
1182 | 208 | if return_keys: | ||
1183 | 209 | keys = parser.get_last_used_keys() | ||
1184 | 210 | except ConfigParser.NoOptionError: | ||
1185 | 211 | continue | ||
1186 | 212 | |||
1187 | 213 | if return_keys: | ||
1188 | 214 | return data, hwpack_with_data, keys | ||
1189 | 215 | return data, hwpack_with_data | ||
1190 | 216 | |||
1191 | 217 | def get_format(self): | ||
1192 | 218 | format = None | ||
1193 | 219 | supported_formats = [self.FORMAT_1, self.FORMAT_2, self.FORMAT_3] | ||
1194 | 220 | for hwpack_tarfile in self.hwpack_tarfiles: | ||
1195 | 221 | format_file = hwpack_tarfile.extractfile(self.format_filename) | ||
1196 | 222 | format_string = format_file.read().strip() | ||
1197 | 223 | if not format_string in supported_formats: | ||
1198 | 224 | raise AssertionError( | ||
1199 | 225 | "Format version '%s' is not supported." % format_string) | ||
1200 | 226 | if format is None: | ||
1201 | 227 | format = format_string | ||
1202 | 228 | elif format != format_string: | ||
1203 | 229 | return self.FORMAT_MIXED | ||
1204 | 230 | return format | ||
1205 | 231 | |||
1206 | 232 | def get_file(self, file_alias): | ||
1207 | 233 | """Get file(s) from a hwpack. | ||
1208 | 234 | :param file_alias: Property name (not field name) which contains | ||
1209 | 235 | file reference(s) | ||
1210 | 236 | :return: path to a file or list of paths to files | ||
1211 | 237 | """ | ||
1212 | 238 | file_names, hwpack_tarfile, keys = self.get_field(file_alias, | ||
1213 | 239 | return_keys=True) | ||
1214 | 240 | if not file_names: | ||
1215 | 241 | return file_names | ||
1216 | 242 | single = False | ||
1217 | 243 | if not isinstance(file_names, list): | ||
1218 | 244 | single = True | ||
1219 | 245 | file_names = [file_names] | ||
1220 | 246 | out_files = [] | ||
1221 | 247 | |||
1222 | 248 | # Depending on if board and/or bootloader were used to look up the | ||
1223 | 249 | # file we are getting, we need to prepend those names to the path | ||
1224 | 250 | # to get the correct extracted file from the hardware pack. | ||
1225 | 251 | config_names = [("board", "boards"), ("bootloader", "bootloaders")] | ||
1226 | 252 | base_path = "" | ||
1227 | 253 | if keys: | ||
1228 | 254 | # If keys is non-empty, we have a V3 config option that was | ||
1229 | 255 | # modified by the bootloader and/or boot option... | ||
1230 | 256 | for name, key in config_names: | ||
1231 | 257 | if self.get_field(name): | ||
1232 | 258 | value = self.get_field(name)[0] | ||
1233 | 259 | if keys[0] == key: | ||
1234 | 260 | base_path = os.path.join(base_path, value) | ||
1235 | 261 | keys = keys[1:] | ||
1236 | 262 | |||
1237 | 263 | for f in file_names: | ||
1238 | 264 | # Check that the base path is needed. If the file doesn't exist, | ||
1239 | 265 | # try without it (this provides fallback to V2 style directory | ||
1240 | 266 | # layouts with a V3 config). | ||
1241 | 267 | path_inc_board_and_bootloader = os.path.join(base_path, f) | ||
1242 | 268 | if path_inc_board_and_bootloader in hwpack_tarfile.getnames(): | ||
1243 | 269 | f = path_inc_board_and_bootloader | ||
1244 | 270 | hwpack_tarfile.extract(f, self.tempdir) | ||
1245 | 271 | f = os.path.join(self.tempdir, f) | ||
1246 | 272 | out_files.append(f) | ||
1247 | 273 | if single: | ||
1248 | 274 | return out_files[0] | ||
1249 | 275 | return out_files | ||
1250 | 276 | |||
1251 | 277 | def list_packages(self): | ||
1252 | 278 | """Return list of (package names, TarFile object containing them)""" | ||
1253 | 279 | packages = [] | ||
1254 | 280 | for tf in self.hwpack_tarfiles: | ||
1255 | 281 | for name in tf.getnames(): | ||
1256 | 282 | if name.startswith("pkgs/") and name.endswith(".deb"): | ||
1257 | 283 | packages.append((tf, name)) | ||
1258 | 284 | return packages | ||
1259 | 285 | |||
1260 | 286 | def find_package_for(self, name, version=None, revision=None, | ||
1261 | 287 | architecture=None): | ||
1262 | 288 | """Find a package that matches the name, version, rev and arch given. | ||
1263 | 289 | |||
1264 | 290 | Packages are named according to the debian specification: | ||
1265 | 291 | http://www.debian.org/doc/manuals/debian-faq/ch-pkg_basics.en.html | ||
1266 | 292 | <name>_<Version>-<DebianRevisionNumber>_<DebianArchitecture>.deb | ||
1267 | 293 | DebianRevisionNumber seems to be optional. | ||
1268 | 294 | Use this spec to return a package matching the requirements given. | ||
1269 | 295 | """ | ||
1270 | 296 | for tar_file, package in self.list_packages(): | ||
1271 | 297 | file_name = os.path.basename(package) | ||
1272 | 298 | dpkg_chunks = re.search("^(.+)_(.+)_(.+)\.deb$", | ||
1273 | 299 | file_name) | ||
1274 | 300 | assert dpkg_chunks, "Could not split package file name into"\ | ||
1275 | 301 | "<name>_<Version>_<DebianArchitecture>.deb" | ||
1276 | 302 | |||
1277 | 303 | pkg_name = dpkg_chunks.group(1) | ||
1278 | 304 | pkg_version = dpkg_chunks.group(2) | ||
1279 | 305 | pkg_architecture = dpkg_chunks.group(3) | ||
1280 | 306 | |||
1281 | 307 | ver_chunks = re.search("^(.+)-(.+)$", pkg_version) | ||
1282 | 308 | if ver_chunks: | ||
1283 | 309 | pkg_version = ver_chunks.group(1) | ||
1284 | 310 | pkg_revision = ver_chunks.group(2) | ||
1285 | 311 | else: | ||
1286 | 312 | pkg_revision = None | ||
1287 | 313 | |||
1288 | 314 | if name != pkg_name: | ||
1289 | 315 | continue | ||
1290 | 316 | if version != None and str(version) != pkg_version: | ||
1291 | 317 | continue | ||
1292 | 318 | if revision != None and str(revision) != pkg_revision: | ||
1293 | 319 | continue | ||
1294 | 320 | if (architecture != None and | ||
1295 | 321 | str(architecture) != pkg_architecture): | ||
1296 | 322 | continue | ||
1297 | 323 | |||
1298 | 324 | # Got a matching package - return its path inside the tarball | ||
1299 | 325 | return tar_file, package | ||
1300 | 326 | |||
1301 | 327 | # Failed to find a matching package - return None | ||
1302 | 328 | return None | ||
1303 | 329 | |||
1304 | 330 | def get_file_from_package(self, file_path, package_name, | ||
1305 | 331 | package_version=None, package_revision=None, | ||
1306 | 332 | package_architecture=None): | ||
1307 | 333 | """Extract named file from package specified by name, ver, rev, arch. | ||
1308 | 334 | |||
1309 | 335 | File is extracted from the package matching the given specification | ||
1310 | 336 | to a temporary directory. The absolute path to the extracted file is | ||
1311 | 337 | returned. | ||
1312 | 338 | """ | ||
1313 | 339 | |||
1314 | 340 | package_info = self.find_package_for(package_name, | ||
1315 | 341 | package_version, | ||
1316 | 342 | package_revision, | ||
1317 | 343 | package_architecture) | ||
1318 | 344 | if package_info is None: | ||
1319 | 345 | return None | ||
1320 | 346 | tar_file, package = package_info | ||
1321 | 347 | |||
1322 | 348 | # Avoid unpacking hardware pack more than once by assigning each one | ||
1323 | 349 | # its own tempdir to unpack into. | ||
1324 | 350 | # TODO: update logic that uses self.tempdir so we can get rid of this | ||
1325 | 351 | # by sharing nicely. | ||
1326 | 352 | if not package in self.tempdirs: | ||
1327 | 353 | self.tempdirs[package] = tempfile.mkdtemp() | ||
1328 | 354 | tempdir = self.tempdirs[package] | ||
1329 | 355 | |||
1330 | 356 | # We extract everything in the hardware pack so we don't have to worry | ||
1331 | 357 | # about chasing links (extract a link, find where it points to, extract | ||
1332 | 358 | # that...). This is slower, but more reliable. | ||
1333 | 359 | tar_file.extractall(tempdir) | ||
1334 | 360 | package_path = os.path.join(tempdir, package) | ||
1335 | 361 | |||
1336 | 362 | with PackageUnpacker() as self.package_unpacker: | ||
1337 | 363 | extracted_file = self.package_unpacker.get_file(package_path, | ||
1338 | 364 | file_path) | ||
1339 | 365 | after_tmp = re.sub(self.package_unpacker.tempdir, "", | ||
1340 | 366 | extracted_file).lstrip("/\\") | ||
1341 | 367 | extract_dir = os.path.join(tempdir, "extracted", | ||
1342 | 368 | os.path.dirname(after_tmp)) | ||
1343 | 369 | os.makedirs(extract_dir) | ||
1344 | 370 | shutil.move(extracted_file, extract_dir) | ||
1345 | 371 | extracted_file = os.path.join(extract_dir, | ||
1346 | 372 | os.path.basename(extracted_file)) | ||
1347 | 373 | return extracted_file | ||
1348 | 374 | |||
1349 | 375 | |||
1350 | 376 | class BoardConfig(object): | 139 | class BoardConfig(object): |
1351 | 377 | board = None | ||
1352 | 378 | """The configuration used when building an image for a board.""" | 140 | """The configuration used when building an image for a board.""" |
1373 | 379 | hwpack_format = None | 141 | |
1354 | 380 | # These attributes may not need to be redefined on some subclasses. | ||
1355 | 381 | bootloader_flavor = None | ||
1356 | 382 | # whether to copy u-boot to the boot partition | ||
1357 | 383 | bootloader_file_in_boot_part = False | ||
1358 | 384 | bootloader_dd = False | ||
1359 | 385 | spl_in_boot_part = False | ||
1360 | 386 | spl_dd = False | ||
1361 | 387 | env_dd = False | ||
1362 | 388 | fatload_command = 'fatload' | ||
1363 | 389 | mmc_option = '0:1' | ||
1364 | 390 | mmc_device_id = 0 | ||
1365 | 391 | mmc_part_offset = 0 | ||
1366 | 392 | uimage_path = '' | ||
1367 | 393 | fat_size = 32 | ||
1368 | 394 | extra_serial_opts = '' | ||
1369 | 395 | _extra_serial_opts = '' | ||
1370 | 396 | _live_serial_opts = '' | ||
1371 | 397 | extra_boot_args_options = None | ||
1372 | 398 | supports_writing_to_mmc = True | ||
1374 | 399 | LOADER_MIN_SIZE_S = align_up(1 * 1024 ** 2, SECTOR_SIZE) / SECTOR_SIZE | 142 | LOADER_MIN_SIZE_S = align_up(1 * 1024 ** 2, SECTOR_SIZE) / SECTOR_SIZE |
1375 | 400 | BOOT_MIN_SIZE_S = align_up(50 * 1024 ** 2, SECTOR_SIZE) / SECTOR_SIZE | 143 | BOOT_MIN_SIZE_S = align_up(50 * 1024 ** 2, SECTOR_SIZE) / SECTOR_SIZE |
1376 | 401 | ROOT_MIN_SIZE_S = align_up(50 * 1024 ** 2, SECTOR_SIZE) / SECTOR_SIZE | 144 | ROOT_MIN_SIZE_S = align_up(50 * 1024 ** 2, SECTOR_SIZE) / SECTOR_SIZE |
1377 | 402 | 145 | ||
1439 | 403 | # These attributes must be defined on all subclasses for backwards | 146 | def __init__(self): |
1440 | 404 | # compatibility with hwpacks v1 format. Hwpacks v2 format allows these to | 147 | super(BoardConfig, self).__init__() |
1441 | 405 | # be specified in the hwpack metadata. | 148 | # XXX: when killing v1 hwpack, we might rename these two without the |
1442 | 406 | kernel_addr = None | 149 | # leading underscore. It is done in this way since sublcasses use |
1443 | 407 | initrd_addr = None | 150 | # placeholders in the string for dinamically change values. But this |
1444 | 408 | initrd_high = '0xffffffff' | 151 | # is done only for hwpack v1. |
1445 | 409 | load_addr = None | 152 | self._extra_serial_opts = '' |
1446 | 410 | dtb_addr = None | 153 | self._live_serial_opts = '' |
1447 | 411 | dtb_name = None | 154 | self.board = None |
1448 | 412 | dtb_file = None | 155 | self.boot_script = None |
1449 | 413 | fdt_high = '0xffffffff' | 156 | self.bootloader_dd = False |
1450 | 414 | kernel_flavors = None | 157 | self.bootloader_file_in_boot_part = False |
1451 | 415 | boot_script = None | 158 | self.bootloader_flavor = None |
1452 | 416 | serial_tty = None | 159 | self.dtb_addr = None |
1453 | 417 | wired_interfaces = None | 160 | self.dtb_file = None |
1454 | 418 | wireless_interfaces = None | 161 | self.dtb_files = None |
1455 | 419 | mmc_id = None | 162 | self.dtb_name = None |
1456 | 420 | vmlinuz = None | 163 | self.env_dd = False |
1457 | 421 | initrd = None | 164 | self.extra_boot_args_options = None |
1458 | 422 | partition_layout = None | 165 | self.fat_size = 32 |
1459 | 423 | LOADER_START_S = 1 | 166 | self.fatload_command = 'fatload' |
1460 | 424 | 167 | self.fdt_high = '0xffffffff' | |
1461 | 425 | # Support for dtb_files as per hwpack v3 format. | 168 | self.hardwarepack_handler = None |
1462 | 426 | dtb_files = None | 169 | self.hwpack_format = None |
1463 | 427 | 170 | self.initrd_addr = None | |
1464 | 428 | # Samsung v310 implementation notes and terminology | 171 | self.initrd_high = '0xffffffff' |
1465 | 429 | # | 172 | self.kernel_addr = None |
1466 | 430 | # * BL0, BL1 etc. are the various bootloaders in order of execution | 173 | self.kernel_flavors = None |
1467 | 431 | # * BL0 is the first stage bootloader, located in ROM; it loads a 32s | 174 | self.load_addr = None |
1468 | 432 | # long BL1 from MMC offset +1s and runs it | 175 | self.loader_start_s = 1 |
1469 | 433 | # * BL1 is the secondary program loader (SPL), a small (< 14k) version | 176 | self.mmc_device_id = 0 |
1470 | 434 | # of U-Boot with a checksum; it inits DRAM and loads a 1024s long BL2 | 177 | self.mmc_id = None |
1471 | 435 | # to DRAM from MMC offset +65s | 178 | self.mmc_option = '0:1' |
1472 | 436 | # * BL2 is U-Boot; it loads its 32s (16 KiB) long environment from MMC | 179 | self.mmc_part_offset = 0 |
1473 | 437 | # offset +33s which tells it to load a boot.scr from the first FAT | 180 | self.partition_layout = None |
1474 | 438 | # partition of the MMC | 181 | self.serial_tty = None |
1475 | 439 | # | 182 | self.spl_dd = False |
1476 | 440 | # Layout: | 183 | self.spl_in_boot_part = False |
1477 | 441 | # +0s: part table / MBR, 1s long | 184 | self.supports_writing_to_mmc = True |
1478 | 442 | # +1s: BL1/SPL, 32s long | 185 | self.uimage_path = '' |
1479 | 443 | # +33s: U-Boot environment, 32s long | 186 | self.wired_interfaces = None |
1480 | 444 | # +65s: U-Boot, 1024s long | 187 | self.wireless_interfaces = None |
1481 | 445 | # >= +1089s: FAT partition with boot script (boot.scr), kernel (uImage) | 188 | # Samsung v310 implementation notes and terminology |
1482 | 446 | # and initrd (uInitrd) | 189 | # |
1483 | 447 | SAMSUNG_V310_BL1_START = 1 | 190 | # * BL0, BL1 etc. are the various bootloaders in order of execution |
1484 | 448 | SAMSUNG_V310_BL1_LEN = 32 | 191 | # * BL0 is the first stage bootloader, located in ROM; it loads a 32s |
1485 | 449 | SAMSUNG_V310_ENV_START = SAMSUNG_V310_BL1_START + SAMSUNG_V310_BL1_LEN | 192 | # long BL1 from MMC offset +1s and runs it |
1486 | 450 | SAMSUNG_V310_ENV_LEN = 32 | 193 | # * BL1 is the secondary program loader (SPL), a small (< 14k) version |
1487 | 451 | assert SAMSUNG_V310_ENV_START == 33, ( | 194 | # of U-Boot with a checksum; it inits DRAM and loads a 1024s long BL2 |
1488 | 452 | "BL1 expects u-boot environment at +33s") | 195 | # to DRAM from MMC offset +65s |
1489 | 453 | assert SAMSUNG_V310_ENV_LEN * SECTOR_SIZE == 16 * 1024, ( | 196 | # * BL2 is U-Boot; it loads its 32s (16 KiB) long environment from MMC |
1490 | 454 | "BL1 expects u-boot environment to be 16 KiB") | 197 | # offset +33s which tells it to load a boot.scr from the first FAT |
1491 | 455 | SAMSUNG_V310_BL2_START = SAMSUNG_V310_ENV_START + SAMSUNG_V310_ENV_LEN | 198 | # partition of the MMC |
1492 | 456 | SAMSUNG_V310_BL2_LEN = 1024 | 199 | # |
1493 | 457 | assert SAMSUNG_V310_BL2_LEN * SECTOR_SIZE == 512 * 1024, ( | 200 | # Layout: |
1494 | 458 | "BL1 expects BL2 (u-boot) to be 512 KiB") | 201 | # +0s: part table / MBR, 1s long |
1495 | 459 | 202 | # +1s: BL1/SPL, 32s long | |
1496 | 460 | hardwarepack_handler = None | 203 | # +33s: U-Boot environment, 32s long |
1497 | 461 | 204 | # +65s: U-Boot, 1024s long | |
1498 | 462 | @classmethod | 205 | # >= +1089s: FAT partition with boot script (boot.scr), kernel (uImage) |
1499 | 463 | def get_metadata_field(cls, field_name): | 206 | # and initrd (uInitrd) |
1500 | 207 | self.samsung_v310_bl1_start = 1 | ||
1501 | 208 | self.samsung_v310_bl1_len = 32 | ||
1502 | 209 | self._samsung_v310_env_start = (self.samsung_v310_bl1_start + | ||
1503 | 210 | self.samsung_v310_bl1_len) | ||
1504 | 211 | self._samsung_v310_env_len = 32 | ||
1505 | 212 | self._samsung_v310_bl2_start = (self.samsung_v310_env_start + | ||
1506 | 213 | self.samsung_v310_env_len) | ||
1507 | 214 | self._samsung_v310_bl2_len = 1024 | ||
1508 | 215 | # XXX: attributes that are not listed in hwpackV3, should be removed? | ||
1509 | 216 | self.vmlinuz = None | ||
1510 | 217 | self.initrd = None | ||
1511 | 218 | |||
1512 | 219 | def _get_samsung_v310_env_start(self): | ||
1513 | 220 | return self._samsung_v310_env_start | ||
1514 | 221 | |||
1515 | 222 | def _set_samsung_v310_env_start(self, value): | ||
1516 | 223 | assert value == 33, ("BL1 expects u-boot environment at +33s.") | ||
1517 | 224 | self._samsung_v310_env_start = value | ||
1518 | 225 | |||
1519 | 226 | samsung_v310_env_start = property(_get_samsung_v310_env_start, | ||
1520 | 227 | _set_samsung_v310_env_start) | ||
1521 | 228 | |||
1522 | 229 | def _get_samsung_v310_env_len(self): | ||
1523 | 230 | return self._samsung_v310_env_len | ||
1524 | 231 | |||
1525 | 232 | def _set_samsung_v310_env_len(self, value): | ||
1526 | 233 | assert value * SECTOR_SIZE == 16 * 1024, ("BL1 expects u-boot " | ||
1527 | 234 | "environment to be 16 KiB.") | ||
1528 | 235 | self._samsung_v310_env_len = value | ||
1529 | 236 | |||
1530 | 237 | samsung_v310_env_len = property(_get_samsung_v310_env_len, | ||
1531 | 238 | _set_samsung_v310_env_len) | ||
1532 | 239 | |||
1533 | 240 | def _get_samsung_v310_bl2_start(self): | ||
1534 | 241 | return self._samsung_v310_bl2_start | ||
1535 | 242 | |||
1536 | 243 | def _set_samsung_v310_bl2_start(self, value): | ||
1537 | 244 | self._samsung_v310_bl2_start = value | ||
1538 | 245 | |||
1539 | 246 | samsung_v310_bl2_start = property(_get_samsung_v310_bl2_start, | ||
1540 | 247 | _set_samsung_v310_bl2_start) | ||
1541 | 248 | |||
1542 | 249 | def _get_samsung_v310_bl2_len(self): | ||
1543 | 250 | return self._samsung_v310_bl2_len | ||
1544 | 251 | |||
1545 | 252 | def _set_samsung_v310_bl2_len(self, value): | ||
1546 | 253 | assert value * SECTOR_SIZE == 512 * 1024, ("BL1 expects BL2 (u-boot) " | ||
1547 | 254 | "to be 512 KiB.") | ||
1548 | 255 | self._samsung_v310_bl2_len = value | ||
1549 | 256 | |||
1550 | 257 | samsung_v310_bl2_len = property(_get_samsung_v310_bl2_len, | ||
1551 | 258 | _set_samsung_v310_bl2_len) | ||
1552 | 259 | |||
1553 | 260 | # XXX: can be removed when killing v1 hwpack. | ||
1554 | 261 | def _get_live_serial_opts(self): | ||
1555 | 262 | return_value = self._live_serial_opts | ||
1556 | 263 | if self._check_placeholder_presence(return_value, r'%s'): | ||
1557 | 264 | return_value = self._live_serial_opts % self.serial_tty | ||
1558 | 265 | return return_value | ||
1559 | 266 | |||
1560 | 267 | def _set_live_serial_opts(self, value): | ||
1561 | 268 | self._live_serial_opts = value | ||
1562 | 269 | |||
1563 | 270 | live_serial_opts = property(_get_live_serial_opts, _set_live_serial_opts) | ||
1564 | 271 | |||
1565 | 272 | # XXX: can be removed when killing v1 hwpack. | ||
1566 | 273 | def _get_extra_serial_opts(self): | ||
1567 | 274 | return_value = self._extra_serial_opts | ||
1568 | 275 | if self._check_placeholder_presence(return_value, r'%s'): | ||
1569 | 276 | return_value = return_value % self.serial_tty | ||
1570 | 277 | return return_value | ||
1571 | 278 | |||
1572 | 279 | def _set_extra_serial_opts(self, value): | ||
1573 | 280 | self._extra_serial_opts = value | ||
1574 | 281 | |||
1575 | 282 | extra_serial_opts = property(_get_extra_serial_opts, | ||
1576 | 283 | _set_extra_serial_opts) | ||
1577 | 284 | |||
1578 | 285 | def get_metadata_field(self, field_name): | ||
1579 | 464 | """ Return the metadata value for field_name if it can be found. | 286 | """ Return the metadata value for field_name if it can be found. |
1580 | 465 | """ | 287 | """ |
1582 | 466 | data, _ = cls.hardwarepack_handler.get_field(field_name) | 288 | data, _ = self.hardwarepack_handler.get_field(field_name) |
1583 | 467 | return data | 289 | return data |
1584 | 468 | 290 | ||
1592 | 469 | @classmethod | 291 | def set_metadata(self, hwpacks, bootloader=None, board=None): |
1593 | 470 | def set_board(cls, board): | 292 | self.hardwarepack_handler = HardwarepackHandler(hwpacks, bootloader, |
1587 | 471 | cls.board = board | ||
1588 | 472 | |||
1589 | 473 | @classmethod | ||
1590 | 474 | def set_metadata(cls, hwpacks, bootloader=None, board=None): | ||
1591 | 475 | cls.hardwarepack_handler = HardwarepackHandler(hwpacks, bootloader, | ||
1594 | 476 | board) | 293 | board) |
1598 | 477 | with cls.hardwarepack_handler: | 294 | with self.hardwarepack_handler: |
1599 | 478 | cls.hwpack_format = cls.hardwarepack_handler.get_format() | 295 | self.hwpack_format = self.hardwarepack_handler.get_format() |
1600 | 479 | if (cls.hwpack_format == cls.hardwarepack_handler.FORMAT_1): | 296 | if (self.hwpack_format == self.hardwarepack_handler.FORMAT_1): |
1601 | 480 | return | 297 | return |
1602 | 481 | 298 | ||
1604 | 482 | if (cls.hwpack_format != cls.hardwarepack_handler.FORMAT_1): | 299 | if (self.hwpack_format != self.hardwarepack_handler.FORMAT_1): |
1605 | 483 | # Clear V1 defaults. | 300 | # Clear V1 defaults. |
1624 | 484 | cls.kernel_addr = None | 301 | # TODO When removing v1 support, remove also default values |
1625 | 485 | cls.initrd_addr = None | 302 | # in the constructor and avoid all this. |
1626 | 486 | cls.load_addr = None | 303 | self.kernel_addr = None |
1627 | 487 | cls.serial_tty = None | 304 | self.initrd_addr = None |
1628 | 488 | cls.fat_size = None | 305 | self.load_addr = None |
1629 | 489 | cls.dtb_name = None | 306 | self.serial_tty = None |
1630 | 490 | cls.dtb_addr = None | 307 | self.fat_size = None |
1631 | 491 | cls.extra_boot_args_options = None | 308 | self.dtb_name = None |
1632 | 492 | cls.boot_script = None | 309 | self.dtb_addr = None |
1633 | 493 | cls.kernel_flavors = None | 310 | self.extra_boot_args_options = None |
1634 | 494 | cls.mmc_option = None | 311 | self.boot_script = None |
1635 | 495 | cls.mmc_part_offset = None | 312 | self.kernel_flavors = None |
1636 | 496 | cls.SAMSUNG_V310_BL1_START = None | 313 | self.mmc_option = None |
1637 | 497 | cls.SAMSUNG_V310_BL1_LEN = None | 314 | self.mmc_part_offset = None |
1638 | 498 | cls.SAMSUNG_V310_ENV_START = None | 315 | self.samsung_v310_bl1_start = None |
1639 | 499 | cls.SAMSUNG_V310_ENV_LEN = None | 316 | self.samsung_v310_bl1_len = None |
1640 | 500 | cls.SAMSUNG_V310_BL2_START = None | 317 | self._samsung_v310_env_start = None |
1641 | 501 | cls.SAMSUNG_V310_BL2_LEN = None | 318 | self._samsung_v310_env_len = None |
1642 | 319 | self.samsung_v310_bl2_start = None | ||
1643 | 320 | self._samsung_v310_bl2_len = None | ||
1644 | 502 | 321 | ||
1645 | 322 | self.board = board | ||
1646 | 503 | # Set new values from metadata. | 323 | # Set new values from metadata. |
1677 | 504 | cls.kernel_addr = cls.get_metadata_field('kernel_addr') | 324 | self.kernel_addr = self.get_metadata_field(KERNEL_ADDR_FIELD) |
1678 | 505 | cls.initrd_addr = cls.get_metadata_field('initrd_addr') | 325 | self.initrd_addr = self.get_metadata_field(INITRD_ADDR_FIELD) |
1679 | 506 | cls.load_addr = cls.get_metadata_field('load_addr') | 326 | self.load_addr = self.get_metadata_field(LOAD_ADDR_FIELD) |
1680 | 507 | cls.dtb_addr = cls.get_metadata_field('dtb_addr') | 327 | self.dtb_addr = self.get_metadata_field(DTB_ADDR_FIELD) |
1681 | 508 | cls.serial_tty = cls.get_metadata_field('serial_tty') | 328 | self.serial_tty = self.get_metadata_field(SERIAL_TTY_FIELD) |
1682 | 509 | wired_interfaces = cls.get_metadata_field('wired_interfaces') | 329 | wired_interfaces = self.get_metadata_field(WIRED_INTERFACES_FIELD) |
1683 | 510 | if wired_interfaces is not None: | 330 | if wired_interfaces: |
1684 | 511 | cls.wired_interfaces = wired_interfaces | 331 | self.wired_interfaces = wired_interfaces |
1685 | 512 | wireless_interfaces = cls.get_metadata_field( | 332 | wireless_interfaces = self.get_metadata_field( |
1686 | 513 | 'wireless_interfaces') | 333 | WIRELESS_INTERFACES_FIELD) |
1687 | 514 | if wireless_interfaces is not None: | 334 | if wireless_interfaces: |
1688 | 515 | cls.wireless_interfaces = wireless_interfaces | 335 | self.wireless_interfaces = wireless_interfaces |
1689 | 516 | cls.vmlinuz = cls.get_metadata_field('vmlinuz') | 336 | self.dtb_file = self.get_metadata_field(DTB_FILE_FIELD) |
1690 | 517 | cls.initrd = cls.get_metadata_field('initrd') | 337 | # XXX: need to deprecate dtb_file field and use only dtb_files |
1691 | 518 | cls.dtb_file = cls.get_metadata_field('dtb_file') | 338 | # for multiple entries. |
1692 | 519 | cls.dtb_files = cls.get_metadata_field('dtb_files') | 339 | if self.dtb_file: |
1693 | 520 | cls.extra_boot_args_options = cls.get_metadata_field( | 340 | logger.warn("Deprecation warning: use the 'dtb_files' field " |
1694 | 521 | 'extra_boot_options') | 341 | "instead of 'dtb_file'.") |
1695 | 522 | cls.boot_script = cls.get_metadata_field('boot_script') | 342 | self.dtb_files = self.get_metadata_field(DTB_FILES_FIELD) |
1696 | 523 | cls.extra_serial_opts = cls.get_metadata_field( | 343 | self.extra_boot_args_options = self.get_metadata_field( |
1697 | 524 | 'extra_serial_opts') | 344 | EXTRA_BOOT_OPTIONS_FIELD) |
1698 | 525 | cls.snowball_startup_files_config = cls.get_metadata_field( | 345 | self.boot_script = self.get_metadata_field(BOOT_SCRIPT_FIELD) |
1699 | 526 | 'snowball_startup_files_config') | 346 | self.extra_serial_opts = self.get_metadata_field( |
1700 | 527 | 347 | EXTRA_SERIAL_OPTIONS_FIELD) | |
1701 | 528 | cls.partition_layout = cls.get_metadata_field('partition_layout') | 348 | self.snowball_startup_files_config = self.get_metadata_field( |
1702 | 529 | if cls.partition_layout in [ | 349 | SNOWBALL_STARTUP_FILES_CONFIG_FIELD) |
1703 | 530 | 'bootfs_rootfs', 'reserved_bootfs_rootfs', None]: | 350 | self.partition_layout = self.get_metadata_field( |
1704 | 531 | cls.fat_size = 32 | 351 | PARTITION_LAYOUT_FIELD) |
1705 | 532 | elif cls.partition_layout == 'bootfs16_rootfs': | 352 | if self.partition_layout in [BOOTFS, RESERVED_BOOTFS, None]: |
1706 | 533 | cls.fat_size = 16 | 353 | self.fat_size = 32 |
1707 | 354 | elif self.partition_layout == BOOTFS16: | ||
1708 | 355 | self.fat_size = 16 | ||
1709 | 534 | else: | 356 | else: |
1710 | 535 | raise AssertionError("Unknown partition layout '%s'." % \ | 357 | raise AssertionError("Unknown partition layout '%s'." % \ |
1729 | 536 | cls.partition_layout) | 358 | self.partition_layout) |
1730 | 537 | 359 | ||
1731 | 538 | cls.mmc_option = cls.get_metadata_field('mmc_id') | 360 | self.mmc_option = self.get_metadata_field(MMC_ID_FIELD) |
1732 | 539 | if cls.mmc_option is not None: | 361 | if self.mmc_option: |
1733 | 540 | cls.mmc_device_id = int(cls.mmc_option.split(':')[0]) | 362 | self.mmc_device_id = int(self.mmc_option.split(':')[0]) |
1734 | 541 | cls.mmc_part_offset = int(cls.mmc_option.split(':')[1]) - 1 | 363 | self.mmc_part_offset = int(self.mmc_option.split(':')[1]) - 1 |
1735 | 542 | 364 | ||
1736 | 543 | boot_min_size = cls.get_metadata_field('boot_min_size') | 365 | # XXX: need to fix these values. |
1737 | 544 | if boot_min_size is not None: | 366 | boot_min_size = self.get_metadata_field(BOOT_MIN_SIZE_FIELD) |
1738 | 545 | cls.BOOT_MIN_SIZE_S = align_up(int(boot_min_size) * 1024 ** 2, | 367 | if boot_min_size: |
1739 | 546 | SECTOR_SIZE) / SECTOR_SIZE | 368 | self.BOOT_MIN_SIZE_S = align_up(int(boot_min_size) * 1024 ** 2, |
1740 | 547 | root_min_size = cls.get_metadata_field('root_min_size') | 369 | SECTOR_SIZE) / SECTOR_SIZE |
1741 | 548 | if root_min_size is not None: | 370 | root_min_size = self.get_metadata_field(ROOT_MIN_SIZE_FIELD) |
1742 | 549 | cls.ROOT_MIN_SIZE_S = align_up(int(root_min_size) * 1024 ** 2, | 371 | if root_min_size: |
1743 | 550 | SECTOR_SIZE) / SECTOR_SIZE | 372 | self.ROOT_MIN_SIZE_S = align_up(int(root_min_size) * 1024 ** 2, |
1744 | 551 | loader_min_size = cls.get_metadata_field('loader_min_size') | 373 | SECTOR_SIZE) / SECTOR_SIZE |
1745 | 552 | if loader_min_size is not None: | 374 | loader_min_size = self.get_metadata_field(LOADER_MIN_SIZE_FIELD) |
1746 | 553 | cls.LOADER_MIN_SIZE_S = ( | 375 | if loader_min_size: |
1747 | 376 | self.LOADER_MIN_SIZE_S = ( | ||
1748 | 554 | align_up(int(loader_min_size) * 1024 ** 2, | 377 | align_up(int(loader_min_size) * 1024 ** 2, |
1749 | 555 | SECTOR_SIZE) / SECTOR_SIZE) | 378 | SECTOR_SIZE) / SECTOR_SIZE) |
1750 | 556 | 379 | ||
1760 | 557 | bootloader_file_in_boot_part = cls.get_metadata_field( | 380 | spl_in_boot_part = self.get_metadata_field(SPL_IN_BOOT_PART_FIELD) |
1752 | 558 | 'bootloader_file_in_boot_part') | ||
1753 | 559 | if bootloader_file_in_boot_part is None: | ||
1754 | 560 | cls.bootloader_file_in_boot_part = False | ||
1755 | 561 | elif string.lower(bootloader_file_in_boot_part) == 'yes': | ||
1756 | 562 | cls.bootloader_file_in_boot_part = True | ||
1757 | 563 | elif string.lower(bootloader_file_in_boot_part) == 'no': | ||
1758 | 564 | cls.bootloader_file_in_boot_part = False | ||
1759 | 565 | spl_in_boot_part = cls.get_metadata_field('spl_in_boot_part') | ||
1761 | 566 | if spl_in_boot_part is None: | 381 | if spl_in_boot_part is None: |
1763 | 567 | cls.spl_in_boot_part = False | 382 | self.spl_in_boot_part = False |
1764 | 568 | elif string.lower(spl_in_boot_part) == 'yes': | 383 | elif string.lower(spl_in_boot_part) == 'yes': |
1766 | 569 | cls.spl_in_boot_part = True | 384 | self.spl_in_boot_part = True |
1767 | 570 | elif string.lower(spl_in_boot_part) == 'no': | 385 | elif string.lower(spl_in_boot_part) == 'no': |
1770 | 571 | cls.spl_in_boot_part = False | 386 | self.spl_in_boot_part = False |
1771 | 572 | env_dd = cls.get_metadata_field('env_dd') | 387 | |
1772 | 388 | env_dd = self.get_metadata_field(ENV_DD_FIELD) | ||
1773 | 573 | if env_dd is None: | 389 | if env_dd is None: |
1775 | 574 | cls.env_dd = False | 390 | self.env_dd = False |
1776 | 575 | elif string.lower(env_dd) == 'yes': | 391 | elif string.lower(env_dd) == 'yes': |
1778 | 576 | cls.env_dd = True | 392 | self.env_dd = True |
1779 | 577 | elif string.lower(env_dd) == 'no': | 393 | elif string.lower(env_dd) == 'no': |
1781 | 578 | cls.env_dd = False | 394 | self.env_dd = False |
1782 | 579 | 395 | ||
1784 | 580 | bootloader_dd = cls.get_metadata_field('bootloader_dd') | 396 | # XXX: in hwpack v3 this field is just called 'dd'. |
1785 | 397 | # Need to check its use. | ||
1786 | 398 | bootloader_dd = self.get_metadata_field('bootloader_dd') | ||
1787 | 581 | # Either bootloader_dd is not specified, or it contains the dd | 399 | # Either bootloader_dd is not specified, or it contains the dd |
1788 | 582 | # offset. | 400 | # offset. |
1789 | 583 | if bootloader_dd is None: | 401 | if bootloader_dd is None: |
1791 | 584 | cls.bootloader_dd = False | 402 | self.bootloader_dd = False |
1792 | 585 | else: | 403 | else: |
1795 | 586 | cls.bootloader_dd = int(bootloader_dd) | 404 | self.bootloader_dd = int(bootloader_dd) |
1796 | 587 | spl_dd = cls.get_metadata_field('spl_dd') | 405 | spl_dd = self.get_metadata_field(SPL_DD_FIELD) |
1797 | 588 | # Either spl_dd is not specified, or it contains the dd offset. | 406 | # Either spl_dd is not specified, or it contains the dd offset. |
1798 | 589 | if spl_dd is None: | 407 | if spl_dd is None: |
1800 | 590 | cls.spl_dd = False | 408 | self.spl_dd = False |
1801 | 591 | else: | 409 | else: |
1834 | 592 | cls.spl_dd = int(spl_dd) | 410 | self.spl_dd = int(spl_dd) |
1835 | 593 | 411 | ||
1836 | 594 | loader_start = cls.get_metadata_field('loader_start') | 412 | loader_start = self.get_metadata_field(LOADER_START_FIELD) |
1837 | 595 | if loader_start is not None: | 413 | if loader_start: |
1838 | 596 | cls.LOADER_START_S = int(loader_start) | 414 | self.loader_start_s = int(loader_start) |
1839 | 597 | samsung_bl1_start = cls.get_metadata_field('samsung_bl1_start') | 415 | samsung_bl1_start = self.get_metadata_field( |
1840 | 598 | if samsung_bl1_start is not None: | 416 | SAMSUNG_BL1_START_FIELD) |
1841 | 599 | cls.SAMSUNG_V310_BL1_START = int(samsung_bl1_start) | 417 | if samsung_bl1_start: |
1842 | 600 | samsung_bl1_len = cls.get_metadata_field('samsung_bl1_len') | 418 | self.samsung_v310_bl1_start = int(samsung_bl1_start) |
1843 | 601 | if samsung_bl1_len is not None: | 419 | samsung_bl1_len = self.get_metadata_field(SAMSUNG_BL1_LEN_FIELD) |
1844 | 602 | cls.SAMSUNG_V310_BL1_LEN = int(samsung_bl1_len) | 420 | if samsung_bl1_len: |
1845 | 603 | samsung_env_len = cls.get_metadata_field('samsung_env_len') | 421 | self.samsung_v310_bl1_len = int(samsung_bl1_len) |
1846 | 604 | if samsung_env_len is not None: | 422 | samsung_env_len = self.get_metadata_field(SAMSUNG_ENV_LEN_FIELD) |
1847 | 605 | cls.SAMSUNG_V310_ENV_LEN = int(samsung_env_len) | 423 | if samsung_env_len: |
1848 | 606 | assert cls.SAMSUNG_V310_ENV_LEN * SECTOR_SIZE == 16 * 1024, ( | 424 | self.samsung_v310_env_len = int(samsung_env_len) |
1849 | 607 | "BL1 expects u-boot environment to be 16 KiB") | 425 | samsung_bl2_len = self.get_metadata_field(SAMSUNG_BL2_LEN_FIELD) |
1850 | 608 | samsung_bl2_len = cls.get_metadata_field('samsung_bl2_len') | 426 | if samsung_bl2_len: |
1851 | 609 | if samsung_bl2_len is not None: | 427 | self.samsung_v310_bl2_len = int(samsung_bl2_len) |
1852 | 610 | cls.SAMSUNG_V310_BL2_LEN = int(samsung_bl2_len) | 428 | |
1853 | 611 | assert cls.SAMSUNG_V310_BL2_LEN * SECTOR_SIZE == 512 * 1024, ( | 429 | if (self.samsung_v310_bl1_start and self.samsung_v310_bl1_len): |
1854 | 612 | "BL1 expects BL2 (u-boot) to be 512 KiB") | 430 | self.samsung_v310_env_start = (self.samsung_v310_bl1_start + |
1855 | 613 | 431 | self.samsung_v310_bl1_len) | |
1856 | 614 | if (cls.SAMSUNG_V310_BL1_START and cls.SAMSUNG_V310_BL1_LEN): | 432 | if (self.samsung_v310_env_start and self.samsung_v310_env_len): |
1857 | 615 | cls.SAMSUNG_V310_ENV_START = (cls.SAMSUNG_V310_BL1_START + | 433 | self.samsung_v310_bl2_start = (self.samsung_v310_env_start + |
1858 | 616 | cls.SAMSUNG_V310_BL1_LEN) | 434 | self.samsung_v310_env_len) |
1859 | 617 | assert cls.SAMSUNG_V310_ENV_START == 33, ( | 435 | |
1860 | 618 | "BL1 expects u-boot environment at +33s") | 436 | self.bootloader_copy_files = self.hardwarepack_handler.get_field( |
1829 | 619 | if (cls.SAMSUNG_V310_ENV_START and cls.SAMSUNG_V310_ENV_LEN): | ||
1830 | 620 | cls.SAMSUNG_V310_BL2_START = (cls.SAMSUNG_V310_ENV_START + | ||
1831 | 621 | cls.SAMSUNG_V310_ENV_LEN) | ||
1832 | 622 | |||
1833 | 623 | cls.bootloader_copy_files = cls.hardwarepack_handler.get_field( | ||
1861 | 624 | "bootloader_copy_files")[0] | 437 | "bootloader_copy_files")[0] |
1862 | 625 | 438 | ||
1866 | 626 | cls.bootloader = cls.hardwarepack_handler.get_field( | 439 | # XXX: no reference in hwpackV3 format of these fields, double |
1867 | 627 | "bootloader") | 440 | # check if they can be dropped when killing v1. |
1868 | 628 | cls.board = board | 441 | self.bootloader = self.hardwarepack_handler.get_field( |
1869 | 442 | "bootloader") | ||
1870 | 443 | self.vmlinuz = self.get_metadata_field('vmlinuz') | ||
1871 | 444 | self.initrd = self.get_metadata_field('initrd') | ||
1872 | 445 | bootloader_file_in_boot_part = self.get_metadata_field( | ||
1873 | 446 | 'bootloader_file_in_boot_part') | ||
1874 | 447 | if bootloader_file_in_boot_part is None: | ||
1875 | 448 | self.bootloader_file_in_boot_part = False | ||
1876 | 449 | elif string.lower(bootloader_file_in_boot_part) == 'yes': | ||
1877 | 450 | self.bootloader_file_in_boot_part = True | ||
1878 | 451 | elif string.lower(bootloader_file_in_boot_part) == 'no': | ||
1879 | 452 | self.bootloader_file_in_boot_part = False | ||
1880 | 629 | 453 | ||
1883 | 630 | @classmethod | 454 | def get_file(self, file_alias, default=None): |
1882 | 631 | def get_file(cls, file_alias, default=None): | ||
1884 | 632 | # XXX remove the 'default' parameter when V1 support is removed! | 455 | # XXX remove the 'default' parameter when V1 support is removed! |
1886 | 633 | file_in_hwpack = cls.hardwarepack_handler.get_file(file_alias) | 456 | file_in_hwpack = self.hardwarepack_handler.get_file(file_alias) |
1887 | 634 | if file_in_hwpack is not None: | 457 | if file_in_hwpack is not None: |
1888 | 635 | return file_in_hwpack | 458 | return file_in_hwpack |
1889 | 636 | else: | 459 | else: |
1890 | 637 | return default | 460 | return default |
1891 | 638 | 461 | ||
1936 | 639 | @classmethod | 462 | def get_v1_sfdisk_cmd(self, should_align_boot_part=False): |
1937 | 640 | def get_v1_sfdisk_cmd(cls, should_align_boot_part=False): | 463 | # XXX: This default implementation and all overrides are left for V1 |
1938 | 641 | """Return the sfdisk command to partition the media. | 464 | # compatibility only. They should be removed as part of the work to |
1939 | 642 | 465 | # kill off hwpacks V1. | |
1940 | 643 | :param should_align_boot_part: Whether to align the boot partition too. | 466 | return self.get_normal_sfdisk_cmd(should_align_boot_part) |
1941 | 644 | 467 | ||
1942 | 645 | This default implementation returns a boot vfat partition of type | 468 | def get_normal_sfdisk_cmd(self, should_align_boot_part=False): |
1899 | 646 | FAT16 or FAT32, followed by a root partition. | ||
1900 | 647 | |||
1901 | 648 | XXX: This default implementation and all overrides are left for V1 | ||
1902 | 649 | compatibility only. They should be removed as part of the work to | ||
1903 | 650 | kill off hwpacks V1. | ||
1904 | 651 | """ | ||
1905 | 652 | if cls.fat_size == 32: | ||
1906 | 653 | partition_type = '0x0C' | ||
1907 | 654 | else: | ||
1908 | 655 | partition_type = '0x0E' | ||
1909 | 656 | |||
1910 | 657 | # align on sector 63 for compatibility with broken versions of x-loader | ||
1911 | 658 | # unless align_boot_part is set | ||
1912 | 659 | boot_align = 63 | ||
1913 | 660 | if should_align_boot_part: | ||
1914 | 661 | boot_align = PART_ALIGN_S | ||
1915 | 662 | |||
1916 | 663 | # can only start on sector 1 (sector 0 is MBR / partition table) | ||
1917 | 664 | boot_start, boot_end, boot_len = align_partition( | ||
1918 | 665 | 1, cls.BOOT_MIN_SIZE_S, boot_align, PART_ALIGN_S) | ||
1919 | 666 | # apparently OMAP3 ROMs require the vfat length to be an even number | ||
1920 | 667 | # of sectors (multiple of 1 KiB); decrease the length if it's odd, | ||
1921 | 668 | # there should still be enough room | ||
1922 | 669 | boot_len = boot_len - boot_len % 2 | ||
1923 | 670 | boot_end = boot_start + boot_len - 1 | ||
1924 | 671 | |||
1925 | 672 | # we ignore _root_end / _root_len and return a sfdisk command to | ||
1926 | 673 | # instruct the use of all remaining space; XXX if we had some root size | ||
1927 | 674 | # config, we could do something more sensible | ||
1928 | 675 | root_start, _root_end, _root_len = align_partition( | ||
1929 | 676 | boot_end + 1, cls.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) | ||
1930 | 677 | |||
1931 | 678 | return '%s,%s,%s,*\n%s,,,-' % ( | ||
1932 | 679 | boot_start, boot_len, partition_type, root_start) | ||
1933 | 680 | |||
1934 | 681 | @classmethod | ||
1935 | 682 | def get_normal_sfdisk_cmd(cls, should_align_boot_part=False): | ||
1943 | 683 | """Return the sfdisk command to partition the media. | 469 | """Return the sfdisk command to partition the media. |
1944 | 684 | 470 | ||
1945 | 685 | :param should_align_boot_part: Whether to align the boot partition too. | 471 | :param should_align_boot_part: Whether to align the boot partition too. |
1946 | @@ -687,7 +473,7 @@ | |||
1947 | 687 | This returns a boot vfat partition of type FAT16 | 473 | This returns a boot vfat partition of type FAT16 |
1948 | 688 | or FAT32, followed by a root partition. | 474 | or FAT32, followed by a root partition. |
1949 | 689 | """ | 475 | """ |
1951 | 690 | if cls.fat_size == 32: | 476 | if self.fat_size == 32: |
1952 | 691 | partition_type = '0x0C' | 477 | partition_type = '0x0C' |
1953 | 692 | else: | 478 | else: |
1954 | 693 | partition_type = '0x0E' | 479 | partition_type = '0x0E' |
1955 | @@ -701,7 +487,7 @@ | |||
1956 | 701 | 487 | ||
1957 | 702 | # can only start on sector 1 (sector 0 is MBR / partition table) | 488 | # can only start on sector 1 (sector 0 is MBR / partition table) |
1958 | 703 | boot_start, boot_end, boot_len = align_partition( | 489 | boot_start, boot_end, boot_len = align_partition( |
1960 | 704 | 1, cls.BOOT_MIN_SIZE_S, boot_align, PART_ALIGN_S) | 490 | 1, self.BOOT_MIN_SIZE_S, boot_align, PART_ALIGN_S) |
1961 | 705 | # apparently OMAP3 ROMs require the vfat length to be an even number | 491 | # apparently OMAP3 ROMs require the vfat length to be an even number |
1962 | 706 | # of sectors (multiple of 1 KiB); decrease the length if it's odd, | 492 | # of sectors (multiple of 1 KiB); decrease the length if it's odd, |
1963 | 707 | # there should still be enough room | 493 | # there should still be enough room |
1964 | @@ -713,13 +499,12 @@ | |||
1965 | 713 | # instruct the use of all remaining space; XXX we now have root size | 499 | # instruct the use of all remaining space; XXX we now have root size |
1966 | 714 | # config, so we can do something more sensible | 500 | # config, so we can do something more sensible |
1967 | 715 | root_start, _root_end, _root_len = align_partition( | 501 | root_start, _root_end, _root_len = align_partition( |
1969 | 716 | boot_end + 1, cls.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) | 502 | boot_end + 1, self.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) |
1970 | 717 | 503 | ||
1971 | 718 | return '%s,%s,%s,*\n%s,,,-' % ( | 504 | return '%s,%s,%s,*\n%s,,,-' % ( |
1972 | 719 | boot_start, boot_len, partition_type, root_start) | 505 | boot_start, boot_len, partition_type, root_start) |
1973 | 720 | 506 | ||
1976 | 721 | @classmethod | 507 | def get_reserved_sfdisk_cmd(self, should_align_boot_part=None): |
1975 | 722 | def get_reserved_sfdisk_cmd(cls, should_align_boot_part=None): | ||
1977 | 723 | """Return the sfdisk command to partition the media. | 508 | """Return the sfdisk command to partition the media. |
1978 | 724 | 509 | ||
1979 | 725 | :param should_align_boot_part: Ignored. | 510 | :param should_align_boot_part: Ignored. |
1980 | @@ -728,40 +513,38 @@ | |||
1981 | 728 | FAT16 or FAT32, followed by a root partition. | 513 | FAT16 or FAT32, followed by a root partition. |
1982 | 729 | """ | 514 | """ |
1983 | 730 | loader_start, loader_end, loader_len = align_partition( | 515 | loader_start, loader_end, loader_len = align_partition( |
1985 | 731 | cls.LOADER_START_S, cls.LOADER_MIN_SIZE_S, 1, PART_ALIGN_S) | 516 | self.loader_start_s, self.LOADER_MIN_SIZE_S, 1, PART_ALIGN_S) |
1986 | 732 | 517 | ||
1987 | 733 | boot_start, boot_end, boot_len = align_partition( | 518 | boot_start, boot_end, boot_len = align_partition( |
1989 | 734 | loader_end + 1, cls.BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) | 519 | loader_end + 1, self.BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) |
1990 | 735 | 520 | ||
1991 | 736 | root_start, _root_end, _root_len = align_partition( | 521 | root_start, _root_end, _root_len = align_partition( |
1993 | 737 | boot_end + 1, cls.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) | 522 | boot_end + 1, self.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) |
1994 | 738 | 523 | ||
1995 | 739 | return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % ( | 524 | return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % ( |
1996 | 740 | loader_start, loader_len, boot_start, boot_len, root_start) | 525 | loader_start, loader_len, boot_start, boot_len, root_start) |
1997 | 741 | 526 | ||
2005 | 742 | @classmethod | 527 | def get_sfdisk_cmd(self, should_align_boot_part=False): |
2006 | 743 | def get_sfdisk_cmd(cls, should_align_boot_part=False): | 528 | if (self.partition_layout in ['bootfs_rootfs', 'bootfs16_rootfs'] or |
2007 | 744 | if (cls.partition_layout in ['bootfs_rootfs', 'bootfs16_rootfs'] or | 529 | self.board == 'snowball_sd'): |
2008 | 745 | cls.board == 'snowball_sd'): | 530 | return self.get_normal_sfdisk_cmd(should_align_boot_part) |
2009 | 746 | return cls.get_normal_sfdisk_cmd(should_align_boot_part) | 531 | elif self.partition_layout in ['reserved_bootfs_rootfs']: |
2010 | 747 | elif cls.partition_layout in ['reserved_bootfs_rootfs']: | 532 | return self.get_reserved_sfdisk_cmd(should_align_boot_part) |
2004 | 748 | return cls.get_reserved_sfdisk_cmd(should_align_boot_part) | ||
2011 | 749 | else: | 533 | else: |
2013 | 750 | assert (cls.hwpack_format == HardwarepackHandler.FORMAT_1), ( | 534 | assert (self.hwpack_format == HardwarepackHandler.FORMAT_1), ( |
2014 | 751 | "Hwpack format is not 1.0 but " | 535 | "Hwpack format is not 1.0 but " |
2015 | 752 | "partition_layout is unspecified.") | 536 | "partition_layout is unspecified.") |
2017 | 753 | return cls.get_v1_sfdisk_cmd(should_align_boot_part) | 537 | return self.get_v1_sfdisk_cmd(should_align_boot_part) |
2018 | 754 | 538 | ||
2021 | 755 | @classmethod | 539 | def _get_bootcmd(self, i_img_data, d_img_data): |
2020 | 756 | def _get_bootcmd(cls, i_img_data, d_img_data): | ||
2022 | 757 | """Get the bootcmd for this board. | 540 | """Get the bootcmd for this board. |
2023 | 758 | 541 | ||
2024 | 759 | In general subclasses should not have to override this. | 542 | In general subclasses should not have to override this. |
2025 | 760 | """ | 543 | """ |
2026 | 761 | replacements = dict( | 544 | replacements = dict( |
2030 | 762 | fatload_command=cls.fatload_command, uimage_path=cls.uimage_path, | 545 | fatload_command=self.fatload_command, uimage_path=self.uimage_path, |
2031 | 763 | mmc_option=cls.mmc_option, kernel_addr=cls.kernel_addr, | 546 | mmc_option=self.mmc_option, kernel_addr=self.kernel_addr, |
2032 | 764 | initrd_addr=cls.initrd_addr, dtb_addr=cls.dtb_addr) | 547 | initrd_addr=self.initrd_addr, dtb_addr=self.dtb_addr) |
2033 | 765 | boot_script = ( | 548 | boot_script = ( |
2034 | 766 | ("%(fatload_command)s mmc %(mmc_option)s %(kernel_addr)s " + | 549 | ("%(fatload_command)s mmc %(mmc_option)s %(kernel_addr)s " + |
2035 | 767 | "%(uimage_path)suImage; ")) % replacements | 550 | "%(uimage_path)suImage; ")) % replacements |
2036 | @@ -770,7 +553,7 @@ | |||
2037 | 770 | ("%(fatload_command)s mmc %(mmc_option)s %(initrd_addr)s " + | 553 | ("%(fatload_command)s mmc %(mmc_option)s %(initrd_addr)s " + |
2038 | 771 | "%(uimage_path)suInitrd; ")) % replacements | 554 | "%(uimage_path)suInitrd; ")) % replacements |
2039 | 772 | if d_img_data is not None: | 555 | if d_img_data is not None: |
2041 | 773 | assert cls.dtb_addr is not None, ( | 556 | assert self.dtb_addr is not None, ( |
2042 | 774 | "Need a dtb_addr when passing d_img_data") | 557 | "Need a dtb_addr when passing d_img_data") |
2043 | 775 | boot_script += ( | 558 | boot_script += ( |
2044 | 776 | ("%(fatload_command)s mmc %(mmc_option)s %(dtb_addr)s " + | 559 | ("%(fatload_command)s mmc %(mmc_option)s %(dtb_addr)s " + |
2045 | @@ -782,37 +565,34 @@ | |||
2046 | 782 | boot_script += ((" %(dtb_addr)s")) % replacements | 565 | boot_script += ((" %(dtb_addr)s")) % replacements |
2047 | 783 | return boot_script | 566 | return boot_script |
2048 | 784 | 567 | ||
2051 | 785 | @classmethod | 568 | def add_boot_args(self, extra_args): |
2050 | 786 | def add_boot_args(cls, extra_args): | ||
2052 | 787 | if extra_args is not None: | 569 | if extra_args is not None: |
2055 | 788 | if cls.extra_boot_args_options is None: | 570 | if self.extra_boot_args_options is None: |
2056 | 789 | cls.extra_boot_args_options = extra_args | 571 | self.extra_boot_args_options = extra_args |
2057 | 790 | else: | 572 | else: |
2059 | 791 | cls.extra_boot_args_options += ' %s' % extra_args | 573 | self.extra_boot_args_options += ' %s' % extra_args |
2060 | 792 | 574 | ||
2063 | 793 | @classmethod | 575 | def add_boot_args_from_file(self, path): |
2062 | 794 | def add_boot_args_from_file(cls, path): | ||
2064 | 795 | if path is not None: | 576 | if path is not None: |
2065 | 796 | with open(path, 'r') as boot_args_file: | 577 | with open(path, 'r') as boot_args_file: |
2067 | 797 | cls.add_boot_args(boot_args_file.read().strip()) | 578 | self.add_boot_args(boot_args_file.read().strip()) |
2068 | 798 | 579 | ||
2071 | 799 | @classmethod | 580 | def _get_bootargs(self, is_live, is_lowmem, consoles, rootfs_id): |
2070 | 800 | def _get_bootargs(cls, is_live, is_lowmem, consoles, rootfs_id): | ||
2072 | 801 | """Get the bootargs for this board. | 581 | """Get the bootargs for this board. |
2073 | 802 | 582 | ||
2074 | 803 | In general subclasses should not have to override this. | 583 | In general subclasses should not have to override this. |
2075 | 804 | """ | 584 | """ |
2076 | 805 | boot_args_options = 'rootwait ro' | 585 | boot_args_options = 'rootwait ro' |
2080 | 806 | if cls.extra_boot_args_options is not None: | 586 | if self.extra_boot_args_options: |
2081 | 807 | boot_args_options += ' %s' % cls.extra_boot_args_options | 587 | boot_args_options += ' %s' % self.extra_boot_args_options |
2082 | 808 | serial_opts = cls.extra_serial_opts | 588 | serial_opts = self.extra_serial_opts |
2083 | 809 | for console in consoles: | 589 | for console in consoles: |
2084 | 810 | serial_opts += ' console=%s' % console | 590 | serial_opts += ' console=%s' % console |
2085 | 811 | 591 | ||
2086 | 812 | lowmem_opt = '' | 592 | lowmem_opt = '' |
2087 | 813 | boot_snippet = 'root=%s' % rootfs_id | 593 | boot_snippet = 'root=%s' % rootfs_id |
2088 | 814 | if is_live: | 594 | if is_live: |
2090 | 815 | serial_opts += ' %s' % cls.live_serial_opts | 595 | serial_opts += ' %s' % self.live_serial_opts |
2091 | 816 | boot_snippet = 'boot=casper' | 596 | boot_snippet = 'boot=casper' |
2092 | 817 | if is_lowmem: | 597 | if is_lowmem: |
2093 | 818 | lowmem_opt = 'only-ubiquity' | 598 | lowmem_opt = 'only-ubiquity' |
2094 | @@ -826,45 +606,42 @@ | |||
2095 | 826 | "%(boot_snippet)s %(boot_args_options)s" | 606 | "%(boot_snippet)s %(boot_args_options)s" |
2096 | 827 | % replacements) | 607 | % replacements) |
2097 | 828 | 608 | ||
2100 | 829 | @classmethod | 609 | def _get_boot_env(self, is_live, is_lowmem, consoles, rootfs_id, |
2099 | 830 | def _get_boot_env(cls, is_live, is_lowmem, consoles, rootfs_id, | ||
2101 | 831 | i_img_data, d_img_data): | 610 | i_img_data, d_img_data): |
2102 | 832 | """Get the boot environment for this board. | 611 | """Get the boot environment for this board. |
2103 | 833 | 612 | ||
2104 | 834 | In general subclasses should not have to override this. | 613 | In general subclasses should not have to override this. |
2105 | 835 | """ | 614 | """ |
2106 | 836 | boot_env = {} | 615 | boot_env = {} |
2108 | 837 | boot_env["bootargs"] = cls._get_bootargs( | 616 | boot_env["bootargs"] = self._get_bootargs( |
2109 | 838 | is_live, is_lowmem, consoles, rootfs_id) | 617 | is_live, is_lowmem, consoles, rootfs_id) |
2113 | 839 | boot_env["bootcmd"] = cls._get_bootcmd(i_img_data, d_img_data) | 618 | boot_env["bootcmd"] = self._get_bootcmd(i_img_data, d_img_data) |
2114 | 840 | boot_env["initrd_high"] = cls.initrd_high | 619 | boot_env["initrd_high"] = self.initrd_high |
2115 | 841 | boot_env["fdt_high"] = cls.fdt_high | 620 | boot_env["fdt_high"] = self.fdt_high |
2116 | 842 | return boot_env | 621 | return boot_env |
2117 | 843 | 622 | ||
2120 | 844 | @classmethod | 623 | def make_boot_files(self, bootloader_parts_dir, is_live, is_lowmem, |
2119 | 845 | def make_boot_files(cls, bootloader_parts_dir, is_live, is_lowmem, | ||
2121 | 846 | consoles, chroot_dir, rootfs_id, boot_dir, | 624 | consoles, chroot_dir, rootfs_id, boot_dir, |
2122 | 847 | boot_device_or_file): | 625 | boot_device_or_file): |
2124 | 848 | if cls.hwpack_format == HardwarepackHandler.FORMAT_1: | 626 | if self.hwpack_format == HardwarepackHandler.FORMAT_1: |
2125 | 849 | parts_dir = bootloader_parts_dir | 627 | parts_dir = bootloader_parts_dir |
2126 | 850 | else: | 628 | else: |
2127 | 851 | parts_dir = chroot_dir | 629 | parts_dir = chroot_dir |
2129 | 852 | (k_img_data, i_img_data, d_img_data) = cls._get_kflavor_files( | 630 | (k_img_data, i_img_data, d_img_data) = self._get_kflavor_files( |
2130 | 853 | parts_dir) | 631 | parts_dir) |
2132 | 854 | boot_env = cls._get_boot_env(is_live, is_lowmem, consoles, rootfs_id, | 632 | boot_env = self._get_boot_env(is_live, is_lowmem, consoles, rootfs_id, |
2133 | 855 | i_img_data, d_img_data) | 633 | i_img_data, d_img_data) |
2134 | 856 | 634 | ||
2137 | 857 | if cls.hwpack_format == HardwarepackHandler.FORMAT_1: | 635 | if self.hwpack_format == HardwarepackHandler.FORMAT_1: |
2138 | 858 | cls._make_boot_files( | 636 | self._make_boot_files( |
2139 | 859 | boot_env, chroot_dir, boot_dir, | 637 | boot_env, chroot_dir, boot_dir, |
2140 | 860 | boot_device_or_file, k_img_data, i_img_data, d_img_data) | 638 | boot_device_or_file, k_img_data, i_img_data, d_img_data) |
2141 | 861 | else: | 639 | else: |
2143 | 862 | cls._make_boot_files_v2( | 640 | self._make_boot_files_v2( |
2144 | 863 | boot_env, chroot_dir, boot_dir, | 641 | boot_env, chroot_dir, boot_dir, |
2145 | 864 | boot_device_or_file, k_img_data, i_img_data, d_img_data) | 642 | boot_device_or_file, k_img_data, i_img_data, d_img_data) |
2146 | 865 | 643 | ||
2149 | 866 | @classmethod | 644 | def _copy_dtb_files(self, dtb_files, dest_dir, search_dir): |
2148 | 867 | def _copy_dtb_files(cls, dtb_files, dest_dir, search_dir): | ||
2150 | 868 | """Copy the files defined in dtb_files into the boot directory. | 645 | """Copy the files defined in dtb_files into the boot directory. |
2151 | 869 | 646 | ||
2152 | 870 | :param dtb_files: The list of dtb files | 647 | :param dtb_files: The list of dtb files |
2153 | @@ -904,13 +681,12 @@ | |||
2154 | 904 | else: | 681 | else: |
2155 | 905 | # Hopefully we should never get here. | 682 | # Hopefully we should never get here. |
2156 | 906 | # This should only happen if the hwpack config YAML file is | 683 | # This should only happen if the hwpack config YAML file is |
2158 | 907 | # wrong | 684 | # wrong. |
2159 | 908 | logger.warn('WARNING: Wrong syntax in metadata file. ' | 685 | logger.warn('WARNING: Wrong syntax in metadata file. ' |
2160 | 909 | 'Check the hwpack configuration file used to ' | 686 | 'Check the hwpack configuration file used to ' |
2161 | 910 | 'generate the hwpack archive.') | 687 | 'generate the hwpack archive.') |
2162 | 911 | 688 | ||
2165 | 912 | @classmethod | 689 | def _dd_file(self, from_file, to_file, seek, max_size=None): |
2164 | 913 | def _dd_file(cls, from_file, to_file, seek, max_size=None): | ||
2166 | 914 | assert from_file is not None, "No source file name given." | 690 | assert from_file is not None, "No source file name given." |
2167 | 915 | if max_size is not None: | 691 | if max_size is not None: |
2168 | 916 | assert os.path.getsize(from_file) <= max_size, ( | 692 | assert os.path.getsize(from_file) <= max_size, ( |
2169 | @@ -918,23 +694,21 @@ | |||
2170 | 918 | logger.info("Writing '%s' to '%s' at %s." % (from_file, to_file, seek)) | 694 | logger.info("Writing '%s' to '%s' at %s." % (from_file, to_file, seek)) |
2171 | 919 | _dd(from_file, to_file, seek=seek) | 695 | _dd(from_file, to_file, seek=seek) |
2172 | 920 | 696 | ||
2175 | 921 | @classmethod | 697 | def install_samsung_boot_loader(self, samsung_spl_file, bootloader_file, |
2174 | 922 | def install_samsung_boot_loader(cls, samsung_spl_file, bootloader_file, | ||
2176 | 923 | boot_device_or_file): | 698 | boot_device_or_file): |
2183 | 924 | cls._dd_file(samsung_spl_file, boot_device_or_file, | 699 | self._dd_file(samsung_spl_file, boot_device_or_file, |
2184 | 925 | cls.SAMSUNG_V310_BL1_START, | 700 | self.samsung_v310_bl1_start, |
2185 | 926 | cls.SAMSUNG_V310_BL1_LEN * SECTOR_SIZE) | 701 | self.samsung_v310_bl1_len * SECTOR_SIZE) |
2186 | 927 | cls._dd_file(bootloader_file, boot_device_or_file, | 702 | self._dd_file(bootloader_file, boot_device_or_file, |
2187 | 928 | cls.SAMSUNG_V310_BL2_START, | 703 | self.samsung_v310_bl2_start, |
2188 | 929 | cls.SAMSUNG_V310_BL2_LEN * SECTOR_SIZE) | 704 | self.samsung_v310_bl2_len * SECTOR_SIZE) |
2189 | 930 | 705 | ||
2192 | 931 | @classmethod | 706 | def _make_boot_files_v2(self, boot_env, chroot_dir, boot_dir, |
2191 | 932 | def _make_boot_files_v2(cls, boot_env, chroot_dir, boot_dir, | ||
2193 | 933 | boot_device_or_file, k_img_data, i_img_data, | 707 | boot_device_or_file, k_img_data, i_img_data, |
2194 | 934 | d_img_data): | 708 | d_img_data): |
2198 | 935 | with cls.hardwarepack_handler: | 709 | with self.hardwarepack_handler: |
2199 | 936 | spl_file = cls.get_file('spl_file') | 710 | spl_file = self.get_file('spl_file') |
2200 | 937 | if cls.spl_in_boot_part: | 711 | if self.spl_in_boot_part: |
2201 | 938 | assert spl_file is not None, ( | 712 | assert spl_file is not None, ( |
2202 | 939 | "SPL binary could not be found") | 713 | "SPL binary could not be found") |
2203 | 940 | logger.info( | 714 | logger.info( |
2204 | @@ -944,15 +718,15 @@ | |||
2205 | 944 | # XXX: Is this really needed? | 718 | # XXX: Is this really needed? |
2206 | 945 | cmd_runner.run(["sync"]).wait() | 719 | cmd_runner.run(["sync"]).wait() |
2207 | 946 | 720 | ||
2217 | 947 | if cls.spl_dd: | 721 | if self.spl_dd: |
2218 | 948 | cls._dd_file(spl_file, boot_device_or_file, cls.spl_dd) | 722 | self._dd_file(spl_file, boot_device_or_file, self.spl_dd) |
2219 | 949 | 723 | ||
2220 | 950 | bootloader_file = cls.get_file('bootloader_file') | 724 | bootloader_file = self.get_file('bootloader_file') |
2221 | 951 | if cls.bootloader_dd: | 725 | if self.bootloader_dd: |
2222 | 952 | cls._dd_file(bootloader_file, boot_device_or_file, | 726 | self._dd_file(bootloader_file, boot_device_or_file, |
2223 | 953 | cls.bootloader_dd) | 727 | self.bootloader_dd) |
2224 | 954 | 728 | ||
2225 | 955 | make_uImage(cls.load_addr, k_img_data, boot_dir) | 729 | make_uImage(self.load_addr, k_img_data, boot_dir) |
2226 | 956 | 730 | ||
2227 | 957 | if i_img_data is not None: | 731 | if i_img_data is not None: |
2228 | 958 | make_uInitrd(i_img_data, boot_dir) | 732 | make_uInitrd(i_img_data, boot_dir) |
2229 | @@ -960,29 +734,28 @@ | |||
2230 | 960 | if d_img_data is not None: | 734 | if d_img_data is not None: |
2231 | 961 | make_dtb(d_img_data, boot_dir) | 735 | make_dtb(d_img_data, boot_dir) |
2232 | 962 | 736 | ||
2235 | 963 | if cls.boot_script is not None: | 737 | if self.boot_script is not None: |
2236 | 964 | boot_script_path = os.path.join(boot_dir, cls.boot_script) | 738 | boot_script_path = os.path.join(boot_dir, self.boot_script) |
2237 | 965 | make_boot_script(boot_env, boot_script_path) | 739 | make_boot_script(boot_env, boot_script_path) |
2238 | 966 | 740 | ||
2239 | 967 | # Only used for Omap, will this be bad for the other boards? | 741 | # Only used for Omap, will this be bad for the other boards? |
2240 | 968 | make_boot_ini(boot_script_path, boot_dir) | 742 | make_boot_ini(boot_script_path, boot_dir) |
2241 | 969 | 743 | ||
2245 | 970 | if (cls.snowball_startup_files_config is not None and | 744 | if (self.snowball_startup_files_config is not None and |
2246 | 971 | cls.board != 'snowball_sd'): | 745 | self.board != 'snowball_sd'): |
2247 | 972 | cls.populate_raw_partition(boot_device_or_file, chroot_dir) | 746 | self.populate_raw_partition(boot_device_or_file, chroot_dir) |
2248 | 973 | 747 | ||
2250 | 974 | if cls.env_dd: | 748 | if self.env_dd: |
2251 | 975 | # Do we need to zero out the env before flashing it? | 749 | # Do we need to zero out the env before flashing it? |
2252 | 976 | _dd("/dev/zero", boot_device_or_file, | 750 | _dd("/dev/zero", boot_device_or_file, |
2256 | 977 | count=cls.SAMSUNG_V310_ENV_LEN, | 751 | count=self.samsung_v310_env_len, |
2257 | 978 | seek=cls.SAMSUNG_V310_ENV_START) | 752 | seek=self.samsung_v310_env_start) |
2258 | 979 | env_size = cls.SAMSUNG_V310_ENV_LEN * SECTOR_SIZE | 753 | env_size = self.samsung_v310_env_len * SECTOR_SIZE |
2259 | 980 | env_file = make_flashable_env(boot_env, env_size) | 754 | env_file = make_flashable_env(boot_env, env_size) |
2262 | 981 | cls._dd_file(env_file, boot_device_or_file, | 755 | self._dd_file(env_file, boot_device_or_file, |
2263 | 982 | cls.SAMSUNG_V310_ENV_START) | 756 | self.samsung_v310_env_start) |
2264 | 983 | 757 | ||
2267 | 984 | @classmethod | 758 | def _make_boot_files(self, boot_env, chroot_dir, boot_dir, |
2266 | 985 | def _make_boot_files(cls, boot_env, chroot_dir, boot_dir, | ||
2268 | 986 | boot_device_or_file, k_img_data, i_img_data, | 759 | boot_device_or_file, k_img_data, i_img_data, |
2269 | 987 | d_img_data): | 760 | d_img_data): |
2270 | 988 | """Make the necessary boot files for this board. | 761 | """Make the necessary boot files for this board. |
2271 | @@ -992,8 +765,7 @@ | |||
2272 | 992 | """ | 765 | """ |
2273 | 993 | raise NotImplementedError() | 766 | raise NotImplementedError() |
2274 | 994 | 767 | ||
2277 | 995 | @classmethod | 768 | def populate_boot(self, chroot_dir, rootfs_id, boot_partition, boot_disk, |
2276 | 996 | def populate_boot(cls, chroot_dir, rootfs_id, boot_partition, boot_disk, | ||
2278 | 997 | boot_device_or_file, is_live, is_lowmem, consoles): | 769 | boot_device_or_file, is_live, is_lowmem, consoles): |
2279 | 998 | parts_dir = 'boot' | 770 | parts_dir = 'boot' |
2280 | 999 | if is_live: | 771 | if is_live: |
2281 | @@ -1001,21 +773,21 @@ | |||
2282 | 1001 | bootloader_parts_dir = os.path.join(chroot_dir, parts_dir) | 773 | bootloader_parts_dir = os.path.join(chroot_dir, parts_dir) |
2283 | 1002 | cmd_runner.run(['mkdir', '-p', boot_disk]).wait() | 774 | cmd_runner.run(['mkdir', '-p', boot_disk]).wait() |
2284 | 1003 | with partition_mounted(boot_partition, boot_disk): | 775 | with partition_mounted(boot_partition, boot_disk): |
2287 | 1004 | with cls.hardwarepack_handler: | 776 | with self.hardwarepack_handler: |
2288 | 1005 | if cls.bootloader_file_in_boot_part: | 777 | if self.bootloader_file_in_boot_part: |
2289 | 1006 | # <legacy v1 support> | 778 | # <legacy v1 support> |
2291 | 1007 | if cls.bootloader_flavor is not None: | 779 | if self.bootloader_flavor is not None: |
2292 | 1008 | default = os.path.join( | 780 | default = os.path.join( |
2293 | 1009 | chroot_dir, 'usr', 'lib', 'u-boot', | 781 | chroot_dir, 'usr', 'lib', 'u-boot', |
2295 | 1010 | cls.bootloader_flavor, 'u-boot.img') | 782 | self.bootloader_flavor, 'u-boot.img') |
2296 | 1011 | if not os.path.exists(default): | 783 | if not os.path.exists(default): |
2297 | 1012 | default = os.path.join( | 784 | default = os.path.join( |
2298 | 1013 | chroot_dir, 'usr', 'lib', 'u-boot', | 785 | chroot_dir, 'usr', 'lib', 'u-boot', |
2300 | 1014 | cls.bootloader_flavor, 'u-boot.bin') | 786 | self.bootloader_flavor, 'u-boot.bin') |
2301 | 1015 | else: | 787 | else: |
2302 | 1016 | default = None | 788 | default = None |
2303 | 1017 | # </legacy v1 support> | 789 | # </legacy v1 support> |
2305 | 1018 | bootloader_bin = cls.get_file('bootloader_file', | 790 | bootloader_bin = self.get_file('bootloader_file', |
2306 | 1019 | default=default) | 791 | default=default) |
2307 | 1020 | assert bootloader_bin is not None, ( | 792 | assert bootloader_bin is not None, ( |
2308 | 1021 | "bootloader binary could not be found") | 793 | "bootloader binary could not be found") |
2309 | @@ -1025,18 +797,17 @@ | |||
2310 | 1025 | proc.wait() | 797 | proc.wait() |
2311 | 1026 | 798 | ||
2312 | 1027 | # Handle copy_files field. | 799 | # Handle copy_files field. |
2314 | 1028 | cls.copy_files(boot_disk) | 800 | self.copy_files(boot_disk) |
2315 | 1029 | 801 | ||
2316 | 1030 | # Handle dtb_files field. | 802 | # Handle dtb_files field. |
2319 | 1031 | if cls.dtb_files: | 803 | if self.dtb_files: |
2320 | 1032 | cls._copy_dtb_files(cls.dtb_files, boot_disk, chroot_dir) | 804 | self._copy_dtb_files(self.dtb_files, boot_disk, chroot_dir) |
2321 | 1033 | 805 | ||
2323 | 1034 | cls.make_boot_files( | 806 | self.make_boot_files( |
2324 | 1035 | bootloader_parts_dir, is_live, is_lowmem, consoles, chroot_dir, | 807 | bootloader_parts_dir, is_live, is_lowmem, consoles, chroot_dir, |
2325 | 1036 | rootfs_id, boot_disk, boot_device_or_file) | 808 | rootfs_id, boot_disk, boot_device_or_file) |
2326 | 1037 | 809 | ||
2329 | 1038 | @classmethod | 810 | def copy_files(self, boot_disk): |
2328 | 1039 | def copy_files(cls, boot_disk): | ||
2330 | 1040 | """Handle the copy_files metadata field.""" | 811 | """Handle the copy_files metadata field.""" |
2331 | 1041 | 812 | ||
2332 | 1042 | # Extract anything specified by copy_files sections | 813 | # Extract anything specified by copy_files sections |
2333 | @@ -1046,13 +817,14 @@ | |||
2334 | 1046 | # {'source_path': 'dest_path'} | 817 | # {'source_path': 'dest_path'} |
2335 | 1047 | # ] | 818 | # ] |
2336 | 1048 | # } | 819 | # } |
2338 | 1049 | if cls.bootloader_copy_files is None: | 820 | if self.bootloader_copy_files is None: |
2339 | 1050 | return | 821 | return |
2340 | 1051 | 822 | ||
2342 | 1052 | for source_package, file_list in cls.bootloader_copy_files.iteritems(): | 823 | for source_package, file_list in \ |
2343 | 824 | self.bootloader_copy_files.iteritems(): | ||
2344 | 1053 | for file_info in file_list: | 825 | for file_info in file_list: |
2345 | 1054 | for source_path, dest_path in file_info.iteritems(): | 826 | for source_path, dest_path in file_info.iteritems(): |
2347 | 1055 | source = cls.hardwarepack_handler.get_file_from_package( | 827 | source = self.hardwarepack_handler.get_file_from_package( |
2348 | 1056 | source_path, source_package) | 828 | source_path, source_package) |
2349 | 1057 | dest_path = dest_path.lstrip("/\\") | 829 | dest_path = dest_path.lstrip("/\\") |
2350 | 1058 | dirname = os.path.dirname(dest_path) | 830 | dirname = os.path.dirname(dest_path) |
2351 | @@ -1065,25 +837,24 @@ | |||
2352 | 1065 | os.path.join(boot_disk, dest_path)], as_root=True) | 837 | os.path.join(boot_disk, dest_path)], as_root=True) |
2353 | 1066 | proc.wait() | 838 | proc.wait() |
2354 | 1067 | 839 | ||
2357 | 1068 | @classmethod | 840 | def _get_kflavor_files(self, path): |
2356 | 1069 | def _get_kflavor_files(cls, path): | ||
2358 | 1070 | """Search for kernel, initrd and optional dtb in path.""" | 841 | """Search for kernel, initrd and optional dtb in path.""" |
2360 | 1071 | if cls.kernel_flavors is None: | 842 | if self.kernel_flavors is None: |
2361 | 1072 | # V2 metadata specifies each glob, not flavors. | 843 | # V2 metadata specifies each glob, not flavors. |
2362 | 1073 | # XXX This duplication is temporary until V1 dies. | 844 | # XXX This duplication is temporary until V1 dies. |
2364 | 1074 | return cls._get_kflavor_files_v2(path) | 845 | return self._get_kflavor_files_v2(path) |
2365 | 1075 | 846 | ||
2367 | 1076 | for flavor in cls.kernel_flavors: | 847 | for flavor in self.kernel_flavors: |
2368 | 1077 | kregex = KERNEL_GLOB % {'kernel_flavor': flavor} | 848 | kregex = KERNEL_GLOB % {'kernel_flavor': flavor} |
2369 | 1078 | iregex = INITRD_GLOB % {'kernel_flavor': flavor} | 849 | iregex = INITRD_GLOB % {'kernel_flavor': flavor} |
2370 | 1079 | dregex = DTB_GLOB % {'kernel_flavor': flavor, | 850 | dregex = DTB_GLOB % {'kernel_flavor': flavor, |
2372 | 1080 | 'dtb_name': cls.dtb_name} | 851 | 'dtb_name': self.dtb_name} |
2373 | 1081 | kernel = _get_file_matching(os.path.join(path, kregex)) | 852 | kernel = _get_file_matching(os.path.join(path, kregex)) |
2374 | 1082 | if kernel is not None: | 853 | if kernel is not None: |
2375 | 1083 | initrd = _get_file_matching(os.path.join(path, iregex)) | 854 | initrd = _get_file_matching(os.path.join(path, iregex)) |
2376 | 1084 | if initrd is not None: | 855 | if initrd is not None: |
2377 | 1085 | dtb = None | 856 | dtb = None |
2379 | 1086 | if cls.dtb_name is not None: | 857 | if self.dtb_name is not None: |
2380 | 1087 | dtb = _get_file_matching(os.path.join(path, dregex)) | 858 | dtb = _get_file_matching(os.path.join(path, dregex)) |
2381 | 1088 | return (kernel, initrd, dtb) | 859 | return (kernel, initrd, dtb) |
2382 | 1089 | raise ValueError( | 860 | raise ValueError( |
2383 | @@ -1091,83 +862,83 @@ | |||
2384 | 1091 | flavor, iregex)) | 862 | flavor, iregex)) |
2385 | 1092 | raise ValueError( | 863 | raise ValueError( |
2386 | 1093 | "No kernel found matching %s for flavors %s" % ( | 864 | "No kernel found matching %s for flavors %s" % ( |
2388 | 1094 | KERNEL_GLOB, " ".join(cls.kernel_flavors))) | 865 | KERNEL_GLOB, " ".join(self.kernel_flavors))) |
2389 | 1095 | 866 | ||
2392 | 1096 | @classmethod | 867 | def _get_kflavor_files_v2(self, path): |
2391 | 1097 | def _get_kflavor_files_v2(cls, path): | ||
2393 | 1098 | kernel = initrd = dtb = None | 868 | kernel = initrd = dtb = None |
2394 | 1099 | 869 | ||
2398 | 1100 | if cls.vmlinuz: | 870 | if self.vmlinuz: |
2399 | 1101 | kernel = _get_file_matching(os.path.join(path, cls.vmlinuz)) | 871 | kernel = _get_file_matching(os.path.join(path, self.vmlinuz)) |
2400 | 1102 | if not cls.vmlinuz or not kernel: | 872 | if not self.vmlinuz or not kernel: |
2401 | 1103 | raise ValueError("Unable to find a valid kernel image.") | 873 | raise ValueError("Unable to find a valid kernel image.") |
2402 | 1104 | 874 | ||
2406 | 1105 | if cls.initrd: | 875 | if self.initrd: |
2407 | 1106 | initrd = _get_file_matching(os.path.join(path, cls.initrd)) | 876 | initrd = _get_file_matching(os.path.join(path, self.initrd)) |
2408 | 1107 | if not cls.initrd or not initrd: | 877 | if not self.initrd or not initrd: |
2409 | 1108 | logger.warn("Could not find a valid initrd, skipping uInitd.") | 878 | logger.warn("Could not find a valid initrd, skipping uInitd.") |
2410 | 1109 | 879 | ||
2414 | 1110 | if cls.dtb_file: | 880 | if self.dtb_file: |
2415 | 1111 | dtb = _get_file_matching(os.path.join(path, cls.dtb_file)) | 881 | dtb = _get_file_matching(os.path.join(path, self.dtb_file)) |
2416 | 1112 | if not cls.dtb_file or not dtb: | 882 | if not self.dtb_file or not dtb: |
2417 | 1113 | logger.warn("Could not find a valid dtb file, skipping it.") | 883 | logger.warn("Could not find a valid dtb file, skipping it.") |
2418 | 1114 | 884 | ||
2419 | 1115 | logger.info("Will use kernel=%s, initrd=%s, dtb=%s." % \ | 885 | logger.info("Will use kernel=%s, initrd=%s, dtb=%s." % \ |
2420 | 1116 | (kernel, initrd, dtb)) | 886 | (kernel, initrd, dtb)) |
2421 | 1117 | return (kernel, initrd, dtb) | 887 | return (kernel, initrd, dtb) |
2422 | 1118 | 888 | ||
2425 | 1119 | @classmethod | 889 | def populate_raw_partition(self, media, boot_dir): |
2424 | 1120 | def populate_raw_partition(cls, media, boot_dir): | ||
2426 | 1121 | # Override in subclass if needed | 890 | # Override in subclass if needed |
2427 | 1122 | pass | 891 | pass |
2428 | 1123 | 892 | ||
2431 | 1124 | @classmethod | 893 | def snowball_config(self, chroot_dir): |
2430 | 1125 | def snowball_config(cls, chroot_dir): | ||
2432 | 1126 | # Override in subclasses where applicable | 894 | # Override in subclasses where applicable |
2433 | 1127 | raise NotImplementedError( | 895 | raise NotImplementedError( |
2434 | 1128 | "snowball_config() must only be called on BoardConfigs that " | 896 | "snowball_config() must only be called on BoardConfigs that " |
2435 | 1129 | "use the Snowball startupfiles.") | 897 | "use the Snowball startupfiles.") |
2436 | 1130 | 898 | ||
2437 | 899 | # XXX: can be removed when killing v1 hwpack and updating the attributes | ||
2438 | 900 | # that use it. | ||
2439 | 901 | @staticmethod | ||
2440 | 902 | def _check_placeholder_presence(string, placeholder): | ||
2441 | 903 | """Checks if the passed string contains the particular placeholder.""" | ||
2442 | 904 | # Very simple way of achieving that. | ||
2443 | 905 | presence = False | ||
2444 | 906 | if placeholder in string: | ||
2445 | 907 | presence = True | ||
2446 | 908 | return presence | ||
2447 | 909 | |||
2448 | 1131 | 910 | ||
2449 | 1132 | class OmapConfig(BoardConfig): | 911 | class OmapConfig(BoardConfig): |
2479 | 1133 | kernel_flavors = ['linaro-omap4', 'linaro-lt-omap', 'linaro-omap', 'omap4'] | 912 | |
2480 | 1134 | bootloader_file_in_boot_part = True | 913 | def __init__(self): |
2481 | 1135 | 914 | super(OmapConfig, self).__init__() | |
2482 | 1136 | # XXX: Here we define these things as dynamic properties because our | 915 | self.kernel_flavors = ['linaro-omap4', 'linaro-lt-omap', |
2483 | 1137 | # temporary hack to fix bug 697824 relies on changing the board's | 916 | 'linaro-omap', 'omap4'] |
2484 | 1138 | # serial_tty at run time. | 917 | self.bootloader_file_in_boot_part = True |
2485 | 1139 | _extra_serial_opts = None | 918 | # XXX: Here we define these things as dynamic properties because our |
2486 | 1140 | _live_serial_opts = None | 919 | # temporary hack to fix bug 697824 relies on changing the board's |
2487 | 1141 | _serial_tty = None | 920 | # serial_tty at run time. |
2488 | 1142 | 921 | self._serial_tty = None | |
2489 | 1143 | @classproperty | 922 | |
2490 | 1144 | def serial_tty(cls): | 923 | # XXX: when killing v1 hwpack this should be safely removed. |
2491 | 1145 | # This is just to make sure no callsites use .serial_tty before | 924 | def _get_serial_tty(self): |
2492 | 1146 | # calling set_appropriate_serial_tty(). If we had this in the first | 925 | return self._serial_tty |
2493 | 1147 | # place we'd have uncovered bug 710971 before releasing. | 926 | |
2494 | 1148 | raise AttributeError( | 927 | def _set_serial_tty(self, value): |
2495 | 1149 | "You must not use this attribute before calling " | 928 | self._serial_tty = value |
2496 | 1150 | "set_appropriate_serial_tty") | 929 | |
2497 | 1151 | 930 | serial_tty = property(_get_serial_tty, _set_serial_tty) | |
2498 | 1152 | @classproperty | 931 | |
2499 | 1153 | def live_serial_opts(cls): | 932 | def set_appropriate_serial_tty(self, chroot_dir): |
2471 | 1154 | return cls._live_serial_opts % cls.serial_tty | ||
2472 | 1155 | |||
2473 | 1156 | @classproperty | ||
2474 | 1157 | def extra_serial_opts(cls): | ||
2475 | 1158 | return cls._extra_serial_opts % cls.serial_tty | ||
2476 | 1159 | |||
2477 | 1160 | @classmethod | ||
2478 | 1161 | def set_appropriate_serial_tty(cls, chroot_dir): | ||
2500 | 1162 | """Set the appropriate serial_tty depending on the kernel used. | 933 | """Set the appropriate serial_tty depending on the kernel used. |
2501 | 1163 | 934 | ||
2502 | 1164 | If the kernel found in the chroot dir is << 2.6.36 we use tyyS2, else | 935 | If the kernel found in the chroot dir is << 2.6.36 we use tyyS2, else |
2503 | 1165 | we use the default value (_serial_tty). | 936 | we use the default value (_serial_tty). |
2504 | 1166 | """ | 937 | """ |
2505 | 1167 | # XXX: delete this method when hwpacks V1 can die | 938 | # XXX: delete this method when hwpacks V1 can die |
2507 | 1168 | assert cls.hwpack_format == HardwarepackHandler.FORMAT_1 | 939 | assert self.hwpack_format == HardwarepackHandler.FORMAT_1 |
2508 | 1169 | # XXX: This is also part of our temporary hack to fix bug 697824. | 940 | # XXX: This is also part of our temporary hack to fix bug 697824. |
2510 | 1170 | cls.serial_tty = classproperty(lambda cls: cls._serial_tty) | 941 | # cls.serial_tty = classproperty(lambda cls: cls._serial_tty) |
2511 | 1171 | vmlinuz = _get_file_matching( | 942 | vmlinuz = _get_file_matching( |
2512 | 1172 | os.path.join(chroot_dir, 'boot', 'vmlinuz*')) | 943 | os.path.join(chroot_dir, 'boot', 'vmlinuz*')) |
2513 | 1173 | basename = os.path.basename(vmlinuz) | 944 | basename = os.path.basename(vmlinuz) |
2514 | @@ -1176,135 +947,134 @@ | |||
2515 | 1176 | if match is not None: | 947 | if match is not None: |
2516 | 1177 | minor_version = match.group(1) | 948 | minor_version = match.group(1) |
2517 | 1178 | if int(minor_version) < 36: | 949 | if int(minor_version) < 36: |
2519 | 1179 | cls.serial_tty = classproperty(lambda cls: 'ttyS2') | 950 | self.serial_tty = 'ttyS2' |
2520 | 1180 | 951 | ||
2523 | 1181 | @classmethod | 952 | def make_boot_files(self, bootloader_parts_dir, is_live, is_lowmem, |
2522 | 1182 | def make_boot_files(cls, bootloader_parts_dir, is_live, is_lowmem, | ||
2524 | 1183 | consoles, chroot_dir, rootfs_id, boot_dir, | 953 | consoles, chroot_dir, rootfs_id, boot_dir, |
2525 | 1184 | boot_device_or_file): | 954 | boot_device_or_file): |
2526 | 1185 | # XXX: This is also part of our temporary hack to fix bug 697824; we | 955 | # XXX: This is also part of our temporary hack to fix bug 697824; we |
2527 | 1186 | # need to call set_appropriate_serial_tty() before doing anything that | 956 | # need to call set_appropriate_serial_tty() before doing anything that |
2532 | 1187 | # may use cls.serial_tty. | 957 | # may use self.serial_tty. |
2533 | 1188 | if cls.hwpack_format == HardwarepackHandler.FORMAT_1: | 958 | if self.hwpack_format == HardwarepackHandler.FORMAT_1: |
2534 | 1189 | cls.set_appropriate_serial_tty(chroot_dir) | 959 | self.set_appropriate_serial_tty(chroot_dir) |
2535 | 1190 | super(OmapConfig, cls).make_boot_files( | 960 | super(OmapConfig, self).make_boot_files( |
2536 | 1191 | bootloader_parts_dir, is_live, is_lowmem, consoles, chroot_dir, | 961 | bootloader_parts_dir, is_live, is_lowmem, consoles, chroot_dir, |
2537 | 1192 | rootfs_id, boot_dir, boot_device_or_file) | 962 | rootfs_id, boot_dir, boot_device_or_file) |
2538 | 1193 | 963 | ||
2541 | 1194 | @classmethod | 964 | def _make_boot_files(self, boot_env, chroot_dir, boot_dir, |
2540 | 1195 | def _make_boot_files(cls, boot_env, chroot_dir, boot_dir, | ||
2542 | 1196 | boot_device_or_file, k_img_data, i_img_data, | 965 | boot_device_or_file, k_img_data, i_img_data, |
2543 | 1197 | d_img_data): | 966 | d_img_data): |
2544 | 1198 | # XXX: delete this method when hwpacks V1 can die | 967 | # XXX: delete this method when hwpacks V1 can die |
2548 | 1199 | assert cls.hwpack_format == HardwarepackHandler.FORMAT_1 | 968 | assert self.hwpack_format == HardwarepackHandler.FORMAT_1 |
2549 | 1200 | install_omap_boot_loader(chroot_dir, boot_dir, cls) | 969 | install_omap_boot_loader(chroot_dir, boot_dir, self) |
2550 | 1201 | make_uImage(cls.load_addr, k_img_data, boot_dir) | 970 | make_uImage(self.load_addr, k_img_data, boot_dir) |
2551 | 1202 | make_uInitrd(i_img_data, boot_dir) | 971 | make_uInitrd(i_img_data, boot_dir) |
2552 | 1203 | make_dtb(d_img_data, boot_dir) | 972 | make_dtb(d_img_data, boot_dir) |
2554 | 1204 | boot_script_path = os.path.join(boot_dir, cls.boot_script) | 973 | boot_script_path = os.path.join(boot_dir, self.boot_script) |
2555 | 1205 | make_boot_script(boot_env, boot_script_path) | 974 | make_boot_script(boot_env, boot_script_path) |
2556 | 1206 | make_boot_ini(boot_script_path, boot_dir) | 975 | make_boot_ini(boot_script_path, boot_dir) |
2557 | 1207 | 976 | ||
2558 | 1208 | 977 | ||
2559 | 1209 | class BeagleConfig(OmapConfig): | 978 | class BeagleConfig(OmapConfig): |
2573 | 1210 | bootloader_flavor = 'omap3_beagle' | 979 | |
2574 | 1211 | dtb_name = 'omap3-beagle.dtb' | 980 | def __init__(self): |
2575 | 1212 | _serial_tty = 'ttyO2' | 981 | super(BeagleConfig, self).__init__() |
2576 | 1213 | _extra_serial_opts = 'console=tty0 console=%s,115200n8' | 982 | self.boot_script = 'boot.scr' |
2577 | 1214 | _live_serial_opts = 'serialtty=%s' | 983 | self.bootloader_flavor = 'omap3_beagle' |
2578 | 1215 | kernel_addr = '0x80000000' | 984 | self.dtb_addr = '0x815f0000' |
2579 | 1216 | dtb_addr = '0x815f0000' | 985 | self.dtb_name = 'omap3-beagle.dtb' |
2580 | 1217 | initrd_addr = '0x81600000' | 986 | self.extra_boot_args_options = ( |
2581 | 1218 | load_addr = '0x80008000' | 987 | 'earlyprintk fixrtc nocompcache vram=12M ' |
2582 | 1219 | boot_script = 'boot.scr' | 988 | 'omapfb.mode=dvi:1280x720MR-16@60 mpurate=${mpurate}') |
2583 | 1220 | extra_boot_args_options = ( | 989 | self.initrd_addr = '0x81600000' |
2584 | 1221 | 'earlyprintk fixrtc nocompcache vram=12M ' | 990 | self.kernel_addr = '0x80000000' |
2585 | 1222 | 'omapfb.mode=dvi:1280x720MR-16@60 mpurate=${mpurate}') | 991 | self.load_addr = '0x80008000' |
2586 | 992 | self._serial_tty = 'ttyO2' | ||
2587 | 993 | self._extra_serial_opts = 'console=tty0 console=%s,115200n8' | ||
2588 | 994 | self._live_serial_opts = 'serialtty=%s' | ||
2589 | 1223 | 995 | ||
2590 | 1224 | 996 | ||
2591 | 1225 | class OveroConfig(OmapConfig): | 997 | class OveroConfig(OmapConfig): |
2604 | 1226 | bootloader_flavor = 'omap3_overo' | 998 | def __init__(self): |
2605 | 1227 | dtb_name = 'omap3-overo.dtb' | 999 | super(OveroConfig, self).__init__() |
2606 | 1228 | _serial_tty = 'ttyO2' | 1000 | self.boot_script = 'boot.scr' |
2607 | 1229 | _extra_serial_opts = 'console=tty0 console=%s,115200n8' | 1001 | self.bootloader_flavor = 'omap3_overo' |
2608 | 1230 | kernel_addr = '0x80000000' | 1002 | self.dtb_addr = '0x815f0000' |
2609 | 1231 | dtb_addr = '0x815f0000' | 1003 | self.dtb_name = 'omap3-overo.dtb' |
2610 | 1232 | initrd_addr = '0x81600000' | 1004 | self.extra_boot_args_options = ( |
2611 | 1233 | load_addr = '0x80008000' | 1005 | 'earlyprintk mpurate=${mpurate} vram=12M ' |
2612 | 1234 | boot_script = 'boot.scr' | 1006 | 'omapdss.def_disp=${defaultdisplay} omapfb.mode=dvi:${dvimode}') |
2613 | 1235 | extra_boot_args_options = ( | 1007 | self.initrd_addr = '0x81600000' |
2614 | 1236 | 'earlyprintk mpurate=${mpurate} vram=12M ' | 1008 | self.kernel_addr = '0x80000000' |
2615 | 1237 | 'omapdss.def_disp=${defaultdisplay} omapfb.mode=dvi:${dvimode}') | 1009 | self.load_addr = '0x80008000' |
2616 | 1010 | self._extra_serial_opts = 'console=tty0 console=%s,115200n8' | ||
2617 | 1011 | self._serial_tty = 'ttyO2' | ||
2618 | 1238 | 1012 | ||
2619 | 1239 | 1013 | ||
2620 | 1240 | class PandaConfig(OmapConfig): | 1014 | class PandaConfig(OmapConfig): |
2634 | 1241 | bootloader_flavor = 'omap4_panda' | 1015 | def __init__(self): |
2635 | 1242 | dtb_name = 'omap4-panda.dtb' | 1016 | super(PandaConfig, self).__init__() |
2636 | 1243 | _serial_tty = 'ttyO2' | 1017 | self._serial_tty = 'ttyO2' |
2637 | 1244 | _extra_serial_opts = 'console=tty0 console=%s,115200n8' | 1018 | self.boot_script = 'boot.scr' |
2638 | 1245 | _live_serial_opts = 'serialtty=%s' | 1019 | self.bootloader_flavor = 'omap4_panda' |
2639 | 1246 | kernel_addr = '0x80200000' | 1020 | self.dtb_addr = '0x815f0000' |
2640 | 1247 | dtb_addr = '0x815f0000' | 1021 | self.dtb_name = 'omap4-panda.dtb' |
2641 | 1248 | initrd_addr = '0x81600000' | 1022 | self.extra_boot_args_options = ( |
2642 | 1249 | load_addr = '0x80008000' | 1023 | 'earlyprintk fixrtc nocompcache vram=48M ' |
2643 | 1250 | boot_script = 'boot.scr' | 1024 | 'omapfb.vram=0:24M mem=456M@0x80000000 mem=512M@0xA0000000') |
2644 | 1251 | extra_boot_args_options = ( | 1025 | self.initrd_addr = '0x81600000' |
2645 | 1252 | 'earlyprintk fixrtc nocompcache vram=48M ' | 1026 | self.kernel_addr = '0x80200000' |
2646 | 1253 | 'omapfb.vram=0:24M mem=456M@0x80000000 mem=512M@0xA0000000') | 1027 | self.load_addr = '0x80008000' |
2647 | 1028 | self._extra_serial_opts = 'console=tty0 console=%s,115200n8' | ||
2648 | 1029 | self._live_serial_opts = 'serialtty=%s' | ||
2649 | 1254 | 1030 | ||
2650 | 1255 | 1031 | ||
2651 | 1256 | class IgepConfig(BeagleConfig): | 1032 | class IgepConfig(BeagleConfig): |
2655 | 1257 | bootloader_file_in_boot_part = False | 1033 | def __init__(self): |
2656 | 1258 | bootloader_flavor = None | 1034 | super(IgepConfig, self).__init__() |
2657 | 1259 | dtb_name = 'isee-igep-v2.dtb' | 1035 | self.bootloader_file_in_boot_part = False |
2658 | 1036 | self.bootloader_flavor = None | ||
2659 | 1037 | self.dtb_name = 'isee-igep-v2.dtb' | ||
2660 | 1260 | 1038 | ||
2663 | 1261 | @classmethod | 1039 | def _make_boot_files(self, boot_env, chroot_dir, boot_dir, |
2662 | 1262 | def _make_boot_files(cls, boot_env, chroot_dir, boot_dir, | ||
2664 | 1263 | boot_device_or_file, k_img_data, i_img_data, | 1040 | boot_device_or_file, k_img_data, i_img_data, |
2665 | 1264 | d_img_data): | 1041 | d_img_data): |
2666 | 1265 | # XXX: delete this method when hwpacks V1 can die | 1042 | # XXX: delete this method when hwpacks V1 can die |
2669 | 1266 | assert cls.hwpack_format == HardwarepackHandler.FORMAT_1 | 1043 | assert self.hwpack_format == HardwarepackHandler.FORMAT_1 |
2670 | 1267 | make_uImage(cls.load_addr, k_img_data, boot_dir) | 1044 | make_uImage(self.load_addr, k_img_data, boot_dir) |
2671 | 1268 | make_uInitrd(i_img_data, boot_dir) | 1045 | make_uInitrd(i_img_data, boot_dir) |
2672 | 1269 | make_dtb(d_img_data, boot_dir) | 1046 | make_dtb(d_img_data, boot_dir) |
2674 | 1270 | boot_script_path = os.path.join(boot_dir, cls.boot_script) | 1047 | boot_script_path = os.path.join(boot_dir, self.boot_script) |
2675 | 1271 | make_boot_script(boot_env, boot_script_path) | 1048 | make_boot_script(boot_env, boot_script_path) |
2676 | 1272 | make_boot_ini(boot_script_path, boot_dir) | 1049 | make_boot_ini(boot_script_path, boot_dir) |
2677 | 1273 | 1050 | ||
2678 | 1274 | 1051 | ||
2679 | 1275 | class Ux500Config(BoardConfig): | 1052 | class Ux500Config(BoardConfig): |
2705 | 1276 | serial_tty = 'ttyAMA2' | 1053 | def __init__(self): |
2706 | 1277 | _extra_serial_opts = 'console=tty0 console=%s,115200n8' | 1054 | super(Ux500Config, self).__init__() |
2707 | 1278 | _live_serial_opts = 'serialtty=%s' | 1055 | self.boot_script = 'flash.scr' |
2708 | 1279 | kernel_addr = '0x00100000' | 1056 | self.extra_boot_args_options = ( |
2709 | 1280 | initrd_addr = '0x08000000' | 1057 | 'earlyprintk rootdelay=1 fixrtc nocompcache ' |
2710 | 1281 | load_addr = '0x00008000' | 1058 | 'mem=96M@0 mem_modem=32M@96M mem=44M@128M pmem=22M@172M ' |
2711 | 1282 | kernel_flavors = ['u8500', 'ux500'] | 1059 | 'mem=30M@194M mem_mali=32M@224M pmem_hwb=54M@256M ' |
2712 | 1283 | boot_script = 'flash.scr' | 1060 | 'hwmem=48M@302M mem=152M@360M') |
2713 | 1284 | extra_boot_args_options = ( | 1061 | self.initrd_addr = '0x08000000' |
2714 | 1285 | 'earlyprintk rootdelay=1 fixrtc nocompcache ' | 1062 | self.kernel_addr = '0x00100000' |
2715 | 1286 | 'mem=96M@0 mem_modem=32M@96M mem=44M@128M pmem=22M@172M ' | 1063 | self.kernel_flavors = ['u8500', 'ux500'] |
2716 | 1287 | 'mem=30M@194M mem_mali=32M@224M pmem_hwb=54M@256M ' | 1064 | self.load_addr = '0x00008000' |
2717 | 1288 | 'hwmem=48M@302M mem=152M@360M') | 1065 | self.mmc_option = '1:1' |
2718 | 1289 | mmc_option = '1:1' | 1066 | self.serial_tty = 'ttyAMA2' |
2719 | 1290 | 1067 | self._extra_serial_opts = 'console=tty0 console=%s,115200n8' | |
2720 | 1291 | @classproperty | 1068 | self._live_serial_opts = 'serialtty=%s' |
2721 | 1292 | def live_serial_opts(cls): | 1069 | |
2722 | 1293 | return cls._live_serial_opts % cls.serial_tty | 1070 | def _make_boot_files(self, boot_env, chroot_dir, boot_dir, |
2698 | 1294 | |||
2699 | 1295 | @classproperty | ||
2700 | 1296 | def extra_serial_opts(cls): | ||
2701 | 1297 | return cls._extra_serial_opts % cls.serial_tty | ||
2702 | 1298 | |||
2703 | 1299 | @classmethod | ||
2704 | 1300 | def _make_boot_files(cls, boot_env, chroot_dir, boot_dir, | ||
2723 | 1301 | boot_device_or_file, k_img_data, i_img_data, | 1071 | boot_device_or_file, k_img_data, i_img_data, |
2724 | 1302 | d_img_data): | 1072 | d_img_data): |
2725 | 1303 | # XXX: delete this method when hwpacks V1 can die | 1073 | # XXX: delete this method when hwpacks V1 can die |
2728 | 1304 | assert cls.hwpack_format == HardwarepackHandler.FORMAT_1 | 1074 | assert self.hwpack_format == HardwarepackHandler.FORMAT_1 |
2729 | 1305 | make_uImage(cls.load_addr, k_img_data, boot_dir) | 1075 | make_uImage(self.load_addr, k_img_data, boot_dir) |
2730 | 1306 | make_uInitrd(i_img_data, boot_dir) | 1076 | make_uInitrd(i_img_data, boot_dir) |
2732 | 1307 | boot_script_path = os.path.join(boot_dir, cls.boot_script) | 1077 | boot_script_path = os.path.join(boot_dir, self.boot_script) |
2733 | 1308 | make_boot_script(boot_env, boot_script_path) | 1078 | make_boot_script(boot_env, boot_script_path) |
2734 | 1309 | 1079 | ||
2735 | 1310 | 1080 | ||
2736 | @@ -1314,15 +1084,16 @@ | |||
2737 | 1314 | Note that the Snowball board needs a loader partition on the | 1084 | Note that the Snowball board needs a loader partition on the |
2738 | 1315 | internal eMMC flash to boot. That partition is created with | 1085 | internal eMMC flash to boot. That partition is created with |
2739 | 1316 | the SnowballConfigImage configuration.''' | 1086 | the SnowballConfigImage configuration.''' |
2740 | 1087 | def __init__(self): | ||
2741 | 1088 | super(SnowballSdConfig, self).__init__() | ||
2742 | 1317 | 1089 | ||
2745 | 1318 | @classmethod | 1090 | def _make_boot_files(self, boot_env, chroot_dir, boot_dir, |
2744 | 1319 | def _make_boot_files(cls, boot_env, chroot_dir, boot_dir, | ||
2746 | 1320 | boot_device_or_file, k_img_data, i_img_data, | 1091 | boot_device_or_file, k_img_data, i_img_data, |
2747 | 1321 | d_img_data): | 1092 | d_img_data): |
2748 | 1322 | # XXX: delete this method when hwpacks V1 can die | 1093 | # XXX: delete this method when hwpacks V1 can die |
2752 | 1323 | assert cls.hwpack_format == HardwarepackHandler.FORMAT_1 | 1094 | assert self.hwpack_format == HardwarepackHandler.FORMAT_1 |
2753 | 1324 | make_uImage(cls.load_addr, k_img_data, boot_dir) | 1095 | make_uImage(self.load_addr, k_img_data, boot_dir) |
2754 | 1325 | boot_script_path = os.path.join(boot_dir, cls.boot_script) | 1096 | boot_script_path = os.path.join(boot_dir, self.boot_script) |
2755 | 1326 | make_boot_script(boot_env, boot_script_path) | 1097 | make_boot_script(boot_env, boot_script_path) |
2756 | 1327 | 1098 | ||
2757 | 1328 | 1099 | ||
2758 | @@ -1330,16 +1101,18 @@ | |||
2759 | 1330 | '''Use only with --image option. Creates a raw image which contains an | 1101 | '''Use only with --image option. Creates a raw image which contains an |
2760 | 1331 | additional (raw) loader partition, containing some boot stages | 1102 | additional (raw) loader partition, containing some boot stages |
2761 | 1332 | and u-boot.''' | 1103 | and u-boot.''' |
2762 | 1333 | # Boot ROM looks for a boot table of contents (TOC) at 0x20000 | ||
2763 | 1334 | # Actually, it first looks at address 0, but that's where l-m-c | ||
2764 | 1335 | # puts the MBR, so the boot loader skips that address. | ||
2765 | 1336 | supports_writing_to_mmc = False | ||
2766 | 1337 | SNOWBALL_LOADER_START_S = (128 * 1024) / SECTOR_SIZE | 1104 | SNOWBALL_LOADER_START_S = (128 * 1024) / SECTOR_SIZE |
2767 | 1338 | snowball_startup_files_config = 'startfiles.cfg' | ||
2768 | 1339 | TOC_SIZE = 512 | 1105 | TOC_SIZE = 512 |
2769 | 1340 | 1106 | ||
2772 | 1341 | @classmethod | 1107 | def __init__(self): |
2773 | 1342 | def get_v1_sfdisk_cmd(cls, should_align_boot_part=None): | 1108 | super(SnowballEmmcConfig, self).__init__() |
2774 | 1109 | # Boot ROM looks for a boot table of contents (TOC) at 0x20000 | ||
2775 | 1110 | # Actually, it first looks at address 0, but that's where l-m-c | ||
2776 | 1111 | # puts the MBR, so the boot loader skips that address. | ||
2777 | 1112 | self.supports_writing_to_mmc = False | ||
2778 | 1113 | self.snowball_startup_files_config = 'startfiles.cfg' | ||
2779 | 1114 | |||
2780 | 1115 | def get_v1_sfdisk_cmd(self, should_align_boot_part=None): | ||
2781 | 1343 | """Return the sfdisk command to partition the media. | 1116 | """Return the sfdisk command to partition the media. |
2782 | 1344 | 1117 | ||
2783 | 1345 | :param should_align_boot_part: Ignored. | 1118 | :param should_align_boot_part: Ignored. |
2784 | @@ -1357,68 +1130,64 @@ | |||
2785 | 1357 | # with the usual SECTOR_SIZE of 0x200. | 1130 | # with the usual SECTOR_SIZE of 0x200. |
2786 | 1358 | # (sector 0 is MBR / partition table) | 1131 | # (sector 0 is MBR / partition table) |
2787 | 1359 | loader_start, loader_end, loader_len = align_partition( | 1132 | loader_start, loader_end, loader_len = align_partition( |
2790 | 1360 | SnowballEmmcConfig.SNOWBALL_LOADER_START_S, | 1133 | self.SNOWBALL_LOADER_START_S, |
2791 | 1361 | cls.LOADER_MIN_SIZE_S, 1, PART_ALIGN_S) | 1134 | self.LOADER_MIN_SIZE_S, 1, PART_ALIGN_S) |
2792 | 1362 | 1135 | ||
2793 | 1363 | boot_start, boot_end, boot_len = align_partition( | 1136 | boot_start, boot_end, boot_len = align_partition( |
2795 | 1364 | loader_end + 1, cls.BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) | 1137 | loader_end + 1, self.BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) |
2796 | 1365 | # we ignore _root_end / _root_len and return an sfdisk command to | 1138 | # we ignore _root_end / _root_len and return an sfdisk command to |
2797 | 1366 | # instruct the use of all remaining space; XXX if we had some root size | 1139 | # instruct the use of all remaining space; XXX if we had some root size |
2798 | 1367 | # config, we could do something more sensible | 1140 | # config, we could do something more sensible |
2799 | 1368 | root_start, _root_end, _root_len = align_partition( | 1141 | root_start, _root_end, _root_len = align_partition( |
2801 | 1369 | boot_end + 1, cls.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) | 1142 | boot_end + 1, self.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) |
2802 | 1370 | 1143 | ||
2803 | 1371 | return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % ( | 1144 | return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % ( |
2804 | 1372 | loader_start, loader_len, boot_start, boot_len, root_start) | 1145 | loader_start, loader_len, boot_start, boot_len, root_start) |
2805 | 1373 | 1146 | ||
2808 | 1374 | @classmethod | 1147 | def _make_boot_files(self, boot_env, chroot_dir, boot_dir, |
2807 | 1375 | def _make_boot_files(cls, boot_env, chroot_dir, boot_dir, | ||
2809 | 1376 | boot_device_or_file, k_img_data, i_img_data, | 1148 | boot_device_or_file, k_img_data, i_img_data, |
2810 | 1377 | d_img_data): | 1149 | d_img_data): |
2811 | 1378 | # XXX: delete this method when hwpacks V1 can die | 1150 | # XXX: delete this method when hwpacks V1 can die |
2815 | 1379 | assert cls.hwpack_format == HardwarepackHandler.FORMAT_1 | 1151 | assert self.hwpack_format == HardwarepackHandler.FORMAT_1 |
2816 | 1380 | make_uImage(cls.load_addr, k_img_data, boot_dir) | 1152 | make_uImage(self.load_addr, k_img_data, boot_dir) |
2817 | 1381 | boot_script_path = os.path.join(boot_dir, cls.boot_script) | 1153 | boot_script_path = os.path.join(boot_dir, self.boot_script) |
2818 | 1382 | make_boot_script(boot_env, boot_script_path) | 1154 | make_boot_script(boot_env, boot_script_path) |
2820 | 1383 | cls.populate_raw_partition(boot_device_or_file, chroot_dir) | 1155 | self.populate_raw_partition(boot_device_or_file, chroot_dir) |
2821 | 1384 | 1156 | ||
2824 | 1385 | @classmethod | 1157 | def populate_raw_partition(self, boot_device_or_file, chroot_dir): |
2823 | 1386 | def populate_raw_partition(cls, boot_device_or_file, chroot_dir): | ||
2825 | 1387 | # Populate created raw partition with TOC and startup files. | 1158 | # Populate created raw partition with TOC and startup files. |
2826 | 1388 | _, toc_filename = tempfile.mkstemp() | 1159 | _, toc_filename = tempfile.mkstemp() |
2829 | 1389 | config_files_dir = cls.snowball_config(chroot_dir) | 1160 | config_files_dir = self.snowball_config(chroot_dir) |
2830 | 1390 | new_files = cls.get_file_info(chroot_dir, config_files_dir) | 1161 | new_files = self.get_file_info(chroot_dir, config_files_dir) |
2831 | 1391 | with open(toc_filename, 'wb') as toc: | 1162 | with open(toc_filename, 'wb') as toc: |
2834 | 1392 | cls.create_toc(toc, new_files) | 1163 | self.create_toc(toc, new_files) |
2835 | 1393 | cls.install_snowball_boot_loader(toc_filename, new_files, | 1164 | self.install_snowball_boot_loader(toc_filename, new_files, |
2836 | 1394 | boot_device_or_file, | 1165 | boot_device_or_file, |
2843 | 1395 | cls.SNOWBALL_LOADER_START_S, | 1166 | self.SNOWBALL_LOADER_START_S, |
2844 | 1396 | cls.delete_startupfiles) | 1167 | self.delete_startupfiles) |
2845 | 1397 | cls.delete_file(toc_filename) | 1168 | self.delete_file(toc_filename) |
2846 | 1398 | if cls.delete_startupfiles: | 1169 | if self.delete_startupfiles: |
2847 | 1399 | cls.delete_file(os.path.join(config_files_dir, | 1170 | self.delete_file(os.path.join(config_files_dir, |
2848 | 1400 | cls.snowball_startup_files_config)) | 1171 | self.snowball_startup_files_config)) |
2849 | 1401 | 1172 | ||
2852 | 1402 | @classmethod | 1173 | def snowball_config(self, chroot_dir): |
2851 | 1403 | def snowball_config(cls, chroot_dir): | ||
2853 | 1404 | # We will find the startupfiles in the target boot partition. | 1174 | # We will find the startupfiles in the target boot partition. |
2854 | 1405 | return os.path.join(chroot_dir, 'boot') | 1175 | return os.path.join(chroot_dir, 'boot') |
2855 | 1406 | 1176 | ||
2858 | 1407 | @classproperty | 1177 | @property |
2859 | 1408 | def delete_startupfiles(cls): | 1178 | def delete_startupfiles(self): |
2860 | 1409 | # The startupfiles will have been installed to the target boot | 1179 | # The startupfiles will have been installed to the target boot |
2861 | 1410 | # partition by the hwpack, and should be deleted so we don't leave | 1180 | # partition by the hwpack, and should be deleted so we don't leave |
2862 | 1411 | # them on the target system. | 1181 | # them on the target system. |
2863 | 1412 | return True | 1182 | return True |
2864 | 1413 | 1183 | ||
2867 | 1414 | @classmethod | 1184 | def install_snowball_boot_loader(self, toc_file_name, files, |
2866 | 1415 | def install_snowball_boot_loader(cls, toc_file_name, files, | ||
2868 | 1416 | boot_device_or_file, start_sector, | 1185 | boot_device_or_file, start_sector, |
2869 | 1417 | delete_startupfiles=False): | 1186 | delete_startupfiles=False): |
2870 | 1418 | ''' Copies TOC and boot files into the boot partition. | 1187 | ''' Copies TOC and boot files into the boot partition. |
2871 | 1419 | A sector size of 1 is used for some files, as they do not | 1188 | A sector size of 1 is used for some files, as they do not |
2872 | 1420 | necessarily start on an even address. ''' | 1189 | necessarily start on an even address. ''' |
2874 | 1421 | assert os.path.getsize(toc_file_name) <= cls.TOC_SIZE | 1190 | assert os.path.getsize(toc_file_name) <= self.TOC_SIZE |
2875 | 1422 | _dd(toc_file_name, boot_device_or_file, seek=start_sector) | 1191 | _dd(toc_file_name, boot_device_or_file, seek=start_sector) |
2876 | 1423 | 1192 | ||
2877 | 1424 | for file in files: | 1193 | for file in files: |
2878 | @@ -1433,16 +1202,14 @@ | |||
2879 | 1433 | seek_sectors = start_sector + file['offset'] / SECTOR_SIZE | 1202 | seek_sectors = start_sector + file['offset'] / SECTOR_SIZE |
2880 | 1434 | _dd(filename, boot_device_or_file, seek=seek_sectors) | 1203 | _dd(filename, boot_device_or_file, seek=seek_sectors) |
2881 | 1435 | if delete_startupfiles: | 1204 | if delete_startupfiles: |
2883 | 1436 | cls.delete_file(filename) | 1205 | self.delete_file(filename) |
2884 | 1437 | 1206 | ||
2887 | 1438 | @classmethod | 1207 | def delete_file(self, file_path): |
2886 | 1439 | def delete_file(cls, file_path): | ||
2888 | 1440 | cmd = ["rm", "%s" % file_path] | 1208 | cmd = ["rm", "%s" % file_path] |
2889 | 1441 | proc = cmd_runner.run(cmd, as_root=True) | 1209 | proc = cmd_runner.run(cmd, as_root=True) |
2890 | 1442 | proc.wait() | 1210 | proc.wait() |
2891 | 1443 | 1211 | ||
2894 | 1444 | @classmethod | 1212 | def create_toc(self, f, files): |
2893 | 1445 | def create_toc(cls, f, files): | ||
2895 | 1446 | ''' Writes a table of contents of the boot binaries. | 1213 | ''' Writes a table of contents of the boot binaries. |
2896 | 1447 | Boot rom searches this table to find the binaries.''' | 1214 | Boot rom searches this table to find the binaries.''' |
2897 | 1448 | # Format string means: < little endian, | 1215 | # Format string means: < little endian, |
2898 | @@ -1464,15 +1231,14 @@ | |||
2899 | 1464 | file['section_name']) | 1231 | file['section_name']) |
2900 | 1465 | f.write(data) | 1232 | f.write(data) |
2901 | 1466 | 1233 | ||
2904 | 1467 | @classmethod | 1234 | def get_file_info(self, chroot_dir, config_files_dir): |
2903 | 1468 | def get_file_info(cls, chroot_dir, config_files_dir): | ||
2905 | 1469 | ''' Fills in the offsets of files that are located in | 1235 | ''' Fills in the offsets of files that are located in |
2906 | 1470 | non-absolute memory locations depending on their sizes.' | 1236 | non-absolute memory locations depending on their sizes.' |
2907 | 1471 | Also fills in file sizes''' | 1237 | Also fills in file sizes''' |
2909 | 1472 | ofs = cls.TOC_SIZE | 1238 | ofs = self.TOC_SIZE |
2910 | 1473 | files = [] | 1239 | files = [] |
2911 | 1474 | with open(os.path.join(config_files_dir, | 1240 | with open(os.path.join(config_files_dir, |
2913 | 1475 | cls.snowball_startup_files_config), | 1241 | self.snowball_startup_files_config), |
2914 | 1476 | 'r') as info_file: | 1242 | 'r') as info_file: |
2915 | 1477 | for line in info_file: | 1243 | for line in info_file: |
2916 | 1478 | file_data = line.split() | 1244 | file_data = line.split() |
2917 | @@ -1503,23 +1269,16 @@ | |||
2918 | 1503 | 1269 | ||
2919 | 1504 | 1270 | ||
2920 | 1505 | class Mx5Config(BoardConfig): | 1271 | class Mx5Config(BoardConfig): |
2938 | 1506 | serial_tty = 'ttymxc0' | 1272 | def __init__(self): |
2939 | 1507 | _extra_serial_opts = 'console=tty0 console=%s,115200n8' | 1273 | super(Mx5Config, self).__init__() |
2940 | 1508 | _live_serial_opts = 'serialtty=%s' | 1274 | self.boot_script = 'boot.scr' |
2941 | 1509 | boot_script = 'boot.scr' | 1275 | self.mmc_option = '0:2' |
2942 | 1510 | mmc_part_offset = 1 | 1276 | self.mmc_part_offset = 1 |
2943 | 1511 | mmc_option = '0:2' | 1277 | self.serial_tty = 'ttymxc0' |
2944 | 1512 | 1278 | self._extra_serial_opts = 'console=tty0 console=%s,115200n8' | |
2945 | 1513 | @classproperty | 1279 | self._live_serial_opts = 'serialtty=%s' |
2946 | 1514 | def live_serial_opts(cls): | 1280 | |
2947 | 1515 | return cls._live_serial_opts % cls.serial_tty | 1281 | def get_v1_sfdisk_cmd(self, should_align_boot_part=None): |
2931 | 1516 | |||
2932 | 1517 | @classproperty | ||
2933 | 1518 | def extra_serial_opts(cls): | ||
2934 | 1519 | return cls._extra_serial_opts % cls.serial_tty | ||
2935 | 1520 | |||
2936 | 1521 | @classmethod | ||
2937 | 1522 | def get_v1_sfdisk_cmd(cls, should_align_boot_part=None): | ||
2948 | 1523 | """Return the sfdisk command to partition the media. | 1282 | """Return the sfdisk command to partition the media. |
2949 | 1524 | 1283 | ||
2950 | 1525 | :param should_align_boot_part: Ignored. | 1284 | :param should_align_boot_part: Ignored. |
2951 | @@ -1533,103 +1292,107 @@ | |||
2952 | 1533 | # onwards, so it's safer to just start at the first sector, sector 1 | 1292 | # onwards, so it's safer to just start at the first sector, sector 1 |
2953 | 1534 | # (sector 0 is MBR / partition table) | 1293 | # (sector 0 is MBR / partition table) |
2954 | 1535 | loader_start, loader_end, loader_len = align_partition( | 1294 | loader_start, loader_end, loader_len = align_partition( |
2956 | 1536 | 1, cls.LOADER_MIN_SIZE_S, 1, PART_ALIGN_S) | 1295 | 1, self.LOADER_MIN_SIZE_S, 1, PART_ALIGN_S) |
2957 | 1537 | 1296 | ||
2958 | 1538 | boot_start, boot_end, boot_len = align_partition( | 1297 | boot_start, boot_end, boot_len = align_partition( |
2960 | 1539 | loader_end + 1, cls.BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) | 1298 | loader_end + 1, self.BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) |
2961 | 1540 | # we ignore _root_end / _root_len and return a sfdisk command to | 1299 | # we ignore _root_end / _root_len and return a sfdisk command to |
2962 | 1541 | # instruct the use of all remaining space; XXX if we had some root size | 1300 | # instruct the use of all remaining space; XXX if we had some root size |
2963 | 1542 | # config, we could do something more sensible | 1301 | # config, we could do something more sensible |
2964 | 1543 | root_start, _root_end, _root_len = align_partition( | 1302 | root_start, _root_end, _root_len = align_partition( |
2966 | 1544 | boot_end + 1, cls.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) | 1303 | boot_end + 1, self.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) |
2967 | 1545 | 1304 | ||
2968 | 1546 | return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % ( | 1305 | return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % ( |
2969 | 1547 | loader_start, loader_len, boot_start, boot_len, root_start) | 1306 | loader_start, loader_len, boot_start, boot_len, root_start) |
2970 | 1548 | 1307 | ||
2973 | 1549 | @classmethod | 1308 | def _make_boot_files(self, boot_env, chroot_dir, boot_dir, |
2972 | 1550 | def _make_boot_files(cls, boot_env, chroot_dir, boot_dir, | ||
2974 | 1551 | boot_device_or_file, k_img_data, i_img_data, | 1309 | boot_device_or_file, k_img_data, i_img_data, |
2975 | 1552 | d_img_data): | 1310 | d_img_data): |
2976 | 1553 | # XXX: delete this method when hwpacks V1 can die | 1311 | # XXX: delete this method when hwpacks V1 can die |
2980 | 1554 | assert cls.hwpack_format == HardwarepackHandler.FORMAT_1 | 1312 | assert self.hwpack_format == HardwarepackHandler.FORMAT_1 |
2981 | 1555 | with cls.hardwarepack_handler: | 1313 | with self.hardwarepack_handler: |
2982 | 1556 | bootloader_file = cls.get_file('bootloader_file', | 1314 | bootloader_file = self.get_file('bootloader_file', |
2983 | 1557 | default=os.path.join( | 1315 | default=os.path.join( |
2985 | 1558 | chroot_dir, 'usr', 'lib', 'u-boot', cls.bootloader_flavor, | 1316 | chroot_dir, 'usr', 'lib', 'u-boot', self.bootloader_flavor, |
2986 | 1559 | 'u-boot.imx')) | 1317 | 'u-boot.imx')) |
2987 | 1560 | install_mx5_boot_loader(bootloader_file, boot_device_or_file, | 1318 | install_mx5_boot_loader(bootloader_file, boot_device_or_file, |
2990 | 1561 | cls.LOADER_MIN_SIZE_S) | 1319 | self.LOADER_MIN_SIZE_S) |
2991 | 1562 | make_uImage(cls.load_addr, k_img_data, boot_dir) | 1320 | make_uImage(self.load_addr, k_img_data, boot_dir) |
2992 | 1563 | make_uInitrd(i_img_data, boot_dir) | 1321 | make_uInitrd(i_img_data, boot_dir) |
2993 | 1564 | make_dtb(d_img_data, boot_dir) | 1322 | make_dtb(d_img_data, boot_dir) |
2995 | 1565 | boot_script_path = os.path.join(boot_dir, cls.boot_script) | 1323 | boot_script_path = os.path.join(boot_dir, self.boot_script) |
2996 | 1566 | make_boot_script(boot_env, boot_script_path) | 1324 | make_boot_script(boot_env, boot_script_path) |
2997 | 1567 | 1325 | ||
2998 | 1568 | 1326 | ||
2999 | 1569 | class Mx51Config(Mx5Config): | 1327 | class Mx51Config(Mx5Config): |
3005 | 1570 | kernel_addr = '0x90000000' | 1328 | def __init__(self): |
3006 | 1571 | dtb_addr = '0x91ff0000' | 1329 | super(Mx51Config, self).__init__() |
3007 | 1572 | initrd_addr = '0x92000000' | 1330 | self.dtb_addr = '0x91ff0000' |
3008 | 1573 | load_addr = '0x90008000' | 1331 | self.initrd_addr = '0x92000000' |
3009 | 1574 | kernel_flavors = ['linaro-mx51', 'linaro-lt-mx5'] | 1332 | self.kernel_addr = '0x90000000' |
3010 | 1333 | self.kernel_flavors = ['linaro-mx51', 'linaro-lt-mx5'] | ||
3011 | 1334 | self.load_addr = '0x90008000' | ||
3012 | 1575 | 1335 | ||
3013 | 1576 | 1336 | ||
3014 | 1577 | class Mx53Config(Mx5Config): | 1337 | class Mx53Config(Mx5Config): |
3020 | 1578 | kernel_addr = '0x70000000' | 1338 | def __init__(self): |
3021 | 1579 | dtb_addr = '0x71ff0000' | 1339 | super(Mx53Config, self).__init__() |
3022 | 1580 | initrd_addr = '0x72000000' | 1340 | self.dtb_addr = '0x71ff0000' |
3023 | 1581 | load_addr = '0x70008000' | 1341 | self.initrd_addr = '0x72000000' |
3024 | 1582 | kernel_flavors = ['linaro-lt-mx53', 'linaro-lt-mx5'] | 1342 | self.kernel_addr = '0x70000000' |
3025 | 1343 | self.kernel_flavors = ['linaro-lt-mx53', 'linaro-lt-mx5'] | ||
3026 | 1344 | self.load_addr = '0x70008000' | ||
3027 | 1583 | 1345 | ||
3028 | 1584 | 1346 | ||
3029 | 1585 | class EfikamxConfig(Mx51Config): | 1347 | class EfikamxConfig(Mx51Config): |
3032 | 1586 | bootloader_flavor = 'efikamx' | 1348 | def __init__(self): |
3033 | 1587 | dtb_name = 'genesi-efikamx.dtb' | 1349 | super(EfikamxConfig, self).__init__() |
3034 | 1350 | self.bootloader_flavor = 'efikamx' | ||
3035 | 1351 | self.dtb_name = 'genesi-efikamx.dtb' | ||
3036 | 1588 | 1352 | ||
3037 | 1589 | 1353 | ||
3038 | 1590 | class EfikasbConfig(Mx51Config): | 1354 | class EfikasbConfig(Mx51Config): |
3041 | 1591 | bootloader_flavor = 'efikasb' | 1355 | def __init__(self): |
3042 | 1592 | dtb_name = 'genesi-efikasb.dtb' | 1356 | super(EfikasbConfig, self).__init__() |
3043 | 1357 | self.bootloader_flavor = 'efikasb' | ||
3044 | 1358 | self.dtb_name = 'genesi-efikasb.dtb' | ||
3045 | 1593 | 1359 | ||
3046 | 1594 | 1360 | ||
3047 | 1595 | class Mx51evkConfig(Mx51Config): | 1361 | class Mx51evkConfig(Mx51Config): |
3050 | 1596 | bootloader_flavor = 'mx51evk' | 1362 | def __init__(self): |
3051 | 1597 | dtb_name = 'mx51-babbage.dtb' | 1363 | super(Mx51evkConfig, self).__init__() |
3052 | 1364 | self.bootloader_flavor = 'mx51evk' | ||
3053 | 1365 | self.dtb_name = 'mx51-babbage.dtb' | ||
3054 | 1598 | 1366 | ||
3055 | 1599 | 1367 | ||
3056 | 1600 | class Mx53LoCoConfig(Mx53Config): | 1368 | class Mx53LoCoConfig(Mx53Config): |
3059 | 1601 | bootloader_flavor = 'mx53loco' | 1369 | def __init__(self): |
3060 | 1602 | dtb_name = 'mx53-loco.dtb' | 1370 | super(Mx53LoCoConfig, self).__init__() |
3061 | 1371 | self.bootloader_flavor = 'mx53loco' | ||
3062 | 1372 | self.dtb_name = 'mx53-loco.dtb' | ||
3063 | 1603 | 1373 | ||
3064 | 1604 | 1374 | ||
3065 | 1605 | class VexpressConfig(BoardConfig): | 1375 | class VexpressConfig(BoardConfig): |
3090 | 1606 | bootloader_flavor = 'ca9x4_ct_vxp' | 1376 | def __init__(self): |
3091 | 1607 | bootloader_file_in_boot_part = True | 1377 | super(VexpressConfig, self).__init__() |
3092 | 1608 | serial_tty = 'ttyAMA0' | 1378 | self.boot_script = 'boot.scr' |
3093 | 1609 | _extra_serial_opts = 'console=tty0 console=%s,38400n8' | 1379 | self.bootloader_file_in_boot_part = True |
3094 | 1610 | _live_serial_opts = 'serialtty=%s' | 1380 | self.bootloader_flavor = 'ca9x4_ct_vxp' |
3095 | 1611 | kernel_addr = '0x60000000' | 1381 | # ARM Boot Monitor is used to load u-boot, uImage etc. into flash and |
3096 | 1612 | initrd_addr = '0x62000000' | 1382 | # only allows for FAT16 |
3097 | 1613 | load_addr = '0x60008000' | 1383 | self.fat_size = 16 |
3098 | 1614 | kernel_flavors = ['linaro-vexpress'] | 1384 | self.initrd_addr = '0x62000000' |
3099 | 1615 | boot_script = 'boot.scr' | 1385 | self.kernel_addr = '0x60000000' |
3100 | 1616 | # ARM Boot Monitor is used to load u-boot, uImage etc. into flash and | 1386 | self.kernel_flavors = ['linaro-vexpress'] |
3101 | 1617 | # only allows for FAT16 | 1387 | self.load_addr = '0x60008000' |
3102 | 1618 | fat_size = 16 | 1388 | self.serial_tty = 'ttyAMA0' |
3103 | 1619 | 1389 | self._extra_serial_opts = 'console=tty0 console=%s,38400n8' | |
3104 | 1620 | @classproperty | 1390 | self._live_serial_opts = 'serialtty=%s' |
3105 | 1621 | def live_serial_opts(cls): | 1391 | |
3106 | 1622 | return cls._live_serial_opts % cls.serial_tty | 1392 | def _make_boot_files(self, boot_env, chroot_dir, boot_dir, |
3083 | 1623 | |||
3084 | 1624 | @classproperty | ||
3085 | 1625 | def extra_serial_opts(cls): | ||
3086 | 1626 | return cls._extra_serial_opts % cls.serial_tty | ||
3087 | 1627 | |||
3088 | 1628 | @classmethod | ||
3089 | 1629 | def _make_boot_files(cls, boot_env, chroot_dir, boot_dir, | ||
3107 | 1630 | boot_device_or_file, k_img_data, i_img_data, | 1393 | boot_device_or_file, k_img_data, i_img_data, |
3108 | 1631 | d_img_data): | 1394 | d_img_data): |
3110 | 1632 | make_uImage(cls.load_addr, k_img_data, boot_dir) | 1395 | make_uImage(self.load_addr, k_img_data, boot_dir) |
3111 | 1633 | make_uInitrd(i_img_data, boot_dir) | 1396 | make_uInitrd(i_img_data, boot_dir) |
3112 | 1634 | 1397 | ||
3113 | 1635 | 1398 | ||
3114 | @@ -1637,22 +1400,23 @@ | |||
3115 | 1637 | # For now, this is a duplicate of VexpressConfig. | 1400 | # For now, this is a duplicate of VexpressConfig. |
3116 | 1638 | # In future, there will also be A5 and A15 variants. | 1401 | # In future, there will also be A5 and A15 variants. |
3117 | 1639 | # For all of these, there should never be any V1 hardware packs. | 1402 | # For all of these, there should never be any V1 hardware packs. |
3119 | 1640 | pass | 1403 | def __init__(self): |
3120 | 1404 | super(VexpressA9Config, self).__init__() | ||
3121 | 1641 | 1405 | ||
3122 | 1642 | 1406 | ||
3123 | 1643 | class FastModelConfig(BoardConfig): | 1407 | class FastModelConfig(BoardConfig): |
3125 | 1644 | supports_writing_to_mmc = False | 1408 | def __init__(self): |
3126 | 1409 | super(FastModelConfig, self).__init__() | ||
3127 | 1410 | self.supports_writing_to_mmc = False | ||
3128 | 1645 | 1411 | ||
3131 | 1646 | @classmethod | 1412 | def _get_bootcmd(self, i_img_data, d_img_data): |
3130 | 1647 | def _get_bootcmd(cls, i_img_data, d_img_data): | ||
3132 | 1648 | """Get the bootcmd for FastModel. | 1413 | """Get the bootcmd for FastModel. |
3133 | 1649 | 1414 | ||
3134 | 1650 | We override this as we don't do uboot. | 1415 | We override this as we don't do uboot. |
3135 | 1651 | """ | 1416 | """ |
3136 | 1652 | return "" | 1417 | return "" |
3137 | 1653 | 1418 | ||
3140 | 1654 | @classmethod | 1419 | def _make_boot_files_v2(self, boot_env, chroot_dir, boot_dir, |
3139 | 1655 | def _make_boot_files_v2(cls, boot_env, chroot_dir, boot_dir, | ||
3141 | 1656 | boot_device_or_file, k_img_data, i_img_data, | 1420 | boot_device_or_file, k_img_data, i_img_data, |
3142 | 1657 | d_img_data): | 1421 | d_img_data): |
3143 | 1658 | output_dir = os.path.dirname(boot_device_or_file) | 1422 | output_dir = os.path.dirname(boot_device_or_file) |
3144 | @@ -1669,16 +1433,15 @@ | |||
3145 | 1669 | 1433 | ||
3146 | 1670 | 1434 | ||
3147 | 1671 | class SamsungConfig(BoardConfig): | 1435 | class SamsungConfig(BoardConfig): |
3151 | 1672 | @classproperty | 1436 | def __init__(self): |
3152 | 1673 | def extra_serial_opts(cls): | 1437 | super(SamsungConfig, self).__init__() |
3153 | 1674 | return cls._extra_serial_opts % cls.serial_tty | 1438 | self._extra_serial_opts = None |
3154 | 1675 | 1439 | ||
3157 | 1676 | @classmethod | 1440 | def get_v1_sfdisk_cmd(self, should_align_boot_part=False): |
3156 | 1677 | def get_v1_sfdisk_cmd(cls, should_align_boot_part=False): | ||
3158 | 1678 | # bootloaders partition needs to hold BL1, U-Boot environment, and BL2 | 1441 | # bootloaders partition needs to hold BL1, U-Boot environment, and BL2 |
3159 | 1679 | loaders_min_len = ( | 1442 | loaders_min_len = ( |
3162 | 1680 | cls.SAMSUNG_V310_BL2_START + cls.SAMSUNG_V310_BL2_LEN - | 1443 | self.samsung_v310_bl2_start + self.samsung_v310_bl2_len - |
3163 | 1681 | cls.SAMSUNG_V310_BL1_START) | 1444 | self.samsung_v310_bl1_start) |
3164 | 1682 | 1445 | ||
3165 | 1683 | # bootloaders partition | 1446 | # bootloaders partition |
3166 | 1684 | loaders_start, loaders_end, loaders_len = align_partition( | 1447 | loaders_start, loaders_end, loaders_len = align_partition( |
3167 | @@ -1686,44 +1449,42 @@ | |||
3168 | 1686 | 1449 | ||
3169 | 1687 | # FAT boot partition | 1450 | # FAT boot partition |
3170 | 1688 | boot_start, boot_end, boot_len = align_partition( | 1451 | boot_start, boot_end, boot_len = align_partition( |
3172 | 1689 | loaders_end + 1, cls.BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) | 1452 | loaders_end + 1, self.BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) |
3173 | 1690 | 1453 | ||
3174 | 1691 | # root partition | 1454 | # root partition |
3175 | 1692 | # we ignore _root_end / _root_len and return a sfdisk command to | 1455 | # we ignore _root_end / _root_len and return a sfdisk command to |
3176 | 1693 | # instruct the use of all remaining space; XXX if we had some root size | 1456 | # instruct the use of all remaining space; XXX if we had some root size |
3177 | 1694 | # config, we could do something more sensible | 1457 | # config, we could do something more sensible |
3178 | 1695 | root_start, _root_end, _root_len = align_partition( | 1458 | root_start, _root_end, _root_len = align_partition( |
3180 | 1696 | boot_end + 1, cls.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) | 1459 | boot_end + 1, self.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) |
3181 | 1697 | 1460 | ||
3182 | 1698 | return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % ( | 1461 | return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % ( |
3183 | 1699 | loaders_start, loaders_len, boot_start, boot_len, root_start) | 1462 | loaders_start, loaders_len, boot_start, boot_len, root_start) |
3184 | 1700 | 1463 | ||
3187 | 1701 | @classmethod | 1464 | def _make_boot_files(self, boot_env, chroot_dir, boot_dir, |
3186 | 1702 | def _make_boot_files(cls, boot_env, chroot_dir, boot_dir, | ||
3188 | 1703 | boot_device_or_file, k_img_data, i_img_data, | 1465 | boot_device_or_file, k_img_data, i_img_data, |
3189 | 1704 | d_img_data): | 1466 | d_img_data): |
3190 | 1705 | # XXX: delete this method when hwpacks V1 can die | 1467 | # XXX: delete this method when hwpacks V1 can die |
3195 | 1706 | assert cls.hwpack_format == HardwarepackHandler.FORMAT_1 | 1468 | assert self.hwpack_format == HardwarepackHandler.FORMAT_1 |
3196 | 1707 | cls.install_samsung_boot_loader(cls._get_samsung_spl(chroot_dir), | 1469 | self.install_samsung_boot_loader(self._get_samsung_spl(chroot_dir), |
3197 | 1708 | cls._get_samsung_bootloader(chroot_dir), boot_device_or_file) | 1470 | self._get_samsung_bootloader(chroot_dir), boot_device_or_file) |
3198 | 1709 | env_size = cls.SAMSUNG_V310_ENV_LEN * SECTOR_SIZE | 1471 | env_size = self.samsung_v310_env_len * SECTOR_SIZE |
3199 | 1710 | env_file = make_flashable_env(boot_env, env_size) | 1472 | env_file = make_flashable_env(boot_env, env_size) |
3201 | 1711 | _dd(env_file, boot_device_or_file, seek=cls.SAMSUNG_V310_ENV_START) | 1473 | _dd(env_file, boot_device_or_file, seek=self.samsung_v310_env_start) |
3202 | 1712 | 1474 | ||
3204 | 1713 | make_uImage(cls.load_addr, k_img_data, boot_dir) | 1475 | make_uImage(self.load_addr, k_img_data, boot_dir) |
3205 | 1714 | make_uInitrd(i_img_data, boot_dir) | 1476 | make_uInitrd(i_img_data, boot_dir) |
3206 | 1715 | 1477 | ||
3207 | 1716 | # unused at the moment once FAT support enabled for the | 1478 | # unused at the moment once FAT support enabled for the |
3208 | 1717 | # Samsung u-boot this can be used bug 727978 | 1479 | # Samsung u-boot this can be used bug 727978 |
3210 | 1718 | boot_script_path = os.path.join(boot_dir, cls.boot_script) | 1480 | boot_script_path = os.path.join(boot_dir, self.boot_script) |
3211 | 1719 | make_boot_script(boot_env, boot_script_path) | 1481 | make_boot_script(boot_env, boot_script_path) |
3212 | 1720 | 1482 | ||
3215 | 1721 | @classmethod | 1483 | def _get_samsung_spl(self, chroot_dir): |
3214 | 1722 | def _get_samsung_spl(cls, chroot_dir): | ||
3216 | 1723 | # XXX: delete this method when hwpacks V1 can die | 1484 | # XXX: delete this method when hwpacks V1 can die |
3218 | 1724 | assert cls.hwpack_format == HardwarepackHandler.FORMAT_1 | 1485 | assert self.hwpack_format == HardwarepackHandler.FORMAT_1 |
3219 | 1725 | spl_dir = os.path.join( | 1486 | spl_dir = os.path.join( |
3221 | 1726 | chroot_dir, 'usr', 'lib', 'u-boot', cls.bootloader_flavor) | 1487 | chroot_dir, 'usr', 'lib', 'u-boot', self.bootloader_flavor) |
3222 | 1727 | old_spl_path = os.path.join(spl_dir, 'v310_mmc_spl.bin') | 1488 | old_spl_path = os.path.join(spl_dir, 'v310_mmc_spl.bin') |
3223 | 1728 | new_spl_path = os.path.join(spl_dir, 'u-boot-mmc-spl.bin') | 1489 | new_spl_path = os.path.join(spl_dir, 'u-boot-mmc-spl.bin') |
3224 | 1729 | new_new_spl_path = os.path.join(spl_dir, 'origen-spl.bin') | 1490 | new_new_spl_path = os.path.join(spl_dir, 'origen-spl.bin') |
3225 | @@ -1743,49 +1504,48 @@ | |||
3226 | 1743 | % (old_spl_path, new_spl_path)) | 1504 | % (old_spl_path, new_spl_path)) |
3227 | 1744 | return spl_file | 1505 | return spl_file |
3228 | 1745 | 1506 | ||
3231 | 1746 | @classmethod | 1507 | def _get_samsung_bootloader(self, chroot_dir): |
3230 | 1747 | def _get_samsung_bootloader(cls, chroot_dir): | ||
3232 | 1748 | # XXX: delete this method when hwpacks V1 can die | 1508 | # XXX: delete this method when hwpacks V1 can die |
3234 | 1749 | assert cls.hwpack_format == HardwarepackHandler.FORMAT_1 | 1509 | assert self.hwpack_format == HardwarepackHandler.FORMAT_1 |
3235 | 1750 | bootloader_file = os.path.join( | 1510 | bootloader_file = os.path.join( |
3237 | 1751 | chroot_dir, 'usr', 'lib', 'u-boot', cls.bootloader_flavor, | 1511 | chroot_dir, 'usr', 'lib', 'u-boot', self.bootloader_flavor, |
3238 | 1752 | 'u-boot.bin') | 1512 | 'u-boot.bin') |
3239 | 1753 | return bootloader_file | 1513 | return bootloader_file |
3240 | 1754 | 1514 | ||
3243 | 1755 | @classmethod | 1515 | def populate_raw_partition(self, boot_device_or_file, chroot_dir): |
3242 | 1756 | def populate_raw_partition(cls, boot_device_or_file, chroot_dir): | ||
3244 | 1757 | # Zero the env so that the boot_script will get loaded | 1516 | # Zero the env so that the boot_script will get loaded |
3247 | 1758 | _dd("/dev/zero", boot_device_or_file, count=cls.SAMSUNG_V310_ENV_LEN, | 1517 | _dd("/dev/zero", boot_device_or_file, count=self.samsung_v310_env_len, |
3248 | 1759 | seek=cls.SAMSUNG_V310_ENV_START) | 1518 | seek=self.samsung_v310_env_start) |
3249 | 1760 | # Populate created raw partition with BL1 and u-boot | 1519 | # Populate created raw partition with BL1 and u-boot |
3250 | 1761 | spl_file = os.path.join(chroot_dir, 'boot', 'u-boot-mmc-spl.bin') | 1520 | spl_file = os.path.join(chroot_dir, 'boot', 'u-boot-mmc-spl.bin') |
3251 | 1762 | assert os.path.getsize(spl_file) <= ( | 1521 | assert os.path.getsize(spl_file) <= ( |
3255 | 1763 | cls.SAMSUNG_V310_BL1_LEN * SECTOR_SIZE), ( | 1522 | self.samsung_v310_bl1_len * SECTOR_SIZE), ( |
3256 | 1764 | "%s is larger than SAMSUNG_V310_BL1_LEN" % spl_file) | 1523 | "%s is larger than samsung_v310_bl1_len" % spl_file) |
3257 | 1765 | _dd(spl_file, boot_device_or_file, seek=cls.SAMSUNG_V310_BL1_START) | 1524 | _dd(spl_file, boot_device_or_file, seek=self.samsung_v310_bl1_start) |
3258 | 1766 | uboot_file = os.path.join(chroot_dir, 'boot', 'u-boot.bin') | 1525 | uboot_file = os.path.join(chroot_dir, 'boot', 'u-boot.bin') |
3259 | 1767 | assert os.path.getsize(uboot_file) <= ( | 1526 | assert os.path.getsize(uboot_file) <= ( |
3263 | 1768 | cls.SAMSUNG_V310_BL2_LEN * SECTOR_SIZE), ( | 1527 | self.samsung_v310_bl2_len * SECTOR_SIZE), ( |
3264 | 1769 | "%s is larger than SAMSUNG_V310_BL2_LEN" % uboot_file) | 1528 | "%s is larger than samsung_v310_bl2_len" % uboot_file) |
3265 | 1770 | _dd(uboot_file, boot_device_or_file, seek=cls.SAMSUNG_V310_BL2_START) | 1529 | _dd(uboot_file, boot_device_or_file, seek=self.samsung_v310_bl2_start) |
3266 | 1771 | 1530 | ||
3267 | 1772 | 1531 | ||
3268 | 1773 | class SMDKV310Config(SamsungConfig): | 1532 | class SMDKV310Config(SamsungConfig): |
3279 | 1774 | bootloader_flavor = 'smdkv310' | 1533 | def __init__(self): |
3280 | 1775 | serial_tty = 'ttySAC1' | 1534 | super(SMDKV310Config, self).__init__() |
3281 | 1776 | _extra_serial_opts = 'console=%s,115200n8' | 1535 | self.boot_script = 'boot.scr' |
3282 | 1777 | kernel_addr = '0x40007000' | 1536 | self.bootloader_flavor = 'smdkv310' |
3283 | 1778 | initrd_addr = '0x42000000' | 1537 | self.initrd_addr = '0x42000000' |
3284 | 1779 | load_addr = '0x40008000' | 1538 | self.kernel_addr = '0x40007000' |
3285 | 1780 | kernel_flavors = ['s5pv310'] | 1539 | self.kernel_flavors = ['s5pv310'] |
3286 | 1781 | boot_script = 'boot.scr' | 1540 | self.load_addr = '0x40008000' |
3287 | 1782 | mmc_part_offset = 1 | 1541 | self.mmc_option = '0:2' |
3288 | 1783 | mmc_option = '0:2' | 1542 | self.mmc_part_offset = 1 |
3289 | 1543 | self.serial_tty = 'ttySAC1' | ||
3290 | 1544 | self._extra_serial_opts = 'console=%s,115200n8' | ||
3291 | 1784 | 1545 | ||
3294 | 1785 | @classmethod | 1546 | def _get_boot_env(self, is_live, is_lowmem, consoles, rootfs_id, |
3293 | 1786 | def _get_boot_env(cls, is_live, is_lowmem, consoles, rootfs_id, | ||
3295 | 1787 | i_img_data, d_img_data): | 1547 | i_img_data, d_img_data): |
3297 | 1788 | boot_env = super(SamsungConfig, cls)._get_boot_env( | 1548 | boot_env = super(SamsungConfig, self)._get_boot_env( |
3298 | 1789 | is_live, is_lowmem, consoles, rootfs_id, i_img_data, d_img_data) | 1549 | is_live, is_lowmem, consoles, rootfs_id, i_img_data, d_img_data) |
3299 | 1790 | 1550 | ||
3300 | 1791 | boot_env["ethact"] = "smc911x-0" | 1551 | boot_env["ethact"] = "smc911x-0" |
3301 | @@ -1795,27 +1555,22 @@ | |||
3302 | 1795 | 1555 | ||
3303 | 1796 | 1556 | ||
3304 | 1797 | class OrigenConfig(SamsungConfig): | 1557 | class OrigenConfig(SamsungConfig): |
3315 | 1798 | bootloader_flavor = 'origen' | 1558 | # TODO test |
3316 | 1799 | serial_tty = 'ttySAC2' | 1559 | def __init__(self): |
3317 | 1800 | _extra_serial_opts = 'console=%s,115200n8' | 1560 | super(OrigenConfig, self).__init__() |
3318 | 1801 | kernel_addr = '0x40007000' | 1561 | self.boot_script = 'boot.scr' |
3319 | 1802 | initrd_addr = '0x42000000' | 1562 | self.bootloader_flavor = 'origen' |
3320 | 1803 | load_addr = '0x40008000' | 1563 | self.initrd_addr = '0x42000000' |
3321 | 1804 | kernel_flavors = ['origen'] | 1564 | self.kernel_addr = '0x40007000' |
3322 | 1805 | boot_script = 'boot.scr' | 1565 | self.kernel_flavors = ['origen'] |
3323 | 1806 | mmc_part_offset = 1 | 1566 | self.load_addr = '0x40008000' |
3324 | 1807 | mmc_option = '0:2' | 1567 | self.mmc_option = '0:2' |
3325 | 1568 | self.mmc_part_offset = 1 | ||
3326 | 1569 | self.serial_tty = 'ttySAC2' | ||
3327 | 1570 | self._extra_serial_opts = 'console=%s,115200n8' | ||
3328 | 1808 | 1571 | ||
3329 | 1809 | 1572 | ||
3330 | 1810 | class I386Config(BoardConfig): | 1573 | class I386Config(BoardConfig): |
3331 | 1811 | # define serial | ||
3332 | 1812 | serial_tty = 'ttyS0' | ||
3333 | 1813 | _extra_serial_opts = 'console=tty0 console=%s,115200n8' | ||
3334 | 1814 | _live_serial_opts = 'serialtty=%s' | ||
3335 | 1815 | |||
3336 | 1816 | # define kernel image | ||
3337 | 1817 | kernel_flavors = ['generic', 'pae'] | ||
3338 | 1818 | |||
3339 | 1819 | # define bootloader | 1574 | # define bootloader |
3340 | 1820 | BOOTLOADER_CMD = 'grub-install' | 1575 | BOOTLOADER_CMD = 'grub-install' |
3341 | 1821 | BOOTLOADER_CFG_FILE = 'grub/grub.cfg' | 1576 | BOOTLOADER_CFG_FILE = 'grub/grub.cfg' |
3342 | @@ -1827,16 +1582,14 @@ | |||
3343 | 1827 | initrd /%s | 1582 | initrd /%s |
3344 | 1828 | }""" | 1583 | }""" |
3345 | 1829 | 1584 | ||
3356 | 1830 | @classproperty | 1585 | def __init__(self): |
3357 | 1831 | def live_serial_opts(cls): | 1586 | super(I386Config, self).__init__() |
3358 | 1832 | return cls._live_serial_opts % cls.serial_tty | 1587 | self.kernel_flavors = ['generic', 'pae'] |
3359 | 1833 | 1588 | self.serial_tty = 'ttyS0' | |
3360 | 1834 | @classproperty | 1589 | self._extra_serial_opts = 'console=tty0 console=%s,115200n8' |
3361 | 1835 | def extra_serial_opts(cls): | 1590 | self._live_serial_opts = 'serialtty=%s' |
3362 | 1836 | return cls._extra_serial_opts % cls.serial_tty | 1591 | |
3363 | 1837 | 1592 | def _make_boot_files(self, boot_env, chroot_dir, boot_dir, | |
3354 | 1838 | @classmethod | ||
3355 | 1839 | def _make_boot_files(cls, boot_env, chroot_dir, boot_dir, | ||
3364 | 1840 | boot_device_or_file, k_img_data, i_img_data, | 1593 | boot_device_or_file, k_img_data, i_img_data, |
3365 | 1841 | d_img_data): | 1594 | d_img_data): |
3366 | 1842 | # copy image and init into boot partition | 1595 | # copy image and init into boot partition |
3367 | @@ -1849,13 +1602,13 @@ | |||
3368 | 1849 | img_loop = register_loopback(boot_device_or_file, 0, img_size) | 1602 | img_loop = register_loopback(boot_device_or_file, 0, img_size) |
3369 | 1850 | 1603 | ||
3370 | 1851 | # install bootloader | 1604 | # install bootloader |
3372 | 1852 | cmd_runner.run([cls.BOOTLOADER_CMD, '--boot-directory=%s' % boot_dir, | 1605 | cmd_runner.run([self.BOOTLOADER_CMD, '--boot-directory=%s' % boot_dir, |
3373 | 1853 | '--modules', 'part_msdos', img_loop], | 1606 | '--modules', 'part_msdos', img_loop], |
3374 | 1854 | as_root=True).wait() | 1607 | as_root=True).wait() |
3375 | 1855 | 1608 | ||
3376 | 1856 | # generate loader config file | 1609 | # generate loader config file |
3379 | 1857 | loader_config = cls.BOOTLOADER_CFG % (os.path.basename(k_img_data), | 1610 | loader_config = self.BOOTLOADER_CFG % (os.path.basename(k_img_data), |
3380 | 1858 | cls.extra_serial_opts, os.path.basename(i_img_data)) | 1611 | self.extra_serial_opts, os.path.basename(i_img_data)) |
3381 | 1859 | 1612 | ||
3382 | 1860 | _, tmpfile = tempfile.mkstemp() | 1613 | _, tmpfile = tempfile.mkstemp() |
3383 | 1861 | atexit.register(os.unlink, tmpfile) | 1614 | atexit.register(os.unlink, tmpfile) |
3384 | @@ -1863,40 +1616,57 @@ | |||
3385 | 1863 | fd.write(loader_config) | 1616 | fd.write(loader_config) |
3386 | 1864 | 1617 | ||
3387 | 1865 | cmd_runner.run(['cp', tmpfile, os.path.join(boot_dir, | 1618 | cmd_runner.run(['cp', tmpfile, os.path.join(boot_dir, |
3389 | 1866 | cls.BOOTLOADER_CFG_FILE)], as_root=True).wait() | 1619 | self.BOOTLOADER_CFG_FILE)], as_root=True).wait() |
3390 | 1867 | 1620 | ||
3393 | 1868 | @classmethod | 1621 | def _make_boot_files_v2(self, boot_env, chroot_dir, boot_dir, |
3392 | 1869 | def _make_boot_files_v2(cls, boot_env, chroot_dir, boot_dir, | ||
3394 | 1870 | boot_device_or_file, k_img_data, i_img_data, | 1622 | boot_device_or_file, k_img_data, i_img_data, |
3395 | 1871 | d_img_data): | 1623 | d_img_data): |
3396 | 1872 | # reuse hwpack v1 function | 1624 | # reuse hwpack v1 function |
3400 | 1873 | cls._make_boot_files(boot_env, chroot_dir, boot_dir, | 1625 | self._make_boot_files(boot_env, chroot_dir, boot_dir, |
3401 | 1874 | boot_device_or_file, k_img_data, i_img_data, | 1626 | boot_device_or_file, k_img_data, i_img_data, |
3402 | 1875 | d_img_data) | 1627 | d_img_data) |
3403 | 1628 | |||
3404 | 1629 | |||
3405 | 1630 | class BoardConfigException(Exception): | ||
3406 | 1631 | """General board config exception.""" | ||
3407 | 1876 | 1632 | ||
3408 | 1877 | 1633 | ||
3409 | 1878 | board_configs = { | 1634 | board_configs = { |
3410 | 1879 | 'beagle': BeagleConfig, | 1635 | 'beagle': BeagleConfig, |
3411 | 1880 | 'igep': IgepConfig, | ||
3412 | 1881 | 'panda': PandaConfig, | ||
3413 | 1882 | 'vexpress': VexpressConfig, | ||
3414 | 1883 | 'vexpress-a9': VexpressA9Config, | ||
3415 | 1884 | 'fastmodel': FastModelConfig, | ||
3416 | 1885 | 'ux500': Ux500Config, | ||
3417 | 1886 | 'snowball_sd': SnowballSdConfig, | ||
3418 | 1887 | 'snowball_emmc': SnowballEmmcConfig, | ||
3419 | 1888 | 'efikamx': EfikamxConfig, | 1636 | 'efikamx': EfikamxConfig, |
3420 | 1889 | 'efikasb': EfikasbConfig, | 1637 | 'efikasb': EfikasbConfig, |
3421 | 1638 | 'fastmodel': FastModelConfig, | ||
3422 | 1639 | 'i386': I386Config, | ||
3423 | 1640 | 'igep': IgepConfig, | ||
3424 | 1890 | 'mx51evk': Mx51evkConfig, | 1641 | 'mx51evk': Mx51evkConfig, |
3425 | 1891 | 'mx53loco': Mx53LoCoConfig, | 1642 | 'mx53loco': Mx53LoCoConfig, |
3426 | 1643 | 'mx6qsabrelite': BoardConfig, | ||
3427 | 1644 | 'origen': OrigenConfig, | ||
3428 | 1892 | 'overo': OveroConfig, | 1645 | 'overo': OveroConfig, |
3429 | 1646 | 'panda': PandaConfig, | ||
3430 | 1893 | 'smdkv310': SMDKV310Config, | 1647 | 'smdkv310': SMDKV310Config, |
3434 | 1894 | 'origen': OrigenConfig, | 1648 | 'snowball_emmc': SnowballEmmcConfig, |
3435 | 1895 | 'mx6qsabrelite': BoardConfig, | 1649 | 'snowball_sd': SnowballSdConfig, |
3436 | 1896 | 'i386': I386Config, | 1650 | 'ux500': Ux500Config, |
3437 | 1651 | 'vexpress': VexpressConfig, | ||
3438 | 1652 | 'vexpress-a9': VexpressA9Config, | ||
3439 | 1897 | } | 1653 | } |
3440 | 1898 | 1654 | ||
3441 | 1899 | 1655 | ||
3442 | 1656 | def get_board_config(board): | ||
3443 | 1657 | """Get the board configuration for the specified board. | ||
3444 | 1658 | |||
3445 | 1659 | :param board: The name of the board to get the configuration of. | ||
3446 | 1660 | :type board: str | ||
3447 | 1661 | """ | ||
3448 | 1662 | clazz = board_configs.get(board, None) | ||
3449 | 1663 | if clazz: | ||
3450 | 1664 | return clazz() | ||
3451 | 1665 | else: | ||
3452 | 1666 | raise BoardConfigException("Board name '%s' has no configuration " | ||
3453 | 1667 | "available." % board) | ||
3454 | 1668 | |||
3455 | 1669 | |||
3456 | 1900 | def _dd(input_file, output_file, block_size=SECTOR_SIZE, count=None, seek=None, | 1670 | def _dd(input_file, output_file, block_size=SECTOR_SIZE, count=None, seek=None, |
3457 | 1901 | skip=None): | 1671 | skip=None): |
3458 | 1902 | """Wrapper around the dd command""" | 1672 | """Wrapper around the dd command""" |
3459 | 1903 | 1673 | ||
3460 | === modified file 'linaro_image_tools/media_create/chroot_utils.py' | |||
3461 | --- linaro_image_tools/media_create/chroot_utils.py 2012-10-04 09:12:57 +0000 | |||
3462 | +++ linaro_image_tools/media_create/chroot_utils.py 2012-11-20 10:49:03 +0000 | |||
3463 | @@ -25,7 +25,7 @@ | |||
3464 | 25 | is_arm_host, | 25 | is_arm_host, |
3465 | 26 | find_command, | 26 | find_command, |
3466 | 27 | ) | 27 | ) |
3468 | 28 | from linaro_image_tools.media_create.boards import HardwarepackHandler | 28 | from linaro_image_tools.hwpack.handler import HardwarepackHandler |
3469 | 29 | 29 | ||
3470 | 30 | # It'd be nice if we could use atexit here, but all the things we need to undo | 30 | # It'd be nice if we could use atexit here, but all the things we need to undo |
3471 | 31 | # have to happen right after install_hwpacks completes and the atexit | 31 | # have to happen right after install_hwpacks completes and the atexit |
3472 | 32 | 32 | ||
3473 | === modified file 'linaro_image_tools/media_create/tests/__init__.py' | |||
3474 | --- linaro_image_tools/media_create/tests/__init__.py 2012-06-07 13:12:42 +0000 | |||
3475 | +++ linaro_image_tools/media_create/tests/__init__.py 2012-11-20 10:49:03 +0000 | |||
3476 | @@ -2,8 +2,10 @@ | |||
3477 | 2 | 2 | ||
3478 | 3 | 3 | ||
3479 | 4 | def test_suite(): | 4 | def test_suite(): |
3482 | 5 | module_names = ['linaro_image_tools.media_create.tests.test_media_create', | 5 | module_names = [ |
3483 | 6 | ] | 6 | 'linaro_image_tools.media_create.tests.test_media_create', |
3484 | 7 | 'linaro_image_tools.media_create.tests.test_android_boards', | ||
3485 | 8 | ] | ||
3486 | 7 | loader = unittest.TestLoader() | 9 | loader = unittest.TestLoader() |
3487 | 8 | suite = loader.loadTestsFromNames(module_names) | 10 | suite = loader.loadTestsFromNames(module_names) |
3488 | 9 | return suite | 11 | return suite |
3489 | 10 | 12 | ||
3490 | === added file 'linaro_image_tools/media_create/tests/test_android_boards.py' | |||
3491 | --- linaro_image_tools/media_create/tests/test_android_boards.py 1970-01-01 00:00:00 +0000 | |||
3492 | +++ linaro_image_tools/media_create/tests/test_android_boards.py 2012-11-20 10:49:03 +0000 | |||
3493 | @@ -0,0 +1,249 @@ | |||
3494 | 1 | # Copyright (C) 2010, 2011 Linaro | ||
3495 | 2 | # | ||
3496 | 3 | # Author: Milo Casagrande <milo.casagrande@linaro.org> | ||
3497 | 4 | # | ||
3498 | 5 | # This file is part of Linaro Image Tools. | ||
3499 | 6 | # | ||
3500 | 7 | # Linaro Image Tools is free software: you can redistribute it and/or modify | ||
3501 | 8 | # it under the terms of the GNU General Public License as published by | ||
3502 | 9 | # the Free Software Foundation, either version 3 of the License, or | ||
3503 | 10 | # (at your option) any later version. | ||
3504 | 11 | # | ||
3505 | 12 | # Linaro Image Tools is distributed in the hope that it will be useful, | ||
3506 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
3507 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
3508 | 15 | # GNU General Public License for more details. | ||
3509 | 16 | # | ||
3510 | 17 | # You should have received a copy of the GNU General Public License | ||
3511 | 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
3512 | 19 | |||
3513 | 20 | from StringIO import StringIO | ||
3514 | 21 | from testtools import TestCase | ||
3515 | 22 | |||
3516 | 23 | from linaro_image_tools.media_create.boards import ( | ||
3517 | 24 | BoardConfigException, | ||
3518 | 25 | ) | ||
3519 | 26 | |||
3520 | 27 | from linaro_image_tools.media_create.android_boards import ( | ||
3521 | 28 | AndroidBeagleConfig, | ||
3522 | 29 | get_board_config, | ||
3523 | 30 | ) | ||
3524 | 31 | |||
3525 | 32 | |||
3526 | 33 | class TestAndroidBoards(TestCase): | ||
3527 | 34 | """Class to test small things in android_boards.""" | ||
3528 | 35 | |||
3529 | 36 | def test_get_board_config(self): | ||
3530 | 37 | instance = get_board_config('beagle') | ||
3531 | 38 | self.assertIsInstance(instance, AndroidBeagleConfig) | ||
3532 | 39 | |||
3533 | 40 | def test_get_board_config_wrong(self): | ||
3534 | 41 | self.assertRaises(BoardConfigException, get_board_config, 'notadevice') | ||
3535 | 42 | |||
3536 | 43 | |||
3537 | 44 | class TestAndroidBoardsHwpack(TestCase): | ||
3538 | 45 | """Class to test the new Android hwpack configuration file.""" | ||
3539 | 46 | |||
3540 | 47 | def setUp(self): | ||
3541 | 48 | super(TestAndroidBoardsHwpack, self).setUp() | ||
3542 | 49 | # Pick a default board. | ||
3543 | 50 | self.config = get_board_config('beagle') | ||
3544 | 51 | self.hwpack_base = "format: 3.0\n" | ||
3545 | 52 | self.fake_hwpack = (self.hwpack_base + "dtb_name: a_name\n" | ||
3546 | 53 | "fdt_high: '0xFFFFFFFF'\nfat_size: 16\n") | ||
3547 | 54 | |||
3548 | 55 | def test_read_from_file(self): | ||
3549 | 56 | conf = self.config.from_file(StringIO(self.fake_hwpack)) | ||
3550 | 57 | expected = {'format': 3.0, 'dtb_name': 'a_name', | ||
3551 | 58 | 'fdt_high': '0xFFFFFFFF', 'fat_size': 16} | ||
3552 | 59 | self.assertEqual(expected, conf) | ||
3553 | 60 | |||
3554 | 61 | def test_android_specific_args(self): | ||
3555 | 62 | """The field android_specific_args should be a concatenated string.""" | ||
3556 | 63 | specific_args = ("android_specific_args:\n - init=/init\n " | ||
3557 | 64 | "- androidboot.console=ttyO2") | ||
3558 | 65 | hwpack_config = self.hwpack_base + specific_args | ||
3559 | 66 | self.config.from_file(StringIO(hwpack_config)) | ||
3560 | 67 | expected = 'init=/init androidboot.console=ttyO2' | ||
3561 | 68 | self.assertEqual(expected, self.config.android_specific_args) | ||
3562 | 69 | |||
3563 | 70 | def test_extra_serial_options(self): | ||
3564 | 71 | """The field extra_serial_options should be a concatenated string.""" | ||
3565 | 72 | extra_serial_opts = ("extra_serial_options:\n - console=tty0\n " | ||
3566 | 73 | "- console=ttyO2,115200n8") | ||
3567 | 74 | hwpack_config = self.hwpack_base + extra_serial_opts | ||
3568 | 75 | self.config.from_file(StringIO(hwpack_config)) | ||
3569 | 76 | expected = 'console=tty0 console=ttyO2,115200n8' | ||
3570 | 77 | self.assertEqual(expected, self.config.extra_serial_options) | ||
3571 | 78 | |||
3572 | 79 | def test_extra_boot_args_options(self): | ||
3573 | 80 | """The field extra_boot_args_options should be a concatenated string. | ||
3574 | 81 | Testing presence of a field defined in the parent class.""" | ||
3575 | 82 | extra_boot_args_options = ("extra_boot_args_options:\n " | ||
3576 | 83 | "- earlyprintk\n - mem=128M@0\n " | ||
3577 | 84 | "- mali.mali_mem=64M@128M\n") | ||
3578 | 85 | hwpack_config = self.hwpack_base + extra_boot_args_options | ||
3579 | 86 | self.config.from_file(StringIO(hwpack_config)) | ||
3580 | 87 | expected = 'earlyprintk mem=128M@0 mali.mali_mem=64M@128M' | ||
3581 | 88 | self.assertEqual(expected, self.config.extra_boot_args_options) | ||
3582 | 89 | |||
3583 | 90 | def test_android_mx6(self): | ||
3584 | 91 | android_mx6_config = (self.hwpack_base + "bootloader_flavor: " | ||
3585 | 92 | "mx6qsabrelite\nextra_boot_args_options:\n - earlyprintk\n" | ||
3586 | 93 | " - rootdelay=1\n - fixrtc\n - nocompcache\n - di1_primary\n" | ||
3587 | 94 | " - tve\nextra_serial_options:\n - console=%s,115200n8\n" | ||
3588 | 95 | "android_specific_args:\n - init=/init\n - " | ||
3589 | 96 | "androidboot.console=%s\nkernel_addr: '0x10000000'\n" | ||
3590 | 97 | "initrd_addr: '0x12000000'\nload_addr: '0x10008000'\ndtb_addr:" | ||
3591 | 98 | " '0x11ff0000'\ndtb_name: board.dtb") | ||
3592 | 99 | expected = { | ||
3593 | 100 | 'bootargs': 'console=ttymxc0,115200n8 ' | ||
3594 | 101 | 'rootwait ro earlyprintk rootdelay=1 fixrtc ' | ||
3595 | 102 | 'nocompcache di1_primary tve init=/init ' | ||
3596 | 103 | 'androidboot.console=ttymxc0', | ||
3597 | 104 | 'bootcmd': 'fatload mmc 0:2 0x10000000 uImage; ' | ||
3598 | 105 | 'fatload mmc 0:2 0x12000000 uInitrd; ' | ||
3599 | 106 | 'fatload mmc 0:2 0x11ff0000 board.dtb; ' | ||
3600 | 107 | 'bootm 0x10000000 0x12000000 0x11ff0000', | ||
3601 | 108 | 'fdt_high': '0xffffffff', | ||
3602 | 109 | 'initrd_high': '0xffffffff'} | ||
3603 | 110 | config = get_board_config('mx6qsabrelite') | ||
3604 | 111 | config.from_file(StringIO(android_mx6_config)) | ||
3605 | 112 | self.assertBootEnv(config, expected) | ||
3606 | 113 | |||
3607 | 114 | def test_panda(self): | ||
3608 | 115 | panda_config = (self.hwpack_base + "bootloader_flavor: omap4_panda\n" | ||
3609 | 116 | "dtb_addr: '0x815f0000'\ndtb_name: board.dtb\n" | ||
3610 | 117 | "extra_serial_options:\n - console=ttyO2,115200n8\n" | ||
3611 | 118 | "extra_boot_args_options:\n - earlyprintk\n" | ||
3612 | 119 | " - fixrtc\n - nocompcache\n - vram=48M\n" | ||
3613 | 120 | " - omapfb.vram=0:24M,1:24M\n - mem=456M@0x80000000\n" | ||
3614 | 121 | " - mem=512M@0xA0000000\nandroid_specific_args:\n" | ||
3615 | 122 | " - init=/init\n - androidboot.console=ttyO2") | ||
3616 | 123 | # XXX: To fix bug 697824 we have to change class attributes of our | ||
3617 | 124 | # OMAP board configs, and some tests do that so to make sure they | ||
3618 | 125 | # don't interfere with us we'll reset that before doing anything. | ||
3619 | 126 | config = get_board_config('panda') | ||
3620 | 127 | config.from_file(StringIO(panda_config)) | ||
3621 | 128 | expected = { | ||
3622 | 129 | 'bootargs': 'console=ttyO2,115200n8 ' | ||
3623 | 130 | 'rootwait ro earlyprintk fixrtc ' | ||
3624 | 131 | 'nocompcache vram=48M omapfb.vram=0:24M,1:24M ' | ||
3625 | 132 | 'mem=456M@0x80000000 mem=512M@0xA0000000 ' | ||
3626 | 133 | 'init=/init androidboot.console=ttyO2', | ||
3627 | 134 | 'bootcmd': 'fatload mmc 0:1 0x80200000 uImage; ' | ||
3628 | 135 | 'fatload mmc 0:1 0x81600000 uInitrd; ' | ||
3629 | 136 | 'fatload mmc 0:1 0x815f0000 board.dtb; ' | ||
3630 | 137 | 'bootm 0x80200000 0x81600000 0x815f0000', | ||
3631 | 138 | 'fdt_high': '0xffffffff', | ||
3632 | 139 | 'initrd_high': '0xffffffff'} | ||
3633 | 140 | self.assertBootEnv(config, expected) | ||
3634 | 141 | |||
3635 | 142 | def test_android_snowball_sd(self): | ||
3636 | 143 | snowball_config = (self.hwpack_base + "boot_script: boot.scr\n" | ||
3637 | 144 | "fdt_high: '0x05000000'\ninitrd_addr: '0x05000000'\n" | ||
3638 | 145 | "initrd_high: '0x06000000'\nextra_boot_args_options:\n " | ||
3639 | 146 | "- earlyprintk\n - mem=128M@0\n - mali.mali_mem=64M@128M\n " | ||
3640 | 147 | "- hwmem=168M@192M\n - mem=22M@360M\n - mem_issw=1M@383M\n " | ||
3641 | 148 | "- mem=640M@384M\n - vmalloc=500M\nextra_serial_options:\n" | ||
3642 | 149 | " - console=ttyAMA2,115200n8\nandroid_specific_args:\n " | ||
3643 | 150 | "- init=/init\n - androidboot.console=ttyAMA2\n" | ||
3644 | 151 | "dtb_name: board.dtb\ndtb_addr: '0x8000000'") | ||
3645 | 152 | config = get_board_config('snowball_sd') | ||
3646 | 153 | config.from_file(StringIO(snowball_config)) | ||
3647 | 154 | expected = { | ||
3648 | 155 | 'bootargs': 'console=ttyAMA2,115200n8 ' | ||
3649 | 156 | 'rootwait ro earlyprintk ' | ||
3650 | 157 | 'mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M ' | ||
3651 | 158 | 'mem=22M@360M mem_issw=1M@383M mem=640M@384M ' | ||
3652 | 159 | 'vmalloc=500M init=/init androidboot.console=ttyAMA2', | ||
3653 | 160 | 'bootcmd': 'fatload mmc 1:1 0x00100000 uImage; ' | ||
3654 | 161 | 'fatload mmc 1:1 0x05000000 uInitrd; ' | ||
3655 | 162 | 'fatload mmc 1:1 0x8000000 board.dtb; ' | ||
3656 | 163 | 'bootm 0x00100000 0x05000000 0x8000000', | ||
3657 | 164 | 'fdt_high': '0x05000000', | ||
3658 | 165 | 'initrd_high': '0x06000000'} | ||
3659 | 166 | self.assertBootEnv(config, expected) | ||
3660 | 167 | |||
3661 | 168 | def test_android_snowball_emmc(self): | ||
3662 | 169 | snowball_config = (self.hwpack_base + "boot_script: boot.scr\n" | ||
3663 | 170 | "fdt_high: '0x05000000'\ninitrd_addr: '0x05000000'\n" | ||
3664 | 171 | "initrd_high: '0x06000000'\nextra_boot_args_options:\n " | ||
3665 | 172 | "- earlyprintk\n - mem=128M@0\n - mali.mali_mem=64M@128M\n " | ||
3666 | 173 | "- hwmem=168M@192M\n - mem=22M@360M\n - mem_issw=1M@383M\n " | ||
3667 | 174 | "- mem=640M@384M\n - vmalloc=500M\nextra_serial_options:\n" | ||
3668 | 175 | " - console=ttyAMA2,115200n8\nandroid_specific_args:\n " | ||
3669 | 176 | "- init=/init\n - androidboot.console=ttyAMA2\n" | ||
3670 | 177 | "dtb_name: board.dtb\ndtb_addr: '0x8000000'\nmmc_option: '0:2'") | ||
3671 | 178 | config = get_board_config('snowball_emmc') | ||
3672 | 179 | config.from_file(StringIO(snowball_config)) | ||
3673 | 180 | expected = { | ||
3674 | 181 | 'bootargs': 'console=ttyAMA2,115200n8 ' | ||
3675 | 182 | 'rootwait ro earlyprintk ' | ||
3676 | 183 | 'mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M ' | ||
3677 | 184 | 'mem=22M@360M mem_issw=1M@383M mem=640M@384M ' | ||
3678 | 185 | 'vmalloc=500M init=/init androidboot.console=ttyAMA2', | ||
3679 | 186 | 'bootcmd': 'fatload mmc 0:2 0x00100000 uImage; ' | ||
3680 | 187 | 'fatload mmc 0:2 0x05000000 uInitrd; ' | ||
3681 | 188 | 'fatload mmc 0:2 0x8000000 board.dtb; ' | ||
3682 | 189 | 'bootm 0x00100000 0x05000000 0x8000000', | ||
3683 | 190 | 'fdt_high': '0x05000000', | ||
3684 | 191 | 'initrd_high': '0x06000000'} | ||
3685 | 192 | self.assertBootEnv(config, expected) | ||
3686 | 193 | |||
3687 | 194 | def test_android_origen(self): | ||
3688 | 195 | origen_config = (self.hwpack_base + "extra_serial_options:\n " | ||
3689 | 196 | "- console=tty0\n - console=ttySAC2,115200n8\n" | ||
3690 | 197 | "android_specific_args:\n - init=/init\n " | ||
3691 | 198 | "- androidboot.console=ttySAC2") | ||
3692 | 199 | config = get_board_config('origen') | ||
3693 | 200 | config.from_file(StringIO(origen_config)) | ||
3694 | 201 | expected = { | ||
3695 | 202 | 'bootargs': 'console=tty0 console=ttySAC2,115200n8 ' | ||
3696 | 203 | 'rootwait ro init=/init androidboot.console=ttySAC2', | ||
3697 | 204 | 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; ' | ||
3698 | 205 | 'fatload mmc 0:2 0x42000000 uInitrd; ' | ||
3699 | 206 | 'bootm 0x40007000 0x42000000', | ||
3700 | 207 | 'fdt_high': '0xffffffff', | ||
3701 | 208 | 'initrd_high': '0xffffffff'} | ||
3702 | 209 | self.assertBootEnv(config, expected) | ||
3703 | 210 | |||
3704 | 211 | def test_android_vexpress(self): | ||
3705 | 212 | vexpress_config = (self.hwpack_base + "extra_serial_options:\n " | ||
3706 | 213 | "- console=tty0\n - console=ttyAMA0,38400n8\n" | ||
3707 | 214 | "android_specific_args:\n - init=/init\n " | ||
3708 | 215 | "- androidboot.console=ttyAMA0") | ||
3709 | 216 | config = get_board_config('vexpress') | ||
3710 | 217 | config.from_file(StringIO(vexpress_config)) | ||
3711 | 218 | expected = { | ||
3712 | 219 | 'bootargs': 'console=tty0 console=ttyAMA0,38400n8 ' | ||
3713 | 220 | 'rootwait ro init=/init androidboot.console=ttyAMA0', | ||
3714 | 221 | 'bootcmd': 'fatload mmc 0:1 0x60000000 uImage; ' | ||
3715 | 222 | 'fatload mmc 0:1 0x62000000 uInitrd; ' | ||
3716 | 223 | 'bootm 0x60000000 0x62000000', | ||
3717 | 224 | 'fdt_high': '0xffffffff', | ||
3718 | 225 | 'initrd_high': '0xffffffff'} | ||
3719 | 226 | self.assertBootEnv(config, expected) | ||
3720 | 227 | |||
3721 | 228 | def test_android_mx5(self): | ||
3722 | 229 | mx5_config = (self.hwpack_base + "extra_boot_args_options:\n " | ||
3723 | 230 | "- earlyprintk\n - rootdelay=1\n - fixrtc\n - nocompcache\n " | ||
3724 | 231 | "- di1_primary\n - tve\nextra_serial_options:\n" | ||
3725 | 232 | " - console=%s,115200n8\nandroid_specific_args:\n " | ||
3726 | 233 | "- init=/init\n - androidboot.console=%s") | ||
3727 | 234 | config = get_board_config('mx53loco') | ||
3728 | 235 | config.from_file(mx5_config) | ||
3729 | 236 | expected = { | ||
3730 | 237 | 'bootargs': 'console=ttymxc0,115200n8 ' | ||
3731 | 238 | 'rootwait ro earlyprintk rootdelay=1 fixrtc ' | ||
3732 | 239 | 'nocompcache di1_primary tve init=/init ' | ||
3733 | 240 | 'androidboot.console=ttymxc0', | ||
3734 | 241 | 'bootcmd': 'fatload mmc 0:2 0x70000000 uImage; ' | ||
3735 | 242 | 'fatload mmc 0:2 0x72000000 uInitrd; ' | ||
3736 | 243 | 'bootm 0x70000000 0x72000000', | ||
3737 | 244 | 'fdt_high': '0xffffffff', | ||
3738 | 245 | 'initrd_high': '0xffffffff'} | ||
3739 | 246 | self.assertBootEnv(config, expected) | ||
3740 | 247 | |||
3741 | 248 | def assertBootEnv(self, config, expected): | ||
3742 | 249 | self.assertEqual(expected, config._get_boot_env(consoles=[])) | ||
3743 | 0 | 250 | ||
3744 | === modified file 'linaro_image_tools/media_create/tests/test_media_create.py' | |||
3745 | --- linaro_image_tools/media_create/tests/test_media_create.py 2012-10-17 08:59:25 +0000 | |||
3746 | +++ linaro_image_tools/media_create/tests/test_media_create.py 2012-11-20 10:49:03 +0000 | |||
3747 | @@ -36,6 +36,7 @@ | |||
3748 | 36 | from testtools import TestCase | 36 | from testtools import TestCase |
3749 | 37 | 37 | ||
3750 | 38 | from linaro_image_tools import cmd_runner | 38 | from linaro_image_tools import cmd_runner |
3751 | 39 | from linaro_image_tools.hwpack.handler import HardwarepackHandler | ||
3752 | 39 | from linaro_image_tools.hwpack.packages import PackageMaker | 40 | from linaro_image_tools.hwpack.packages import PackageMaker |
3753 | 40 | import linaro_image_tools.media_create | 41 | import linaro_image_tools.media_create |
3754 | 41 | from linaro_image_tools.media_create import ( | 42 | from linaro_image_tools.media_create import ( |
3755 | @@ -49,7 +50,6 @@ | |||
3756 | 49 | SECTOR_SIZE, | 50 | SECTOR_SIZE, |
3757 | 50 | align_up, | 51 | align_up, |
3758 | 51 | align_partition, | 52 | align_partition, |
3759 | 52 | board_configs, | ||
3760 | 53 | get_plain_boot_script_contents, | 53 | get_plain_boot_script_contents, |
3761 | 54 | make_flashable_env, | 54 | make_flashable_env, |
3762 | 55 | install_mx5_boot_loader, | 55 | install_mx5_boot_loader, |
3763 | @@ -61,12 +61,11 @@ | |||
3764 | 61 | _get_file_matching, | 61 | _get_file_matching, |
3765 | 62 | _get_mlo_file, | 62 | _get_mlo_file, |
3766 | 63 | _run_mkimage, | 63 | _run_mkimage, |
3767 | 64 | HardwarepackHandler, | ||
3768 | 65 | BoardConfig, | 64 | BoardConfig, |
3769 | 65 | get_board_config, | ||
3770 | 66 | ) | 66 | ) |
3771 | 67 | from linaro_image_tools.media_create.android_boards import ( | 67 | from linaro_image_tools.media_create.android_boards import ( |
3772 | 68 | AndroidSnowballEmmcConfig, | 68 | AndroidSnowballEmmcConfig, |
3773 | 69 | android_board_configs, | ||
3774 | 70 | ) | 69 | ) |
3775 | 71 | from linaro_image_tools.media_create.chroot_utils import ( | 70 | from linaro_image_tools.media_create.chroot_utils import ( |
3776 | 72 | copy_file, | 71 | copy_file, |
3777 | @@ -427,10 +426,9 @@ | |||
3778 | 427 | linaro_image_tools.media_create.boards, 'HardwarepackHandler', | 426 | linaro_image_tools.media_create.boards, 'HardwarepackHandler', |
3779 | 428 | self.MockHardwarepackHandler)) | 427 | self.MockHardwarepackHandler)) |
3780 | 429 | 428 | ||
3785 | 430 | class config(BoardConfig): | 429 | board_conf = BoardConfig() |
3786 | 431 | pass | 430 | board_conf.set_metadata('ahwpack.tar.gz') |
3787 | 432 | config.set_metadata('ahwpack.tar.gz') | 431 | self.assertEquals(None, board_conf.kernel_addr) |
3784 | 433 | self.assertEquals(None, config.kernel_addr) | ||
3788 | 434 | 432 | ||
3789 | 435 | def test_sets_kernel_addr(self): | 433 | def test_sets_kernel_addr(self): |
3790 | 436 | self.useFixture(MockSomethingFixture( | 434 | self.useFixture(MockSomethingFixture( |
3791 | @@ -442,10 +440,9 @@ | |||
3792 | 442 | field_to_test: data_to_set, | 440 | field_to_test: data_to_set, |
3793 | 443 | } | 441 | } |
3794 | 444 | 442 | ||
3799 | 445 | class config(BoardConfig): | 443 | board_conf = BoardConfig() |
3800 | 446 | pass | 444 | board_conf.set_metadata('ahwpack.tar.gz') |
3801 | 447 | config.set_metadata('ahwpack.tar.gz') | 445 | self.assertEquals(data_to_set, board_conf.kernel_addr) |
3798 | 448 | self.assertEquals(data_to_set, config.kernel_addr) | ||
3802 | 449 | 446 | ||
3803 | 450 | def test_sets_initrd_addr(self): | 447 | def test_sets_initrd_addr(self): |
3804 | 451 | self.useFixture(MockSomethingFixture( | 448 | self.useFixture(MockSomethingFixture( |
3805 | @@ -457,10 +454,9 @@ | |||
3806 | 457 | field_to_test: data_to_set, | 454 | field_to_test: data_to_set, |
3807 | 458 | } | 455 | } |
3808 | 459 | 456 | ||
3813 | 460 | class config(BoardConfig): | 457 | board_conf = BoardConfig() |
3814 | 461 | pass | 458 | board_conf.set_metadata('ahwpack.tar.gz') |
3815 | 462 | config.set_metadata('ahwpack.tar.gz') | 459 | self.assertEquals(data_to_set, board_conf.initrd_addr) |
3812 | 463 | self.assertEquals(data_to_set, config.initrd_addr) | ||
3816 | 464 | 460 | ||
3817 | 465 | def test_sets_load_addr(self): | 461 | def test_sets_load_addr(self): |
3818 | 466 | self.useFixture(MockSomethingFixture( | 462 | self.useFixture(MockSomethingFixture( |
3819 | @@ -472,10 +468,9 @@ | |||
3820 | 472 | field_to_test: data_to_set, | 468 | field_to_test: data_to_set, |
3821 | 473 | } | 469 | } |
3822 | 474 | 470 | ||
3827 | 475 | class config(BoardConfig): | 471 | board_conf = BoardConfig() |
3828 | 476 | pass | 472 | board_conf.set_metadata('ahwpack.tar.gz') |
3829 | 477 | config.set_metadata('ahwpack.tar.gz') | 473 | self.assertEquals(data_to_set, board_conf.load_addr) |
3826 | 478 | self.assertEquals(data_to_set, config.load_addr) | ||
3830 | 479 | 474 | ||
3831 | 480 | def test_sets_serial_tty(self): | 475 | def test_sets_serial_tty(self): |
3832 | 481 | self.useFixture(MockSomethingFixture( | 476 | self.useFixture(MockSomethingFixture( |
3833 | @@ -487,10 +482,9 @@ | |||
3834 | 487 | field_to_test: data_to_set, | 482 | field_to_test: data_to_set, |
3835 | 488 | } | 483 | } |
3836 | 489 | 484 | ||
3841 | 490 | class config(BoardConfig): | 485 | board_conf = BoardConfig() |
3842 | 491 | pass | 486 | board_conf.set_metadata('ahwpack.tar.gz') |
3843 | 492 | config.set_metadata('ahwpack.tar.gz') | 487 | self.assertEquals(data_to_set, board_conf.serial_tty) |
3840 | 493 | self.assertEquals(data_to_set, config.serial_tty) | ||
3844 | 494 | 488 | ||
3845 | 495 | def test_sets_wired_interfaces(self): | 489 | def test_sets_wired_interfaces(self): |
3846 | 496 | self.useFixture(MockSomethingFixture( | 490 | self.useFixture(MockSomethingFixture( |
3847 | @@ -502,10 +496,9 @@ | |||
3848 | 502 | field_to_test: data_to_set, | 496 | field_to_test: data_to_set, |
3849 | 503 | } | 497 | } |
3850 | 504 | 498 | ||
3855 | 505 | class config(BoardConfig): | 499 | board_conf = BoardConfig() |
3856 | 506 | pass | 500 | board_conf.set_metadata('ahwpack.tar.gz') |
3857 | 507 | config.set_metadata('ahwpack.tar.gz') | 501 | self.assertEquals(data_to_set, board_conf.wired_interfaces) |
3854 | 508 | self.assertEquals(data_to_set, config.wired_interfaces) | ||
3858 | 509 | 502 | ||
3859 | 510 | def test_sets_wireless_interfaces(self): | 503 | def test_sets_wireless_interfaces(self): |
3860 | 511 | self.useFixture(MockSomethingFixture( | 504 | self.useFixture(MockSomethingFixture( |
3861 | @@ -517,10 +510,9 @@ | |||
3862 | 517 | field_to_test: data_to_set, | 510 | field_to_test: data_to_set, |
3863 | 518 | } | 511 | } |
3864 | 519 | 512 | ||
3869 | 520 | class config(BoardConfig): | 513 | board_conf = BoardConfig() |
3870 | 521 | pass | 514 | board_conf.set_metadata('ahwpack.tar.gz') |
3871 | 522 | config.set_metadata('ahwpack.tar.gz') | 515 | self.assertEquals(data_to_set, board_conf.wireless_interfaces) |
3868 | 523 | self.assertEquals(data_to_set, config.wireless_interfaces) | ||
3872 | 524 | 516 | ||
3873 | 525 | def test_sets_mmc_id(self): | 517 | def test_sets_mmc_id(self): |
3874 | 526 | self.useFixture(MockSomethingFixture( | 518 | self.useFixture(MockSomethingFixture( |
3875 | @@ -532,12 +524,11 @@ | |||
3876 | 532 | field_to_test: data_to_set, | 524 | field_to_test: data_to_set, |
3877 | 533 | } | 525 | } |
3878 | 534 | 526 | ||
3885 | 535 | class config(BoardConfig): | 527 | board_conf = BoardConfig() |
3886 | 536 | pass | 528 | board_conf.set_metadata('ahwpack.tar.gz') |
3887 | 537 | config.set_metadata('ahwpack.tar.gz') | 529 | self.assertEquals(data_to_set, board_conf.mmc_option) |
3888 | 538 | self.assertEquals(data_to_set, config.mmc_option) | 530 | self.assertEquals(0, board_conf.mmc_device_id) |
3889 | 539 | self.assertEquals(0, config.mmc_device_id) | 531 | self.assertEquals(0, board_conf.mmc_part_offset) |
3884 | 540 | self.assertEquals(0, config.mmc_part_offset) | ||
3890 | 541 | 532 | ||
3891 | 542 | def test_sets_boot_min_size(self): | 533 | def test_sets_boot_min_size(self): |
3892 | 543 | self.useFixture(MockSomethingFixture( | 534 | self.useFixture(MockSomethingFixture( |
3893 | @@ -551,10 +542,9 @@ | |||
3894 | 551 | field_to_test: data_to_set, | 542 | field_to_test: data_to_set, |
3895 | 552 | } | 543 | } |
3896 | 553 | 544 | ||
3901 | 554 | class config(BoardConfig): | 545 | board_conf = BoardConfig() |
3902 | 555 | pass | 546 | board_conf.set_metadata('ahwpack.tar.gz') |
3903 | 556 | config.set_metadata('ahwpack.tar.gz') | 547 | self.assertEquals(expected, board_conf.BOOT_MIN_SIZE_S) |
3900 | 557 | self.assertEquals(expected, config.BOOT_MIN_SIZE_S) | ||
3904 | 558 | 548 | ||
3905 | 559 | def test_sets_root_min_size(self): | 549 | def test_sets_root_min_size(self): |
3906 | 560 | self.useFixture(MockSomethingFixture( | 550 | self.useFixture(MockSomethingFixture( |
3907 | @@ -568,10 +558,9 @@ | |||
3908 | 568 | field_to_test: data_to_set, | 558 | field_to_test: data_to_set, |
3909 | 569 | } | 559 | } |
3910 | 570 | 560 | ||
3915 | 571 | class config(BoardConfig): | 561 | board_conf = BoardConfig() |
3916 | 572 | pass | 562 | board_conf.set_metadata('ahwpack.tar.gz') |
3917 | 573 | config.set_metadata('ahwpack.tar.gz') | 563 | self.assertEquals(expected, board_conf.ROOT_MIN_SIZE_S) |
3914 | 574 | self.assertEquals(expected, config.ROOT_MIN_SIZE_S) | ||
3918 | 575 | 564 | ||
3919 | 576 | def test_sets_loader_min_size(self): | 565 | def test_sets_loader_min_size(self): |
3920 | 577 | self.useFixture(MockSomethingFixture( | 566 | self.useFixture(MockSomethingFixture( |
3921 | @@ -585,10 +574,9 @@ | |||
3922 | 585 | field_to_test: data_to_set, | 574 | field_to_test: data_to_set, |
3923 | 586 | } | 575 | } |
3924 | 587 | 576 | ||
3929 | 588 | class config(BoardConfig): | 577 | board_conf = BoardConfig() |
3930 | 589 | pass | 578 | board_conf.set_metadata('ahwpack.tar.gz') |
3931 | 590 | config.set_metadata('ahwpack.tar.gz') | 579 | self.assertEquals(expected, board_conf.LOADER_MIN_SIZE_S) |
3928 | 591 | self.assertEquals(expected, config.LOADER_MIN_SIZE_S) | ||
3932 | 592 | 580 | ||
3933 | 593 | def test_sets_partition_layout_32(self): | 581 | def test_sets_partition_layout_32(self): |
3934 | 594 | self.useFixture(MockSomethingFixture( | 582 | self.useFixture(MockSomethingFixture( |
3935 | @@ -600,10 +588,9 @@ | |||
3936 | 600 | field_to_test: data_to_set, | 588 | field_to_test: data_to_set, |
3937 | 601 | } | 589 | } |
3938 | 602 | 590 | ||
3943 | 603 | class config(BoardConfig): | 591 | board_conf = BoardConfig() |
3944 | 604 | pass | 592 | board_conf.set_metadata('ahwpack.tar.gz') |
3945 | 605 | config.set_metadata('ahwpack.tar.gz') | 593 | self.assertEquals(32, board_conf.fat_size) |
3942 | 606 | self.assertEquals(32, config.fat_size) | ||
3946 | 607 | 594 | ||
3947 | 608 | def test_sets_partition_layout_16(self): | 595 | def test_sets_partition_layout_16(self): |
3948 | 609 | self.useFixture(MockSomethingFixture( | 596 | self.useFixture(MockSomethingFixture( |
3949 | @@ -615,10 +602,9 @@ | |||
3950 | 615 | field_to_test: data_to_set, | 602 | field_to_test: data_to_set, |
3951 | 616 | } | 603 | } |
3952 | 617 | 604 | ||
3957 | 618 | class config(BoardConfig): | 605 | board_conf = BoardConfig() |
3958 | 619 | pass | 606 | board_conf.set_metadata('ahwpack.tar.gz') |
3959 | 620 | config.set_metadata('ahwpack.tar.gz') | 607 | self.assertEquals(16, board_conf.fat_size) |
3956 | 621 | self.assertEquals(16, config.fat_size) | ||
3960 | 622 | 608 | ||
3961 | 623 | def test_sets_partition_layout_raises(self): | 609 | def test_sets_partition_layout_raises(self): |
3962 | 624 | self.useFixture(MockSomethingFixture( | 610 | self.useFixture(MockSomethingFixture( |
3963 | @@ -630,10 +616,9 @@ | |||
3964 | 630 | field_to_test: data_to_set, | 616 | field_to_test: data_to_set, |
3965 | 631 | } | 617 | } |
3966 | 632 | 618 | ||
3969 | 633 | class config(BoardConfig): | 619 | board_conf = BoardConfig() |
3968 | 634 | pass | ||
3970 | 635 | self.assertRaises( | 620 | self.assertRaises( |
3972 | 636 | AssertionError, config.set_metadata, 'ahwpack.tar.gz') | 621 | AssertionError, board_conf.set_metadata, 'ahwpack.tar.gz') |
3973 | 637 | 622 | ||
3974 | 638 | def test_sets_copy_files(self): | 623 | def test_sets_copy_files(self): |
3975 | 639 | self.useFixture(MockSomethingFixture( | 624 | self.useFixture(MockSomethingFixture( |
3976 | @@ -647,10 +632,9 @@ | |||
3977 | 647 | field_to_test: data_to_set, | 632 | field_to_test: data_to_set, |
3978 | 648 | } | 633 | } |
3979 | 649 | 634 | ||
3984 | 650 | class config(BoardConfig): | 635 | board_conf = BoardConfig() |
3985 | 651 | pass | 636 | board_conf.set_metadata('ahwpack.tar.gz') |
3986 | 652 | config.set_metadata('ahwpack.tar.gz') | 637 | self.assertEquals(data_to_set, board_conf.bootloader_copy_files) |
3983 | 653 | self.assertEquals(data_to_set, config.bootloader_copy_files) | ||
3987 | 654 | 638 | ||
3988 | 655 | 639 | ||
3989 | 656 | class TestGetMLOFile(TestCaseWithFixtures): | 640 | class TestGetMLOFile(TestCaseWithFixtures): |
3990 | @@ -697,7 +681,10 @@ | |||
3991 | 697 | 681 | ||
3992 | 698 | 682 | ||
3993 | 699 | class TestGetSMDKSPL(TestCaseWithFixtures): | 683 | class TestGetSMDKSPL(TestCaseWithFixtures): |
3995 | 700 | config = boards.SMDKV310Config | 684 | def setUp(self): |
3996 | 685 | super(TestGetSMDKSPL, self).setUp() | ||
3997 | 686 | self.config = boards.SMDKV310Config() | ||
3998 | 687 | self.config.hwpack_format = '1.0' | ||
3999 | 701 | 688 | ||
4000 | 702 | def test_no_file_present(self): | 689 | def test_no_file_present(self): |
4001 | 703 | tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir() | 690 | tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir() |
4002 | @@ -729,7 +716,10 @@ | |||
4003 | 729 | 716 | ||
4004 | 730 | 717 | ||
4005 | 731 | class TestGetSMDKUboot(TestCaseWithFixtures): | 718 | class TestGetSMDKUboot(TestCaseWithFixtures): |
4007 | 732 | config = boards.SMDKV310Config | 719 | def setUp(self): |
4008 | 720 | super(TestGetSMDKUboot, self).setUp() | ||
4009 | 721 | self.config = boards.SMDKV310Config() | ||
4010 | 722 | self.config.hwpack_format = '1.0' | ||
4011 | 733 | 723 | ||
4012 | 734 | def test_uses_uboot_flavour(self): | 724 | def test_uses_uboot_flavour(self): |
4013 | 735 | chroot_dir = "chroot" | 725 | chroot_dir = "chroot" |
4014 | @@ -740,7 +730,10 @@ | |||
4015 | 740 | 730 | ||
4016 | 741 | 731 | ||
4017 | 742 | class TestGetOrigenSPL(TestCaseWithFixtures): | 732 | class TestGetOrigenSPL(TestCaseWithFixtures): |
4019 | 743 | config = boards.OrigenConfig | 733 | def setUp(self): |
4020 | 734 | super(TestGetOrigenSPL, self).setUp() | ||
4021 | 735 | self.config = boards.OrigenConfig() | ||
4022 | 736 | self.config.hwpack_format = '1.0' | ||
4023 | 744 | 737 | ||
4024 | 745 | def test_no_file_present(self): | 738 | def test_no_file_present(self): |
4025 | 746 | tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir() | 739 | tempdir = self.useFixture(CreateTempDirFixture()).get_temp_dir() |
4026 | @@ -756,7 +749,7 @@ | |||
4027 | 756 | 749 | ||
4028 | 757 | 750 | ||
4029 | 758 | class TestGetOrigenUboot(TestGetSMDKUboot): | 751 | class TestGetOrigenUboot(TestGetSMDKUboot): |
4031 | 759 | config = boards.OrigenConfig | 752 | config = boards.OrigenConfig() |
4032 | 760 | 753 | ||
4033 | 761 | 754 | ||
4034 | 762 | class TestCreateToc(TestCaseWithFixtures): | 755 | class TestCreateToc(TestCaseWithFixtures): |
4035 | @@ -778,6 +771,7 @@ | |||
4036 | 778 | '\x05\x00\x00\x00' '\x05\x00\x00\x00' \ | 771 | '\x05\x00\x00\x00' '\x05\x00\x00\x00' \ |
4037 | 779 | 'hello' + zero + '\x00\x00\x00' | 772 | 'hello' + zero + '\x00\x00\x00' |
4038 | 780 | self.expected = line1 + line2 + line3 | 773 | self.expected = line1 + line2 + line3 |
4039 | 774 | self.board_conf = boards.SnowballEmmcConfig() | ||
4040 | 781 | 775 | ||
4041 | 782 | def create_files_structure(self, src_data): | 776 | def create_files_structure(self, src_data): |
4042 | 783 | ''' Creates the data structure that the tested function | 777 | ''' Creates the data structure that the tested function |
4043 | @@ -801,7 +795,7 @@ | |||
4044 | 801 | files = self.create_files_structure(correct_data) | 795 | files = self.create_files_structure(correct_data) |
4045 | 802 | filename = os.path.join(self.tempdir, 'toc') | 796 | filename = os.path.join(self.tempdir, 'toc') |
4046 | 803 | with open(filename, 'w') as f: | 797 | with open(filename, 'w') as f: |
4048 | 804 | boards.SnowballEmmcConfig.create_toc(f, files) | 798 | self.board_conf.create_toc(f, files) |
4049 | 805 | with open(filename, 'r') as f: | 799 | with open(filename, 'r') as f: |
4050 | 806 | actual = f.read() | 800 | actual = f.read() |
4051 | 807 | self.assertEquals(96, len(actual)) | 801 | self.assertEquals(96, len(actual)) |
4052 | @@ -816,7 +810,7 @@ | |||
4053 | 816 | files = self.create_files_structure(illegal_name_data) | 810 | files = self.create_files_structure(illegal_name_data) |
4054 | 817 | with open(os.path.join(self.tempdir, 'toc'), 'w') as f: | 811 | with open(os.path.join(self.tempdir, 'toc'), 'w') as f: |
4055 | 818 | self.assertRaises(AssertionError, | 812 | self.assertRaises(AssertionError, |
4057 | 819 | boards.SnowballEmmcConfig.create_toc, | 813 | self.board_conf.create_toc, |
4058 | 820 | f, files) | 814 | f, files) |
4059 | 821 | 815 | ||
4060 | 822 | def test_create_toc_error_negative_unsigned(self): | 816 | def test_create_toc_error_negative_unsigned(self): |
4061 | @@ -826,7 +820,7 @@ | |||
4062 | 826 | files = self.create_files_structure(illegal_unsigned_data) | 820 | files = self.create_files_structure(illegal_unsigned_data) |
4063 | 827 | with open(os.path.join(self.tempdir, 'toc'), 'w') as f: | 821 | with open(os.path.join(self.tempdir, 'toc'), 'w') as f: |
4064 | 828 | self.assertRaises(struct.error, | 822 | self.assertRaises(struct.error, |
4066 | 829 | boards.SnowballEmmcConfig.create_toc, | 823 | self.board_conf.create_toc, |
4067 | 830 | f, files) | 824 | f, files) |
4068 | 831 | 825 | ||
4069 | 832 | 826 | ||
4070 | @@ -845,6 +839,8 @@ | |||
4071 | 845 | os.makedirs(self.temp_bootdir_path) | 839 | os.makedirs(self.temp_bootdir_path) |
4072 | 846 | if not os.path.exists(self.temp_configdir_path): | 840 | if not os.path.exists(self.temp_configdir_path): |
4073 | 847 | os.makedirs(self.temp_configdir_path) | 841 | os.makedirs(self.temp_configdir_path) |
4074 | 842 | self.snowball_config = get_board_config('snowball_emmc') | ||
4075 | 843 | self.snowball_config.hwpack_format = HardwarepackHandler.FORMAT_1 | ||
4076 | 848 | 844 | ||
4077 | 849 | def setupFiles(self): | 845 | def setupFiles(self): |
4078 | 850 | return self.create_test_files(self.temp_bootdir_path) | 846 | return self.create_test_files(self.temp_bootdir_path) |
4079 | @@ -870,7 +866,7 @@ | |||
4080 | 870 | ('UBOOT_ENV', 'u-boot-env.bin', 0, 0x00C1F000, '10')] | 866 | ('UBOOT_ENV', 'u-boot-env.bin', 0, 0x00C1F000, '10')] |
4081 | 871 | # Create a config file | 867 | # Create a config file |
4082 | 872 | cfg_file = os.path.join( | 868 | cfg_file = os.path.join( |
4084 | 873 | path, boards.SnowballEmmcConfig.snowball_startup_files_config) | 869 | path, self.snowball_config.snowball_startup_files_config) |
4085 | 874 | with open(cfg_file, 'w') as f: | 870 | with open(cfg_file, 'w') as f: |
4086 | 875 | for line in src_data: | 871 | for line in src_data: |
4087 | 876 | # Write comments, so we test that the parser can read them | 872 | # Write comments, so we test that the parser can read them |
4088 | @@ -886,8 +882,8 @@ | |||
4089 | 886 | f.write(line[0]) | 882 | f.write(line[0]) |
4090 | 887 | #define the expected values read from the config file | 883 | #define the expected values read from the config file |
4091 | 888 | expected = [] | 884 | expected = [] |
4094 | 889 | ofs = [boards.SnowballEmmcConfig.TOC_SIZE, | 885 | ofs = [self.snowball_config.TOC_SIZE, |
4095 | 890 | boards.SnowballEmmcConfig.TOC_SIZE + len('ISSW'), 0x160000, | 886 | self.snowball_config.TOC_SIZE + len('ISSW'), 0x160000, |
4096 | 891 | 0x170000, 0xBA0000, 0xC1F000] | 887 | 0x170000, 0xBA0000, 0xC1F000] |
4097 | 892 | size = [len('ISSW'), len('X-LOADER'), len('MEM_INIT'), \ | 888 | size = [len('ISSW'), len('X-LOADER'), len('MEM_INIT'), \ |
4098 | 893 | len('PWR_MGT'), len('NORMAL'), len('UBOOT_ENV')] | 889 | len('PWR_MGT'), len('NORMAL'), len('UBOOT_ENV')] |
4099 | @@ -906,13 +902,13 @@ | |||
4100 | 906 | def test_get_file_info_relative_path(self): | 902 | def test_get_file_info_relative_path(self): |
4101 | 907 | # Create a config file | 903 | # Create a config file |
4102 | 908 | cfg_file = os.path.join(self.temp_bootdir_path, | 904 | cfg_file = os.path.join(self.temp_bootdir_path, |
4104 | 909 | boards.SnowballEmmcConfig.snowball_startup_files_config) | 905 | self.snowball_config.snowball_startup_files_config) |
4105 | 910 | uboot_file = 'u-boot.bin' | 906 | uboot_file = 'u-boot.bin' |
4106 | 911 | with open(cfg_file, 'w') as f: | 907 | with open(cfg_file, 'w') as f: |
4107 | 912 | f.write('%s %s %i %#x %s\n' % ('NORMAL', uboot_file, 0, | 908 | f.write('%s %s %i %#x %s\n' % ('NORMAL', uboot_file, 0, |
4108 | 913 | 0xBA0000, '9')) | 909 | 0xBA0000, '9')) |
4109 | 914 | with open(os.path.join(self.temp_bootdir_path, uboot_file), 'w') as f: | 910 | with open(os.path.join(self.temp_bootdir_path, uboot_file), 'w') as f: |
4111 | 915 | file_info = boards.SnowballEmmcConfig.get_file_info( | 911 | file_info = self.snowball_config.get_file_info( |
4112 | 916 | self.tempdir, self.temp_bootdir_path) | 912 | self.tempdir, self.temp_bootdir_path) |
4113 | 917 | self.assertEquals(file_info[0]['filename'], | 913 | self.assertEquals(file_info[0]['filename'], |
4114 | 918 | os.path.join(self.temp_bootdir_path, uboot_file)) | 914 | os.path.join(self.temp_bootdir_path, uboot_file)) |
4115 | @@ -920,7 +916,7 @@ | |||
4116 | 920 | def test_get_file_info_abs_path(self): | 916 | def test_get_file_info_abs_path(self): |
4117 | 921 | # Create a config file | 917 | # Create a config file |
4118 | 922 | cfg_file = os.path.join(self.temp_bootdir_path, | 918 | cfg_file = os.path.join(self.temp_bootdir_path, |
4120 | 923 | boards.SnowballEmmcConfig.snowball_startup_files_config) | 919 | self.snowball_config.snowball_startup_files_config) |
4121 | 924 | uboot_dir = tempfile.mkdtemp(dir=self.tempdir) | 920 | uboot_dir = tempfile.mkdtemp(dir=self.tempdir) |
4122 | 925 | uboot_file = os.path.join(uboot_dir, 'u-boot.bin') | 921 | uboot_file = os.path.join(uboot_dir, 'u-boot.bin') |
4123 | 926 | uboot_relative_file = uboot_file.replace(self.tempdir, '') | 922 | uboot_relative_file = uboot_file.replace(self.tempdir, '') |
4124 | @@ -928,19 +924,19 @@ | |||
4125 | 928 | f.write('%s %s %i %#x %s\n' % ( | 924 | f.write('%s %s %i %#x %s\n' % ( |
4126 | 929 | 'NORMAL', uboot_relative_file, 0, 0xBA0000, '9')) | 925 | 'NORMAL', uboot_relative_file, 0, 0xBA0000, '9')) |
4127 | 930 | with open(uboot_file, 'w') as f: | 926 | with open(uboot_file, 'w') as f: |
4129 | 931 | file_info = boards.SnowballEmmcConfig.get_file_info( | 927 | file_info = self.snowball_config.get_file_info( |
4130 | 932 | self.tempdir, self.temp_bootdir_path) | 928 | self.tempdir, self.temp_bootdir_path) |
4131 | 933 | self.assertEquals(file_info[0]['filename'], uboot_file) | 929 | self.assertEquals(file_info[0]['filename'], uboot_file) |
4132 | 934 | 930 | ||
4133 | 935 | def test_get_file_info_raises(self): | 931 | def test_get_file_info_raises(self): |
4134 | 936 | # Create a config file | 932 | # Create a config file |
4135 | 937 | cfg_file = os.path.join(self.temp_bootdir_path, | 933 | cfg_file = os.path.join(self.temp_bootdir_path, |
4137 | 938 | boards.SnowballEmmcConfig.snowball_startup_files_config) | 934 | self.snowball_config.snowball_startup_files_config) |
4138 | 939 | with open(cfg_file, 'w') as f: | 935 | with open(cfg_file, 'w') as f: |
4139 | 940 | f.write('%s %s %i %#x %s\n' % ('NORMAL', 'u-boot.bin', 0, | 936 | f.write('%s %s %i %#x %s\n' % ('NORMAL', 'u-boot.bin', 0, |
4140 | 941 | 0xBA0000, '9')) | 937 | 0xBA0000, '9')) |
4141 | 942 | self.assertRaises( | 938 | self.assertRaises( |
4143 | 943 | AssertionError, boards.SnowballEmmcConfig.get_file_info, | 939 | AssertionError, self.snowball_config.get_file_info, |
4144 | 944 | self.tempdir, self.temp_bootdir_path) | 940 | self.tempdir, self.temp_bootdir_path) |
4145 | 945 | 941 | ||
4146 | 946 | def test_file_name_size(self): | 942 | def test_file_name_size(self): |
4147 | @@ -948,28 +944,28 @@ | |||
4148 | 948 | _, toc_filename = tempfile.mkstemp() | 944 | _, toc_filename = tempfile.mkstemp() |
4149 | 949 | atexit.register(os.unlink, toc_filename) | 945 | atexit.register(os.unlink, toc_filename) |
4150 | 950 | filedata = 'X' | 946 | filedata = 'X' |
4152 | 951 | bytes = boards.SnowballEmmcConfig.TOC_SIZE + 1 | 947 | bytes = self.snowball_config.TOC_SIZE + 1 |
4153 | 952 | tmpfile = open(toc_filename, 'wb') | 948 | tmpfile = open(toc_filename, 'wb') |
4154 | 953 | for n in xrange(bytes): | 949 | for n in xrange(bytes): |
4155 | 954 | tmpfile.write(filedata) | 950 | tmpfile.write(filedata) |
4156 | 955 | tmpfile.close() | 951 | tmpfile.close() |
4157 | 956 | files = self.setupFiles() | 952 | files = self.setupFiles() |
4158 | 957 | self.assertRaises(AssertionError, | 953 | self.assertRaises(AssertionError, |
4160 | 958 | boards.SnowballEmmcConfig.install_snowball_boot_loader, | 954 | self.snowball_config.install_snowball_boot_loader, |
4161 | 959 | toc_filename, files, "boot_device_or_file", | 955 | toc_filename, files, "boot_device_or_file", |
4163 | 960 | boards.SnowballEmmcConfig.SNOWBALL_LOADER_START_S) | 956 | self.snowball_config.SNOWBALL_LOADER_START_S) |
4164 | 961 | 957 | ||
4165 | 962 | def test_install_snowball_boot_loader_toc_dont_delete(self): | 958 | def test_install_snowball_boot_loader_toc_dont_delete(self): |
4166 | 963 | fixture = self.useFixture(MockCmdRunnerPopenFixture()) | 959 | fixture = self.useFixture(MockCmdRunnerPopenFixture()) |
4167 | 964 | toc_filename = self.createTempFileAsFixture() | 960 | toc_filename = self.createTempFileAsFixture() |
4168 | 965 | files = self.setupFiles() | 961 | files = self.setupFiles() |
4170 | 966 | boards.SnowballEmmcConfig.install_snowball_boot_loader(toc_filename, | 962 | self.snowball_config.install_snowball_boot_loader(toc_filename, |
4171 | 967 | files, "boot_device_or_file", | 963 | files, "boot_device_or_file", |
4173 | 968 | boards.SnowballEmmcConfig.SNOWBALL_LOADER_START_S) | 964 | self.snowball_config.SNOWBALL_LOADER_START_S) |
4174 | 969 | expected = [ | 965 | expected = [ |
4175 | 970 | '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc' \ | 966 | '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc' \ |
4176 | 971 | ' seek=%s' % (sudo_args, toc_filename, | 967 | ' seek=%s' % (sudo_args, toc_filename, |
4178 | 972 | boards.SnowballEmmcConfig.SNOWBALL_LOADER_START_S), | 968 | self.snowball_config.SNOWBALL_LOADER_START_S), |
4179 | 973 | '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512' \ | 969 | '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512' \ |
4180 | 974 | ' conv=notrunc seek=257' % (sudo_args, self.temp_bootdir_path), | 970 | ' conv=notrunc seek=257' % (sudo_args, self.temp_bootdir_path), |
4181 | 975 | '%s dd if=%s/boot_image_x-loader.bin of=boot_device_or_file' \ | 971 | '%s dd if=%s/boot_image_x-loader.bin of=boot_device_or_file' \ |
4182 | @@ -990,13 +986,13 @@ | |||
4183 | 990 | fixture = self.useFixture(MockCmdRunnerPopenFixture()) | 986 | fixture = self.useFixture(MockCmdRunnerPopenFixture()) |
4184 | 991 | toc_filename = self.createTempFileAsFixture() | 987 | toc_filename = self.createTempFileAsFixture() |
4185 | 992 | files = self.setupFiles() | 988 | files = self.setupFiles() |
4187 | 993 | boards.SnowballEmmcConfig.install_snowball_boot_loader(toc_filename, | 989 | self.snowball_config.install_snowball_boot_loader(toc_filename, |
4188 | 994 | files, "boot_device_or_file", | 990 | files, "boot_device_or_file", |
4190 | 995 | boards.SnowballEmmcConfig.SNOWBALL_LOADER_START_S, True) | 991 | self.snowball_config.SNOWBALL_LOADER_START_S, True) |
4191 | 996 | expected = [ | 992 | expected = [ |
4192 | 997 | '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc' \ | 993 | '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc' \ |
4193 | 998 | ' seek=%s' % (sudo_args, toc_filename, | 994 | ' seek=%s' % (sudo_args, toc_filename, |
4195 | 999 | boards.SnowballEmmcConfig.SNOWBALL_LOADER_START_S), | 995 | self.snowball_config.SNOWBALL_LOADER_START_S), |
4196 | 1000 | '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512' \ | 996 | '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512' \ |
4197 | 1001 | ' conv=notrunc seek=257' % (sudo_args, self.temp_bootdir_path), | 997 | ' conv=notrunc seek=257' % (sudo_args, self.temp_bootdir_path), |
4198 | 1002 | '%s rm %s/boot_image_issw.bin' % (sudo_args, | 998 | '%s rm %s/boot_image_issw.bin' % (sudo_args, |
4199 | @@ -1026,13 +1022,14 @@ | |||
4200 | 1026 | fixture = self.useFixture(MockCmdRunnerPopenFixture()) | 1022 | fixture = self.useFixture(MockCmdRunnerPopenFixture()) |
4201 | 1027 | toc_filename = self.createTempFileAsFixture() | 1023 | toc_filename = self.createTempFileAsFixture() |
4202 | 1028 | files = self.setupFiles() | 1024 | files = self.setupFiles() |
4204 | 1029 | AndroidSnowballEmmcConfig.install_snowball_boot_loader( | 1025 | board_conf = AndroidSnowballEmmcConfig() |
4205 | 1026 | board_conf.install_snowball_boot_loader( | ||
4206 | 1030 | toc_filename, files, "boot_device_or_file", | 1027 | toc_filename, files, "boot_device_or_file", |
4208 | 1031 | AndroidSnowballEmmcConfig.SNOWBALL_LOADER_START_S) | 1028 | board_conf.SNOWBALL_LOADER_START_S) |
4209 | 1032 | expected = [ | 1029 | expected = [ |
4210 | 1033 | '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc' \ | 1030 | '%s dd if=%s of=boot_device_or_file bs=512 conv=notrunc' \ |
4211 | 1034 | ' seek=%s' % (sudo_args, toc_filename, | 1031 | ' seek=%s' % (sudo_args, toc_filename, |
4213 | 1035 | AndroidSnowballEmmcConfig.SNOWBALL_LOADER_START_S), | 1032 | board_conf.SNOWBALL_LOADER_START_S), |
4214 | 1036 | '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512' \ | 1033 | '%s dd if=%s/boot_image_issw.bin of=boot_device_or_file bs=512' \ |
4215 | 1037 | ' conv=notrunc seek=257' % (sudo_args, self.temp_bootdir_path), | 1034 | ' conv=notrunc seek=257' % (sudo_args, self.temp_bootdir_path), |
4216 | 1038 | '%s dd if=%s/boot_image_x-loader.bin of=boot_device_or_file' \ | 1035 | '%s dd if=%s/boot_image_x-loader.bin of=boot_device_or_file' \ |
4217 | @@ -1057,11 +1054,11 @@ | |||
4218 | 1057 | k_img_file = os.path.join(self.tempdir, 'vmlinuz-1-ux500') | 1054 | k_img_file = os.path.join(self.tempdir, 'vmlinuz-1-ux500') |
4219 | 1058 | i_img_file = os.path.join(self.tempdir, 'initrd.img-1-ux500') | 1055 | i_img_file = os.path.join(self.tempdir, 'initrd.img-1-ux500') |
4220 | 1059 | 1056 | ||
4222 | 1060 | boot_env = board_configs['snowball_emmc']._get_boot_env( | 1057 | boot_env = self.snowball_config._get_boot_env( |
4223 | 1061 | is_live=False, is_lowmem=False, consoles=[], | 1058 | is_live=False, is_lowmem=False, consoles=[], |
4224 | 1062 | rootfs_id="UUID=test_boot_env_uuid", | 1059 | rootfs_id="UUID=test_boot_env_uuid", |
4225 | 1063 | i_img_data=None, d_img_data=None) | 1060 | i_img_data=None, d_img_data=None) |
4227 | 1064 | boards.SnowballEmmcConfig._make_boot_files(boot_env, self.tempdir, | 1061 | self.snowball_config._make_boot_files(boot_env, self.tempdir, |
4228 | 1065 | self.temp_bootdir_path, 'boot_device_or_file', k_img_file, | 1062 | self.temp_bootdir_path, 'boot_device_or_file', k_img_file, |
4229 | 1066 | i_img_file, None) | 1063 | i_img_file, None) |
4230 | 1067 | expected = [ | 1064 | expected = [ |
4231 | @@ -1105,12 +1102,12 @@ | |||
4232 | 1105 | def test_missing_files(self): | 1102 | def test_missing_files(self): |
4233 | 1106 | '''When the files cannot be read, an IOError should be raised''' | 1103 | '''When the files cannot be read, an IOError should be raised''' |
4234 | 1107 | self.assertRaises(IOError, | 1104 | self.assertRaises(IOError, |
4236 | 1108 | boards.SnowballEmmcConfig.get_file_info, | 1105 | self.snowball_config.get_file_info, |
4237 | 1109 | self.tempdir, self.temp_bootdir_path) | 1106 | self.tempdir, self.temp_bootdir_path) |
4238 | 1110 | 1107 | ||
4239 | 1111 | def test_normal_case(self): | 1108 | def test_normal_case(self): |
4240 | 1112 | expected = self.setupFiles() | 1109 | expected = self.setupFiles() |
4242 | 1113 | actual = boards.SnowballEmmcConfig.get_file_info( | 1110 | actual = self.snowball_config.get_file_info( |
4243 | 1114 | self.tempdir, self.temp_bootdir_path) | 1111 | self.tempdir, self.temp_bootdir_path) |
4244 | 1115 | self.assertEquals(expected, actual) | 1112 | self.assertEquals(expected, actual) |
4245 | 1116 | 1113 | ||
4246 | @@ -1147,8 +1144,8 @@ | |||
4247 | 1147 | classmethod(set_appropriate_serial_tty_mock))) | 1144 | classmethod(set_appropriate_serial_tty_mock))) |
4248 | 1148 | 1145 | ||
4249 | 1149 | def make_boot_files(self, config): | 1146 | def make_boot_files(self, config): |
4252 | 1150 | def _get_kflavor_files_mock(cls, path): | 1147 | def _get_kflavor_files_mock(self, path): |
4253 | 1151 | if cls.dtb_name is None: | 1148 | if self.dtb_name is None: |
4254 | 1152 | return (path, path, None) | 1149 | return (path, path, None) |
4255 | 1153 | return (path, path, path) | 1150 | return (path, path, path) |
4256 | 1154 | 1151 | ||
4257 | @@ -1159,23 +1156,25 @@ | |||
4258 | 1159 | config.make_boot_files('', False, False, [], '', '', '', '') | 1156 | config.make_boot_files('', False, False, [], '', '', '', '') |
4259 | 1160 | 1157 | ||
4260 | 1161 | def test_vexpress_steps(self): | 1158 | def test_vexpress_steps(self): |
4262 | 1162 | self.make_boot_files(boards.VexpressConfig) | 1159 | board_conf = boards.VexpressConfig() |
4263 | 1160 | self.make_boot_files(board_conf) | ||
4264 | 1163 | expected = ['make_uImage', 'make_uInitrd'] | 1161 | expected = ['make_uImage', 'make_uInitrd'] |
4265 | 1164 | self.assertEqual(expected, self.funcs_calls) | 1162 | self.assertEqual(expected, self.funcs_calls) |
4266 | 1165 | 1163 | ||
4267 | 1166 | def test_vexpress_a9_steps(self): | 1164 | def test_vexpress_a9_steps(self): |
4269 | 1167 | self.make_boot_files(boards.VexpressA9Config) | 1165 | board_conf = boards.VexpressA9Config() |
4270 | 1166 | self.make_boot_files(board_conf) | ||
4271 | 1168 | expected = ['make_uImage', 'make_uInitrd'] | 1167 | expected = ['make_uImage', 'make_uInitrd'] |
4272 | 1169 | self.assertEqual(expected, self.funcs_calls) | 1168 | self.assertEqual(expected, self.funcs_calls) |
4273 | 1170 | 1169 | ||
4274 | 1171 | def test_mx5_steps(self): | 1170 | def test_mx5_steps(self): |
4278 | 1172 | class SomeMx5Config(boards.Mx5Config): | 1171 | board_conf = boards.Mx5Config() |
4279 | 1173 | bootloader_flavor = 'bootloader_flavor' | 1172 | board_conf.bootloader_flavor = 'bootloader_flavor' |
4280 | 1174 | SomeMx5Config.hardwarepack_handler = ( | 1173 | board_conf.hardwarepack_handler = ( |
4281 | 1175 | TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz')) | 1174 | TestSetMetadata.MockHardwarepackHandler('ahwpack.tar.gz')) |
4283 | 1176 | SomeMx5Config.hardwarepack_handler.get_format = ( | 1175 | board_conf.hardwarepack_handler.get_format = ( |
4284 | 1177 | lambda: '1.0') | 1176 | lambda: '1.0') |
4286 | 1178 | self.make_boot_files(SomeMx5Config) | 1177 | self.make_boot_files(board_conf) |
4287 | 1179 | expected = [ | 1178 | expected = [ |
4288 | 1180 | 'install_mx5_boot_loader', 'make_uImage', 'make_uInitrd', | 1179 | 'install_mx5_boot_loader', 'make_uImage', 'make_uInitrd', |
4289 | 1181 | 'make_dtb', 'make_boot_script'] | 1180 | 'make_dtb', 'make_boot_script'] |
4290 | @@ -1224,42 +1223,46 @@ | |||
4291 | 1224 | self.assertEqual(expected, self.funcs_calls) | 1223 | self.assertEqual(expected, self.funcs_calls) |
4292 | 1225 | 1224 | ||
4293 | 1226 | def test_ux500_steps(self): | 1225 | def test_ux500_steps(self): |
4295 | 1227 | self.make_boot_files(boards.Ux500Config) | 1226 | self.make_boot_files(boards.Ux500Config()) |
4296 | 1228 | expected = ['make_uImage', 'make_uInitrd', 'make_boot_script'] | 1227 | expected = ['make_uImage', 'make_uInitrd', 'make_boot_script'] |
4297 | 1229 | self.assertEqual(expected, self.funcs_calls) | 1228 | self.assertEqual(expected, self.funcs_calls) |
4298 | 1230 | 1229 | ||
4299 | 1231 | def test_snowball_sd_steps(self): | 1230 | def test_snowball_sd_steps(self): |
4301 | 1232 | self.make_boot_files(boards.SnowballSdConfig) | 1231 | self.make_boot_files(boards.SnowballSdConfig()) |
4302 | 1233 | expected = ['make_uImage', 'make_boot_script'] | 1232 | expected = ['make_uImage', 'make_boot_script'] |
4303 | 1234 | self.assertEqual(expected, self.funcs_calls) | 1233 | self.assertEqual(expected, self.funcs_calls) |
4304 | 1235 | 1234 | ||
4305 | 1236 | def test_panda_steps(self): | 1235 | def test_panda_steps(self): |
4308 | 1237 | self.mock_set_appropriate_serial_tty(boards.PandaConfig) | 1236 | board_conf = boards.PandaConfig() |
4309 | 1238 | self.make_boot_files(boards.PandaConfig) | 1237 | self.mock_set_appropriate_serial_tty(board_conf) |
4310 | 1238 | self.make_boot_files(board_conf) | ||
4311 | 1239 | expected = [ | 1239 | expected = [ |
4312 | 1240 | 'install_omap_boot_loader', 'make_uImage', 'make_uInitrd', | 1240 | 'install_omap_boot_loader', 'make_uImage', 'make_uInitrd', |
4313 | 1241 | 'make_dtb', 'make_boot_script', 'make_boot_ini'] | 1241 | 'make_dtb', 'make_boot_script', 'make_boot_ini'] |
4314 | 1242 | self.assertEqual(expected, self.funcs_calls) | 1242 | self.assertEqual(expected, self.funcs_calls) |
4315 | 1243 | 1243 | ||
4316 | 1244 | def test_beagle_steps(self): | 1244 | def test_beagle_steps(self): |
4319 | 1245 | self.mock_set_appropriate_serial_tty(boards.BeagleConfig) | 1245 | board_conf = boards.BeagleConfig() |
4320 | 1246 | self.make_boot_files(boards.BeagleConfig) | 1246 | self.mock_set_appropriate_serial_tty(board_conf) |
4321 | 1247 | self.make_boot_files(board_conf) | ||
4322 | 1247 | expected = [ | 1248 | expected = [ |
4323 | 1248 | 'install_omap_boot_loader', 'make_uImage', 'make_uInitrd', | 1249 | 'install_omap_boot_loader', 'make_uImage', 'make_uInitrd', |
4324 | 1249 | 'make_dtb', 'make_boot_script', 'make_boot_ini'] | 1250 | 'make_dtb', 'make_boot_script', 'make_boot_ini'] |
4325 | 1250 | self.assertEqual(expected, self.funcs_calls) | 1251 | self.assertEqual(expected, self.funcs_calls) |
4326 | 1251 | 1252 | ||
4327 | 1252 | def test_igep_steps(self): | 1253 | def test_igep_steps(self): |
4330 | 1253 | self.mock_set_appropriate_serial_tty(boards.IgepConfig) | 1254 | board_conf = boards.IgepConfig() |
4331 | 1254 | self.make_boot_files(boards.IgepConfig) | 1255 | self.mock_set_appropriate_serial_tty(board_conf) |
4332 | 1256 | self.make_boot_files(board_conf) | ||
4333 | 1255 | expected = [ | 1257 | expected = [ |
4334 | 1256 | 'make_uImage', 'make_uInitrd', 'make_dtb', 'make_boot_script', | 1258 | 'make_uImage', 'make_uInitrd', 'make_dtb', 'make_boot_script', |
4335 | 1257 | 'make_boot_ini'] | 1259 | 'make_boot_ini'] |
4336 | 1258 | self.assertEqual(expected, self.funcs_calls) | 1260 | self.assertEqual(expected, self.funcs_calls) |
4337 | 1259 | 1261 | ||
4338 | 1260 | def test_overo_steps(self): | 1262 | def test_overo_steps(self): |
4341 | 1261 | self.mock_set_appropriate_serial_tty(boards.OveroConfig) | 1263 | board_conf = boards.OveroConfig() |
4342 | 1262 | self.make_boot_files(boards.OveroConfig) | 1264 | self.mock_set_appropriate_serial_tty(board_conf) |
4343 | 1265 | self.make_boot_files(board_conf) | ||
4344 | 1263 | expected = [ | 1266 | expected = [ |
4345 | 1264 | 'install_omap_boot_loader', 'make_uImage', 'make_uInitrd', | 1267 | 'install_omap_boot_loader', 'make_uImage', 'make_uInitrd', |
4346 | 1265 | 'make_dtb', 'make_boot_script', 'make_boot_ini'] | 1268 | 'make_dtb', 'make_boot_script', 'make_boot_ini'] |
4347 | @@ -1291,20 +1294,20 @@ | |||
4348 | 1291 | 1294 | ||
4349 | 1292 | def test_snowball_config_raises(self): | 1295 | def test_snowball_config_raises(self): |
4350 | 1293 | self.assertRaises(NotImplementedError, | 1296 | self.assertRaises(NotImplementedError, |
4352 | 1294 | boards.SnowballSdConfig.snowball_config, '') | 1297 | boards.SnowballSdConfig().snowball_config, '') |
4353 | 1295 | 1298 | ||
4354 | 1296 | def test_beagle_raw(self): | 1299 | def test_beagle_raw(self): |
4356 | 1297 | self.populate_raw_partition(android_boards.AndroidBeagleConfig) | 1300 | self.populate_raw_partition(android_boards.AndroidBeagleConfig()) |
4357 | 1298 | expected = [] | 1301 | expected = [] |
4358 | 1299 | self.assertEqual(expected, self.funcs_calls) | 1302 | self.assertEqual(expected, self.funcs_calls) |
4359 | 1300 | 1303 | ||
4360 | 1301 | def test_panda_raw(self): | 1304 | def test_panda_raw(self): |
4362 | 1302 | self.populate_raw_partition(android_boards.AndroidPandaConfig) | 1305 | self.populate_raw_partition(android_boards.AndroidPandaConfig()) |
4363 | 1303 | expected = [] | 1306 | expected = [] |
4364 | 1304 | self.assertEqual(expected, self.funcs_calls) | 1307 | self.assertEqual(expected, self.funcs_calls) |
4365 | 1305 | 1308 | ||
4366 | 1306 | def test_snowball_sd_raw(self): | 1309 | def test_snowball_sd_raw(self): |
4368 | 1307 | self.populate_raw_partition(boards.SnowballSdConfig) | 1310 | self.populate_raw_partition(boards.SnowballSdConfig()) |
4369 | 1308 | expected = [] | 1311 | expected = [] |
4370 | 1309 | self.assertEqual(expected, self.funcs_calls) | 1312 | self.assertEqual(expected, self.funcs_calls) |
4371 | 1310 | 1313 | ||
4372 | @@ -1329,7 +1332,7 @@ | |||
4373 | 1329 | linaro_image_tools.media_create.boards.SnowballEmmcConfig, | 1332 | linaro_image_tools.media_create.boards.SnowballEmmcConfig, |
4374 | 1330 | 'delete_file', | 1333 | 'delete_file', |
4375 | 1331 | mock_func_creator('delete_file'))) | 1334 | mock_func_creator('delete_file'))) |
4377 | 1332 | self.populate_raw_partition(boards.SnowballEmmcConfig) | 1335 | self.populate_raw_partition(boards.SnowballEmmcConfig()) |
4378 | 1333 | expected = ['get_file_info', 'create_toc', | 1336 | expected = ['get_file_info', 'create_toc', |
4379 | 1334 | 'install_snowball_boot_loader', 'delete_file', | 1337 | 'install_snowball_boot_loader', 'delete_file', |
4380 | 1335 | 'delete_file'] | 1338 | 'delete_file'] |
4381 | @@ -1341,12 +1344,12 @@ | |||
4382 | 1341 | self.useFixture(MockSomethingFixture(os.path, 'getsize', | 1344 | self.useFixture(MockSomethingFixture(os.path, 'getsize', |
4383 | 1342 | lambda file: 1)) | 1345 | lambda file: 1)) |
4384 | 1343 | 1346 | ||
4386 | 1344 | self.populate_raw_partition(boards.SMDKV310Config) | 1347 | self.populate_raw_partition(boards.SMDKV310Config()) |
4387 | 1345 | expected = ['_dd', '_dd', '_dd'] | 1348 | expected = ['_dd', '_dd', '_dd'] |
4388 | 1346 | self.assertEqual(expected, self.funcs_calls) | 1349 | self.assertEqual(expected, self.funcs_calls) |
4389 | 1347 | 1350 | ||
4390 | 1348 | def test_mx53loco_raw(self): | 1351 | def test_mx53loco_raw(self): |
4392 | 1349 | self.populate_raw_partition(boards.Mx53LoCoConfig) | 1352 | self.populate_raw_partition(boards.Mx53LoCoConfig()) |
4393 | 1350 | expected = [] | 1353 | expected = [] |
4394 | 1351 | self.assertEqual(expected, self.funcs_calls) | 1354 | self.assertEqual(expected, self.funcs_calls) |
4395 | 1352 | 1355 | ||
4396 | @@ -1354,12 +1357,12 @@ | |||
4397 | 1354 | self.useFixture(MockSomethingFixture(os.path, 'getsize', | 1357 | self.useFixture(MockSomethingFixture(os.path, 'getsize', |
4398 | 1355 | lambda file: 1)) | 1358 | lambda file: 1)) |
4399 | 1356 | 1359 | ||
4401 | 1357 | self.populate_raw_partition(boards.OrigenConfig) | 1360 | self.populate_raw_partition(boards.OrigenConfig()) |
4402 | 1358 | expected = ['_dd', '_dd', '_dd'] | 1361 | expected = ['_dd', '_dd', '_dd'] |
4403 | 1359 | self.assertEqual(expected, self.funcs_calls) | 1362 | self.assertEqual(expected, self.funcs_calls) |
4404 | 1360 | 1363 | ||
4405 | 1361 | def test_vexpress_a9_raw(self): | 1364 | def test_vexpress_a9_raw(self): |
4407 | 1362 | self.populate_raw_partition(boards.VexpressA9Config) | 1365 | self.populate_raw_partition(boards.VexpressA9Config()) |
4408 | 1363 | expected = [] | 1366 | expected = [] |
4409 | 1364 | self.assertEqual(expected, self.funcs_calls) | 1367 | self.assertEqual(expected, self.funcs_calls) |
4410 | 1365 | 1368 | ||
4411 | @@ -1374,17 +1377,17 @@ | |||
4412 | 1374 | config.populate_raw_partition('', '') | 1377 | config.populate_raw_partition('', '') |
4413 | 1375 | 1378 | ||
4414 | 1376 | def test_beagle_raw(self): | 1379 | def test_beagle_raw(self): |
4416 | 1377 | self.populate_raw_partition(android_boards.AndroidBeagleConfig) | 1380 | self.populate_raw_partition(android_boards.AndroidBeagleConfig()) |
4417 | 1378 | expected = [] | 1381 | expected = [] |
4418 | 1379 | self.assertEqual(expected, self.funcs_calls) | 1382 | self.assertEqual(expected, self.funcs_calls) |
4419 | 1380 | 1383 | ||
4420 | 1381 | def test_panda_raw(self): | 1384 | def test_panda_raw(self): |
4422 | 1382 | self.populate_raw_partition(android_boards.AndroidPandaConfig) | 1385 | self.populate_raw_partition(android_boards.AndroidPandaConfig()) |
4423 | 1383 | expected = [] | 1386 | expected = [] |
4424 | 1384 | self.assertEqual(expected, self.funcs_calls) | 1387 | self.assertEqual(expected, self.funcs_calls) |
4425 | 1385 | 1388 | ||
4426 | 1386 | def test_snowball_sd_raw(self): | 1389 | def test_snowball_sd_raw(self): |
4428 | 1387 | self.populate_raw_partition(android_boards.AndroidSnowballSdConfig) | 1390 | self.populate_raw_partition(android_boards.AndroidSnowballSdConfig()) |
4429 | 1388 | expected = [] | 1391 | expected = [] |
4430 | 1389 | self.assertEqual(expected, self.funcs_calls) | 1392 | self.assertEqual(expected, self.funcs_calls) |
4431 | 1390 | 1393 | ||
4432 | @@ -1415,7 +1418,7 @@ | |||
4433 | 1415 | android_boards.AndroidSnowballEmmcConfig, | 1418 | android_boards.AndroidSnowballEmmcConfig, |
4434 | 1416 | 'delete_file', | 1419 | 'delete_file', |
4435 | 1417 | mock_func_creator('delete_file'))) | 1420 | mock_func_creator('delete_file'))) |
4437 | 1418 | self.populate_raw_partition(android_boards.AndroidSnowballEmmcConfig) | 1421 | self.populate_raw_partition(android_boards.AndroidSnowballEmmcConfig()) |
4438 | 1419 | expected_calls = ['get_file_info', 'create_toc', | 1422 | expected_calls = ['get_file_info', 'create_toc', |
4439 | 1420 | 'install_snowball_boot_loader', 'delete_file'] | 1423 | 'install_snowball_boot_loader', 'delete_file'] |
4440 | 1421 | # Test that we copy the u-boot files to the local startupfiles dir. | 1424 | # Test that we copy the u-boot files to the local startupfiles dir. |
4441 | @@ -1435,14 +1438,14 @@ | |||
4442 | 1435 | self.useFixture(MockSomethingFixture(os.path, 'getsize', | 1438 | self.useFixture(MockSomethingFixture(os.path, 'getsize', |
4443 | 1436 | lambda file: 1)) | 1439 | lambda file: 1)) |
4444 | 1437 | 1440 | ||
4446 | 1438 | self.populate_raw_partition(android_boards.AndroidSMDKV310Config) | 1441 | self.populate_raw_partition(android_boards.AndroidSMDKV310Config()) |
4447 | 1439 | expected_calls = [] | 1442 | expected_calls = [] |
4448 | 1440 | # Test that we dd the files | 1443 | # Test that we dd the files |
4449 | 1441 | self.assertEqual(expected_commands, fixture.mock.commands_executed) | 1444 | self.assertEqual(expected_commands, fixture.mock.commands_executed) |
4450 | 1442 | self.assertEqual(expected_calls, self.funcs_calls) | 1445 | self.assertEqual(expected_calls, self.funcs_calls) |
4451 | 1443 | 1446 | ||
4452 | 1444 | def test_mx53loco_raw(self): | 1447 | def test_mx53loco_raw(self): |
4454 | 1445 | self.populate_raw_partition(android_boards.AndroidMx53LoCoConfig) | 1448 | self.populate_raw_partition(android_boards.AndroidMx53LoCoConfig()) |
4455 | 1446 | expected = [] | 1449 | expected = [] |
4456 | 1447 | self.assertEqual(expected, self.funcs_calls) | 1450 | self.assertEqual(expected, self.funcs_calls) |
4457 | 1448 | 1451 | ||
4458 | @@ -1457,14 +1460,14 @@ | |||
4459 | 1457 | self.useFixture(MockSomethingFixture(os.path, 'getsize', | 1460 | self.useFixture(MockSomethingFixture(os.path, 'getsize', |
4460 | 1458 | lambda file: 1)) | 1461 | lambda file: 1)) |
4461 | 1459 | 1462 | ||
4463 | 1460 | self.populate_raw_partition(android_boards.AndroidOrigenConfig) | 1463 | self.populate_raw_partition(android_boards.AndroidOrigenConfig()) |
4464 | 1461 | expected = [] | 1464 | expected = [] |
4465 | 1462 | # Test that we dd the files | 1465 | # Test that we dd the files |
4466 | 1463 | self.assertEqual(expected_commands, fixture.mock.commands_executed) | 1466 | self.assertEqual(expected_commands, fixture.mock.commands_executed) |
4467 | 1464 | self.assertEqual(expected, self.funcs_calls) | 1467 | self.assertEqual(expected, self.funcs_calls) |
4468 | 1465 | 1468 | ||
4469 | 1466 | def test_vexpress_raw(self): | 1469 | def test_vexpress_raw(self): |
4471 | 1467 | self.populate_raw_partition(android_boards.AndroidVexpressConfig) | 1470 | self.populate_raw_partition(android_boards.AndroidVexpressConfig()) |
4472 | 1468 | expected = [] | 1471 | expected = [] |
4473 | 1469 | self.assertEqual(expected, self.funcs_calls) | 1472 | self.assertEqual(expected, self.funcs_calls) |
4474 | 1470 | 1473 | ||
4475 | @@ -1505,15 +1508,16 @@ | |||
4476 | 1505 | 1508 | ||
4477 | 1506 | def test_omap_make_boot_files(self): | 1509 | def test_omap_make_boot_files(self): |
4478 | 1507 | self.set_appropriate_serial_tty_called = False | 1510 | self.set_appropriate_serial_tty_called = False |
4480 | 1508 | self.mock_set_appropriate_serial_tty(board_configs['beagle']) | 1511 | board_conf = get_board_config('beagle') |
4481 | 1512 | self.mock_set_appropriate_serial_tty(board_conf) | ||
4482 | 1509 | self.useFixture(MockSomethingFixture( | 1513 | self.useFixture(MockSomethingFixture( |
4484 | 1510 | boards.BoardConfig, 'make_boot_files', | 1514 | board_conf, 'make_boot_files', |
4485 | 1511 | classmethod(lambda *args: None))) | 1515 | classmethod(lambda *args: None))) |
4486 | 1512 | # We don't need to worry about what's passed to make_boot_files() | 1516 | # We don't need to worry about what's passed to make_boot_files() |
4487 | 1513 | # because we mock the method which does the real work above and here | 1517 | # because we mock the method which does the real work above and here |
4488 | 1514 | # we're only interested in ensuring that OmapConfig.make_boot_files() | 1518 | # we're only interested in ensuring that OmapConfig.make_boot_files() |
4489 | 1515 | # calls set_appropriate_serial_tty(). | 1519 | # calls set_appropriate_serial_tty(). |
4491 | 1516 | board_configs['beagle'].make_boot_files( | 1520 | board_conf.make_boot_files( |
4492 | 1517 | None, None, None, None, None, None, None, None) | 1521 | None, None, None, None, None, None, None, None) |
4493 | 1518 | self.assertTrue( | 1522 | self.assertTrue( |
4494 | 1519 | self.set_appropriate_serial_tty_called, | 1523 | self.set_appropriate_serial_tty_called, |
4495 | @@ -1522,17 +1526,17 @@ | |||
4496 | 1522 | def test_omap_make_boot_files_v2(self): | 1526 | def test_omap_make_boot_files_v2(self): |
4497 | 1523 | self.set_appropriate_serial_tty_called = False | 1527 | self.set_appropriate_serial_tty_called = False |
4498 | 1524 | 1528 | ||
4502 | 1525 | class config(boards.BeagleConfig): | 1529 | board_conf = boards.BeagleConfig() |
4503 | 1526 | hwpack_format = HardwarepackHandler.FORMAT_2 | 1530 | board_conf.hwpack_format = HardwarepackHandler.FORMAT_2 |
4504 | 1527 | self.mock_set_appropriate_serial_tty(config) | 1531 | self.mock_set_appropriate_serial_tty(board_conf) |
4505 | 1528 | self.useFixture(MockSomethingFixture( | 1532 | self.useFixture(MockSomethingFixture( |
4507 | 1529 | boards.BoardConfig, 'make_boot_files', | 1533 | board_conf, 'make_boot_files', |
4508 | 1530 | classmethod(lambda *args: None))) | 1534 | classmethod(lambda *args: None))) |
4509 | 1531 | # We don't need to worry about what's passed to make_boot_files() | 1535 | # We don't need to worry about what's passed to make_boot_files() |
4510 | 1532 | # because we mock the method which does the real work above and here | 1536 | # because we mock the method which does the real work above and here |
4511 | 1533 | # we're only interested in ensuring that OmapConfig.make_boot_files() | 1537 | # we're only interested in ensuring that OmapConfig.make_boot_files() |
4512 | 1534 | # does not call set_appropriate_serial_tty(). | 1538 | # does not call set_appropriate_serial_tty(). |
4514 | 1535 | config.make_boot_files( | 1539 | board_conf.make_boot_files( |
4515 | 1536 | None, None, None, None, None, None, None, None) | 1540 | None, None, None, None, None, None, None, None) |
4516 | 1537 | self.assertFalse( | 1541 | self.assertFalse( |
4517 | 1538 | self.set_appropriate_serial_tty_called, | 1542 | self.set_appropriate_serial_tty_called, |
4518 | @@ -1543,149 +1547,173 @@ | |||
4519 | 1543 | boot_dir = os.path.join(tempdir, 'boot') | 1547 | boot_dir = os.path.join(tempdir, 'boot') |
4520 | 1544 | os.makedirs(boot_dir) | 1548 | os.makedirs(boot_dir) |
4521 | 1545 | open(os.path.join(boot_dir, 'vmlinuz-2.6.35-23-foo'), 'w').close() | 1549 | open(os.path.join(boot_dir, 'vmlinuz-2.6.35-23-foo'), 'w').close() |
4524 | 1546 | boards.BeagleConfig.set_appropriate_serial_tty(tempdir) | 1550 | board_conf = boards.BeagleConfig() |
4525 | 1547 | self.assertEquals('ttyS2', boards.BeagleConfig.serial_tty) | 1551 | board_conf.hwpack_format = '1.0' |
4526 | 1552 | board_conf.set_appropriate_serial_tty(tempdir) | ||
4527 | 1553 | self.assertEquals('ttyS2', board_conf.serial_tty) | ||
4528 | 1548 | 1554 | ||
4529 | 1549 | def test_set_appropriate_serial_tty_new_kernel(self): | 1555 | def test_set_appropriate_serial_tty_new_kernel(self): |
4530 | 1550 | tempdir = self.useFixture(CreateTempDirFixture()).tempdir | 1556 | tempdir = self.useFixture(CreateTempDirFixture()).tempdir |
4531 | 1551 | boot_dir = os.path.join(tempdir, 'boot') | 1557 | boot_dir = os.path.join(tempdir, 'boot') |
4532 | 1552 | os.makedirs(boot_dir) | 1558 | os.makedirs(boot_dir) |
4533 | 1553 | open(os.path.join(boot_dir, 'vmlinuz-2.6.36-13-foo'), 'w').close() | 1559 | open(os.path.join(boot_dir, 'vmlinuz-2.6.36-13-foo'), 'w').close() |
4536 | 1554 | boards.BeagleConfig.set_appropriate_serial_tty(tempdir) | 1560 | board_conf = boards.BeagleConfig() |
4537 | 1555 | self.assertEquals('ttyO2', boards.BeagleConfig.serial_tty) | 1561 | board_conf.hwpack_format = '1.0' |
4538 | 1562 | board_conf.set_appropriate_serial_tty(tempdir) | ||
4539 | 1563 | self.assertEquals('ttyO2', board_conf.serial_tty) | ||
4540 | 1556 | 1564 | ||
4541 | 1557 | def test_set_appropriate_serial_tty_three_dot_oh_kernel(self): | 1565 | def test_set_appropriate_serial_tty_three_dot_oh_kernel(self): |
4542 | 1558 | tempdir = self.useFixture(CreateTempDirFixture()).tempdir | 1566 | tempdir = self.useFixture(CreateTempDirFixture()).tempdir |
4543 | 1559 | boot_dir = os.path.join(tempdir, 'boot') | 1567 | boot_dir = os.path.join(tempdir, 'boot') |
4544 | 1560 | os.makedirs(boot_dir) | 1568 | os.makedirs(boot_dir) |
4545 | 1561 | open(os.path.join(boot_dir, 'vmlinuz-3.0-13-foo'), 'w').close() | 1569 | open(os.path.join(boot_dir, 'vmlinuz-3.0-13-foo'), 'w').close() |
4548 | 1562 | boards.BeagleConfig.set_appropriate_serial_tty(tempdir) | 1570 | board_conf = boards.BeagleConfig() |
4549 | 1563 | self.assertEquals('ttyO2', boards.BeagleConfig.serial_tty) | 1571 | board_conf.hwpack_format = '1.0' |
4550 | 1572 | board_conf.set_appropriate_serial_tty(tempdir) | ||
4551 | 1573 | self.assertEquals('ttyO2', board_conf.serial_tty) | ||
4552 | 1564 | 1574 | ||
4553 | 1565 | 1575 | ||
4554 | 1566 | class TestGetSfdiskCmd(TestCase): | 1576 | class TestGetSfdiskCmd(TestCase): |
4555 | 1567 | 1577 | ||
4556 | 1578 | def set_up_config(self, config): | ||
4557 | 1579 | config.hwpack_format = '1.0' | ||
4558 | 1580 | |||
4559 | 1568 | def test_default(self): | 1581 | def test_default(self): |
4560 | 1582 | board_conf = BoardConfig() | ||
4561 | 1583 | self.set_up_config(board_conf) | ||
4562 | 1569 | self.assertEqual( | 1584 | self.assertEqual( |
4565 | 1570 | '63,106432,0x0C,*\n106496,,,-', | 1585 | '63,106432,0x0C,*\n106496,,,-', board_conf.get_sfdisk_cmd()) |
4564 | 1571 | boards.BoardConfig.get_sfdisk_cmd()) | ||
4566 | 1572 | 1586 | ||
4567 | 1573 | def test_default_aligned(self): | 1587 | def test_default_aligned(self): |
4568 | 1588 | board_conf = BoardConfig() | ||
4569 | 1589 | self.set_up_config(board_conf) | ||
4570 | 1574 | self.assertEqual( | 1590 | self.assertEqual( |
4571 | 1575 | '8192,106496,0x0C,*\n114688,,,-', | 1591 | '8192,106496,0x0C,*\n114688,,,-', |
4573 | 1576 | boards.BoardConfig.get_sfdisk_cmd(should_align_boot_part=True)) | 1592 | board_conf.get_sfdisk_cmd(should_align_boot_part=True)) |
4574 | 1577 | 1593 | ||
4575 | 1578 | def test_mx5(self): | 1594 | def test_mx5(self): |
4576 | 1595 | board_conf = boards.Mx5Config() | ||
4577 | 1596 | board_conf.hwpack_format = '1.0' | ||
4578 | 1579 | self.assertEqual( | 1597 | self.assertEqual( |
4579 | 1580 | '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', | 1598 | '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', |
4581 | 1581 | boards.Mx5Config.get_sfdisk_cmd()) | 1599 | board_conf.get_sfdisk_cmd()) |
4582 | 1582 | 1600 | ||
4583 | 1583 | def test_snowball_sd(self): | 1601 | def test_snowball_sd(self): |
4584 | 1602 | board_conf = boards.SnowballSdConfig() | ||
4585 | 1603 | self.set_up_config(board_conf) | ||
4586 | 1584 | self.assertEqual( | 1604 | self.assertEqual( |
4589 | 1585 | '63,106432,0x0C,*\n106496,,,-', | 1605 | '63,106432,0x0C,*\n106496,,,-', board_conf.get_sfdisk_cmd()) |
4588 | 1586 | boards.SnowballSdConfig.get_sfdisk_cmd()) | ||
4590 | 1587 | 1606 | ||
4591 | 1588 | def test_snowball_emmc(self): | 1607 | def test_snowball_emmc(self): |
4592 | 1608 | board_conf = boards.SnowballEmmcConfig() | ||
4593 | 1609 | self.set_up_config(board_conf) | ||
4594 | 1589 | self.assertEqual( | 1610 | self.assertEqual( |
4595 | 1590 | '256,7936,0xDA\n8192,106496,0x0C,*\n114688,,,-', | 1611 | '256,7936,0xDA\n8192,106496,0x0C,*\n114688,,,-', |
4597 | 1591 | boards.SnowballEmmcConfig.get_sfdisk_cmd()) | 1612 | board_conf.get_sfdisk_cmd()) |
4598 | 1592 | 1613 | ||
4599 | 1593 | def test_smdkv310(self): | 1614 | def test_smdkv310(self): |
4600 | 1615 | board_conf = get_board_config('smdkv310') | ||
4601 | 1616 | self.set_up_config(board_conf) | ||
4602 | 1594 | self.assertEquals( | 1617 | self.assertEquals( |
4603 | 1595 | '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', | 1618 | '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', |
4605 | 1596 | board_configs['smdkv310'].get_sfdisk_cmd()) | 1619 | board_conf.get_sfdisk_cmd()) |
4606 | 1597 | 1620 | ||
4607 | 1598 | def test_origen(self): | 1621 | def test_origen(self): |
4608 | 1622 | board_conf = get_board_config('origen') | ||
4609 | 1623 | self.set_up_config(board_conf) | ||
4610 | 1599 | self.assertEquals( | 1624 | self.assertEquals( |
4611 | 1600 | '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', | 1625 | '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', |
4613 | 1601 | board_configs['origen'].get_sfdisk_cmd()) | 1626 | board_conf.get_sfdisk_cmd()) |
4614 | 1602 | 1627 | ||
4615 | 1603 | def test_panda_android(self): | 1628 | def test_panda_android(self): |
4616 | 1604 | self.assertEqual( | 1629 | self.assertEqual( |
4617 | 1605 | '63,270272,0x0C,*\n270336,1048576,L\n1318912,524288,L\n' | 1630 | '63,270272,0x0C,*\n270336,1048576,L\n1318912,524288,L\n' |
4618 | 1606 | '1843200,-,E\n1843200,1048576,L\n2891776,,,-', | 1631 | '1843200,-,E\n1843200,1048576,L\n2891776,,,-', |
4620 | 1607 | android_boards.AndroidPandaConfig.get_sfdisk_cmd()) | 1632 | android_boards.AndroidPandaConfig().get_sfdisk_cmd()) |
4621 | 1608 | 1633 | ||
4622 | 1609 | def test_origen_android(self): | 1634 | def test_origen_android(self): |
4623 | 1610 | self.assertEqual( | 1635 | self.assertEqual( |
4624 | 1611 | '1,8191,0xDA\n8253,270274,0x0C,*\n278528,1048576,L\n' | 1636 | '1,8191,0xDA\n8253,270274,0x0C,*\n278528,1048576,L\n' |
4625 | 1612 | '1327104,-,E\n1327104,524288,L\n1851392,1048576,L\n2899968,,,-', | 1637 | '1327104,-,E\n1327104,524288,L\n1851392,1048576,L\n2899968,,,-', |
4627 | 1613 | android_boards.AndroidOrigenConfig.get_sfdisk_cmd()) | 1638 | android_boards.AndroidOrigenConfig().get_sfdisk_cmd()) |
4628 | 1614 | 1639 | ||
4629 | 1615 | def test_snowball_emmc_android(self): | 1640 | def test_snowball_emmc_android(self): |
4630 | 1616 | self.assertEqual( | 1641 | self.assertEqual( |
4631 | 1617 | '256,7936,0xDA\n8192,262144,0x0C,*\n270336,1048576,L\n' | 1642 | '256,7936,0xDA\n8192,262144,0x0C,*\n270336,1048576,L\n' |
4632 | 1618 | '1318912,-,E\n1318912,524288,L\n1843200,1048576,L\n2891776,,,-', | 1643 | '1318912,-,E\n1318912,524288,L\n1843200,1048576,L\n2891776,,,-', |
4634 | 1619 | android_boards.AndroidSnowballEmmcConfig.get_sfdisk_cmd()) | 1644 | android_boards.AndroidSnowballEmmcConfig().get_sfdisk_cmd()) |
4635 | 1620 | 1645 | ||
4636 | 1621 | def test_vexpress_android(self): | 1646 | def test_vexpress_android(self): |
4637 | 1622 | self.assertEqual( | 1647 | self.assertEqual( |
4638 | 1623 | '63,270272,0x0E,*\n270336,1048576,L\n1318912,524288,L\n' | 1648 | '63,270272,0x0E,*\n270336,1048576,L\n1318912,524288,L\n' |
4639 | 1624 | '1843200,-,E\n1843200,1048576,L\n2891776,,,-', | 1649 | '1843200,-,E\n1843200,1048576,L\n2891776,,,-', |
4641 | 1625 | android_boards.AndroidVexpressConfig.get_sfdisk_cmd()) | 1650 | android_boards.AndroidVexpressConfig().get_sfdisk_cmd()) |
4642 | 1626 | 1651 | ||
4643 | 1627 | def test_mx5_android(self): | 1652 | def test_mx5_android(self): |
4644 | 1628 | self.assertEqual( | 1653 | self.assertEqual( |
4645 | 1629 | '1,8191,0xDA\n8192,262144,0x0C,*\n270336,1048576,L\n' | 1654 | '1,8191,0xDA\n8192,262144,0x0C,*\n270336,1048576,L\n' |
4646 | 1630 | '1318912,-,E\n1318912,524288,L\n1843200,1048576,L\n2891776,,,-', | 1655 | '1318912,-,E\n1318912,524288,L\n1843200,1048576,L\n2891776,,,-', |
4648 | 1631 | android_boards.AndroidMx53LoCoConfig.get_sfdisk_cmd()) | 1656 | android_boards.AndroidMx53LoCoConfig().get_sfdisk_cmd()) |
4649 | 1632 | 1657 | ||
4650 | 1633 | def test_mx6_android(self): | 1658 | def test_mx6_android(self): |
4651 | 1634 | self.assertEqual( | 1659 | self.assertEqual( |
4652 | 1635 | '1,8191,0xDA\n8192,262144,0x0C,*\n270336,1048576,L\n' | 1660 | '1,8191,0xDA\n8192,262144,0x0C,*\n270336,1048576,L\n' |
4653 | 1636 | '1318912,-,E\n1318912,524288,L\n1843200,1048576,L\n2891776,,,-', | 1661 | '1318912,-,E\n1318912,524288,L\n1843200,1048576,L\n2891776,,,-', |
4655 | 1637 | android_boards.AndroidMx6QSabreliteConfig.get_sfdisk_cmd()) | 1662 | android_boards.AndroidMx6QSabreliteConfig().get_sfdisk_cmd()) |
4656 | 1638 | 1663 | ||
4657 | 1639 | 1664 | ||
4658 | 1640 | class TestGetSfdiskCmdV2(TestCase): | 1665 | class TestGetSfdiskCmdV2(TestCase): |
4659 | 1641 | 1666 | ||
4660 | 1642 | def test_mx5(self): | 1667 | def test_mx5(self): |
4663 | 1643 | class config(boards.Mx5Config): | 1668 | board_conf = boards.Mx5Config() |
4664 | 1644 | partition_layout = 'reserved_bootfs_rootfs' | 1669 | board_conf.partition_layout = 'reserved_bootfs_rootfs' |
4665 | 1645 | self.assertEqual( | 1670 | self.assertEqual( |
4666 | 1646 | '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', | 1671 | '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', |
4668 | 1647 | config.get_sfdisk_cmd()) | 1672 | board_conf.get_sfdisk_cmd()) |
4669 | 1648 | 1673 | ||
4670 | 1649 | def test_snowball_sd(self): | 1674 | def test_snowball_sd(self): |
4673 | 1650 | class config(boards.SnowballSdConfig): | 1675 | board_conf = boards.SnowballSdConfig() |
4674 | 1651 | partition_layout = 'bootfs_rootfs' | 1676 | board_conf.partition_layout = 'bootfs_rootfs' |
4675 | 1652 | self.assertEqual( | 1677 | self.assertEqual( |
4676 | 1653 | '63,106432,0x0C,*\n106496,,,-', | 1678 | '63,106432,0x0C,*\n106496,,,-', |
4678 | 1654 | config.get_sfdisk_cmd()) | 1679 | board_conf.get_sfdisk_cmd()) |
4679 | 1655 | 1680 | ||
4680 | 1656 | def test_snowball_emmc(self): | 1681 | def test_snowball_emmc(self): |
4684 | 1657 | class config(boards.SnowballEmmcConfig): | 1682 | board_conf = boards.SnowballEmmcConfig() |
4685 | 1658 | partition_layout = 'reserved_bootfs_rootfs' | 1683 | board_conf.partition_layout = 'reserved_bootfs_rootfs' |
4686 | 1659 | LOADER_START_S = (128 * 1024) / SECTOR_SIZE | 1684 | board_conf.loader_start_s = (128 * 1024) / SECTOR_SIZE |
4687 | 1660 | self.assertEqual( | 1685 | self.assertEqual( |
4688 | 1661 | '256,7936,0xDA\n8192,106496,0x0C,*\n114688,,,-', | 1686 | '256,7936,0xDA\n8192,106496,0x0C,*\n114688,,,-', |
4690 | 1662 | config.get_sfdisk_cmd()) | 1687 | board_conf.get_sfdisk_cmd()) |
4691 | 1663 | 1688 | ||
4692 | 1664 | def test_smdkv310(self): | 1689 | def test_smdkv310(self): |
4698 | 1665 | class config(board_configs['smdkv310']): | 1690 | board_conf = get_board_config('smdkv310') |
4699 | 1666 | partition_layout = 'reserved_bootfs_rootfs' | 1691 | board_conf.partition_layout = 'reserved_bootfs_rootfs' |
4700 | 1667 | LOADER_MIN_SIZE_S = (boards.BoardConfig.SAMSUNG_V310_BL2_START + | 1692 | board_conf.LOADER_MIN_SIZE_S = ( |
4701 | 1668 | boards.BoardConfig.SAMSUNG_V310_BL2_LEN - | 1693 | board_conf.samsung_v310_bl2_start + |
4702 | 1669 | boards.BoardConfig.SAMSUNG_V310_BL1_START) | 1694 | board_conf.samsung_v310_bl2_len - |
4703 | 1695 | board_conf.samsung_v310_bl1_start) | ||
4704 | 1670 | self.assertEquals( | 1696 | self.assertEquals( |
4705 | 1671 | '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', | 1697 | '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', |
4707 | 1672 | config.get_sfdisk_cmd()) | 1698 | board_conf.get_sfdisk_cmd()) |
4708 | 1673 | 1699 | ||
4709 | 1674 | def test_origen(self): | 1700 | def test_origen(self): |
4715 | 1675 | class config(board_configs['origen']): | 1701 | board_conf = get_board_config('origen') |
4716 | 1676 | partition_layout = 'reserved_bootfs_rootfs' | 1702 | board_conf.partition_layout = 'reserved_bootfs_rootfs' |
4717 | 1677 | LOADER_MIN_SIZE_S = (boards.BoardConfig.SAMSUNG_V310_BL2_START + | 1703 | board_conf.LOADER_MIN_SIZE_S = ( |
4718 | 1678 | boards.BoardConfig.SAMSUNG_V310_BL2_LEN - | 1704 | board_conf.samsung_v310_bl2_start + |
4719 | 1679 | boards.BoardConfig.SAMSUNG_V310_BL1_START) | 1705 | board_conf.samsung_v310_bl2_len - |
4720 | 1706 | board_conf.samsung_v310_bl1_start) | ||
4721 | 1680 | self.assertEquals( | 1707 | self.assertEquals( |
4722 | 1681 | '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', | 1708 | '1,8191,0xDA\n8192,106496,0x0C,*\n114688,,,-', |
4724 | 1682 | config.get_sfdisk_cmd()) | 1709 | board_conf.get_sfdisk_cmd()) |
4725 | 1683 | 1710 | ||
4726 | 1684 | 1711 | ||
4727 | 1685 | class TestGetBootCmd(TestCase): | 1712 | class TestGetBootCmd(TestCase): |
4728 | 1686 | 1713 | ||
4729 | 1687 | def test_vexpress(self): | 1714 | def test_vexpress(self): |
4731 | 1688 | boot_commands = board_configs['vexpress']._get_boot_env( | 1715 | board_conf = get_board_config('vexpress') |
4732 | 1716 | boot_commands = board_conf._get_boot_env( | ||
4733 | 1689 | is_live=False, is_lowmem=False, consoles=['ttyXXX'], | 1717 | is_live=False, is_lowmem=False, consoles=['ttyXXX'], |
4734 | 1690 | rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None) | 1718 | rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None) |
4735 | 1691 | expected = { | 1719 | expected = { |
4736 | @@ -1699,7 +1727,8 @@ | |||
4737 | 1699 | self.assertEqual(expected, boot_commands) | 1727 | self.assertEqual(expected, boot_commands) |
4738 | 1700 | 1728 | ||
4739 | 1701 | def test_vexpress_a9(self): | 1729 | def test_vexpress_a9(self): |
4741 | 1702 | boot_commands = board_configs['vexpress-a9']._get_boot_env( | 1730 | board_conf = get_board_config('vexpress-a9') |
4742 | 1731 | boot_commands = board_conf._get_boot_env( | ||
4743 | 1703 | is_live=False, is_lowmem=False, consoles=['ttyXXX'], | 1732 | is_live=False, is_lowmem=False, consoles=['ttyXXX'], |
4744 | 1704 | rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None) | 1733 | rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None) |
4745 | 1705 | expected = { | 1734 | expected = { |
4746 | @@ -1713,7 +1742,8 @@ | |||
4747 | 1713 | self.assertEqual(expected, boot_commands) | 1742 | self.assertEqual(expected, boot_commands) |
4748 | 1714 | 1743 | ||
4749 | 1715 | def test_mx51(self): | 1744 | def test_mx51(self): |
4751 | 1716 | boot_commands = boards.Mx51Config._get_boot_env( | 1745 | board_conf = boards.Mx51Config() |
4752 | 1746 | boot_commands = board_conf._get_boot_env( | ||
4753 | 1717 | is_live=False, is_lowmem=False, consoles=[], | 1747 | is_live=False, is_lowmem=False, consoles=[], |
4754 | 1718 | rootfs_id="UUID=deadbeef", i_img_data="initrd", | 1748 | rootfs_id="UUID=deadbeef", i_img_data="initrd", |
4755 | 1719 | d_img_data="mx51.dtb") | 1749 | d_img_data="mx51.dtb") |
4756 | @@ -1729,7 +1759,8 @@ | |||
4757 | 1729 | self.assertEqual(expected, boot_commands) | 1759 | self.assertEqual(expected, boot_commands) |
4758 | 1730 | 1760 | ||
4759 | 1731 | def test_smdkv310(self): | 1761 | def test_smdkv310(self): |
4761 | 1732 | boot_commands = board_configs['smdkv310']._get_boot_env( | 1762 | board_conf = get_board_config('smdkv310') |
4762 | 1763 | boot_commands = board_conf._get_boot_env( | ||
4763 | 1733 | is_live=False, is_lowmem=False, consoles=[], | 1764 | is_live=False, is_lowmem=False, consoles=[], |
4764 | 1734 | rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None) | 1765 | rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None) |
4765 | 1735 | expected = { | 1766 | expected = { |
4766 | @@ -1745,7 +1776,8 @@ | |||
4767 | 1745 | self.assertEqual(expected, boot_commands) | 1776 | self.assertEqual(expected, boot_commands) |
4768 | 1746 | 1777 | ||
4769 | 1747 | def test_origen(self): | 1778 | def test_origen(self): |
4771 | 1748 | boot_commands = board_configs['origen']._get_boot_env( | 1779 | board_conf = get_board_config('origen') |
4772 | 1780 | boot_commands = board_conf._get_boot_env( | ||
4773 | 1749 | is_live=False, is_lowmem=False, consoles=[], | 1781 | is_live=False, is_lowmem=False, consoles=[], |
4774 | 1750 | rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None) | 1782 | rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None) |
4775 | 1751 | expected = { | 1783 | expected = { |
4776 | @@ -1759,7 +1791,8 @@ | |||
4777 | 1759 | self.assertEqual(expected, boot_commands) | 1791 | self.assertEqual(expected, boot_commands) |
4778 | 1760 | 1792 | ||
4779 | 1761 | def test_ux500(self): | 1793 | def test_ux500(self): |
4781 | 1762 | boot_commands = board_configs['ux500']._get_boot_env( | 1794 | board_conf = get_board_config('ux500') |
4782 | 1795 | boot_commands = board_conf._get_boot_env( | ||
4783 | 1763 | is_live=False, is_lowmem=False, consoles=[], | 1796 | is_live=False, is_lowmem=False, consoles=[], |
4784 | 1764 | rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None) | 1797 | rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None) |
4785 | 1765 | expected = { | 1798 | expected = { |
4786 | @@ -1777,7 +1810,8 @@ | |||
4787 | 1777 | self.assertEqual(expected, boot_commands) | 1810 | self.assertEqual(expected, boot_commands) |
4788 | 1778 | 1811 | ||
4789 | 1779 | def test_snowball_emmc(self): | 1812 | def test_snowball_emmc(self): |
4791 | 1780 | boot_commands = board_configs['snowball_emmc']._get_boot_env( | 1813 | board_conf = get_board_config('snowball_emmc') |
4792 | 1814 | boot_commands = board_conf._get_boot_env( | ||
4793 | 1781 | is_live=False, is_lowmem=False, consoles=[], | 1815 | is_live=False, is_lowmem=False, consoles=[], |
4794 | 1782 | rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None) | 1816 | rootfs_id="UUID=deadbeef", i_img_data="initrd", d_img_data=None) |
4795 | 1783 | expected = { | 1817 | expected = { |
4796 | @@ -1798,7 +1832,7 @@ | |||
4797 | 1798 | # XXX: To fix bug 697824 we have to change class attributes of our | 1832 | # XXX: To fix bug 697824 we have to change class attributes of our |
4798 | 1799 | # OMAP board configs, and some tests do that so to make sure they | 1833 | # OMAP board configs, and some tests do that so to make sure they |
4799 | 1800 | # don't interfere with us we'll reset that before doing anything. | 1834 | # don't interfere with us we'll reset that before doing anything. |
4801 | 1801 | config = board_configs['panda'] | 1835 | config = get_board_config('panda') |
4802 | 1802 | config.serial_tty = config._serial_tty | 1836 | config.serial_tty = config._serial_tty |
4803 | 1803 | boot_commands = config._get_boot_env( | 1837 | boot_commands = config._get_boot_env( |
4804 | 1804 | is_live=False, is_lowmem=False, consoles=[], | 1838 | is_live=False, is_lowmem=False, consoles=[], |
4805 | @@ -1821,7 +1855,7 @@ | |||
4806 | 1821 | # XXX: To fix bug 697824 we have to change class attributes of our | 1855 | # XXX: To fix bug 697824 we have to change class attributes of our |
4807 | 1822 | # OMAP board configs, and some tests do that so to make sure they | 1856 | # OMAP board configs, and some tests do that so to make sure they |
4808 | 1823 | # don't interfere with us we'll reset that before doing anything. | 1857 | # don't interfere with us we'll reset that before doing anything. |
4810 | 1824 | config = board_configs['beagle'] | 1858 | config = get_board_config('beagle') |
4811 | 1825 | config.serial_tty = config._serial_tty | 1859 | config.serial_tty = config._serial_tty |
4812 | 1826 | boot_commands = config._get_boot_env( | 1860 | boot_commands = config._get_boot_env( |
4813 | 1827 | is_live=False, is_lowmem=False, consoles=[], | 1861 | is_live=False, is_lowmem=False, consoles=[], |
4814 | @@ -1844,7 +1878,7 @@ | |||
4815 | 1844 | # XXX: To fix bug 697824 we have to change class attributes of our | 1878 | # XXX: To fix bug 697824 we have to change class attributes of our |
4816 | 1845 | # OMAP board configs, and some tests do that so to make sure they | 1879 | # OMAP board configs, and some tests do that so to make sure they |
4817 | 1846 | # don't interfere with us we'll reset that before doing anything. | 1880 | # don't interfere with us we'll reset that before doing anything. |
4819 | 1847 | config = boards.IgepConfig | 1881 | config = boards.IgepConfig() |
4820 | 1848 | config.serial_tty = config._serial_tty | 1882 | config.serial_tty = config._serial_tty |
4821 | 1849 | boot_cmd = config._get_boot_env( | 1883 | boot_cmd = config._get_boot_env( |
4822 | 1850 | is_live=False, is_lowmem=False, consoles=[], | 1884 | is_live=False, is_lowmem=False, consoles=[], |
4823 | @@ -1867,7 +1901,7 @@ | |||
4824 | 1867 | # XXX: To fix bug 697824 we have to change class attributes of our | 1901 | # XXX: To fix bug 697824 we have to change class attributes of our |
4825 | 1868 | # OMAP board configs, and some tests do that so to make sure they | 1902 | # OMAP board configs, and some tests do that so to make sure they |
4826 | 1869 | # don't interfere with us we'll reset that before doing anything. | 1903 | # don't interfere with us we'll reset that before doing anything. |
4828 | 1870 | config = board_configs['overo'] | 1904 | config = get_board_config('overo') |
4829 | 1871 | config.serial_tty = config._serial_tty | 1905 | config.serial_tty = config._serial_tty |
4830 | 1872 | boot_commands = config._get_boot_env( | 1906 | boot_commands = config._get_boot_env( |
4831 | 1873 | is_live=False, is_lowmem=False, consoles=[], | 1907 | is_live=False, is_lowmem=False, consoles=[], |
4832 | @@ -1890,12 +1924,15 @@ | |||
4833 | 1890 | 1924 | ||
4834 | 1891 | class TestExtraBootCmd(TestCaseWithFixtures): | 1925 | class TestExtraBootCmd(TestCaseWithFixtures): |
4835 | 1892 | 1926 | ||
4836 | 1927 | def setUp(self): | ||
4837 | 1928 | super(TestExtraBootCmd, self).setUp() | ||
4838 | 1929 | self.board_conf = BoardConfig() | ||
4839 | 1930 | |||
4840 | 1893 | def test_extra_boot_args_options_is_picked_by_get_boot_env(self): | 1931 | def test_extra_boot_args_options_is_picked_by_get_boot_env(self): |
4841 | 1894 | boot_args = 'whatever' | 1932 | boot_args = 'whatever' |
4842 | 1895 | 1933 | ||
4846 | 1896 | class config(BoardConfig): | 1934 | self.board_conf.extra_boot_args_options = boot_args |
4847 | 1897 | extra_boot_args_options = boot_args | 1935 | boot_commands = self.board_conf._get_boot_env( |
4845 | 1898 | boot_commands = config._get_boot_env( | ||
4848 | 1899 | is_live=False, is_lowmem=False, consoles=['ttyXXX'], | 1936 | is_live=False, is_lowmem=False, consoles=['ttyXXX'], |
4849 | 1900 | rootfs_id="UUID=deadbeef", i_img_data=None, d_img_data=None) | 1937 | rootfs_id="UUID=deadbeef", i_img_data=None, d_img_data=None) |
4850 | 1901 | expected = ( | 1938 | expected = ( |
4851 | @@ -1905,28 +1942,25 @@ | |||
4852 | 1905 | def test_passing_None_to_add_boot_args(self): | 1942 | def test_passing_None_to_add_boot_args(self): |
4853 | 1906 | boot_args = 'extra-args' | 1943 | boot_args = 'extra-args' |
4854 | 1907 | 1944 | ||
4859 | 1908 | class config(BoardConfig): | 1945 | self.board_conf.extra_boot_args_options = boot_args |
4860 | 1909 | extra_boot_args_options = boot_args | 1946 | self.board_conf.add_boot_args(None) |
4861 | 1910 | config.add_boot_args(None) | 1947 | self.assertEqual(boot_args, self.board_conf.extra_boot_args_options) |
4858 | 1911 | self.assertEqual(boot_args, config.extra_boot_args_options) | ||
4862 | 1912 | 1948 | ||
4863 | 1913 | def test_passing_string_to_add_boot_args(self): | 1949 | def test_passing_string_to_add_boot_args(self): |
4864 | 1914 | boot_args = 'extra-args' | 1950 | boot_args = 'extra-args' |
4865 | 1915 | extra_args = 'user-args' | 1951 | extra_args = 'user-args' |
4866 | 1916 | 1952 | ||
4870 | 1917 | class config(BoardConfig): | 1953 | self.board_conf.extra_boot_args_options = boot_args |
4871 | 1918 | extra_boot_args_options = boot_args | 1954 | self.board_conf.add_boot_args(extra_args) |
4869 | 1919 | config.add_boot_args(extra_args) | ||
4872 | 1920 | self.assertEqual( | 1955 | self.assertEqual( |
4874 | 1921 | "%s %s" % (boot_args, extra_args), config.extra_boot_args_options) | 1956 | "%s %s" % (boot_args, extra_args), |
4875 | 1957 | self.board_conf.extra_boot_args_options) | ||
4876 | 1922 | 1958 | ||
4877 | 1923 | def test_passing_string_to_add_boot_args_with_no_default_extra_args(self): | 1959 | def test_passing_string_to_add_boot_args_with_no_default_extra_args(self): |
4878 | 1924 | extra_args = 'user-args' | 1960 | extra_args = 'user-args' |
4879 | 1925 | 1961 | ||
4884 | 1926 | class config(BoardConfig): | 1962 | self.board_conf.add_boot_args(extra_args) |
4885 | 1927 | extra_boot_args_options = None | 1963 | self.assertEqual(extra_args, self.board_conf.extra_boot_args_options) |
4882 | 1928 | config.add_boot_args(extra_args) | ||
4883 | 1929 | self.assertEqual(extra_args, config.extra_boot_args_options) | ||
4886 | 1930 | 1964 | ||
4887 | 1931 | def test_add_boot_args_from_file(self): | 1965 | def test_add_boot_args_from_file(self): |
4888 | 1932 | boot_args = 'extra-args' | 1966 | boot_args = 'extra-args' |
4889 | @@ -1935,19 +1969,18 @@ | |||
4890 | 1935 | with open(boot_arg_path, 'w') as boot_arg_file: | 1969 | with open(boot_arg_path, 'w') as boot_arg_file: |
4891 | 1936 | boot_arg_file.write(extra_args) | 1970 | boot_arg_file.write(extra_args) |
4892 | 1937 | 1971 | ||
4896 | 1938 | class config(BoardConfig): | 1972 | self.board_conf.extra_boot_args_options = boot_args |
4897 | 1939 | extra_boot_args_options = boot_args | 1973 | self.board_conf.add_boot_args_from_file(boot_arg_path) |
4895 | 1940 | config.add_boot_args_from_file(boot_arg_path) | ||
4898 | 1941 | self.assertEqual( | 1974 | self.assertEqual( |
4900 | 1942 | "%s %s" % (boot_args, extra_args), config.extra_boot_args_options) | 1975 | "%s %s" % (boot_args, extra_args), |
4901 | 1976 | self.board_conf.extra_boot_args_options) | ||
4902 | 1943 | 1977 | ||
4903 | 1944 | def test_passing_None_to_add_boot_args_from_file(self): | 1978 | def test_passing_None_to_add_boot_args_from_file(self): |
4904 | 1945 | boot_args = 'extra-args' | 1979 | boot_args = 'extra-args' |
4905 | 1946 | 1980 | ||
4910 | 1947 | class config(BoardConfig): | 1981 | self.board_conf.extra_boot_args_options = boot_args |
4911 | 1948 | extra_boot_args_options = boot_args | 1982 | self.board_conf.add_boot_args_from_file(None) |
4912 | 1949 | config.add_boot_args_from_file(None) | 1983 | self.assertEqual(boot_args, self.board_conf.extra_boot_args_options) |
4909 | 1950 | self.assertEqual(boot_args, config.extra_boot_args_options) | ||
4913 | 1951 | 1984 | ||
4914 | 1952 | def test_add_boot_args_from_file_strips_whitespace_from_file(self): | 1985 | def test_add_boot_args_from_file_strips_whitespace_from_file(self): |
4915 | 1953 | boot_args = 'extra-args' | 1986 | boot_args = 'extra-args' |
4916 | @@ -1956,122 +1989,11 @@ | |||
4917 | 1956 | with open(boot_arg_path, 'w') as boot_arg_file: | 1989 | with open(boot_arg_path, 'w') as boot_arg_file: |
4918 | 1957 | boot_arg_file.write('\n\n \t ' + extra_args + ' \n\n') | 1990 | boot_arg_file.write('\n\n \t ' + extra_args + ' \n\n') |
4919 | 1958 | 1991 | ||
4923 | 1959 | class config(BoardConfig): | 1992 | self.board_conf.extra_boot_args_options = boot_args |
4924 | 1960 | extra_boot_args_options = boot_args | 1993 | self.board_conf.add_boot_args_from_file(boot_arg_path) |
4922 | 1961 | config.add_boot_args_from_file(boot_arg_path) | ||
4925 | 1962 | self.assertEqual( | 1994 | self.assertEqual( |
4926 | 1963 | "%s %s" % (boot_args, extra_args), config.extra_boot_args_options) | ||
4927 | 1964 | |||
4928 | 1965 | |||
4929 | 1966 | class TestGetBootCmdAndroid(TestCase): | ||
4930 | 1967 | |||
4931 | 1968 | def test_panda(self): | ||
4932 | 1969 | # XXX: To fix bug 697824 we have to change class attributes of our | ||
4933 | 1970 | # OMAP board configs, and some tests do that so to make sure they | ||
4934 | 1971 | # don't interfere with us we'll reset that before doing anything. | ||
4935 | 1972 | config = android_board_configs['panda'] | ||
4936 | 1973 | config.serial_tty = config._serial_tty | ||
4937 | 1974 | expected = { | ||
4938 | 1975 | 'bootargs': 'console=ttyO2,115200n8 ' | ||
4939 | 1976 | 'rootwait ro earlyprintk fixrtc ' | ||
4940 | 1977 | 'nocompcache vram=48M omapfb.vram=0:24M,1:24M ' | ||
4941 | 1978 | 'mem=456M@0x80000000 mem=512M@0xA0000000 ' | ||
4942 | 1979 | 'init=/init androidboot.console=ttyO2', | ||
4943 | 1980 | 'bootcmd': 'fatload mmc 0:1 0x80200000 uImage; ' | ||
4944 | 1981 | 'fatload mmc 0:1 0x81600000 uInitrd; ' | ||
4945 | 1982 | 'fatload mmc 0:1 0x815f0000 board.dtb; ' | ||
4946 | 1983 | 'bootm 0x80200000 0x81600000 0x815f0000', | ||
4947 | 1984 | 'fdt_high': '0xffffffff', | ||
4948 | 1985 | 'initrd_high': '0xffffffff'} | ||
4949 | 1986 | self.assertBootEnv(config, expected) | ||
4950 | 1987 | |||
4951 | 1988 | def test_android_snowball_sd(self): | ||
4952 | 1989 | expected = { | ||
4953 | 1990 | 'bootargs': 'console=ttyAMA2,115200n8 ' | ||
4954 | 1991 | 'rootwait ro earlyprintk ' | ||
4955 | 1992 | 'mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M ' | ||
4956 | 1993 | 'mem=22M@360M mem_issw=1M@383M mem=640M@384M ' | ||
4957 | 1994 | 'vmalloc=500M init=/init androidboot.console=ttyAMA2', | ||
4958 | 1995 | 'bootcmd': 'fatload mmc 1:1 0x00100000 uImage; ' | ||
4959 | 1996 | 'fatload mmc 1:1 0x05000000 uInitrd; ' | ||
4960 | 1997 | 'fatload mmc 1:1 0x8000000 board.dtb; ' | ||
4961 | 1998 | 'bootm 0x00100000 0x05000000 0x8000000', | ||
4962 | 1999 | 'fdt_high': '0x05000000', | ||
4963 | 2000 | 'initrd_high': '0x06000000'} | ||
4964 | 2001 | self.assertBootEnv( | ||
4965 | 2002 | android_boards.AndroidSnowballSdConfig, expected) | ||
4966 | 2003 | |||
4967 | 2004 | def test_android_snowball_emmc(self): | ||
4968 | 2005 | expected = { | ||
4969 | 2006 | 'bootargs': 'console=ttyAMA2,115200n8 ' | ||
4970 | 2007 | 'rootwait ro earlyprintk ' | ||
4971 | 2008 | 'mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M ' | ||
4972 | 2009 | 'mem=22M@360M mem_issw=1M@383M mem=640M@384M ' | ||
4973 | 2010 | 'vmalloc=500M init=/init androidboot.console=ttyAMA2', | ||
4974 | 2011 | 'bootcmd': 'fatload mmc 0:2 0x00100000 uImage; ' | ||
4975 | 2012 | 'fatload mmc 0:2 0x05000000 uInitrd; ' | ||
4976 | 2013 | 'fatload mmc 0:2 0x8000000 board.dtb; ' | ||
4977 | 2014 | 'bootm 0x00100000 0x05000000 0x8000000', | ||
4978 | 2015 | 'fdt_high': '0x05000000', | ||
4979 | 2016 | 'initrd_high': '0x06000000'} | ||
4980 | 2017 | self.assertBootEnv( | ||
4981 | 2018 | android_boards.AndroidSnowballEmmcConfig, expected) | ||
4982 | 2019 | |||
4983 | 2020 | def test_android_origen(self): | ||
4984 | 2021 | expected = { | ||
4985 | 2022 | 'bootargs': 'console=tty0 console=ttySAC2,115200n8 ' | ||
4986 | 2023 | 'rootwait ro init=/init androidboot.console=ttySAC2', | ||
4987 | 2024 | 'bootcmd': 'fatload mmc 0:2 0x40007000 uImage; ' | ||
4988 | 2025 | 'fatload mmc 0:2 0x42000000 uInitrd; ' | ||
4989 | 2026 | 'bootm 0x40007000 0x42000000', | ||
4990 | 2027 | 'fdt_high': '0xffffffff', | ||
4991 | 2028 | 'initrd_high': '0xffffffff'} | ||
4992 | 2029 | self.assertBootEnv( | ||
4993 | 2030 | android_boards.AndroidOrigenConfig, expected) | ||
4994 | 2031 | |||
4995 | 2032 | def test_android_vexpress(self): | ||
4996 | 2033 | expected = { | ||
4997 | 2034 | 'bootargs': 'console=tty0 console=ttyAMA0,38400n8 ' | ||
4998 | 2035 | 'rootwait ro init=/init androidboot.console=ttyAMA0', | ||
4999 | 2036 | 'bootcmd': 'fatload mmc 0:1 0x60000000 uImage; ' | ||
5000 | 2037 | 'fatload mmc 0:1 0x62000000 uInitrd; ' |
A few things on this branch:
* it needs to be split up into more manageable branches (I said this a few times already)—take the "mechanical" changes out and put them into a branch of it's own (moving code around and enabling use of instances instead of classes all belongs in either one or two separate branches).
* land bits and pieces that can land asap.
* extracted configs contain only the 'final' class elements, not anything out of parent classes.