Merge lp:~milo/linaro-image-tools/boards-refactoring into lp:linaro-image-tools/11.11

Proposed by Milo Casagrande
Status: Merged
Merged at revision: 596
Proposed branch: lp:~milo/linaro-image-tools/boards-refactoring
Merge into: lp:linaro-image-tools/11.11
Prerequisite: lp:~milo/linaro-image-tools/hwpack-handler
Diff against target: 2224 lines (+773/-771)
2 files modified
linaro-media-create (+3/-3)
linaro_image_tools/media_create/boards.py (+770/-768)
To merge this branch: bzr merge lp:~milo/linaro-image-tools/boards-refactoring
Reviewer Review Type Date Requested Status
Paul Sokolovsky Approve
linaro-image-tools maintainers Pending
Review via email: mp+138228@code.launchpad.net

Commit message

Boards class refactoring and clean-up.

Description of the change

Second, and a little big, merge request.

This is the initial refactoring work of the boards module moving from class methods to instance methods.
Some code needs further clean-up. In this branch tests have not been fixed.

To post a comment you must log in.
592. By Milo Casagrande

Merged hwpack-handler into boards-refactoring.

593. By Milo Casagrande

Merged from trunk.

594. By Milo Casagrande

Readedd wrongly removed attribute.

Revision history for this message
Paul Sokolovsky (pfalcon) wrote :

No reason was given for going from class to instance attributes, neither in commit message, nor in MR. Why would that matter? And character content of changes is massive, typo can lurk in easily. Merging this without passing tests is a bit brave IMHO.

review: Abstain
Revision history for this message
Milo Casagrande (milo) wrote :

> No reason was given for going from class to instance attributes, neither in
> commit message, nor in MR. Why would that matter?

You are right, I just discussed this with Danilo.
The problem is due to the introduction of the Android hwpack: a config file that needs to be parsed, and whose values have to be stored in the already defined board classes (both in AndrodiBoardConfig and in BoardConfig, since the former inherits from the latter and uses methods defined in its own and also from the parent one).

The problem I had with the first easy implementation (just parse the file and use everything as it was), was that it was not working, and tests were failing simply because the values were not correctly stored and the "default" ones were used. After a little bit of investigation and trying with different approaches, the "easiest" solution would have been to switch to instance attributes and methods instead of class based ones.

This is due to the fact that I wanted to have an easy way to set-up the attribute values, moslty using getattr and setattr, that work only with instances, not classes. In the old code, the attribute or properties where custom-defined as "classproperty", something that python does not have natively: keeping that approach would have meant an hack to be able to properly set the "classproperty" (not really an hack, but something that doesn't feel natual and definitely not easy to implement: we would have had to use "metaclasses"), since the get part is the only one to work correctly, and defining a class-based setter is close to impossible.

> And character content of
> changes is massive, typo can lurk in easily. Merging this without passing
> tests is a bit brave IMHO.

You are right, but if I fix the tests in the same MP, it will be even bigger than it is now (and there will be that complaint :-P). The tests have been fixed and the branches should be applied one on top of the other until the last one. I know it is sub-optimal, but at least changes have been split out into "smaller" review chunks (even if they result in more than 2000 lines). If I put the test fixes here, I will add almost 3000 more lines.

Revision history for this message
Paul Sokolovsky (pfalcon) wrote :

Thanks for explanation, makes sense to clean up that mess.

If tests are updated in following merge and pass, then it looks good.

review: Approve
595. By Milo Casagrande

Merged from trunk.

596. By Milo Casagrande

Refactored OrigenQuad to be an instance.

597. By Milo Casagrande

Merged from trunk.

598. By Milo Casagrande

Merged from trunk.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'linaro-media-create'
--- linaro-media-create 2012-10-22 06:57:20 +0000
+++ linaro-media-create 2012-12-27 15:00:29 +0000
@@ -25,7 +25,7 @@
2525
26from linaro_image_tools import cmd_runner26from linaro_image_tools import cmd_runner
2727
28from linaro_image_tools.media_create.boards import board_configs28from linaro_image_tools.media_create.boards import get_board_config
29from linaro_image_tools.media_create.check_device import (29from linaro_image_tools.media_create.check_device import (
30 confirm_device_selection_and_ensure_it_is_ready)30 confirm_device_selection_and_ensure_it_is_ready)
31from linaro_image_tools.media_create.chroot_utils import (31from linaro_image_tools.media_create.chroot_utils import (
@@ -131,9 +131,9 @@
131 logger.error(e.value)131 logger.error(e.value)
132 sys.exit(1)132 sys.exit(1)
133133
134 board_config = board_configs[args.dev]134 board_config = get_board_config(args.dev)
135 board_config.set_metadata(args.hwpacks, args.bootloader, args.dev)135 board_config.set_metadata(args.hwpacks, args.bootloader, args.dev)
136 board_config.set_board(args.dev)136 board_config.board(args.dev)
137 board_config.add_boot_args(args.extra_boot_args)137 board_config.add_boot_args(args.extra_boot_args)
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)
139139
140140
=== modified file 'linaro_image_tools/media_create/boards.py'
--- linaro_image_tools/media_create/boards.py 2012-12-23 12:49:02 +0000
+++ linaro_image_tools/media_create/boards.py 2012-12-27 15:00:29 +0000
@@ -24,24 +24,59 @@
24board_configs at the bottom of this file.24board_configs at the bottom of this file.
25"""25"""
2626
27from binascii import crc32
28from parted import Device
27import atexit29import atexit
28import glob30import glob
31import logging
29import os32import os
30import re33import re
34import string
35import struct
31import tempfile36import tempfile
32import struct
33from binascii import crc32
34import string
35import logging
36
37from parted import Device
3837
39from linaro_image_tools import cmd_runner38from linaro_image_tools import cmd_runner
4039
40from linaro_image_tools.hwpack.handler import HardwarepackHandler
41from linaro_image_tools.media_create.partitions import (41from linaro_image_tools.media_create.partitions import (
42 partition_mounted, SECTOR_SIZE, register_loopback)42 SECTOR_SIZE,
43 partition_mounted,
44 register_loopback,
45 )
4346
44from linaro_image_tools.hwpack.handler import HardwarepackHandler47from linaro_image_tools.hwpack.hwpack_fields import (
48 BOOTFS,
49 BOOTFS16,
50 BOOT_MIN_SIZE_FIELD,
51 BOOT_SCRIPT_FIELD,
52 DTB_ADDR_FIELD,
53 DTB_FILES_FIELD,
54 DTB_FILE_FIELD,
55 ENV_DD_FIELD,
56 EXTRA_BOOT_OPTIONS_FIELD,
57 EXTRA_SERIAL_OPTIONS_FIELD,
58 INITRD_ADDR_FIELD,
59 KERNEL_ADDR_FIELD,
60 LOADER_MIN_SIZE_FIELD,
61 LOADER_START_FIELD,
62 LOAD_ADDR_FIELD,
63 MMC_ID_FIELD,
64 PARTITION_LAYOUT_FIELD,
65 RESERVED_BOOTFS,
66 ROOT_MIN_SIZE_FIELD,
67 SAMSUNG_BL1_LEN_FIELD,
68 SAMSUNG_BL1_START_FIELD,
69 SAMSUNG_BL2_LEN_FIELD,
70 SAMSUNG_BL2_START_FIELD,
71 SAMSUNG_ENV_LEN_FIELD,
72 SAMSUNG_ENV_START_FILED,
73 SERIAL_TTY_FIELD,
74 SNOWBALL_STARTUP_FILES_CONFIG_FIELD,
75 SPL_DD_FIELD,
76 SPL_IN_BOOT_PART_FIELD,
77 WIRED_INTERFACES_FIELD,
78 WIRELESS_INTERFACES_FIELD,
79 )
4580
46logger = logging.getLogger(__name__)81logger = logging.getLogger(__name__)
4782
@@ -102,310 +137,290 @@
102 cmd_runner.run(cmd, as_root=True).wait()137 cmd_runner.run(cmd, as_root=True).wait()
103138
104139
105class classproperty(object):
106 """A descriptor that provides @property behavior on class methods."""
107 def __init__(self, getter):
108 self.getter = getter
109
110 def __get__(self, instance, cls):
111 return self.getter(cls)
112
113
114class BoardConfig(object):140class BoardConfig(object):
115 board = None
116 """The configuration used when building an image for a board."""141 """The configuration used when building an image for a board."""
117 hwpack_format = None142
118 # These attributes may not need to be redefined on some subclasses.
119 bootloader_flavor = None
120 # whether to copy u-boot to the boot partition
121 bootloader_file_in_boot_part = False
122 bootloader_dd = False
123 spl_in_boot_part = False
124 spl_dd = False
125 env_dd = False
126 fatload_command = 'fatload'
127 mmc_option = '0:1'
128 mmc_device_id = 0
129 mmc_part_offset = 0
130 uimage_path = ''
131 fat_size = 32
132 extra_serial_opts = ''
133 _extra_serial_opts = ''
134 _live_serial_opts = ''
135 extra_boot_args_options = None
136 supports_writing_to_mmc = True
137 LOADER_MIN_SIZE_S = align_up(1 * 1024 ** 2, SECTOR_SIZE) / SECTOR_SIZE143 LOADER_MIN_SIZE_S = align_up(1 * 1024 ** 2, SECTOR_SIZE) / SECTOR_SIZE
138 BOOT_MIN_SIZE_S = align_up(50 * 1024 ** 2, SECTOR_SIZE) / SECTOR_SIZE144 BOOT_MIN_SIZE_S = align_up(50 * 1024 ** 2, SECTOR_SIZE) / SECTOR_SIZE
139 ROOT_MIN_SIZE_S = align_up(50 * 1024 ** 2, SECTOR_SIZE) / SECTOR_SIZE145 ROOT_MIN_SIZE_S = align_up(50 * 1024 ** 2, SECTOR_SIZE) / SECTOR_SIZE
140146
141 # These attributes must be defined on all subclasses for backwards147 def __init__(self):
142 # compatibility with hwpacks v1 format. Hwpacks v2 format allows these to148 super(BoardConfig, self).__init__()
143 # be specified in the hwpack metadata.149 # XXX: when killing v1 hwpack, we might rename these two without the
144 kernel_addr = None150 # leading underscore. It is done in this way since sublcasses use
145 initrd_addr = None151 # placeholders in the string for dinamically change values. But this
146 initrd_high = '0xffffffff'152 # is done only for hwpack v1.
147 load_addr = None153 self._extra_serial_opts = ''
148 dtb_addr = None154 self._live_serial_opts = ''
149 dtb_name = None155 self.board = None
150 dtb_file = None156 self.boot_script = None
151 fdt_high = '0xffffffff'157 self.bootloader_dd = False
152 kernel_flavors = None158 self.bootloader_file_in_boot_part = False
153 boot_script = None159 self.bootloader_flavor = None
154 serial_tty = None160 self.dtb_addr = None
155 wired_interfaces = None161 self.dtb_file = None
156 wireless_interfaces = None162 self.dtb_files = None
157 mmc_id = None163 self.dtb_name = None
158 vmlinuz = None164 self.env_dd = False
159 initrd = None165 self.extra_boot_args_options = None
160 partition_layout = None166 self.fat_size = 32
161 LOADER_START_S = 1167 self.fatload_command = 'fatload'
162168 self.fdt_high = '0xffffffff'
163 # Support for dtb_files as per hwpack v3 format.169 self.hardwarepack_handler = None
164 dtb_files = None170 self.hwpack_format = None
165171 self.initrd_addr = None
166 # Samsung Boot-loader implementation notes and terminology172 self.initrd_high = '0xffffffff'
167 #173 self.kernel_addr = None
168 # * BL0, BL1 etc. are the various bootloaders in order of execution174 self.kernel_flavors = None
169 # * BL0 is the first stage bootloader, located in ROM; it loads BL1/SPL175 self.load_addr = None
170 # from MMC offset +1s and runs it.176 self.loader_start_s = 1
171 # * BL1 is the secondary program loader (SPL), a small version177 self.mmc_device_id = 0
172 # of U-Boot with a checksum; it inits DRAM and loads a 1024s long BL2178 self.mmc_id = None
173 # from MMC and runs it.179 self.mmc_option = '0:1'
174 # * BL2 is the U-Boot.180 self.mmc_part_offset = 0
175 #181 self.partition_layout = None
176 # samsung_bl1_{start,len}: Offset and maximum size for BL1182 self.serial_tty = None
177 # samsung_bl2_{start,len}: Offset and maximum size for BL2183 self.spl_dd = False
178 # samsung_env_{start,len}: Offset and maximum size for Environment settings184 self.spl_in_boot_part = False
179 #185 self.supports_writing_to_mmc = True
180 samsung_bl1_start = 1186 self.uimage_path = ''
181 samsung_bl1_len = 32187 self.wired_interfaces = None
182 samsung_bl2_start = 65188 self.wireless_interfaces = None
183 samsung_bl2_len = 1024189 # Samsung Boot-loader implementation notes and terminology
184 samsung_env_start = 33190 #
185 samsung_env_len = 32191 # * BL0, BL1 etc. are the various bootloaders in order of execution
186192 # * BL0 is the first stage bootloader, located in ROM; it loads BL1/SPL
187 hardwarepack_handler = None193 # from MMC offset +1s and runs it.
188194 # * BL1 is the secondary program loader (SPL), a small version
189 @classmethod195 # of U-Boot with a checksum; it inits DRAM and loads a 1024s long BL2
190 def get_metadata_field(cls, field_name):196 # from MMC and runs it.
197 # * BL2 is the U-Boot.
198 #
199 # samsung_bl1_{start,len}: Offset and maximum size for BL1
200 # samsung_bl2_{start,len}: Offset and maximum size for BL2
201 # samsung_env_{start,len}: Offset and maximum size for Environment settings
202 #
203 self.samsung_bl1_start = 1
204 self.samsung_bl1_len = 32
205 self.samsung_bl2_start = 65
206 self.samsung_bl2_len = 1024
207 self.samsung_env_start = 33
208 self.samsung_env_len = 32
209 # XXX: attributes that are not listed in hwpackV3, should be removed?
210 self.vmlinuz = None
211 self.initrd = None
212
213 # XXX: can be removed when killing v1 hwpack.
214 def _get_live_serial_opts(self):
215 return_value = self._live_serial_opts
216 if self._check_placeholder_presence(return_value, r'%s'):
217 return_value = self._live_serial_opts % self.serial_tty
218 return return_value
219
220 def _set_live_serial_opts(self, value):
221 self._live_serial_opts = value
222
223 live_serial_opts = property(_get_live_serial_opts, _set_live_serial_opts)
224
225 # XXX: can be removed when killing v1 hwpack.
226 def _get_extra_serial_opts(self):
227 return_value = self._extra_serial_opts
228 if self._check_placeholder_presence(return_value, r'%s'):
229 return_value = return_value % self.serial_tty
230 return return_value
231
232 def _set_extra_serial_opts(self, value):
233 self._extra_serial_opts = value
234
235 extra_serial_opts = property(_get_extra_serial_opts,
236 _set_extra_serial_opts)
237
238 def get_metadata_field(self, field_name):
191 """ Return the metadata value for field_name if it can be found.239 """ Return the metadata value for field_name if it can be found.
192 """240 """
193 data, _ = cls.hardwarepack_handler.get_field(field_name)241 data, _ = self.hardwarepack_handler.get_field(field_name)
194 return data242 return data
195243
196 @classmethod244 def set_metadata(self, hwpacks, bootloader=None, board=None):
197 def set_board(cls, board):245 self.hardwarepack_handler = HardwarepackHandler(hwpacks, bootloader,
198 cls.board = board
199
200 @classmethod
201 def set_metadata(cls, hwpacks, bootloader=None, board=None):
202 cls.hardwarepack_handler = HardwarepackHandler(hwpacks, bootloader,
203 board)246 board)
204 with cls.hardwarepack_handler:247 with self.hardwarepack_handler:
205 cls.hwpack_format = cls.hardwarepack_handler.get_format()248 self.hwpack_format = self.hardwarepack_handler.get_format()
206 if (cls.hwpack_format == cls.hardwarepack_handler.FORMAT_1):249 if (self.hwpack_format == self.hardwarepack_handler.FORMAT_1):
207 return250 return
208251
209 if (cls.hwpack_format != cls.hardwarepack_handler.FORMAT_1):252 if (self.hwpack_format != self.hardwarepack_handler.FORMAT_1):
210 # Clear V1 defaults.253 # Clear V1 defaults.
211 cls.kernel_addr = None254 # TODO When removing v1 support, remove also default values
212 cls.initrd_addr = None255 # in the constructor and avoid all this.
213 cls.load_addr = None256 self.kernel_addr = None
214 cls.serial_tty = None257 self.initrd_addr = None
215 cls.fat_size = None258 self.load_addr = None
216 cls.dtb_name = None259 self.serial_tty = None
217 cls.dtb_addr = None260 self.fat_size = None
218 cls.extra_boot_args_options = None261 self.dtb_name = None
219 cls.boot_script = None262 self.dtb_addr = None
220 cls.kernel_flavors = None263 self.extra_boot_args_options = None
221 cls.mmc_option = None264 self.boot_script = None
222 cls.mmc_part_offset = None265 self.kernel_flavors = None
223 cls.samsung_bl1_start = None266 self.mmc_option = None
224 cls.samsung_bl1_len = None267 self.mmc_part_offset = None
225 cls.samsung_env_len = None268 self.samsung_bl1_start = None
226 cls.samsung_bl2_len = None269 self.samsung_bl1_len = None
270 self.samsung_env_len = None
271 self.samsung_bl2_len = None
227 # cls.samsung_bl2_start and cls.samsung_env_start should272 # cls.samsung_bl2_start and cls.samsung_env_start should
228 # be initialized to default value for backward compatibility.273 # be initialized to default values for backward compatibility.
229274
275 self.board = board
230 # Set new values from metadata.276 # Set new values from metadata.
231 cls.kernel_addr = cls.get_metadata_field('kernel_addr')277 self.kernel_addr = self.get_metadata_field(KERNEL_ADDR_FIELD)
232 cls.initrd_addr = cls.get_metadata_field('initrd_addr')278 self.initrd_addr = self.get_metadata_field(INITRD_ADDR_FIELD)
233 cls.load_addr = cls.get_metadata_field('load_addr')279 self.load_addr = self.get_metadata_field(LOAD_ADDR_FIELD)
234 cls.dtb_addr = cls.get_metadata_field('dtb_addr')280 self.dtb_addr = self.get_metadata_field(DTB_ADDR_FIELD)
235 cls.serial_tty = cls.get_metadata_field('serial_tty')281 self.serial_tty = self.get_metadata_field(SERIAL_TTY_FIELD)
236 wired_interfaces = cls.get_metadata_field('wired_interfaces')282 wired_interfaces = self.get_metadata_field(WIRED_INTERFACES_FIELD)
237 if wired_interfaces is not None:283 if wired_interfaces:
238 cls.wired_interfaces = wired_interfaces284 self.wired_interfaces = wired_interfaces
239 wireless_interfaces = cls.get_metadata_field(285 wireless_interfaces = self.get_metadata_field(
240 'wireless_interfaces')286 WIRELESS_INTERFACES_FIELD)
241 if wireless_interfaces is not None:287 if wireless_interfaces:
242 cls.wireless_interfaces = wireless_interfaces288 self.wireless_interfaces = wireless_interfaces
243 cls.vmlinuz = cls.get_metadata_field('vmlinuz')289 self.dtb_file = self.get_metadata_field(DTB_FILE_FIELD)
244 cls.initrd = cls.get_metadata_field('initrd')290 # XXX: need to deprecate dtb_file field and use only dtb_files
245 cls.dtb_file = cls.get_metadata_field('dtb_file')291 # for multiple entries.
246 cls.dtb_files = cls.get_metadata_field('dtb_files')292 if self.dtb_file:
247 cls.extra_boot_args_options = cls.get_metadata_field(293 logger.warn("Deprecation warning: use the 'dtb_files' field "
248 'extra_boot_options')294 "instead of 'dtb_file'.")
249 cls.boot_script = cls.get_metadata_field('boot_script')295 self.dtb_files = self.get_metadata_field(DTB_FILES_FIELD)
250 cls.extra_serial_opts = cls.get_metadata_field(296 self.extra_boot_args_options = self.get_metadata_field(
251 'extra_serial_opts')297 EXTRA_BOOT_OPTIONS_FIELD)
252 cls.snowball_startup_files_config = cls.get_metadata_field(298 self.boot_script = self.get_metadata_field(BOOT_SCRIPT_FIELD)
253 'snowball_startup_files_config')299 self.extra_serial_opts = self.get_metadata_field(
254300 EXTRA_SERIAL_OPTIONS_FIELD)
255 cls.partition_layout = cls.get_metadata_field('partition_layout')301 self.snowball_startup_files_config = self.get_metadata_field(
256 if cls.partition_layout in [302 SNOWBALL_STARTUP_FILES_CONFIG_FIELD)
257 'bootfs_rootfs', 'reserved_bootfs_rootfs', None]:303 self.partition_layout = self.get_metadata_field(
258 cls.fat_size = 32304 PARTITION_LAYOUT_FIELD)
259 elif cls.partition_layout == 'bootfs16_rootfs':305 if self.partition_layout in [BOOTFS, RESERVED_BOOTFS, None]:
260 cls.fat_size = 16306 self.fat_size = 32
307 elif self.partition_layout == BOOTFS16:
308 self.fat_size = 16
261 else:309 else:
262 raise AssertionError("Unknown partition layout '%s'." % \310 raise AssertionError("Unknown partition layout '%s'." % \
263 cls.partition_layout)311 self.partition_layout)
264312
265 cls.mmc_option = cls.get_metadata_field('mmc_id')313 self.mmc_option = self.get_metadata_field(MMC_ID_FIELD)
266 if cls.mmc_option is not None:314 if self.mmc_option:
267 cls.mmc_device_id = int(cls.mmc_option.split(':')[0])315 self.mmc_device_id = int(self.mmc_option.split(':')[0])
268 cls.mmc_part_offset = int(cls.mmc_option.split(':')[1]) - 1316 self.mmc_part_offset = int(self.mmc_option.split(':')[1]) - 1
269317
270 boot_min_size = cls.get_metadata_field('boot_min_size')318 # XXX: need to fix these values.
271 if boot_min_size is not None:319 boot_min_size = self.get_metadata_field(BOOT_MIN_SIZE_FIELD)
272 cls.BOOT_MIN_SIZE_S = align_up(int(boot_min_size) * 1024 ** 2,320 if boot_min_size:
273 SECTOR_SIZE) / SECTOR_SIZE321 self.BOOT_MIN_SIZE_S = align_up(int(boot_min_size) * 1024 ** 2,
274 root_min_size = cls.get_metadata_field('root_min_size')322 SECTOR_SIZE) / SECTOR_SIZE
275 if root_min_size is not None:323 root_min_size = self.get_metadata_field(ROOT_MIN_SIZE_FIELD)
276 cls.ROOT_MIN_SIZE_S = align_up(int(root_min_size) * 1024 ** 2,324 if root_min_size:
277 SECTOR_SIZE) / SECTOR_SIZE325 self.ROOT_MIN_SIZE_S = align_up(int(root_min_size) * 1024 ** 2,
278 loader_min_size = cls.get_metadata_field('loader_min_size')326 SECTOR_SIZE) / SECTOR_SIZE
279 if loader_min_size is not None:327 loader_min_size = self.get_metadata_field(LOADER_MIN_SIZE_FIELD)
280 cls.LOADER_MIN_SIZE_S = (328 if loader_min_size:
329 self.LOADER_MIN_SIZE_S = (
281 align_up(int(loader_min_size) * 1024 ** 2,330 align_up(int(loader_min_size) * 1024 ** 2,
282 SECTOR_SIZE) / SECTOR_SIZE)331 SECTOR_SIZE) / SECTOR_SIZE)
283332
284 bootloader_file_in_boot_part = cls.get_metadata_field(333 spl_in_boot_part = self.get_metadata_field(SPL_IN_BOOT_PART_FIELD)
285 'bootloader_file_in_boot_part')
286 if bootloader_file_in_boot_part is None:
287 cls.bootloader_file_in_boot_part = False
288 elif string.lower(bootloader_file_in_boot_part) == 'yes':
289 cls.bootloader_file_in_boot_part = True
290 elif string.lower(bootloader_file_in_boot_part) == 'no':
291 cls.bootloader_file_in_boot_part = False
292 spl_in_boot_part = cls.get_metadata_field('spl_in_boot_part')
293 if spl_in_boot_part is None:334 if spl_in_boot_part is None:
294 cls.spl_in_boot_part = False335 self.spl_in_boot_part = False
295 elif string.lower(spl_in_boot_part) == 'yes':336 elif string.lower(spl_in_boot_part) == 'yes':
296 cls.spl_in_boot_part = True337 self.spl_in_boot_part = True
297 elif string.lower(spl_in_boot_part) == 'no':338 elif string.lower(spl_in_boot_part) == 'no':
298 cls.spl_in_boot_part = False339 self.spl_in_boot_part = False
299 env_dd = cls.get_metadata_field('env_dd')340
341 env_dd = self.get_metadata_field(ENV_DD_FIELD)
300 if env_dd is None:342 if env_dd is None:
301 cls.env_dd = False343 self.env_dd = False
302 elif string.lower(env_dd) == 'yes':344 elif string.lower(env_dd) == 'yes':
303 cls.env_dd = True345 self.env_dd = True
304 elif string.lower(env_dd) == 'no':346 elif string.lower(env_dd) == 'no':
305 cls.env_dd = False347 self.env_dd = False
306348
307 bootloader_dd = cls.get_metadata_field('bootloader_dd')349 # XXX: in hwpack v3 this field is just called 'dd'.
350 # Need to check its use.
351 bootloader_dd = self.get_metadata_field('bootloader_dd')
308 # Either bootloader_dd is not specified, or it contains the dd352 # Either bootloader_dd is not specified, or it contains the dd
309 # offset.353 # offset.
310 if bootloader_dd is None:354 if bootloader_dd is None:
311 cls.bootloader_dd = False355 self.bootloader_dd = False
312 else:356 else:
313 cls.bootloader_dd = int(bootloader_dd)357 self.bootloader_dd = int(bootloader_dd)
314 spl_dd = cls.get_metadata_field('spl_dd')358 spl_dd = self.get_metadata_field(SPL_DD_FIELD)
315 # Either spl_dd is not specified, or it contains the dd offset.359 # Either spl_dd is not specified, or it contains the dd offset.
316 if spl_dd is None:360 if spl_dd is None:
317 cls.spl_dd = False361 self.spl_dd = False
318 else:362 else:
319 cls.spl_dd = int(spl_dd)363 self.spl_dd = int(spl_dd)
320364
321 loader_start = cls.get_metadata_field('loader_start')365 loader_start = self.get_metadata_field(LOADER_START_FIELD)
322 if loader_start is not None:366 if loader_start:
323 cls.LOADER_START_S = int(loader_start)367 self.loader_start_s = int(loader_start)
324368
325 samsung_bl1_start = cls.get_metadata_field('samsung_bl1_start')369 samsung_bl1_start = self.get_metadata_field(
326 if samsung_bl1_start is not None:370 SAMSUNG_BL1_START_FIELD)
327 cls.samsung_bl1_start = int(samsung_bl1_start)371 if samsung_bl1_start:
328372 self.samsung_v310_bl1_start = int(samsung_bl1_start)
329 samsung_bl1_len = cls.get_metadata_field('samsung_bl1_len')373 samsung_bl1_len = self.get_metadata_field(SAMSUNG_BL1_LEN_FIELD)
330 if samsung_bl1_len is not None:374 if samsung_bl1_len:
331 cls.samsung_bl1_len = int(samsung_bl1_len)375 self.samsung_v310_bl1_len = int(samsung_bl1_len)
332376 samsung_env_len = self.get_metadata_field(SAMSUNG_ENV_LEN_FIELD)
333 samsung_bl2_len = cls.get_metadata_field('samsung_bl2_len')377 if samsung_env_len:
334 if samsung_bl2_len is not None:378 self.samsung_v310_env_len = int(samsung_env_len)
335 cls.samsung_bl2_len = int(samsung_bl2_len)379 samsung_bl2_len = self.get_metadata_field(SAMSUNG_BL2_LEN_FIELD)
336380 if samsung_bl2_len:
337 samsung_bl2_start = cls.get_metadata_field('samsung_bl2_start')381 self.samsung_v310_bl2_len = int(samsung_bl2_len)
338 if samsung_bl2_start is not None:382 samsung_bl2_start = self.get_metadata_field(
339 cls.samsung_bl2_start = int(samsung_bl2_start)383 SAMSUNG_BL2_START_FIELD)
340384 if samsung_bl2_start:
341 samsung_env_len = cls.get_metadata_field('samsung_env_len')385 self.samsung_bl2_start = int(samsung_bl2_start)
342 if samsung_env_len is not None:386 samsung_env_start = self.get_metadata_field(
343 cls.samsung_env_len = int(samsung_env_len)387 SAMSUNG_ENV_START_FILED)
344388 if samsung_env_start:
345 samsung_env_start = cls.get_metadata_field('samsung_env_start')389 self.samsung_env_start = int(samsung_env_start)
346 if samsung_env_start is not None:390
347 cls.samsung_env_start = int(samsung_env_start)391 self.bootloader_copy_files = self.hardwarepack_handler.get_field(
348
349 cls.bootloader_copy_files = cls.hardwarepack_handler.get_field(
350 "bootloader_copy_files")[0]392 "bootloader_copy_files")[0]
351393
352 cls.bootloader = cls.hardwarepack_handler.get_field(394 # XXX: no reference in hwpackV3 format of these fields, double
353 "bootloader")395 # check if they can be dropped when killing v1.
354 cls.board = board396 self.bootloader = self.hardwarepack_handler.get_field(
397 "bootloader")
398 self.vmlinuz = self.get_metadata_field('vmlinuz')
399 self.initrd = self.get_metadata_field('initrd')
400 bootloader_file_in_boot_part = self.get_metadata_field(
401 'bootloader_file_in_boot_part')
402 if bootloader_file_in_boot_part is None:
403 self.bootloader_file_in_boot_part = False
404 elif string.lower(bootloader_file_in_boot_part) == 'yes':
405 self.bootloader_file_in_boot_part = True
406 elif string.lower(bootloader_file_in_boot_part) == 'no':
407 self.bootloader_file_in_boot_part = False
355408
356 @classmethod409 def get_file(self, file_alias, default=None):
357 def get_file(cls, file_alias, default=None):
358 # XXX remove the 'default' parameter when V1 support is removed!410 # XXX remove the 'default' parameter when V1 support is removed!
359 file_in_hwpack = cls.hardwarepack_handler.get_file(file_alias)411 file_in_hwpack = self.hardwarepack_handler.get_file(file_alias)
360 if file_in_hwpack is not None:412 if file_in_hwpack is not None:
361 return file_in_hwpack413 return file_in_hwpack
362 else:414 else:
363 return default415 return default
364416
365 @classmethod417 def get_v1_sfdisk_cmd(self, should_align_boot_part=False):
366 def get_v1_sfdisk_cmd(cls, should_align_boot_part=False):418 # XXX: This default implementation and all overrides are left for V1
367 """Return the sfdisk command to partition the media.419 # compatibility only. They should be removed as part of the work to
368420 # kill off hwpacks V1.
369 :param should_align_boot_part: Whether to align the boot partition too.421 return self.get_normal_sfdisk_cmd(should_align_boot_part)
370422
371 This default implementation returns a boot vfat partition of type423 def get_normal_sfdisk_cmd(self, should_align_boot_part=False):
372 FAT16 or FAT32, followed by a root partition.
373
374 XXX: This default implementation and all overrides are left for V1
375 compatibility only. They should be removed as part of the work to
376 kill off hwpacks V1.
377 """
378 if cls.fat_size == 32:
379 partition_type = '0x0C'
380 else:
381 partition_type = '0x0E'
382
383 # align on sector 63 for compatibility with broken versions of x-loader
384 # unless align_boot_part is set
385 boot_align = 63
386 if should_align_boot_part:
387 boot_align = PART_ALIGN_S
388
389 # can only start on sector 1 (sector 0 is MBR / partition table)
390 boot_start, boot_end, boot_len = align_partition(
391 1, cls.BOOT_MIN_SIZE_S, boot_align, PART_ALIGN_S)
392 # apparently OMAP3 ROMs require the vfat length to be an even number
393 # of sectors (multiple of 1 KiB); decrease the length if it's odd,
394 # there should still be enough room
395 boot_len = boot_len - boot_len % 2
396 boot_end = boot_start + boot_len - 1
397
398 # we ignore _root_end / _root_len and return a sfdisk command to
399 # instruct the use of all remaining space; XXX if we had some root size
400 # config, we could do something more sensible
401 root_start, _root_end, _root_len = align_partition(
402 boot_end + 1, cls.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
403
404 return '%s,%s,%s,*\n%s,,,-' % (
405 boot_start, boot_len, partition_type, root_start)
406
407 @classmethod
408 def get_normal_sfdisk_cmd(cls, should_align_boot_part=False):
409 """Return the sfdisk command to partition the media.424 """Return the sfdisk command to partition the media.
410425
411 :param should_align_boot_part: Whether to align the boot partition too.426 :param should_align_boot_part: Whether to align the boot partition too.
@@ -413,7 +428,7 @@
413 This returns a boot vfat partition of type FAT16428 This returns a boot vfat partition of type FAT16
414 or FAT32, followed by a root partition.429 or FAT32, followed by a root partition.
415 """430 """
416 if cls.fat_size == 32:431 if self.fat_size == 32:
417 partition_type = '0x0C'432 partition_type = '0x0C'
418 else:433 else:
419 partition_type = '0x0E'434 partition_type = '0x0E'
@@ -427,7 +442,7 @@
427442
428 # can only start on sector 1 (sector 0 is MBR / partition table)443 # can only start on sector 1 (sector 0 is MBR / partition table)
429 boot_start, boot_end, boot_len = align_partition(444 boot_start, boot_end, boot_len = align_partition(
430 1, cls.BOOT_MIN_SIZE_S, boot_align, PART_ALIGN_S)445 1, self.BOOT_MIN_SIZE_S, boot_align, PART_ALIGN_S)
431 # apparently OMAP3 ROMs require the vfat length to be an even number446 # apparently OMAP3 ROMs require the vfat length to be an even number
432 # of sectors (multiple of 1 KiB); decrease the length if it's odd,447 # of sectors (multiple of 1 KiB); decrease the length if it's odd,
433 # there should still be enough room448 # there should still be enough room
@@ -439,13 +454,12 @@
439 # instruct the use of all remaining space; XXX we now have root size454 # instruct the use of all remaining space; XXX we now have root size
440 # config, so we can do something more sensible455 # config, so we can do something more sensible
441 root_start, _root_end, _root_len = align_partition(456 root_start, _root_end, _root_len = align_partition(
442 boot_end + 1, cls.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)457 boot_end + 1, self.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
443458
444 return '%s,%s,%s,*\n%s,,,-' % (459 return '%s,%s,%s,*\n%s,,,-' % (
445 boot_start, boot_len, partition_type, root_start)460 boot_start, boot_len, partition_type, root_start)
446461
447 @classmethod462 def get_reserved_sfdisk_cmd(self, should_align_boot_part=None):
448 def get_reserved_sfdisk_cmd(cls, should_align_boot_part=None):
449 """Return the sfdisk command to partition the media.463 """Return the sfdisk command to partition the media.
450464
451 :param should_align_boot_part: Ignored.465 :param should_align_boot_part: Ignored.
@@ -454,40 +468,38 @@
454 FAT16 or FAT32, followed by a root partition.468 FAT16 or FAT32, followed by a root partition.
455 """469 """
456 loader_start, loader_end, loader_len = align_partition(470 loader_start, loader_end, loader_len = align_partition(
457 cls.LOADER_START_S, cls.LOADER_MIN_SIZE_S, 1, PART_ALIGN_S)471 self.loader_start_s, self.LOADER_MIN_SIZE_S, 1, PART_ALIGN_S)
458472
459 boot_start, boot_end, boot_len = align_partition(473 boot_start, boot_end, boot_len = align_partition(
460 loader_end + 1, cls.BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)474 loader_end + 1, self.BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
461475
462 root_start, _root_end, _root_len = align_partition(476 root_start, _root_end, _root_len = align_partition(
463 boot_end + 1, cls.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)477 boot_end + 1, self.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
464478
465 return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % (479 return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % (
466 loader_start, loader_len, boot_start, boot_len, root_start)480 loader_start, loader_len, boot_start, boot_len, root_start)
467481
468 @classmethod482 def get_sfdisk_cmd(self, should_align_boot_part=False):
469 def get_sfdisk_cmd(cls, should_align_boot_part=False):483 if (self.partition_layout in ['bootfs_rootfs', 'bootfs16_rootfs'] or
470 if (cls.partition_layout in ['bootfs_rootfs', 'bootfs16_rootfs'] or484 self.board == 'snowball_sd'):
471 cls.board == 'snowball_sd'):485 return self.get_normal_sfdisk_cmd(should_align_boot_part)
472 return cls.get_normal_sfdisk_cmd(should_align_boot_part)486 elif self.partition_layout in ['reserved_bootfs_rootfs']:
473 elif cls.partition_layout in ['reserved_bootfs_rootfs']:487 return self.get_reserved_sfdisk_cmd(should_align_boot_part)
474 return cls.get_reserved_sfdisk_cmd(should_align_boot_part)
475 else:488 else:
476 assert (cls.hwpack_format == HardwarepackHandler.FORMAT_1), (489 assert (self.hwpack_format == HardwarepackHandler.FORMAT_1), (
477 "Hwpack format is not 1.0 but "490 "Hwpack format is not 1.0 but "
478 "partition_layout is unspecified.")491 "partition_layout is unspecified.")
479 return cls.get_v1_sfdisk_cmd(should_align_boot_part)492 return self.get_v1_sfdisk_cmd(should_align_boot_part)
480493
481 @classmethod494 def _get_bootcmd(self, i_img_data, d_img_data):
482 def _get_bootcmd(cls, i_img_data, d_img_data):
483 """Get the bootcmd for this board.495 """Get the bootcmd for this board.
484496
485 In general subclasses should not have to override this.497 In general subclasses should not have to override this.
486 """498 """
487 replacements = dict(499 replacements = dict(
488 fatload_command=cls.fatload_command, uimage_path=cls.uimage_path,500 fatload_command=self.fatload_command, uimage_path=self.uimage_path,
489 mmc_option=cls.mmc_option, kernel_addr=cls.kernel_addr,501 mmc_option=self.mmc_option, kernel_addr=self.kernel_addr,
490 initrd_addr=cls.initrd_addr, dtb_addr=cls.dtb_addr)502 initrd_addr=self.initrd_addr, dtb_addr=self.dtb_addr)
491 boot_script = (503 boot_script = (
492 ("%(fatload_command)s mmc %(mmc_option)s %(kernel_addr)s " +504 ("%(fatload_command)s mmc %(mmc_option)s %(kernel_addr)s " +
493 "%(uimage_path)suImage; ")) % replacements505 "%(uimage_path)suImage; ")) % replacements
@@ -496,7 +508,7 @@
496 ("%(fatload_command)s mmc %(mmc_option)s %(initrd_addr)s " +508 ("%(fatload_command)s mmc %(mmc_option)s %(initrd_addr)s " +
497 "%(uimage_path)suInitrd; ")) % replacements509 "%(uimage_path)suInitrd; ")) % replacements
498 if d_img_data is not None:510 if d_img_data is not None:
499 assert cls.dtb_addr is not None, (511 assert self.dtb_addr is not None, (
500 "Need a dtb_addr when passing d_img_data")512 "Need a dtb_addr when passing d_img_data")
501 boot_script += (513 boot_script += (
502 ("%(fatload_command)s mmc %(mmc_option)s %(dtb_addr)s " +514 ("%(fatload_command)s mmc %(mmc_option)s %(dtb_addr)s " +
@@ -508,37 +520,34 @@
508 boot_script += ((" %(dtb_addr)s")) % replacements520 boot_script += ((" %(dtb_addr)s")) % replacements
509 return boot_script521 return boot_script
510522
511 @classmethod523 def add_boot_args(self, extra_args):
512 def add_boot_args(cls, extra_args):
513 if extra_args is not None:524 if extra_args is not None:
514 if cls.extra_boot_args_options is None:525 if self.extra_boot_args_options is None:
515 cls.extra_boot_args_options = extra_args526 self.extra_boot_args_options = extra_args
516 else:527 else:
517 cls.extra_boot_args_options += ' %s' % extra_args528 self.extra_boot_args_options += ' %s' % extra_args
518529
519 @classmethod530 def add_boot_args_from_file(self, path):
520 def add_boot_args_from_file(cls, path):
521 if path is not None:531 if path is not None:
522 with open(path, 'r') as boot_args_file:532 with open(path, 'r') as boot_args_file:
523 cls.add_boot_args(boot_args_file.read().strip())533 self.add_boot_args(boot_args_file.read().strip())
524534
525 @classmethod535 def _get_bootargs(self, is_live, is_lowmem, consoles, rootfs_id):
526 def _get_bootargs(cls, is_live, is_lowmem, consoles, rootfs_id):
527 """Get the bootargs for this board.536 """Get the bootargs for this board.
528537
529 In general subclasses should not have to override this.538 In general subclasses should not have to override this.
530 """539 """
531 boot_args_options = 'rootwait ro'540 boot_args_options = 'rootwait ro'
532 if cls.extra_boot_args_options is not None:541 if self.extra_boot_args_options:
533 boot_args_options += ' %s' % cls.extra_boot_args_options542 boot_args_options += ' %s' % self.extra_boot_args_options
534 serial_opts = cls.extra_serial_opts543 serial_opts = self.extra_serial_opts
535 for console in consoles:544 for console in consoles:
536 serial_opts += ' console=%s' % console545 serial_opts += ' console=%s' % console
537546
538 lowmem_opt = ''547 lowmem_opt = ''
539 boot_snippet = 'root=%s' % rootfs_id548 boot_snippet = 'root=%s' % rootfs_id
540 if is_live:549 if is_live:
541 serial_opts += ' %s' % cls.live_serial_opts550 serial_opts += ' %s' % self.live_serial_opts
542 boot_snippet = 'boot=casper'551 boot_snippet = 'boot=casper'
543 if is_lowmem:552 if is_lowmem:
544 lowmem_opt = 'only-ubiquity'553 lowmem_opt = 'only-ubiquity'
@@ -552,45 +561,42 @@
552 "%(boot_snippet)s %(boot_args_options)s"561 "%(boot_snippet)s %(boot_args_options)s"
553 % replacements)562 % replacements)
554563
555 @classmethod564 def _get_boot_env(self, is_live, is_lowmem, consoles, rootfs_id,
556 def _get_boot_env(cls, is_live, is_lowmem, consoles, rootfs_id,
557 i_img_data, d_img_data):565 i_img_data, d_img_data):
558 """Get the boot environment for this board.566 """Get the boot environment for this board.
559567
560 In general subclasses should not have to override this.568 In general subclasses should not have to override this.
561 """569 """
562 boot_env = {}570 boot_env = {}
563 boot_env["bootargs"] = cls._get_bootargs(571 boot_env["bootargs"] = self._get_bootargs(
564 is_live, is_lowmem, consoles, rootfs_id)572 is_live, is_lowmem, consoles, rootfs_id)
565 boot_env["bootcmd"] = cls._get_bootcmd(i_img_data, d_img_data)573 boot_env["bootcmd"] = self._get_bootcmd(i_img_data, d_img_data)
566 boot_env["initrd_high"] = cls.initrd_high574 boot_env["initrd_high"] = self.initrd_high
567 boot_env["fdt_high"] = cls.fdt_high575 boot_env["fdt_high"] = self.fdt_high
568 return boot_env576 return boot_env
569577
570 @classmethod578 def make_boot_files(self, bootloader_parts_dir, is_live, is_lowmem,
571 def make_boot_files(cls, bootloader_parts_dir, is_live, is_lowmem,
572 consoles, chroot_dir, rootfs_id, boot_dir,579 consoles, chroot_dir, rootfs_id, boot_dir,
573 boot_device_or_file):580 boot_device_or_file):
574 if cls.hwpack_format == HardwarepackHandler.FORMAT_1:581 if self.hwpack_format == HardwarepackHandler.FORMAT_1:
575 parts_dir = bootloader_parts_dir582 parts_dir = bootloader_parts_dir
576 else:583 else:
577 parts_dir = chroot_dir584 parts_dir = chroot_dir
578 (k_img_data, i_img_data, d_img_data) = cls._get_kflavor_files(585 (k_img_data, i_img_data, d_img_data) = self._get_kflavor_files(
579 parts_dir)586 parts_dir)
580 boot_env = cls._get_boot_env(is_live, is_lowmem, consoles, rootfs_id,587 boot_env = self._get_boot_env(is_live, is_lowmem, consoles, rootfs_id,
581 i_img_data, d_img_data)588 i_img_data, d_img_data)
582589
583 if cls.hwpack_format == HardwarepackHandler.FORMAT_1:590 if self.hwpack_format == HardwarepackHandler.FORMAT_1:
584 cls._make_boot_files(591 self._make_boot_files(
585 boot_env, chroot_dir, boot_dir,592 boot_env, chroot_dir, boot_dir,
586 boot_device_or_file, k_img_data, i_img_data, d_img_data)593 boot_device_or_file, k_img_data, i_img_data, d_img_data)
587 else:594 else:
588 cls._make_boot_files_v2(595 self._make_boot_files_v2(
589 boot_env, chroot_dir, boot_dir,596 boot_env, chroot_dir, boot_dir,
590 boot_device_or_file, k_img_data, i_img_data, d_img_data)597 boot_device_or_file, k_img_data, i_img_data, d_img_data)
591598
592 @classmethod599 def _copy_dtb_files(self, dtb_files, dest_dir, search_dir):
593 def _copy_dtb_files(cls, dtb_files, dest_dir, search_dir):
594 """Copy the files defined in dtb_files into the boot directory.600 """Copy the files defined in dtb_files into the boot directory.
595601
596 :param dtb_files: The list of dtb files602 :param dtb_files: The list of dtb files
@@ -630,13 +636,12 @@
630 else:636 else:
631 # Hopefully we should never get here.637 # Hopefully we should never get here.
632 # This should only happen if the hwpack config YAML file is638 # This should only happen if the hwpack config YAML file is
633 # wrong639 # wrong.
634 logger.warn('WARNING: Wrong syntax in metadata file. '640 logger.warn('WARNING: Wrong syntax in metadata file. '
635 'Check the hwpack configuration file used to '641 'Check the hwpack configuration file used to '
636 'generate the hwpack archive.')642 'generate the hwpack archive.')
637643
638 @classmethod644 def _dd_file(self, from_file, to_file, seek, max_size=None):
639 def _dd_file(cls, from_file, to_file, seek, max_size=None):
640 assert from_file is not None, "No source file name given."645 assert from_file is not None, "No source file name given."
641 if max_size is not None:646 if max_size is not None:
642 assert os.path.getsize(from_file) <= max_size, (647 assert os.path.getsize(from_file) <= max_size, (
@@ -644,23 +649,21 @@
644 logger.info("Writing '%s' to '%s' at %s." % (from_file, to_file, seek))649 logger.info("Writing '%s' to '%s' at %s." % (from_file, to_file, seek))
645 _dd(from_file, to_file, seek=seek)650 _dd(from_file, to_file, seek=seek)
646651
647 @classmethod652 def install_samsung_boot_loader(self, samsung_spl_file, bootloader_file,
648 def install_samsung_boot_loader(cls, samsung_spl_file, bootloader_file,
649 boot_device_or_file):653 boot_device_or_file):
650 cls._dd_file(samsung_spl_file, boot_device_or_file,654 self._dd_file(samsung_spl_file, boot_device_or_file,
651 cls.samsung_bl1_start,655 self.samsung_bl1_start,
652 cls.samsung_bl1_len * SECTOR_SIZE)656 self.samsung_bl1_len * SECTOR_SIZE)
653 cls._dd_file(bootloader_file, boot_device_or_file,657 self._dd_file(bootloader_file, boot_device_or_file,
654 cls.samsung_bl2_start,658 self.samsung_bl2_start,
655 cls.samsung_bl2_len * SECTOR_SIZE)659 self.samsung_bl2_len * SECTOR_SIZE)
656660
657 @classmethod661 def _make_boot_files_v2(self, boot_env, chroot_dir, boot_dir,
658 def _make_boot_files_v2(cls, boot_env, chroot_dir, boot_dir,
659 boot_device_or_file, k_img_data, i_img_data,662 boot_device_or_file, k_img_data, i_img_data,
660 d_img_data):663 d_img_data):
661 with cls.hardwarepack_handler:664 with self.hardwarepack_handler:
662 spl_file = cls.get_file('spl_file')665 spl_file = self.get_file('spl_file')
663 if cls.spl_in_boot_part:666 if self.spl_in_boot_part:
664 assert spl_file is not None, (667 assert spl_file is not None, (
665 "SPL binary could not be found")668 "SPL binary could not be found")
666 logger.info(669 logger.info(
@@ -670,15 +673,15 @@
670 # XXX: Is this really needed?673 # XXX: Is this really needed?
671 cmd_runner.run(["sync"]).wait()674 cmd_runner.run(["sync"]).wait()
672675
673 if cls.spl_dd:676 if self.spl_dd:
674 cls._dd_file(spl_file, boot_device_or_file, cls.spl_dd)677 self._dd_file(spl_file, boot_device_or_file, self.spl_dd)
675678
676 bootloader_file = cls.get_file('bootloader_file')679 bootloader_file = self.get_file('bootloader_file')
677 if cls.bootloader_dd:680 if self.bootloader_dd:
678 cls._dd_file(bootloader_file, boot_device_or_file,681 self._dd_file(bootloader_file, boot_device_or_file,
679 cls.bootloader_dd)682 self.bootloader_dd)
680683
681 make_uImage(cls.load_addr, k_img_data, boot_dir)684 make_uImage(self.load_addr, k_img_data, boot_dir)
682685
683 if i_img_data is not None:686 if i_img_data is not None:
684 make_uInitrd(i_img_data, boot_dir)687 make_uInitrd(i_img_data, boot_dir)
@@ -686,29 +689,28 @@
686 if d_img_data is not None:689 if d_img_data is not None:
687 make_dtb(d_img_data, boot_dir)690 make_dtb(d_img_data, boot_dir)
688691
689 if cls.boot_script is not None:692 if self.boot_script is not None:
690 boot_script_path = os.path.join(boot_dir, cls.boot_script)693 boot_script_path = os.path.join(boot_dir, self.boot_script)
691 make_boot_script(boot_env, boot_script_path)694 make_boot_script(boot_env, boot_script_path)
692695
693 # Only used for Omap, will this be bad for the other boards?696 # Only used for Omap, will this be bad for the other boards?
694 make_boot_ini(boot_script_path, boot_dir)697 make_boot_ini(boot_script_path, boot_dir)
695698
696 if (cls.snowball_startup_files_config is not None and699 if (self.snowball_startup_files_config is not None and
697 cls.board != 'snowball_sd'):700 self.board != 'snowball_sd'):
698 cls.populate_raw_partition(boot_device_or_file, chroot_dir)701 self.populate_raw_partition(boot_device_or_file, chroot_dir)
699702
700 if cls.env_dd:703 if self.env_dd:
701 # Do we need to zero out the env before flashing it?704 # Do we need to zero out the env before flashing it?
702 _dd("/dev/zero", boot_device_or_file,705 _dd("/dev/zero", boot_device_or_file,
703 count=cls.samsung_env_len,706 count=self.samsung_env_len,
704 seek=cls.samsung_env_start)707 seek=self.samsung_env_start)
705 env_size = cls.samsung_env_len * SECTOR_SIZE708 env_size = self.samsung_env_len * SECTOR_SIZE
706 env_file = make_flashable_env(boot_env, env_size)709 env_file = make_flashable_env(boot_env, env_size)
707 cls._dd_file(env_file, boot_device_or_file,710 self._dd_file(env_file, boot_device_or_file,
708 cls.samsung_env_start)711 self.samsung_env_start)
709712
710 @classmethod713 def _make_boot_files(self, boot_env, chroot_dir, boot_dir,
711 def _make_boot_files(cls, boot_env, chroot_dir, boot_dir,
712 boot_device_or_file, k_img_data, i_img_data,714 boot_device_or_file, k_img_data, i_img_data,
713 d_img_data):715 d_img_data):
714 """Make the necessary boot files for this board.716 """Make the necessary boot files for this board.
@@ -718,8 +720,7 @@
718 """720 """
719 raise NotImplementedError()721 raise NotImplementedError()
720722
721 @classmethod723 def populate_boot(self, chroot_dir, rootfs_id, boot_partition, boot_disk,
722 def populate_boot(cls, chroot_dir, rootfs_id, boot_partition, boot_disk,
723 boot_device_or_file, is_live, is_lowmem, consoles):724 boot_device_or_file, is_live, is_lowmem, consoles):
724 parts_dir = 'boot'725 parts_dir = 'boot'
725 if is_live:726 if is_live:
@@ -727,21 +728,21 @@
727 bootloader_parts_dir = os.path.join(chroot_dir, parts_dir)728 bootloader_parts_dir = os.path.join(chroot_dir, parts_dir)
728 cmd_runner.run(['mkdir', '-p', boot_disk]).wait()729 cmd_runner.run(['mkdir', '-p', boot_disk]).wait()
729 with partition_mounted(boot_partition, boot_disk):730 with partition_mounted(boot_partition, boot_disk):
730 with cls.hardwarepack_handler:731 with self.hardwarepack_handler:
731 if cls.bootloader_file_in_boot_part:732 if self.bootloader_file_in_boot_part:
732 # <legacy v1 support>733 # <legacy v1 support>
733 if cls.bootloader_flavor is not None:734 if self.bootloader_flavor is not None:
734 default = os.path.join(735 default = os.path.join(
735 chroot_dir, 'usr', 'lib', 'u-boot',736 chroot_dir, 'usr', 'lib', 'u-boot',
736 cls.bootloader_flavor, 'u-boot.img')737 self.bootloader_flavor, 'u-boot.img')
737 if not os.path.exists(default):738 if not os.path.exists(default):
738 default = os.path.join(739 default = os.path.join(
739 chroot_dir, 'usr', 'lib', 'u-boot',740 chroot_dir, 'usr', 'lib', 'u-boot',
740 cls.bootloader_flavor, 'u-boot.bin')741 self.bootloader_flavor, 'u-boot.bin')
741 else:742 else:
742 default = None743 default = None
743 # </legacy v1 support>744 # </legacy v1 support>
744 bootloader_bin = cls.get_file('bootloader_file',745 bootloader_bin = self.get_file('bootloader_file',
745 default=default)746 default=default)
746 assert bootloader_bin is not None, (747 assert bootloader_bin is not None, (
747 "bootloader binary could not be found")748 "bootloader binary could not be found")
@@ -751,18 +752,17 @@
751 proc.wait()752 proc.wait()
752753
753 # Handle copy_files field.754 # Handle copy_files field.
754 cls.copy_files(boot_disk)755 self.copy_files(boot_disk)
755756
756 # Handle dtb_files field.757 # Handle dtb_files field.
757 if cls.dtb_files:758 if self.dtb_files:
758 cls._copy_dtb_files(cls.dtb_files, boot_disk, chroot_dir)759 self._copy_dtb_files(self.dtb_files, boot_disk, chroot_dir)
759760
760 cls.make_boot_files(761 self.make_boot_files(
761 bootloader_parts_dir, is_live, is_lowmem, consoles, chroot_dir,762 bootloader_parts_dir, is_live, is_lowmem, consoles, chroot_dir,
762 rootfs_id, boot_disk, boot_device_or_file)763 rootfs_id, boot_disk, boot_device_or_file)
763764
764 @classmethod765 def copy_files(self, boot_disk):
765 def copy_files(cls, boot_disk):
766 """Handle the copy_files metadata field."""766 """Handle the copy_files metadata field."""
767767
768 # Extract anything specified by copy_files sections768 # Extract anything specified by copy_files sections
@@ -772,13 +772,14 @@
772 # {'source_path': 'dest_path'}772 # {'source_path': 'dest_path'}
773 # ]773 # ]
774 # }774 # }
775 if cls.bootloader_copy_files is None:775 if self.bootloader_copy_files is None:
776 return776 return
777777
778 for source_package, file_list in cls.bootloader_copy_files.iteritems():778 for source_package, file_list in \
779 self.bootloader_copy_files.iteritems():
779 for file_info in file_list:780 for file_info in file_list:
780 for source_path, dest_path in file_info.iteritems():781 for source_path, dest_path in file_info.iteritems():
781 source = cls.hardwarepack_handler.get_file_from_package(782 source = self.hardwarepack_handler.get_file_from_package(
782 source_path, source_package)783 source_path, source_package)
783 dest_path = dest_path.lstrip("/\\")784 dest_path = dest_path.lstrip("/\\")
784 dirname = os.path.dirname(dest_path)785 dirname = os.path.dirname(dest_path)
@@ -791,25 +792,24 @@
791 os.path.join(boot_disk, dest_path)], as_root=True)792 os.path.join(boot_disk, dest_path)], as_root=True)
792 proc.wait()793 proc.wait()
793794
794 @classmethod795 def _get_kflavor_files(self, path):
795 def _get_kflavor_files(cls, path):
796 """Search for kernel, initrd and optional dtb in path."""796 """Search for kernel, initrd and optional dtb in path."""
797 if cls.kernel_flavors is None:797 if self.kernel_flavors is None:
798 # V2 metadata specifies each glob, not flavors.798 # V2 metadata specifies each glob, not flavors.
799 # XXX This duplication is temporary until V1 dies.799 # XXX This duplication is temporary until V1 dies.
800 return cls._get_kflavor_files_v2(path)800 return self._get_kflavor_files_v2(path)
801801
802 for flavor in cls.kernel_flavors:802 for flavor in self.kernel_flavors:
803 kregex = KERNEL_GLOB % {'kernel_flavor': flavor}803 kregex = KERNEL_GLOB % {'kernel_flavor': flavor}
804 iregex = INITRD_GLOB % {'kernel_flavor': flavor}804 iregex = INITRD_GLOB % {'kernel_flavor': flavor}
805 dregex = DTB_GLOB % {'kernel_flavor': flavor,805 dregex = DTB_GLOB % {'kernel_flavor': flavor,
806 'dtb_name': cls.dtb_name}806 'dtb_name': self.dtb_name}
807 kernel = _get_file_matching(os.path.join(path, kregex))807 kernel = _get_file_matching(os.path.join(path, kregex))
808 if kernel is not None:808 if kernel is not None:
809 initrd = _get_file_matching(os.path.join(path, iregex))809 initrd = _get_file_matching(os.path.join(path, iregex))
810 if initrd is not None:810 if initrd is not None:
811 dtb = None811 dtb = None
812 if cls.dtb_name is not None:812 if self.dtb_name is not None:
813 dtb = _get_file_matching(os.path.join(path, dregex))813 dtb = _get_file_matching(os.path.join(path, dregex))
814 return (kernel, initrd, dtb)814 return (kernel, initrd, dtb)
815 raise ValueError(815 raise ValueError(
@@ -817,83 +817,83 @@
817 flavor, iregex))817 flavor, iregex))
818 raise ValueError(818 raise ValueError(
819 "No kernel found matching %s for flavors %s" % (819 "No kernel found matching %s for flavors %s" % (
820 KERNEL_GLOB, " ".join(cls.kernel_flavors)))820 KERNEL_GLOB, " ".join(self.kernel_flavors)))
821821
822 @classmethod822 def _get_kflavor_files_v2(self, path):
823 def _get_kflavor_files_v2(cls, path):
824 kernel = initrd = dtb = None823 kernel = initrd = dtb = None
825824
826 if cls.vmlinuz:825 if self.vmlinuz:
827 kernel = _get_file_matching(os.path.join(path, cls.vmlinuz))826 kernel = _get_file_matching(os.path.join(path, self.vmlinuz))
828 if not cls.vmlinuz or not kernel:827 if not self.vmlinuz or not kernel:
829 raise ValueError("Unable to find a valid kernel image.")828 raise ValueError("Unable to find a valid kernel image.")
830829
831 if cls.initrd:830 if self.initrd:
832 initrd = _get_file_matching(os.path.join(path, cls.initrd))831 initrd = _get_file_matching(os.path.join(path, self.initrd))
833 if not cls.initrd or not initrd:832 if not self.initrd or not initrd:
834 logger.warn("Could not find a valid initrd, skipping uInitd.")833 logger.warn("Could not find a valid initrd, skipping uInitd.")
835834
836 if cls.dtb_file:835 if self.dtb_file:
837 dtb = _get_file_matching(os.path.join(path, cls.dtb_file))836 dtb = _get_file_matching(os.path.join(path, self.dtb_file))
838 if not cls.dtb_file or not dtb:837 if not self.dtb_file or not dtb:
839 logger.warn("Could not find a valid dtb file, skipping it.")838 logger.warn("Could not find a valid dtb file, skipping it.")
840839
841 logger.info("Will use kernel=%s, initrd=%s, dtb=%s." % \840 logger.info("Will use kernel=%s, initrd=%s, dtb=%s." % \
842 (kernel, initrd, dtb))841 (kernel, initrd, dtb))
843 return (kernel, initrd, dtb)842 return (kernel, initrd, dtb)
844843
845 @classmethod844 def populate_raw_partition(self, media, boot_dir):
846 def populate_raw_partition(cls, media, boot_dir):
847 # Override in subclass if needed845 # Override in subclass if needed
848 pass846 pass
849847
850 @classmethod848 def snowball_config(self, chroot_dir):
851 def snowball_config(cls, chroot_dir):
852 # Override in subclasses where applicable849 # Override in subclasses where applicable
853 raise NotImplementedError(850 raise NotImplementedError(
854 "snowball_config() must only be called on BoardConfigs that "851 "snowball_config() must only be called on BoardConfigs that "
855 "use the Snowball startupfiles.")852 "use the Snowball startupfiles.")
856853
854 # XXX: can be removed when killing v1 hwpack and updating the attributes
855 # that use it.
856 @staticmethod
857 def _check_placeholder_presence(string, placeholder):
858 """Checks if the passed string contains the particular placeholder."""
859 # Very simple way of achieving that.
860 presence = False
861 if placeholder in string:
862 presence = True
863 return presence
864
857865
858class OmapConfig(BoardConfig):866class OmapConfig(BoardConfig):
859 kernel_flavors = ['linaro-omap4', 'linaro-lt-omap', 'linaro-omap', 'omap4']867
860 bootloader_file_in_boot_part = True868 def __init__(self):
861869 super(OmapConfig, self).__init__()
862 # XXX: Here we define these things as dynamic properties because our870 self.kernel_flavors = ['linaro-omap4', 'linaro-lt-omap',
863 # temporary hack to fix bug 697824 relies on changing the board's871 'linaro-omap', 'omap4']
864 # serial_tty at run time.872 self.bootloader_file_in_boot_part = True
865 _extra_serial_opts = None873 # XXX: Here we define these things as dynamic properties because our
866 _live_serial_opts = None874 # temporary hack to fix bug 697824 relies on changing the board's
867 _serial_tty = None875 # serial_tty at run time.
868876 self._serial_tty = None
869 @classproperty877
870 def serial_tty(cls):878 # XXX: when killing v1 hwpack this should be safely removed.
871 # This is just to make sure no callsites use .serial_tty before879 def _get_serial_tty(self):
872 # calling set_appropriate_serial_tty(). If we had this in the first880 return self._serial_tty
873 # place we'd have uncovered bug 710971 before releasing.881
874 raise AttributeError(882 def _set_serial_tty(self, value):
875 "You must not use this attribute before calling "883 self._serial_tty = value
876 "set_appropriate_serial_tty")884
877885 serial_tty = property(_get_serial_tty, _set_serial_tty)
878 @classproperty886
879 def live_serial_opts(cls):887 def set_appropriate_serial_tty(self, chroot_dir):
880 return cls._live_serial_opts % cls.serial_tty
881
882 @classproperty
883 def extra_serial_opts(cls):
884 return cls._extra_serial_opts % cls.serial_tty
885
886 @classmethod
887 def set_appropriate_serial_tty(cls, chroot_dir):
888 """Set the appropriate serial_tty depending on the kernel used.888 """Set the appropriate serial_tty depending on the kernel used.
889889
890 If the kernel found in the chroot dir is << 2.6.36 we use tyyS2, else890 If the kernel found in the chroot dir is << 2.6.36 we use tyyS2, else
891 we use the default value (_serial_tty).891 we use the default value (_serial_tty).
892 """892 """
893 # XXX: delete this method when hwpacks V1 can die893 # XXX: delete this method when hwpacks V1 can die
894 assert cls.hwpack_format == HardwarepackHandler.FORMAT_1894 assert self.hwpack_format == HardwarepackHandler.FORMAT_1
895 # XXX: This is also part of our temporary hack to fix bug 697824.895 # XXX: This is also part of our temporary hack to fix bug 697824.
896 cls.serial_tty = classproperty(lambda cls: cls._serial_tty)896 # cls.serial_tty = classproperty(lambda cls: cls._serial_tty)
897 vmlinuz = _get_file_matching(897 vmlinuz = _get_file_matching(
898 os.path.join(chroot_dir, 'boot', 'vmlinuz*'))898 os.path.join(chroot_dir, 'boot', 'vmlinuz*'))
899 basename = os.path.basename(vmlinuz)899 basename = os.path.basename(vmlinuz)
@@ -902,135 +902,134 @@
902 if match is not None:902 if match is not None:
903 minor_version = match.group(1)903 minor_version = match.group(1)
904 if int(minor_version) < 36:904 if int(minor_version) < 36:
905 cls.serial_tty = classproperty(lambda cls: 'ttyS2')905 self.serial_tty = 'ttyS2'
906906
907 @classmethod907 def make_boot_files(self, bootloader_parts_dir, is_live, is_lowmem,
908 def make_boot_files(cls, bootloader_parts_dir, is_live, is_lowmem,
909 consoles, chroot_dir, rootfs_id, boot_dir,908 consoles, chroot_dir, rootfs_id, boot_dir,
910 boot_device_or_file):909 boot_device_or_file):
911 # XXX: This is also part of our temporary hack to fix bug 697824; we910 # XXX: This is also part of our temporary hack to fix bug 697824; we
912 # need to call set_appropriate_serial_tty() before doing anything that911 # need to call set_appropriate_serial_tty() before doing anything that
913 # may use cls.serial_tty.912 # may use self.serial_tty.
914 if cls.hwpack_format == HardwarepackHandler.FORMAT_1:913 if self.hwpack_format == HardwarepackHandler.FORMAT_1:
915 cls.set_appropriate_serial_tty(chroot_dir)914 self.set_appropriate_serial_tty(chroot_dir)
916 super(OmapConfig, cls).make_boot_files(915 super(OmapConfig, self).make_boot_files(
917 bootloader_parts_dir, is_live, is_lowmem, consoles, chroot_dir,916 bootloader_parts_dir, is_live, is_lowmem, consoles, chroot_dir,
918 rootfs_id, boot_dir, boot_device_or_file)917 rootfs_id, boot_dir, boot_device_or_file)
919918
920 @classmethod919 def _make_boot_files(self, boot_env, chroot_dir, boot_dir,
921 def _make_boot_files(cls, boot_env, chroot_dir, boot_dir,
922 boot_device_or_file, k_img_data, i_img_data,920 boot_device_or_file, k_img_data, i_img_data,
923 d_img_data):921 d_img_data):
924 # XXX: delete this method when hwpacks V1 can die922 # XXX: delete this method when hwpacks V1 can die
925 assert cls.hwpack_format == HardwarepackHandler.FORMAT_1923 assert self.hwpack_format == HardwarepackHandler.FORMAT_1
926 install_omap_boot_loader(chroot_dir, boot_dir, cls)924 install_omap_boot_loader(chroot_dir, boot_dir, self)
927 make_uImage(cls.load_addr, k_img_data, boot_dir)925 make_uImage(self.load_addr, k_img_data, boot_dir)
928 make_uInitrd(i_img_data, boot_dir)926 make_uInitrd(i_img_data, boot_dir)
929 make_dtb(d_img_data, boot_dir)927 make_dtb(d_img_data, boot_dir)
930 boot_script_path = os.path.join(boot_dir, cls.boot_script)928 boot_script_path = os.path.join(boot_dir, self.boot_script)
931 make_boot_script(boot_env, boot_script_path)929 make_boot_script(boot_env, boot_script_path)
932 make_boot_ini(boot_script_path, boot_dir)930 make_boot_ini(boot_script_path, boot_dir)
933931
934932
935class BeagleConfig(OmapConfig):933class BeagleConfig(OmapConfig):
936 bootloader_flavor = 'omap3_beagle'934
937 dtb_name = 'omap3-beagle.dtb'935 def __init__(self):
938 _serial_tty = 'ttyO2'936 super(BeagleConfig, self).__init__()
939 _extra_serial_opts = 'console=tty0 console=%s,115200n8'937 self.boot_script = 'boot.scr'
940 _live_serial_opts = 'serialtty=%s'938 self.bootloader_flavor = 'omap3_beagle'
941 kernel_addr = '0x80000000'939 self.dtb_addr = '0x815f0000'
942 dtb_addr = '0x815f0000'940 self.dtb_name = 'omap3-beagle.dtb'
943 initrd_addr = '0x81600000'941 self.extra_boot_args_options = (
944 load_addr = '0x80008000'942 'earlyprintk fixrtc nocompcache vram=12M '
945 boot_script = 'boot.scr'943 'omapfb.mode=dvi:1280x720MR-16@60 mpurate=${mpurate}')
946 extra_boot_args_options = (944 self.initrd_addr = '0x81600000'
947 'earlyprintk fixrtc nocompcache vram=12M '945 self.kernel_addr = '0x80000000'
948 'omapfb.mode=dvi:1280x720MR-16@60 mpurate=${mpurate}')946 self.load_addr = '0x80008000'
947 self._serial_tty = 'ttyO2'
948 self._extra_serial_opts = 'console=tty0 console=%s,115200n8'
949 self._live_serial_opts = 'serialtty=%s'
949950
950951
951class OveroConfig(OmapConfig):952class OveroConfig(OmapConfig):
952 bootloader_flavor = 'omap3_overo'953 def __init__(self):
953 dtb_name = 'omap3-overo.dtb'954 super(OveroConfig, self).__init__()
954 _serial_tty = 'ttyO2'955 self.boot_script = 'boot.scr'
955 _extra_serial_opts = 'console=tty0 console=%s,115200n8'956 self.bootloader_flavor = 'omap3_overo'
956 kernel_addr = '0x80000000'957 self.dtb_addr = '0x815f0000'
957 dtb_addr = '0x815f0000'958 self.dtb_name = 'omap3-overo.dtb'
958 initrd_addr = '0x81600000'959 self.extra_boot_args_options = (
959 load_addr = '0x80008000'960 'earlyprintk mpurate=${mpurate} vram=12M '
960 boot_script = 'boot.scr'961 'omapdss.def_disp=${defaultdisplay} omapfb.mode=dvi:${dvimode}')
961 extra_boot_args_options = (962 self.initrd_addr = '0x81600000'
962 'earlyprintk mpurate=${mpurate} vram=12M '963 self.kernel_addr = '0x80000000'
963 'omapdss.def_disp=${defaultdisplay} omapfb.mode=dvi:${dvimode}')964 self.load_addr = '0x80008000'
965 self._extra_serial_opts = 'console=tty0 console=%s,115200n8'
966 self._serial_tty = 'ttyO2'
964967
965968
966class PandaConfig(OmapConfig):969class PandaConfig(OmapConfig):
967 bootloader_flavor = 'omap4_panda'970 def __init__(self):
968 dtb_name = 'omap4-panda.dtb'971 super(PandaConfig, self).__init__()
969 _serial_tty = 'ttyO2'972 self._serial_tty = 'ttyO2'
970 _extra_serial_opts = 'console=tty0 console=%s,115200n8'973 self.boot_script = 'boot.scr'
971 _live_serial_opts = 'serialtty=%s'974 self.bootloader_flavor = 'omap4_panda'
972 kernel_addr = '0x80200000'975 self.dtb_addr = '0x815f0000'
973 dtb_addr = '0x815f0000'976 self.dtb_name = 'omap4-panda.dtb'
974 initrd_addr = '0x81600000'977 self.extra_boot_args_options = (
975 load_addr = '0x80008000'978 'earlyprintk fixrtc nocompcache vram=48M '
976 boot_script = 'boot.scr'979 'omapfb.vram=0:24M mem=456M@0x80000000 mem=512M@0xA0000000')
977 extra_boot_args_options = (980 self.initrd_addr = '0x81600000'
978 'earlyprintk fixrtc nocompcache vram=48M '981 self.kernel_addr = '0x80200000'
979 'omapfb.vram=0:24M mem=456M@0x80000000 mem=512M@0xA0000000')982 self.load_addr = '0x80008000'
983 self._extra_serial_opts = 'console=tty0 console=%s,115200n8'
984 self._live_serial_opts = 'serialtty=%s'
980985
981986
982class IgepConfig(BeagleConfig):987class IgepConfig(BeagleConfig):
983 bootloader_file_in_boot_part = False988 def __init__(self):
984 bootloader_flavor = None989 super(IgepConfig, self).__init__()
985 dtb_name = 'isee-igep-v2.dtb'990 self.bootloader_file_in_boot_part = False
991 self.bootloader_flavor = None
992 self.dtb_name = 'isee-igep-v2.dtb'
986993
987 @classmethod994 def _make_boot_files(self, boot_env, chroot_dir, boot_dir,
988 def _make_boot_files(cls, boot_env, chroot_dir, boot_dir,
989 boot_device_or_file, k_img_data, i_img_data,995 boot_device_or_file, k_img_data, i_img_data,
990 d_img_data):996 d_img_data):
991 # XXX: delete this method when hwpacks V1 can die997 # XXX: delete this method when hwpacks V1 can die
992 assert cls.hwpack_format == HardwarepackHandler.FORMAT_1998 assert self.hwpack_format == HardwarepackHandler.FORMAT_1
993 make_uImage(cls.load_addr, k_img_data, boot_dir)999 make_uImage(self.load_addr, k_img_data, boot_dir)
994 make_uInitrd(i_img_data, boot_dir)1000 make_uInitrd(i_img_data, boot_dir)
995 make_dtb(d_img_data, boot_dir)1001 make_dtb(d_img_data, boot_dir)
996 boot_script_path = os.path.join(boot_dir, cls.boot_script)1002 boot_script_path = os.path.join(boot_dir, self.boot_script)
997 make_boot_script(boot_env, boot_script_path)1003 make_boot_script(boot_env, boot_script_path)
998 make_boot_ini(boot_script_path, boot_dir)1004 make_boot_ini(boot_script_path, boot_dir)
9991005
10001006
1001class Ux500Config(BoardConfig):1007class Ux500Config(BoardConfig):
1002 serial_tty = 'ttyAMA2'1008 def __init__(self):
1003 _extra_serial_opts = 'console=tty0 console=%s,115200n8'1009 super(Ux500Config, self).__init__()
1004 _live_serial_opts = 'serialtty=%s'1010 self.boot_script = 'flash.scr'
1005 kernel_addr = '0x00100000'1011 self.extra_boot_args_options = (
1006 initrd_addr = '0x08000000'1012 'earlyprintk rootdelay=1 fixrtc nocompcache '
1007 load_addr = '0x00008000'1013 'mem=96M@0 mem_modem=32M@96M mem=44M@128M pmem=22M@172M '
1008 kernel_flavors = ['u8500', 'ux500']1014 'mem=30M@194M mem_mali=32M@224M pmem_hwb=54M@256M '
1009 boot_script = 'flash.scr'1015 'hwmem=48M@302M mem=152M@360M')
1010 extra_boot_args_options = (1016 self.initrd_addr = '0x08000000'
1011 'earlyprintk rootdelay=1 fixrtc nocompcache '1017 self.kernel_addr = '0x00100000'
1012 'mem=96M@0 mem_modem=32M@96M mem=44M@128M pmem=22M@172M '1018 self.kernel_flavors = ['u8500', 'ux500']
1013 'mem=30M@194M mem_mali=32M@224M pmem_hwb=54M@256M '1019 self.load_addr = '0x00008000'
1014 'hwmem=48M@302M mem=152M@360M')1020 self.mmc_option = '1:1'
1015 mmc_option = '1:1'1021 self.serial_tty = 'ttyAMA2'
10161022 self._extra_serial_opts = 'console=tty0 console=%s,115200n8'
1017 @classproperty1023 self._live_serial_opts = 'serialtty=%s'
1018 def live_serial_opts(cls):1024
1019 return cls._live_serial_opts % cls.serial_tty1025 def _make_boot_files(self, boot_env, chroot_dir, boot_dir,
1020
1021 @classproperty
1022 def extra_serial_opts(cls):
1023 return cls._extra_serial_opts % cls.serial_tty
1024
1025 @classmethod
1026 def _make_boot_files(cls, boot_env, chroot_dir, boot_dir,
1027 boot_device_or_file, k_img_data, i_img_data,1026 boot_device_or_file, k_img_data, i_img_data,
1028 d_img_data):1027 d_img_data):
1029 # XXX: delete this method when hwpacks V1 can die1028 # XXX: delete this method when hwpacks V1 can die
1030 assert cls.hwpack_format == HardwarepackHandler.FORMAT_11029 assert self.hwpack_format == HardwarepackHandler.FORMAT_1
1031 make_uImage(cls.load_addr, k_img_data, boot_dir)1030 make_uImage(self.load_addr, k_img_data, boot_dir)
1032 make_uInitrd(i_img_data, boot_dir)1031 make_uInitrd(i_img_data, boot_dir)
1033 boot_script_path = os.path.join(boot_dir, cls.boot_script)1032 boot_script_path = os.path.join(boot_dir, self.boot_script)
1034 make_boot_script(boot_env, boot_script_path)1033 make_boot_script(boot_env, boot_script_path)
10351034
10361035
@@ -1040,15 +1039,16 @@
1040 Note that the Snowball board needs a loader partition on the1039 Note that the Snowball board needs a loader partition on the
1041 internal eMMC flash to boot. That partition is created with1040 internal eMMC flash to boot. That partition is created with
1042 the SnowballConfigImage configuration.'''1041 the SnowballConfigImage configuration.'''
1042 def __init__(self):
1043 super(SnowballSdConfig, self).__init__()
10431044
1044 @classmethod1045 def _make_boot_files(self, boot_env, chroot_dir, boot_dir,
1045 def _make_boot_files(cls, boot_env, chroot_dir, boot_dir,
1046 boot_device_or_file, k_img_data, i_img_data,1046 boot_device_or_file, k_img_data, i_img_data,
1047 d_img_data):1047 d_img_data):
1048 # XXX: delete this method when hwpacks V1 can die1048 # XXX: delete this method when hwpacks V1 can die
1049 assert cls.hwpack_format == HardwarepackHandler.FORMAT_11049 assert self.hwpack_format == HardwarepackHandler.FORMAT_1
1050 make_uImage(cls.load_addr, k_img_data, boot_dir)1050 make_uImage(self.load_addr, k_img_data, boot_dir)
1051 boot_script_path = os.path.join(boot_dir, cls.boot_script)1051 boot_script_path = os.path.join(boot_dir, self.boot_script)
1052 make_boot_script(boot_env, boot_script_path)1052 make_boot_script(boot_env, boot_script_path)
10531053
10541054
@@ -1056,16 +1056,18 @@
1056 '''Use only with --image option. Creates a raw image which contains an1056 '''Use only with --image option. Creates a raw image which contains an
1057 additional (raw) loader partition, containing some boot stages1057 additional (raw) loader partition, containing some boot stages
1058 and u-boot.'''1058 and u-boot.'''
1059 # Boot ROM looks for a boot table of contents (TOC) at 0x20000
1060 # Actually, it first looks at address 0, but that's where l-m-c
1061 # puts the MBR, so the boot loader skips that address.
1062 supports_writing_to_mmc = False
1063 SNOWBALL_LOADER_START_S = (128 * 1024) / SECTOR_SIZE1059 SNOWBALL_LOADER_START_S = (128 * 1024) / SECTOR_SIZE
1064 snowball_startup_files_config = 'startfiles.cfg'
1065 TOC_SIZE = 5121060 TOC_SIZE = 512
10661061
1067 @classmethod1062 def __init__(self):
1068 def get_v1_sfdisk_cmd(cls, should_align_boot_part=None):1063 super(SnowballEmmcConfig, self).__init__()
1064 # Boot ROM looks for a boot table of contents (TOC) at 0x20000
1065 # Actually, it first looks at address 0, but that's where l-m-c
1066 # puts the MBR, so the boot loader skips that address.
1067 self.supports_writing_to_mmc = False
1068 self.snowball_startup_files_config = 'startfiles.cfg'
1069
1070 def get_v1_sfdisk_cmd(self, should_align_boot_part=None):
1069 """Return the sfdisk command to partition the media.1071 """Return the sfdisk command to partition the media.
10701072
1071 :param should_align_boot_part: Ignored.1073 :param should_align_boot_part: Ignored.
@@ -1083,68 +1085,64 @@
1083 # with the usual SECTOR_SIZE of 0x200.1085 # with the usual SECTOR_SIZE of 0x200.
1084 # (sector 0 is MBR / partition table)1086 # (sector 0 is MBR / partition table)
1085 loader_start, loader_end, loader_len = align_partition(1087 loader_start, loader_end, loader_len = align_partition(
1086 SnowballEmmcConfig.SNOWBALL_LOADER_START_S,1088 self.SNOWBALL_LOADER_START_S,
1087 cls.LOADER_MIN_SIZE_S, 1, PART_ALIGN_S)1089 self.LOADER_MIN_SIZE_S, 1, PART_ALIGN_S)
10881090
1089 boot_start, boot_end, boot_len = align_partition(1091 boot_start, boot_end, boot_len = align_partition(
1090 loader_end + 1, cls.BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)1092 loader_end + 1, self.BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
1091 # we ignore _root_end / _root_len and return an sfdisk command to1093 # we ignore _root_end / _root_len and return an sfdisk command to
1092 # instruct the use of all remaining space; XXX if we had some root size1094 # instruct the use of all remaining space; XXX if we had some root size
1093 # config, we could do something more sensible1095 # config, we could do something more sensible
1094 root_start, _root_end, _root_len = align_partition(1096 root_start, _root_end, _root_len = align_partition(
1095 boot_end + 1, cls.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)1097 boot_end + 1, self.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
10961098
1097 return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % (1099 return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % (
1098 loader_start, loader_len, boot_start, boot_len, root_start)1100 loader_start, loader_len, boot_start, boot_len, root_start)
10991101
1100 @classmethod1102 def _make_boot_files(self, boot_env, chroot_dir, boot_dir,
1101 def _make_boot_files(cls, boot_env, chroot_dir, boot_dir,
1102 boot_device_or_file, k_img_data, i_img_data,1103 boot_device_or_file, k_img_data, i_img_data,
1103 d_img_data):1104 d_img_data):
1104 # XXX: delete this method when hwpacks V1 can die1105 # XXX: delete this method when hwpacks V1 can die
1105 assert cls.hwpack_format == HardwarepackHandler.FORMAT_11106 assert self.hwpack_format == HardwarepackHandler.FORMAT_1
1106 make_uImage(cls.load_addr, k_img_data, boot_dir)1107 make_uImage(self.load_addr, k_img_data, boot_dir)
1107 boot_script_path = os.path.join(boot_dir, cls.boot_script)1108 boot_script_path = os.path.join(boot_dir, self.boot_script)
1108 make_boot_script(boot_env, boot_script_path)1109 make_boot_script(boot_env, boot_script_path)
1109 cls.populate_raw_partition(boot_device_or_file, chroot_dir)1110 self.populate_raw_partition(boot_device_or_file, chroot_dir)
11101111
1111 @classmethod1112 def populate_raw_partition(self, boot_device_or_file, chroot_dir):
1112 def populate_raw_partition(cls, boot_device_or_file, chroot_dir):
1113 # Populate created raw partition with TOC and startup files.1113 # Populate created raw partition with TOC and startup files.
1114 _, toc_filename = tempfile.mkstemp()1114 _, toc_filename = tempfile.mkstemp()
1115 config_files_dir = cls.snowball_config(chroot_dir)1115 config_files_dir = self.snowball_config(chroot_dir)
1116 new_files = cls.get_file_info(chroot_dir, config_files_dir)1116 new_files = self.get_file_info(chroot_dir, config_files_dir)
1117 with open(toc_filename, 'wb') as toc:1117 with open(toc_filename, 'wb') as toc:
1118 cls.create_toc(toc, new_files)1118 self.create_toc(toc, new_files)
1119 cls.install_snowball_boot_loader(toc_filename, new_files,1119 self.install_snowball_boot_loader(toc_filename, new_files,
1120 boot_device_or_file,1120 boot_device_or_file,
1121 cls.SNOWBALL_LOADER_START_S,1121 self.SNOWBALL_LOADER_START_S,
1122 cls.delete_startupfiles)1122 self.delete_startupfiles)
1123 cls.delete_file(toc_filename)1123 self.delete_file(toc_filename)
1124 if cls.delete_startupfiles:1124 if self.delete_startupfiles:
1125 cls.delete_file(os.path.join(config_files_dir,1125 self.delete_file(os.path.join(config_files_dir,
1126 cls.snowball_startup_files_config))1126 self.snowball_startup_files_config))
11271127
1128 @classmethod1128 def snowball_config(self, chroot_dir):
1129 def snowball_config(cls, chroot_dir):
1130 # We will find the startupfiles in the target boot partition.1129 # We will find the startupfiles in the target boot partition.
1131 return os.path.join(chroot_dir, 'boot')1130 return os.path.join(chroot_dir, 'boot')
11321131
1133 @classproperty1132 @property
1134 def delete_startupfiles(cls):1133 def delete_startupfiles(self):
1135 # The startupfiles will have been installed to the target boot1134 # The startupfiles will have been installed to the target boot
1136 # partition by the hwpack, and should be deleted so we don't leave1135 # partition by the hwpack, and should be deleted so we don't leave
1137 # them on the target system.1136 # them on the target system.
1138 return True1137 return True
11391138
1140 @classmethod1139 def install_snowball_boot_loader(self, toc_file_name, files,
1141 def install_snowball_boot_loader(cls, toc_file_name, files,
1142 boot_device_or_file, start_sector,1140 boot_device_or_file, start_sector,
1143 delete_startupfiles=False):1141 delete_startupfiles=False):
1144 ''' Copies TOC and boot files into the boot partition.1142 ''' Copies TOC and boot files into the boot partition.
1145 A sector size of 1 is used for some files, as they do not1143 A sector size of 1 is used for some files, as they do not
1146 necessarily start on an even address. '''1144 necessarily start on an even address. '''
1147 assert os.path.getsize(toc_file_name) <= cls.TOC_SIZE1145 assert os.path.getsize(toc_file_name) <= self.TOC_SIZE
1148 _dd(toc_file_name, boot_device_or_file, seek=start_sector)1146 _dd(toc_file_name, boot_device_or_file, seek=start_sector)
11491147
1150 for file in files:1148 for file in files:
@@ -1159,16 +1157,14 @@
1159 seek_sectors = start_sector + file['offset'] / SECTOR_SIZE1157 seek_sectors = start_sector + file['offset'] / SECTOR_SIZE
1160 _dd(filename, boot_device_or_file, seek=seek_sectors)1158 _dd(filename, boot_device_or_file, seek=seek_sectors)
1161 if delete_startupfiles:1159 if delete_startupfiles:
1162 cls.delete_file(filename)1160 self.delete_file(filename)
11631161
1164 @classmethod1162 def delete_file(self, file_path):
1165 def delete_file(cls, file_path):
1166 cmd = ["rm", "%s" % file_path]1163 cmd = ["rm", "%s" % file_path]
1167 proc = cmd_runner.run(cmd, as_root=True)1164 proc = cmd_runner.run(cmd, as_root=True)
1168 proc.wait()1165 proc.wait()
11691166
1170 @classmethod1167 def create_toc(self, f, files):
1171 def create_toc(cls, f, files):
1172 ''' Writes a table of contents of the boot binaries.1168 ''' Writes a table of contents of the boot binaries.
1173 Boot rom searches this table to find the binaries.'''1169 Boot rom searches this table to find the binaries.'''
1174 # Format string means: < little endian,1170 # Format string means: < little endian,
@@ -1190,15 +1186,14 @@
1190 file['section_name'])1186 file['section_name'])
1191 f.write(data)1187 f.write(data)
11921188
1193 @classmethod1189 def get_file_info(self, chroot_dir, config_files_dir):
1194 def get_file_info(cls, chroot_dir, config_files_dir):
1195 ''' Fills in the offsets of files that are located in1190 ''' Fills in the offsets of files that are located in
1196 non-absolute memory locations depending on their sizes.'1191 non-absolute memory locations depending on their sizes.'
1197 Also fills in file sizes'''1192 Also fills in file sizes'''
1198 ofs = cls.TOC_SIZE1193 ofs = self.TOC_SIZE
1199 files = []1194 files = []
1200 with open(os.path.join(config_files_dir,1195 with open(os.path.join(config_files_dir,
1201 cls.snowball_startup_files_config),1196 self.snowball_startup_files_config),
1202 'r') as info_file:1197 'r') as info_file:
1203 for line in info_file:1198 for line in info_file:
1204 file_data = line.split()1199 file_data = line.split()
@@ -1229,23 +1224,16 @@
12291224
12301225
1231class Mx5Config(BoardConfig):1226class Mx5Config(BoardConfig):
1232 serial_tty = 'ttymxc0'1227 def __init__(self):
1233 _extra_serial_opts = 'console=tty0 console=%s,115200n8'1228 super(Mx5Config, self).__init__()
1234 _live_serial_opts = 'serialtty=%s'1229 self.boot_script = 'boot.scr'
1235 boot_script = 'boot.scr'1230 self.mmc_option = '0:2'
1236 mmc_part_offset = 11231 self.mmc_part_offset = 1
1237 mmc_option = '0:2'1232 self.serial_tty = 'ttymxc0'
12381233 self._extra_serial_opts = 'console=tty0 console=%s,115200n8'
1239 @classproperty1234 self._live_serial_opts = 'serialtty=%s'
1240 def live_serial_opts(cls):1235
1241 return cls._live_serial_opts % cls.serial_tty1236 def get_v1_sfdisk_cmd(self, should_align_boot_part=None):
1242
1243 @classproperty
1244 def extra_serial_opts(cls):
1245 return cls._extra_serial_opts % cls.serial_tty
1246
1247 @classmethod
1248 def get_v1_sfdisk_cmd(cls, should_align_boot_part=None):
1249 """Return the sfdisk command to partition the media.1237 """Return the sfdisk command to partition the media.
12501238
1251 :param should_align_boot_part: Ignored.1239 :param should_align_boot_part: Ignored.
@@ -1259,103 +1247,107 @@
1259 # onwards, so it's safer to just start at the first sector, sector 11247 # onwards, so it's safer to just start at the first sector, sector 1
1260 # (sector 0 is MBR / partition table)1248 # (sector 0 is MBR / partition table)
1261 loader_start, loader_end, loader_len = align_partition(1249 loader_start, loader_end, loader_len = align_partition(
1262 1, cls.LOADER_MIN_SIZE_S, 1, PART_ALIGN_S)1250 1, self.LOADER_MIN_SIZE_S, 1, PART_ALIGN_S)
12631251
1264 boot_start, boot_end, boot_len = align_partition(1252 boot_start, boot_end, boot_len = align_partition(
1265 loader_end + 1, cls.BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)1253 loader_end + 1, self.BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
1266 # we ignore _root_end / _root_len and return a sfdisk command to1254 # we ignore _root_end / _root_len and return a sfdisk command to
1267 # instruct the use of all remaining space; XXX if we had some root size1255 # instruct the use of all remaining space; XXX if we had some root size
1268 # config, we could do something more sensible1256 # config, we could do something more sensible
1269 root_start, _root_end, _root_len = align_partition(1257 root_start, _root_end, _root_len = align_partition(
1270 boot_end + 1, cls.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)1258 boot_end + 1, self.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
12711259
1272 return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % (1260 return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % (
1273 loader_start, loader_len, boot_start, boot_len, root_start)1261 loader_start, loader_len, boot_start, boot_len, root_start)
12741262
1275 @classmethod1263 def _make_boot_files(self, boot_env, chroot_dir, boot_dir,
1276 def _make_boot_files(cls, boot_env, chroot_dir, boot_dir,
1277 boot_device_or_file, k_img_data, i_img_data,1264 boot_device_or_file, k_img_data, i_img_data,
1278 d_img_data):1265 d_img_data):
1279 # XXX: delete this method when hwpacks V1 can die1266 # XXX: delete this method when hwpacks V1 can die
1280 assert cls.hwpack_format == HardwarepackHandler.FORMAT_11267 assert self.hwpack_format == HardwarepackHandler.FORMAT_1
1281 with cls.hardwarepack_handler:1268 with self.hardwarepack_handler:
1282 bootloader_file = cls.get_file('bootloader_file',1269 bootloader_file = self.get_file('bootloader_file',
1283 default=os.path.join(1270 default=os.path.join(
1284 chroot_dir, 'usr', 'lib', 'u-boot', cls.bootloader_flavor,1271 chroot_dir, 'usr', 'lib', 'u-boot', self.bootloader_flavor,
1285 'u-boot.imx'))1272 'u-boot.imx'))
1286 install_mx5_boot_loader(bootloader_file, boot_device_or_file,1273 install_mx5_boot_loader(bootloader_file, boot_device_or_file,
1287 cls.LOADER_MIN_SIZE_S)1274 self.LOADER_MIN_SIZE_S)
1288 make_uImage(cls.load_addr, k_img_data, boot_dir)1275 make_uImage(self.load_addr, k_img_data, boot_dir)
1289 make_uInitrd(i_img_data, boot_dir)1276 make_uInitrd(i_img_data, boot_dir)
1290 make_dtb(d_img_data, boot_dir)1277 make_dtb(d_img_data, boot_dir)
1291 boot_script_path = os.path.join(boot_dir, cls.boot_script)1278 boot_script_path = os.path.join(boot_dir, self.boot_script)
1292 make_boot_script(boot_env, boot_script_path)1279 make_boot_script(boot_env, boot_script_path)
12931280
12941281
1295class Mx51Config(Mx5Config):1282class Mx51Config(Mx5Config):
1296 kernel_addr = '0x90000000'1283 def __init__(self):
1297 dtb_addr = '0x91ff0000'1284 super(Mx51Config, self).__init__()
1298 initrd_addr = '0x92000000'1285 self.dtb_addr = '0x91ff0000'
1299 load_addr = '0x90008000'1286 self.initrd_addr = '0x92000000'
1300 kernel_flavors = ['linaro-mx51', 'linaro-lt-mx5']1287 self.kernel_addr = '0x90000000'
1288 self.kernel_flavors = ['linaro-mx51', 'linaro-lt-mx5']
1289 self.load_addr = '0x90008000'
13011290
13021291
1303class Mx53Config(Mx5Config):1292class Mx53Config(Mx5Config):
1304 kernel_addr = '0x70000000'1293 def __init__(self):
1305 dtb_addr = '0x71ff0000'1294 super(Mx53Config, self).__init__()
1306 initrd_addr = '0x72000000'1295 self.dtb_addr = '0x71ff0000'
1307 load_addr = '0x70008000'1296 self.initrd_addr = '0x72000000'
1308 kernel_flavors = ['linaro-lt-mx53', 'linaro-lt-mx5']1297 self.kernel_addr = '0x70000000'
1298 self.kernel_flavors = ['linaro-lt-mx53', 'linaro-lt-mx5']
1299 self.load_addr = '0x70008000'
13091300
13101301
1311class EfikamxConfig(Mx51Config):1302class EfikamxConfig(Mx51Config):
1312 bootloader_flavor = 'efikamx'1303 def __init__(self):
1313 dtb_name = 'genesi-efikamx.dtb'1304 super(EfikamxConfig, self).__init__()
1305 self.bootloader_flavor = 'efikamx'
1306 self.dtb_name = 'genesi-efikamx.dtb'
13141307
13151308
1316class EfikasbConfig(Mx51Config):1309class EfikasbConfig(Mx51Config):
1317 bootloader_flavor = 'efikasb'1310 def __init__(self):
1318 dtb_name = 'genesi-efikasb.dtb'1311 super(EfikasbConfig, self).__init__()
1312 self.bootloader_flavor = 'efikasb'
1313 self.dtb_name = 'genesi-efikasb.dtb'
13191314
13201315
1321class Mx51evkConfig(Mx51Config):1316class Mx51evkConfig(Mx51Config):
1322 bootloader_flavor = 'mx51evk'1317 def __init__(self):
1323 dtb_name = 'mx51-babbage.dtb'1318 super(Mx51evkConfig, self).__init__()
1319 self.bootloader_flavor = 'mx51evk'
1320 self.dtb_name = 'mx51-babbage.dtb'
13241321
13251322
1326class Mx53LoCoConfig(Mx53Config):1323class Mx53LoCoConfig(Mx53Config):
1327 bootloader_flavor = 'mx53loco'1324 def __init__(self):
1328 dtb_name = 'mx53-loco.dtb'1325 super(Mx53LoCoConfig, self).__init__()
1326 self.bootloader_flavor = 'mx53loco'
1327 self.dtb_name = 'mx53-loco.dtb'
13291328
13301329
1331class VexpressConfig(BoardConfig):1330class VexpressConfig(BoardConfig):
1332 bootloader_flavor = 'ca9x4_ct_vxp'1331 def __init__(self):
1333 bootloader_file_in_boot_part = True1332 super(VexpressConfig, self).__init__()
1334 serial_tty = 'ttyAMA0'1333 self.boot_script = 'boot.scr'
1335 _extra_serial_opts = 'console=tty0 console=%s,38400n8'1334 self.bootloader_file_in_boot_part = True
1336 _live_serial_opts = 'serialtty=%s'1335 self.bootloader_flavor = 'ca9x4_ct_vxp'
1337 kernel_addr = '0x60000000'1336 # ARM Boot Monitor is used to load u-boot, uImage etc. into flash and
1338 initrd_addr = '0x62000000'1337 # only allows for FAT16
1339 load_addr = '0x60008000'1338 self.fat_size = 16
1340 kernel_flavors = ['linaro-vexpress']1339 self.initrd_addr = '0x62000000'
1341 boot_script = 'boot.scr'1340 self.kernel_addr = '0x60000000'
1342 # ARM Boot Monitor is used to load u-boot, uImage etc. into flash and1341 self.kernel_flavors = ['linaro-vexpress']
1343 # only allows for FAT161342 self.load_addr = '0x60008000'
1344 fat_size = 161343 self.serial_tty = 'ttyAMA0'
13451344 self._extra_serial_opts = 'console=tty0 console=%s,38400n8'
1346 @classproperty1345 self._live_serial_opts = 'serialtty=%s'
1347 def live_serial_opts(cls):1346
1348 return cls._live_serial_opts % cls.serial_tty1347 def _make_boot_files(self, boot_env, chroot_dir, boot_dir,
1349
1350 @classproperty
1351 def extra_serial_opts(cls):
1352 return cls._extra_serial_opts % cls.serial_tty
1353
1354 @classmethod
1355 def _make_boot_files(cls, boot_env, chroot_dir, boot_dir,
1356 boot_device_or_file, k_img_data, i_img_data,1348 boot_device_or_file, k_img_data, i_img_data,
1357 d_img_data):1349 d_img_data):
1358 make_uImage(cls.load_addr, k_img_data, boot_dir)1350 make_uImage(self.load_addr, k_img_data, boot_dir)
1359 make_uInitrd(i_img_data, boot_dir)1351 make_uInitrd(i_img_data, boot_dir)
13601352
13611353
@@ -1363,22 +1355,23 @@
1363 # For now, this is a duplicate of VexpressConfig.1355 # For now, this is a duplicate of VexpressConfig.
1364 # In future, there will also be A5 and A15 variants.1356 # In future, there will also be A5 and A15 variants.
1365 # For all of these, there should never be any V1 hardware packs.1357 # For all of these, there should never be any V1 hardware packs.
1366 pass1358 def __init__(self):
1359 super(VexpressA9Config, self).__init__()
13671360
13681361
1369class FastModelConfig(BoardConfig):1362class FastModelConfig(BoardConfig):
1370 supports_writing_to_mmc = False1363 def __init__(self):
1364 super(FastModelConfig, self).__init__()
1365 self.supports_writing_to_mmc = False
13711366
1372 @classmethod1367 def _get_bootcmd(self, i_img_data, d_img_data):
1373 def _get_bootcmd(cls, i_img_data, d_img_data):
1374 """Get the bootcmd for FastModel.1368 """Get the bootcmd for FastModel.
13751369
1376 We override this as we don't do uboot.1370 We override this as we don't do uboot.
1377 """1371 """
1378 return ""1372 return ""
13791373
1380 @classmethod1374 def _make_boot_files_v2(self, boot_env, chroot_dir, boot_dir,
1381 def _make_boot_files_v2(cls, boot_env, chroot_dir, boot_dir,
1382 boot_device_or_file, k_img_data, i_img_data,1375 boot_device_or_file, k_img_data, i_img_data,
1383 d_img_data):1376 d_img_data):
1384 output_dir = os.path.dirname(boot_device_or_file)1377 output_dir = os.path.dirname(boot_device_or_file)
@@ -1395,16 +1388,14 @@
13951388
13961389
1397class SamsungConfig(BoardConfig):1390class SamsungConfig(BoardConfig):
1398 @classproperty1391 def __init__(self):
1399 def extra_serial_opts(cls):1392 super(SamsungConfig, self).__init__()
1400 return cls._extra_serial_opts % cls.serial_tty1393 self._extra_serial_opts = None
14011394
1402 @classmethod1395 def get_v1_sfdisk_cmd(self, should_align_boot_part=False):
1403 def get_v1_sfdisk_cmd(cls, should_align_boot_part=False):
1404 # bootloaders partition needs to hold BL1, U-Boot environment, and BL21396 # bootloaders partition needs to hold BL1, U-Boot environment, and BL2
1405 loaders_min_len = (1397 loaders_min_len = (self.samsung_bl1_start + self.samsung_bl1_len +
1406 cls.samsung_bl1_start + cls.samsung_bl1_len + cls.samsung_bl2_len +1398 self.samsung_bl2_len + self.samsung_env_len)
1407 cls.samsung_env_len)
14081399
1409 # bootloaders partition1400 # bootloaders partition
1410 loaders_start, loaders_end, loaders_len = align_partition(1401 loaders_start, loaders_end, loaders_len = align_partition(
@@ -1412,44 +1403,42 @@
14121403
1413 # FAT boot partition1404 # FAT boot partition
1414 boot_start, boot_end, boot_len = align_partition(1405 boot_start, boot_end, boot_len = align_partition(
1415 loaders_end + 1, cls.BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)1406 loaders_end + 1, self.BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
14161407
1417 # root partition1408 # root partition
1418 # we ignore _root_end / _root_len and return a sfdisk command to1409 # we ignore _root_end / _root_len and return a sfdisk command to
1419 # instruct the use of all remaining space; XXX if we had some root size1410 # instruct the use of all remaining space; XXX if we had some root size
1420 # config, we could do something more sensible1411 # config, we could do something more sensible
1421 root_start, _root_end, _root_len = align_partition(1412 root_start, _root_end, _root_len = align_partition(
1422 boot_end + 1, cls.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)1413 boot_end + 1, self.ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
14231414
1424 return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % (1415 return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % (
1425 loaders_start, loaders_len, boot_start, boot_len, root_start)1416 loaders_start, loaders_len, boot_start, boot_len, root_start)
14261417
1427 @classmethod1418 def _make_boot_files(self, boot_env, chroot_dir, boot_dir,
1428 def _make_boot_files(cls, boot_env, chroot_dir, boot_dir,
1429 boot_device_or_file, k_img_data, i_img_data,1419 boot_device_or_file, k_img_data, i_img_data,
1430 d_img_data):1420 d_img_data):
1431 # XXX: delete this method when hwpacks V1 can die1421 # XXX: delete this method when hwpacks V1 can die
1432 assert cls.hwpack_format == HardwarepackHandler.FORMAT_11422 assert self.hwpack_format == HardwarepackHandler.FORMAT_1
1433 cls.install_samsung_boot_loader(cls._get_samsung_spl(chroot_dir),1423 self.install_samsung_boot_loader(self._get_samsung_spl(chroot_dir),
1434 cls._get_samsung_bootloader(chroot_dir), boot_device_or_file)1424 self._get_samsung_bootloader(chroot_dir), boot_device_or_file)
1435 env_size = cls.samsung_env_len * SECTOR_SIZE1425 env_size = self.samsung_env_len * SECTOR_SIZE
1436 env_file = make_flashable_env(boot_env, env_size)1426 env_file = make_flashable_env(boot_env, env_size)
1437 _dd(env_file, boot_device_or_file, seek=cls.samsung_env_start)1427 _dd(env_file, boot_device_or_file, seek=self.samsung_env_start)
14381428
1439 make_uImage(cls.load_addr, k_img_data, boot_dir)1429 make_uImage(self.load_addr, k_img_data, boot_dir)
1440 make_uInitrd(i_img_data, boot_dir)1430 make_uInitrd(i_img_data, boot_dir)
14411431
1442 # unused at the moment once FAT support enabled for the1432 # unused at the moment once FAT support enabled for the
1443 # Samsung u-boot this can be used bug 7279781433 # Samsung u-boot this can be used bug 727978
1444 boot_script_path = os.path.join(boot_dir, cls.boot_script)1434 boot_script_path = os.path.join(boot_dir, self.boot_script)
1445 make_boot_script(boot_env, boot_script_path)1435 make_boot_script(boot_env, boot_script_path)
14461436
1447 @classmethod1437 def _get_samsung_spl(self, chroot_dir):
1448 def _get_samsung_spl(cls, chroot_dir):
1449 # XXX: delete this method when hwpacks V1 can die1438 # XXX: delete this method when hwpacks V1 can die
1450 assert cls.hwpack_format == HardwarepackHandler.FORMAT_11439 assert self.hwpack_format == HardwarepackHandler.FORMAT_1
1451 spl_dir = os.path.join(1440 spl_dir = os.path.join(
1452 chroot_dir, 'usr', 'lib', 'u-boot', cls.bootloader_flavor)1441 chroot_dir, 'usr', 'lib', 'u-boot', self.bootloader_flavor)
1453 old_spl_path = os.path.join(spl_dir, 'v310_mmc_spl.bin')1442 old_spl_path = os.path.join(spl_dir, 'v310_mmc_spl.bin')
1454 new_spl_path = os.path.join(spl_dir, 'u-boot-mmc-spl.bin')1443 new_spl_path = os.path.join(spl_dir, 'u-boot-mmc-spl.bin')
1455 spl_path_origen2 = os.path.join(spl_dir, 'origen-spl.bin')1444 spl_path_origen2 = os.path.join(spl_dir, 'origen-spl.bin')
@@ -1479,49 +1468,48 @@
1479 % (old_spl_path, new_spl_path))1468 % (old_spl_path, new_spl_path))
1480 return spl_file1469 return spl_file
14811470
1482 @classmethod1471 def _get_samsung_bootloader(self, chroot_dir):
1483 def _get_samsung_bootloader(cls, chroot_dir):
1484 # XXX: delete this method when hwpacks V1 can die1472 # XXX: delete this method when hwpacks V1 can die
1485 assert cls.hwpack_format == HardwarepackHandler.FORMAT_11473 assert self.hwpack_format == HardwarepackHandler.FORMAT_1
1486 bootloader_file = os.path.join(1474 bootloader_file = os.path.join(
1487 chroot_dir, 'usr', 'lib', 'u-boot', cls.bootloader_flavor,1475 chroot_dir, 'usr', 'lib', 'u-boot', self.bootloader_flavor,
1488 'u-boot.bin')1476 'u-boot.bin')
1489 return bootloader_file1477 return bootloader_file
14901478
1491 @classmethod1479 def populate_raw_partition(self, boot_device_or_file, chroot_dir):
1492 def populate_raw_partition(cls, boot_device_or_file, chroot_dir):
1493 # Zero the env so that the boot_script will get loaded1480 # Zero the env so that the boot_script will get loaded
1494 _dd("/dev/zero", boot_device_or_file, count=cls.samsung_env_len,1481 _dd("/dev/zero", boot_device_or_file, count=self.samsung_env_len,
1495 seek=cls.samsung_env_start)1482 seek=self.samsung_env_start)
1496 # Populate created raw partition with BL1 and u-boot1483 # Populate created raw partition with BL1 and u-boot
1497 spl_file = os.path.join(chroot_dir, 'boot', 'u-boot-mmc-spl.bin')1484 spl_file = os.path.join(chroot_dir, 'boot', 'u-boot-mmc-spl.bin')
1498 assert os.path.getsize(spl_file) <= (1485 assert os.path.getsize(spl_file) <= (
1499 cls.samsung_bl1_len * SECTOR_SIZE), (1486 self.samsung_bl1_len * SECTOR_SIZE), (
1500 "%s is larger than Samsung BL1 size" % spl_file)1487 "%s is larger than Samsung BL1 size" % spl_file)
1501 _dd(spl_file, boot_device_or_file, seek=cls.samsung_bl1_start)1488 _dd(spl_file, boot_device_or_file, seek=self.samsung_bl1_start)
1502 uboot_file = os.path.join(chroot_dir, 'boot', 'u-boot.bin')1489 uboot_file = os.path.join(chroot_dir, 'boot', 'u-boot.bin')
1503 assert os.path.getsize(uboot_file) <= (1490 assert os.path.getsize(uboot_file) <= (
1504 cls.samsung_bl2_len * SECTOR_SIZE), (1491 self.samsung_bl2_len * SECTOR_SIZE), (
1505 "%s is larger than Samsung BL2 size" % uboot_file)1492 "%s is larger than Samsung BL2 size" % uboot_file)
1506 _dd(uboot_file, boot_device_or_file, seek=cls.samsung_bl2_start)1493 _dd(uboot_file, boot_device_or_file, seek=self.samsung_bl2_start)
15071494
15081495
1509class SMDKV310Config(SamsungConfig):1496class SMDKV310Config(SamsungConfig):
1510 bootloader_flavor = 'smdkv310'1497 def __init__(self):
1511 serial_tty = 'ttySAC1'1498 super(SMDKV310Config, self).__init__()
1512 _extra_serial_opts = 'console=%s,115200n8'1499 self.boot_script = 'boot.scr'
1513 kernel_addr = '0x40007000'1500 self.bootloader_flavor = 'smdkv310'
1514 initrd_addr = '0x42000000'1501 self.initrd_addr = '0x42000000'
1515 load_addr = '0x40008000'1502 self.kernel_addr = '0x40007000'
1516 kernel_flavors = ['s5pv310']1503 self.kernel_flavors = ['s5pv310']
1517 boot_script = 'boot.scr'1504 self.load_addr = '0x40008000'
1518 mmc_part_offset = 11505 self.mmc_option = '0:2'
1519 mmc_option = '0:2'1506 self.mmc_part_offset = 1
1507 self.serial_tty = 'ttySAC1'
1508 self._extra_serial_opts = 'console=%s,115200n8'
15201509
1521 @classmethod1510 def _get_boot_env(self, is_live, is_lowmem, consoles, rootfs_id,
1522 def _get_boot_env(cls, is_live, is_lowmem, consoles, rootfs_id,
1523 i_img_data, d_img_data):1511 i_img_data, d_img_data):
1524 boot_env = super(SamsungConfig, cls)._get_boot_env(1512 boot_env = super(SamsungConfig, self)._get_boot_env(
1525 is_live, is_lowmem, consoles, rootfs_id, i_img_data, d_img_data)1513 is_live, is_lowmem, consoles, rootfs_id, i_img_data, d_img_data)
15261514
1527 boot_env["ethact"] = "smc911x-0"1515 boot_env["ethact"] = "smc911x-0"
@@ -1531,60 +1519,59 @@
15311519
15321520
1533class OrigenConfig(SamsungConfig):1521class OrigenConfig(SamsungConfig):
1534 bootloader_flavor = 'origen'1522 # TODO test
1535 serial_tty = 'ttySAC2'1523 def __init__(self):
1536 _extra_serial_opts = 'console=%s,115200n8'1524 super(OrigenConfig, self).__init__()
1537 kernel_addr = '0x40007000'1525 self.boot_script = 'boot.scr'
1538 initrd_addr = '0x42000000'1526 self.bootloader_flavor = 'origen'
1539 load_addr = '0x40008000'1527 self.initrd_addr = '0x42000000'
1540 kernel_flavors = ['origen']1528 self.kernel_addr = '0x40007000'
1541 boot_script = 'boot.scr'1529 self.kernel_flavors = ['origen']
1542 mmc_part_offset = 11530 self.load_addr = '0x40008000'
1543 mmc_option = '0:2'1531 self.mmc_option = '0:2'
1532 self.mmc_part_offset = 1
1533 self.serial_tty = 'ttySAC2'
1534 self._extra_serial_opts = 'console=%s,115200n8'
15441535
15451536
1546class OrigenQuadConfig(SamsungConfig):1537class OrigenQuadConfig(SamsungConfig):
1547 bootloader_flavor = 'origen_quad'1538 def __init__(self):
1548 serial_tty = 'ttySAC2'1539 super(OrigenQuadConfig, self).__init__()
1549 _extra_serial_opts = 'console=%s,115200n8'1540 self.boot_script = 'boot.scr'
1550 kernel_addr = '0x40007000'1541 self.bootloader_flavor = 'origen_quad'
1551 initrd_addr = '0x42000000'1542 self.initrd_addr = '0x42000000'
1552 load_addr = '0x40008000'1543 self.kernel_addr = '0x40007000'
1553 kernel_flavors = ['origen_quad']1544 self.kernel_flavors = ['origen_quad']
1554 boot_script = 'boot.scr'1545 self.load_addr = '0x40008000'
1555 mmc_part_offset = 11546 self.mmc_option = '0:2'
1556 mmc_option = '0:2'1547 self.mmc_part_offset = 1
1557 samsung_bl1_len = 481548 self.samsung_bl1_len = 48
1558 samsung_bl2_start = 491549 self.samsung_bl2_start = 49
1559 samsung_env_start = 10731550 self.samsung_env_start = 1073
1551 self.serial_tty = 'ttySAC2'
1552 self._extra_serial_opts = 'console=%s,115200n8'
15601553
15611554
1562class ArndaleConfig(SamsungConfig):1555class ArndaleConfig(SamsungConfig):
1563 bootloader_flavor = 'arndale'1556 def __init__(self):
1564 serial_tty = 'ttySAC2'1557 super(ArndaleConfig, self).__init__()
1565 _extra_serial_opts = 'console=%s,115200n8'1558 self.boot_script = 'boot.scr'
1566 kernel_addr = '0x40007000'1559 self.bootloader_flavor = 'arndale'
1567 initrd_addr = '0x42000000'1560 self.dtb_addr = '0x41f00000'
1568 dtb_addr = '0x41f00000'1561 self.initrd_addr = '0x42000000'
1569 load_addr = '0x40008000'1562 self.kernel_addr = '0x40007000'
1570 kernel_flavors = ['arndale']1563 self.kernel_flavors = ['arndale']
1571 boot_script = 'boot.scr'1564 self.load_addr = '0x40008000'
1572 mmc_part_offset = 11565 self.mmc_option = '0:2'
1573 mmc_option = '0:2'1566 self.mmc_part_offset = 1
1574 samsung_bl1_start = 171567 self.samsung_bl1_start = 17
1575 samsung_bl2_start = 491568 self.samsung_bl2_start = 49
1576 samsung_env_start = 10731569 self.samsung_env_start = 1073
1570 self.serial_tty = 'ttySAC2'
1571 self._extra_serial_opts = 'console=%s,115200n8'
15771572
15781573
1579class I386Config(BoardConfig):1574class I386Config(BoardConfig):
1580 # define serial
1581 serial_tty = 'ttyS0'
1582 _extra_serial_opts = 'console=tty0 console=%s,115200n8'
1583 _live_serial_opts = 'serialtty=%s'
1584
1585 # define kernel image
1586 kernel_flavors = ['generic', 'pae']
1587
1588 # define bootloader1575 # define bootloader
1589 BOOTLOADER_CMD = 'grub-install'1576 BOOTLOADER_CMD = 'grub-install'
1590 BOOTLOADER_CFG_FILE = 'grub/grub.cfg'1577 BOOTLOADER_CFG_FILE = 'grub/grub.cfg'
@@ -1596,16 +1583,14 @@
1596 initrd /%s1583 initrd /%s
1597 }"""1584 }"""
15981585
1599 @classproperty1586 def __init__(self):
1600 def live_serial_opts(cls):1587 super(I386Config, self).__init__()
1601 return cls._live_serial_opts % cls.serial_tty1588 self.kernel_flavors = ['generic', 'pae']
16021589 self.serial_tty = 'ttyS0'
1603 @classproperty1590 self._extra_serial_opts = 'console=tty0 console=%s,115200n8'
1604 def extra_serial_opts(cls):1591 self._live_serial_opts = 'serialtty=%s'
1605 return cls._extra_serial_opts % cls.serial_tty1592
16061593 def _make_boot_files(self, boot_env, chroot_dir, boot_dir,
1607 @classmethod
1608 def _make_boot_files(cls, boot_env, chroot_dir, boot_dir,
1609 boot_device_or_file, k_img_data, i_img_data,1594 boot_device_or_file, k_img_data, i_img_data,
1610 d_img_data):1595 d_img_data):
1611 # copy image and init into boot partition1596 # copy image and init into boot partition
@@ -1618,13 +1603,13 @@
1618 img_loop = register_loopback(boot_device_or_file, 0, img_size)1603 img_loop = register_loopback(boot_device_or_file, 0, img_size)
16191604
1620 # install bootloader1605 # install bootloader
1621 cmd_runner.run([cls.BOOTLOADER_CMD, '--boot-directory=%s' % boot_dir,1606 cmd_runner.run([self.BOOTLOADER_CMD, '--boot-directory=%s' % boot_dir,
1622 '--modules', 'part_msdos', img_loop],1607 '--modules', 'part_msdos', img_loop],
1623 as_root=True).wait()1608 as_root=True).wait()
16241609
1625 # generate loader config file1610 # generate loader config file
1626 loader_config = cls.BOOTLOADER_CFG % (os.path.basename(k_img_data),1611 loader_config = self.BOOTLOADER_CFG % (os.path.basename(k_img_data),
1627 cls.extra_serial_opts, os.path.basename(i_img_data))1612 self.extra_serial_opts, os.path.basename(i_img_data))
16281613
1629 _, tmpfile = tempfile.mkstemp()1614 _, tmpfile = tempfile.mkstemp()
1630 atexit.register(os.unlink, tmpfile)1615 atexit.register(os.unlink, tmpfile)
@@ -1632,42 +1617,59 @@
1632 fd.write(loader_config)1617 fd.write(loader_config)
16331618
1634 cmd_runner.run(['cp', tmpfile, os.path.join(boot_dir,1619 cmd_runner.run(['cp', tmpfile, os.path.join(boot_dir,
1635 cls.BOOTLOADER_CFG_FILE)], as_root=True).wait()1620 self.BOOTLOADER_CFG_FILE)], as_root=True).wait()
16361621
1637 @classmethod1622 def _make_boot_files_v2(self, boot_env, chroot_dir, boot_dir,
1638 def _make_boot_files_v2(cls, boot_env, chroot_dir, boot_dir,
1639 boot_device_or_file, k_img_data, i_img_data,1623 boot_device_or_file, k_img_data, i_img_data,
1640 d_img_data):1624 d_img_data):
1641 # reuse hwpack v1 function1625 # reuse hwpack v1 function
1642 cls._make_boot_files(boot_env, chroot_dir, boot_dir,1626 self._make_boot_files(boot_env, chroot_dir, boot_dir,
1643 boot_device_or_file, k_img_data, i_img_data,1627 boot_device_or_file, k_img_data, i_img_data,
1644 d_img_data)1628 d_img_data)
1629
1630
1631class BoardConfigException(Exception):
1632 """General board config exception."""
16451633
16461634
1647board_configs = {1635board_configs = {
1648 'arndale': ArndaleConfig,1636 'arndale': ArndaleConfig,
1649 'beagle': BeagleConfig,1637 'beagle': BeagleConfig,
1650 'igep': IgepConfig,
1651 'panda': PandaConfig,
1652 'vexpress': VexpressConfig,
1653 'vexpress-a9': VexpressA9Config,
1654 'fastmodel': FastModelConfig,
1655 'ux500': Ux500Config,
1656 'snowball_sd': SnowballSdConfig,
1657 'snowball_emmc': SnowballEmmcConfig,
1658 'efikamx': EfikamxConfig,1638 'efikamx': EfikamxConfig,
1659 'efikasb': EfikasbConfig,1639 'efikasb': EfikasbConfig,
1640 'fastmodel': FastModelConfig,
1641 'i386': I386Config,
1642 'igep': IgepConfig,
1660 'mx51evk': Mx51evkConfig,1643 'mx51evk': Mx51evkConfig,
1661 'mx53loco': Mx53LoCoConfig,1644 'mx53loco': Mx53LoCoConfig,
1645 'mx6qsabrelite': BoardConfig,
1646 'origen': OrigenConfig,
1647 'origen_quad': OrigenQuadConfig,
1662 'overo': OveroConfig,1648 'overo': OveroConfig,
1649 'panda': PandaConfig,
1663 'smdkv310': SMDKV310Config,1650 'smdkv310': SMDKV310Config,
1664 'origen': OrigenConfig,1651 'snowball_emmc': SnowballEmmcConfig,
1665 'origen_quad': OrigenQuadConfig,1652 'snowball_sd': SnowballSdConfig,
1666 'mx6qsabrelite': BoardConfig,1653 'ux500': Ux500Config,
1667 'i386': I386Config,1654 'vexpress': VexpressConfig,
1655 'vexpress-a9': VexpressA9Config,
1668 }1656 }
16691657
16701658
1659def get_board_config(board):
1660 """Get the board configuration for the specified board.
1661
1662 :param board: The name of the board to get the configuration of.
1663 :type board: str
1664 """
1665 clazz = board_configs.get(board, None)
1666 if clazz:
1667 return clazz()
1668 else:
1669 raise BoardConfigException("Board name '%s' has no configuration "
1670 "available." % board)
1671
1672
1671def _dd(input_file, output_file, block_size=SECTOR_SIZE, count=None, seek=None,1673def _dd(input_file, output_file, block_size=SECTOR_SIZE, count=None, seek=None,
1672 skip=None):1674 skip=None):
1673 """Wrapper around the dd command"""1675 """Wrapper around the dd command"""

Subscribers

People subscribed via source and target branches