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

Proposed by Milo Casagrande
Status: Merged
Approved by: Данило Шеган
Approved revision: 599
Merged at revision: 596
Proposed branch: lp:~milo/linaro-image-tools/android-boards
Merge into: lp:linaro-image-tools/11.11
Prerequisite: lp:~milo/linaro-image-tools/boards-refactoring
Diff against target: 689 lines (+316/-168)
2 files modified
linaro-android-media-create (+11/-9)
linaro_image_tools/media_create/android_boards.py (+305/-159)
To merge this branch: bzr merge lp:~milo/linaro-image-tools/android-boards
Reviewer Review Type Date Requested Status
Данило Шеган (community) Approve
Review via email: mp+138233@code.launchpad.net

Commit message

Android boards refactoring to support Android hwpack.

Description of the change

This is the biggest part of the work on the android_boards module.

The refactoring al class methods references into instance references. A method to read values from the hwpack file has been added.
Tests have not been fixed here.

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

Merged boards-refactoring into android-boards.

594. By Milo Casagrande

Merged from pipe.

595. By Milo Casagrande

Merged boards-refactoring into android-boards.

596. By Milo Casagrande

Fixed wrong attribute name, added missing one.

597. By Milo Casagrande

Merged from boards-refactoring, fixed conflicts.

598. By Milo Casagrande

Merged boards-refactoring into android-boards.

599. By Milo Casagrande

Merged boards-refactoring into android-boards.

Revision history for this message
Данило Шеган (danilo) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'linaro-android-media-create'
2--- linaro-android-media-create 2012-07-26 08:48:15 +0000
3+++ linaro-android-media-create 2012-12-27 15:00:31 +0000
4@@ -26,7 +26,7 @@
5 from linaro_image_tools import cmd_runner
6
7 from linaro_image_tools.media_create.android_boards import (
8- android_board_configs,
9+ get_board_config,
10 )
11 from linaro_image_tools.media_create.check_device import (
12 confirm_device_selection_and_ensure_it_is_ready)
13@@ -40,8 +40,10 @@
14 unpack_android_binary_tarball
15 )
16 from linaro_image_tools.media_create import get_android_args_parser
17-from linaro_image_tools.utils import ensure_command
18-
19+from linaro_image_tools.utils import (
20+ ensure_command,
21+ get_logger
22+ )
23
24
25 # Just define the global variables
26@@ -89,6 +91,8 @@
27 parser = get_android_args_parser()
28 args = parser.parse_args()
29
30+ logger = get_logger(debug=args.debug)
31+
32 # If --help was specified this won't execute.
33 # Create temp dir and initialize rest of path vars.
34 TMP_DIR = tempfile.mkdtemp()
35@@ -102,13 +106,14 @@
36 DATA_DISK = os.path.join(TMP_DIR, 'userdata-disc')
37 SDCARD_DISK = os.path.join(TMP_DIR, 'sdcard-disc')
38
39- board_config = android_board_configs[args.dev]
40+ board_config = get_board_config(args.dev)
41 board_config.add_boot_args(args.extra_boot_args)
42 board_config.add_boot_args_from_file(args.extra_boot_args_file)
43
44 if args.dev == 'iMX53':
45 # XXX: remove this and the corresponding entry in android_board_configs
46- print "DEPRECATION WARNING: iMX53 is deprecated, please use mx53loco."
47+ logger.warning("DEPRECATION WARNING: iMX53 is deprecated, please "
48+ "use mx53loco.")
49
50 ensure_required_commands(args)
51
52@@ -117,11 +122,8 @@
53 if not confirm_device_selection_and_ensure_it_is_ready(args.device):
54 sys.exit(1)
55 elif not args.should_create_partitions:
56- print ("Do not use --no-part in conjunction with --image_file.")
57+ logger.error("Do not use --no-part in conjunction with --image_file.")
58 sys.exit(1)
59- else:
60- # All good, move on.
61- pass
62
63 cmd_runner.run(['mkdir', '-p', BOOT_DIR]).wait()
64 cmd_runner.run(['mkdir', '-p', SYSTEM_DIR]).wait()
65
66=== modified file 'linaro_image_tools/media_create/android_boards.py'
67--- linaro_image_tools/media_create/android_boards.py 2012-12-12 09:35:49 +0000
68+++ linaro_image_tools/media_create/android_boards.py 2012-12-27 15:00:31 +0000
69@@ -20,45 +20,149 @@
70 """Configuration for boards supported by linaro-android-media-create.
71
72 To add support for a new board, you need to create a subclass of
73-AndroidBoardConfig, set appropriate values for its variables and add it to
74-android_board_configs at the bottom of this file.
75+AndroidBoardConfig, create an Android hwpack as explained here:
76+
77+https://wiki.linaro.org/AndroidHardwarePacksV3
78+
79+and add the board to 'android_board_configs' at the end of this file.
80 """
81
82+import os
83+import yaml
84+import logging
85+
86+from linaro_image_tools import cmd_runner
87 from linaro_image_tools.media_create.partitions import SECTOR_SIZE
88-from linaro_image_tools.media_create.boards import PART_ALIGN_S
89-from linaro_image_tools.media_create.boards import BeagleConfig
90-from linaro_image_tools.media_create.boards import PandaConfig
91-from linaro_image_tools.media_create.boards import Mx53LoCoConfig
92-from linaro_image_tools.media_create.boards import SnowballSdConfig
93-from linaro_image_tools.media_create.boards import SnowballEmmcConfig
94-from linaro_image_tools.media_create.boards import SMDKV310Config
95-from linaro_image_tools.media_create.boards import OrigenConfig
96-from linaro_image_tools.media_create.boards import OrigenQuadConfig
97-from linaro_image_tools.media_create.boards import VexpressConfig
98 from linaro_image_tools.media_create.boards import (
99+ BeagleConfig,
100+ BoardConfig,
101+ BoardConfigException,
102+ Mx53LoCoConfig,
103+ OrigenConfig,
104+ OrigenQuadConfig,
105+ PART_ALIGN_S,
106+ PandaConfig,
107+ SMDKV310Config,
108+ SnowballEmmcConfig,
109+ SnowballSdConfig,
110+ VexpressConfig,
111+ align_partition,
112 align_up,
113- align_partition,
114- classproperty,
115+ install_mx5_boot_loader,
116 make_boot_script,
117- install_mx5_boot_loader,
118 )
119-
120-from linaro_image_tools import cmd_runner
121-import os
122-
123-
124-class AndroidBoardConfig(object):
125- @classmethod
126- def _get_bootargs(cls, consoles):
127+from linaro_image_tools.utils import DEFAULT_LOGGER_NAME
128+
129+logger = logging.getLogger(DEFAULT_LOGGER_NAME)
130+
131+BOOT_MIN_SIZE_S = align_up(128 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
132+SYSTEM_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
133+CACHE_MIN_SIZE_S = align_up(256 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
134+USERDATA_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
135+SDCARD_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
136+LOADER_MIN_SIZE_S = align_up(1 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
137+
138+
139+class AndroidBoardConfig(BoardConfig):
140+
141+ def __init__(self):
142+ super(AndroidBoardConfig, self).__init__()
143+ self.dtb_name = None
144+ self._extra_serial_opts = []
145+ self._android_specific_args = []
146+ self._extra_boot_args_options = []
147+ self._live_serial_options = []
148+
149+ def _get_android_specific_args(self):
150+ android_args = self._android_specific_args
151+ if isinstance(android_args, list):
152+ android_args = ' '.join(self._android_specific_args)
153+ return android_args
154+
155+ def _set_android_specific_args(self, value):
156+ self._android_specific_args = value
157+
158+ android_specific_args = property(_get_android_specific_args,
159+ _set_android_specific_args)
160+
161+ def _get_extra_boot_args_options(self):
162+ extra_boot_args = self._extra_boot_args_options
163+ if isinstance(extra_boot_args, list):
164+ extra_boot_args = ' '.join(self._extra_boot_args_options)
165+ return extra_boot_args
166+
167+ def _set_extra_boot_args_options(self, value):
168+ self._extra_boot_args_options = value
169+
170+ extra_boot_args_options = property(_get_extra_boot_args_options,
171+ _set_extra_boot_args_options)
172+
173+ def _get_extra_serial_opts(self):
174+ extra_serial = self._extra_serial_opts
175+ if isinstance(extra_serial, list):
176+ extra_serial = ' '.join(self._extra_serial_opts)
177+ return extra_serial
178+
179+ def _set_extra_serial_opts(self, value):
180+ self._extra_serial_opts = value
181+
182+ extra_serial_opts = property(_get_extra_serial_opts,
183+ _set_extra_serial_opts)
184+
185+ def _get_live_serial_options(self):
186+ serial_options = self._live_serial_options
187+ if serial_options:
188+ if isinstance(serial_options, list):
189+ serial_options = ' '.join(self._live_serial_options)
190+ if self._check_placeholder_presence(serial_options, '%s'):
191+ serial_options = serial_options % self.serial_tty
192+ return serial_options
193+
194+ def _set_live_serial_options(self, value):
195+ self._live_serial_options = value
196+
197+ live_serial_options = property(_get_live_serial_options,
198+ _set_live_serial_options)
199+
200+ def from_file(self, hwpack):
201+ """Loads the Android board configuration from an Android hardware pack
202+ configuration file and sets the config attributes with their values.
203+
204+ :param hwpack: The Android hwpack configuration file.
205+ :return The configuration read from the file as a dictionary.
206+ """
207+ try:
208+ config = yaml.safe_load(hwpack)
209+ self._set_attributes(config)
210+ return config
211+ except yaml.YAMLError, ex:
212+ logger.debug("Error loading YAML file %s" % hwpack, ex)
213+ raise BoardConfigException("Error reading Android hwpack %s"
214+ % hwpack)
215+
216+ def _set_attributes(self, config):
217+ """Initialize the class attributes with the values read from the
218+ Android hardware pack configuration file.
219+
220+ :param config: The config read from the Android hwpack.
221+ """
222+ for name, value in config.iteritems():
223+ if hasattr(self, name):
224+ setattr(self, name, value)
225+ else:
226+ logger.warning("Attribute '%s' does not belong to this "
227+ "instance of '%s'." % (name, self.__class__))
228+
229+ def _get_bootargs(self, consoles):
230 """Get the bootargs for this board.
231
232 In general subclasses should not have to override this.
233 """
234 boot_args_options = 'rootwait ro'
235- if cls.extra_boot_args_options is not None:
236- boot_args_options += ' %s' % cls.extra_boot_args_options
237- boot_args_options += ' %s' % cls.android_specific_args
238- serial_opts = cls._extra_serial_opts
239+ if self.extra_boot_args_options:
240+ boot_args_options += ' %s' % self.extra_boot_args_options
241+ boot_args_options += ' %s' % self.android_specific_args
242+ serial_opts = self.extra_serial_opts
243 for console in consoles:
244 serial_opts += ' console=%s' % console
245
246@@ -70,34 +174,32 @@
247 "%(boot_args_options)s"
248 % replacements)
249
250- @classmethod
251- def _get_boot_env(cls, consoles):
252+ def _get_boot_env(self, consoles):
253 """Get the boot environment for this board.
254
255 In general subclasses should not have to override this.
256 """
257 boot_env = {}
258- boot_env["bootargs"] = cls._get_bootargs(consoles)
259+ boot_env["bootargs"] = self._get_bootargs(consoles)
260 initrd = False
261- if cls.initrd_addr:
262+ if self.initrd_addr:
263 initrd = True
264 # On Android, the DTB file is always built as part of the kernel it
265 # comes from - and lives in the same directory in the boot tarball, so
266 # here we don't need to pass the whole path to it.
267- boot_env["bootcmd"] = cls._get_bootcmd(initrd, cls.dtb_name)
268- boot_env["initrd_high"] = cls.initrd_high
269- boot_env["fdt_high"] = cls.fdt_high
270+ boot_env["bootcmd"] = self._get_bootcmd(initrd, self.dtb_name)
271+ boot_env["initrd_high"] = self.initrd_high
272+ boot_env["fdt_high"] = self.fdt_high
273 return boot_env
274
275- @classmethod
276- def populate_boot_script(cls, boot_partition, boot_disk, consoles):
277+ def populate_boot_script(self, boot_partition, boot_disk, consoles):
278 cmd_runner.run(['mkdir', '-p', boot_disk]).wait()
279 # TODO: Use partition_mounted() here to make sure the partition is
280 # always umounted after we're done.
281 cmd_runner.run(['mount', boot_partition, boot_disk],
282 as_root=True).wait()
283
284- boot_env = cls._get_boot_env(consoles)
285+ boot_env = self._get_boot_env(consoles)
286 cmdline_filepath = os.path.join(boot_disk, "cmdline")
287 cmdline_file = open(cmdline_filepath, 'r')
288 android_kernel_cmdline = cmdline_file.read()
289@@ -106,7 +208,7 @@
290 cmdline_file.close()
291
292 boot_dir = boot_disk
293- boot_script_path = os.path.join(boot_dir, cls.boot_script)
294+ boot_script_path = os.path.join(boot_dir, self.boot_script)
295 make_boot_script(boot_env, boot_script_path)
296
297 cmd_runner.run(['sync']).wait()
298@@ -115,25 +217,13 @@
299 except cmd_runner.SubcommandNonZeroReturnValue:
300 pass
301
302- @classmethod
303- def get_sfdisk_cmd(cls, should_align_boot_part=False,
304+ def get_sfdisk_cmd(self, should_align_boot_part=False,
305 start_addr=0, extra_part=False):
306- if cls.fat_size == 32:
307+ if self.fat_size == 32:
308 partition_type = '0x0C'
309 else:
310 partition_type = '0x0E'
311
312- BOOT_MIN_SIZE_S = align_up(
313- 128 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
314- SYSTEM_MIN_SIZE_S = align_up(
315- 512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
316- CACHE_MIN_SIZE_S = align_up(
317- 256 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
318- USERDATA_MIN_SIZE_S = align_up(
319- 512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
320- SDCARD_MIN_SIZE_S = align_up(
321- 512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
322-
323 # align on sector 63 for compatibility with broken versions of x-loader
324 # unless align_boot_part is set
325 boot_align = 63
326@@ -175,86 +265,89 @@
327 cache_start, _cache_len, userdata_start, userdata_start,
328 _userdata_len, sdcard_start)
329
330- @classmethod
331- def populate_raw_partition(cls, media, boot_dir):
332- super(AndroidBoardConfig, cls).populate_raw_partition(media, boot_dir)
333+ def populate_raw_partition(self, media, boot_dir):
334+ super(AndroidBoardConfig, self).populate_raw_partition(media, boot_dir)
335
336- @classmethod
337- def install_boot_loader(cls, boot_partition, boot_device_or_file):
338+ def install_boot_loader(self, boot_partition, boot_device_or_file):
339 pass
340
341
342 class AndroidOmapConfig(AndroidBoardConfig):
343- dtb_name = None
344+ """Placeholder class for OMAP configuration inheritance."""
345
346
347 class AndroidBeagleConfig(AndroidOmapConfig, BeagleConfig):
348- _extra_serial_opts = 'console=tty0 console=ttyO2,115200n8'
349- android_specific_args = 'init=/init androidboot.console=ttyO2'
350- dtb_name = None
351-
352-
353-class AndroidPandaConfig(AndroidOmapConfig, PandaConfig):
354- bootloader_flavor = 'omap4_panda'
355- dtb_addr = '0x815f0000'
356- dtb_name = 'board.dtb'
357- _extra_serial_opts = 'console=ttyO2,115200n8'
358- extra_boot_args_options = (
359- 'earlyprintk fixrtc nocompcache vram=48M '
360- 'omapfb.vram=0:24M,1:24M mem=456M@0x80000000 mem=512M@0xA0000000')
361- android_specific_args = 'init=/init androidboot.console=ttyO2'
362+ """Placeholder class for Beagle configuration inheritance."""
363+ def __init__(self):
364+ super(AndroidBeagleConfig, self).__init__()
365+ self._android_specific_args = 'init=/init androidboot.console=ttyO2'
366+ self._extra_serial_opts = 'console=tty0 console=ttyO2,115200n8'
367+
368+
369+class AndroidPandaConfig(AndroidBoardConfig, PandaConfig):
370+ """Placeholder class for Panda configuration inheritance."""
371+ def __init__(self):
372+ super(AndroidPandaConfig, self).__init__()
373+ self.dtb_name = 'board.dtb'
374+ self._extra_serial_opts = 'console=ttyO2,115200n8'
375+ self._extra_boot_args_options = (
376+ 'earlyprintk fixrtc nocompcache vram=48M '
377+ 'omapfb.vram=0:24M,1:24M mem=456M@0x80000000 mem=512M@0xA0000000')
378+ self._android_specific_args = 'init=/init androidboot.console=ttyO2'
379+ self.dtb_addr = '0x815f0000'
380+ self.bootloader_flavor = 'omap4_panda'
381
382
383 class AndroidSnowballSdConfig(AndroidBoardConfig, SnowballSdConfig):
384- boot_script = 'boot.scr'
385- fdt_high = '0x05000000'
386- initrd_addr = '0x05000000'
387- initrd_high = '0x06000000'
388- extra_boot_args_options = (
389- 'earlyprintk mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
390- 'mem=22M@360M mem_issw=1M@383M mem=640M@384M vmalloc=500M')
391- _extra_serial_opts = 'console=ttyAMA2,115200n8'
392- android_specific_args = 'init=/init androidboot.console=ttyAMA2'
393- dtb_name = 'board.dtb'
394- dtb_addr = '0x8000000'
395+ """Placeholder class for Snowball Sd configuration inheritance."""
396+ def __init__(self):
397+ super(AndroidSnowballSdConfig, self).__init__()
398+ self.dtb_name = 'board.dtb'
399+ self._android_specific_args = 'init=/init androidboot.console=ttyAMA2'
400+ self._extra_boot_args_options = (
401+ 'earlyprintk mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
402+ 'mem=22M@360M mem_issw=1M@383M mem=640M@384M vmalloc=500M')
403+ self._extra_serial_opts = 'console=ttyAMA2,115200n8'
404+ self.boot_script = 'boot.scr'
405+ self.fdt_high = '0x05000000'
406+ self.initrd_addr = '0x05000000'
407+ self.initrd_high = '0x06000000'
408+ self.dtb_addr = '0x8000000'
409
410
411 class AndroidSnowballEmmcConfig(AndroidBoardConfig, SnowballEmmcConfig):
412- boot_script = 'boot.scr'
413- fdt_high = '0x05000000'
414- initrd_addr = '0x05000000'
415- initrd_high = '0x06000000'
416- extra_boot_args_options = (
417- 'earlyprintk mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
418- 'mem=22M@360M mem_issw=1M@383M mem=640M@384M vmalloc=500M')
419- _extra_serial_opts = 'console=ttyAMA2,115200n8'
420- android_specific_args = 'init=/init androidboot.console=ttyAMA2'
421- mmc_option = '0:2'
422- dtb_name = 'board.dtb'
423- dtb_addr = '0x8000000'
424-
425- @classmethod
426- def get_sfdisk_cmd(cls, should_align_boot_part=False):
427-
428- LOADER_MIN_SIZE_S = align_up(
429- 1 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
430-
431+ """Class for Snowball Emmc configuration inheritance."""
432+ def __init__(self):
433+ super(AndroidSnowballEmmcConfig, self).__init__()
434+ self.dtb_name = 'board.dtb'
435+ self._extra_boot_args_options = (
436+ 'earlyprintk mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
437+ 'mem=22M@360M mem_issw=1M@383M mem=640M@384M vmalloc=500M')
438+ self._extra_serial_opts = 'console=ttyAMA2,115200n8'
439+ self._android_specific_args = 'init=/init androidboot.console=ttyAMA2'
440+ self.boot_script = 'boot.scr'
441+ self.fdt_high = '0x05000000'
442+ self.initrd_addr = '0x05000000'
443+ self.initrd_high = '0x06000000'
444+ self.mmc_option = '0:2'
445+ self.dtb_addr = '0x8000000'
446+
447+ def get_sfdisk_cmd(self, should_align_boot_part=False):
448 loader_start, loader_end, loader_len = align_partition(
449 SnowballEmmcConfig.SNOWBALL_LOADER_START_S,
450 LOADER_MIN_SIZE_S, 1, PART_ALIGN_S)
451
452- command = super(AndroidSnowballEmmcConfig, cls).get_sfdisk_cmd(
453+ command = super(AndroidSnowballEmmcConfig, self).get_sfdisk_cmd(
454 should_align_boot_part=True, start_addr=loader_end,
455 extra_part=True)
456
457 return '%s,%s,0xDA\n%s' % (
458 loader_start, loader_len, command)
459
460- @classmethod
461- def populate_raw_partition(cls, media, boot_dir):
462+ def populate_raw_partition(self, media, boot_dir):
463 # To avoid adding a Snowball specific command line option, we assume
464 # that the user already has unpacked the startfiles to ./startupfiles
465- config_files_dir = cls.snowball_config(boot_dir)
466+ config_files_dir = self.snowball_config(boot_dir)
467 assert os.path.exists(config_files_dir), (
468 "You need to unpack the Snowball startupfiles to the directory "
469 "'startupfiles' in your current working directory. See "
470@@ -265,72 +358,98 @@
471 for boot_file in boot_files:
472 cmd_runner.run(['cp', os.path.join(boot_dir, 'boot', boot_file),
473 config_files_dir], as_root=True).wait()
474- super(AndroidSnowballEmmcConfig, cls).populate_raw_partition(
475+ super(AndroidSnowballEmmcConfig, self).populate_raw_partition(
476 media, boot_dir)
477
478- @classmethod
479- def snowball_config(cls, chroot_dir):
480+ def snowball_config(self, chroot_dir):
481 # The user is expected to have unpacked the startupfiles to this subdir
482 # of their working dir.
483 return os.path.join('.', 'startupfiles')
484
485- @classproperty
486- def delete_startupfiles(cls):
487+ @property
488+ def delete_startupfiles(self):
489 # The startupfiles will have been unpacked to the user's working dir
490 # and should not be deleted after they have been installed.
491 return False
492
493
494 class AndroidMx53LoCoConfig(AndroidBoardConfig, Mx53LoCoConfig):
495- extra_boot_args_options = (
496- 'earlyprintk rootdelay=1 fixrtc nocompcache di1_primary tve')
497- _extra_serial_opts = 'console=%s,115200n8' % (
498- Mx53LoCoConfig.serial_tty)
499- android_specific_args = 'init=/init androidboot.console=%s' % (
500- Mx53LoCoConfig.serial_tty)
501- dtb_name = None
502-
503- @classmethod
504- def get_sfdisk_cmd(cls, should_align_boot_part=False):
505+ """Class for Mx53LoCo configuration inheritance."""
506+ def __init__(self):
507+ super(AndroidMx53LoCoConfig, self).__init__()
508+ self._extra_boot_args_options = (
509+ 'earlyprintk rootdelay=1 fixrtc nocompcache di1_primary tve')
510+ self._extra_serial_opts = 'console=%s,115200n8'
511+ self._android_specific_args = 'init=/init androidboot.console=%s'
512+
513+ def _get_extra_serial_opts(self):
514+ serial_opts = self._extra_serial_opts
515+ if serial_opts:
516+ if isinstance(serial_opts, list):
517+ serial_opts = ' '.join(serial_opts)
518+ if self._check_placeholder_presence(serial_opts, '%s'):
519+ serial_opts = serial_opts % self.serial_tty
520+ return serial_opts
521+
522+ def _set_extra_serial_opts(self, value):
523+ self._extra_serial_opts = value
524+
525+ extra_serial_opts = property(_get_extra_serial_opts,
526+ _set_extra_serial_opts)
527+
528+ def _get_android_specific_args(self):
529+ android_args = self._android_specific_args
530+ if android_args:
531+ if isinstance(android_args, list):
532+ android_args = ' '.join(android_args)
533+ if self._check_placeholder_presence(android_args, '%s'):
534+ android_args = android_args % self.serial_tty
535+ return android_args
536+
537+ def _set_android_specific_args(self, value):
538+ self._android_specific_args = value
539+
540+ android_specific_args = property(_get_android_specific_args,
541+ _set_android_specific_args)
542+
543+ def get_sfdisk_cmd(self, should_align_boot_part=False):
544 loader_start, loader_end, loader_len = align_partition(
545- 1, cls.LOADER_MIN_SIZE_S, 1, PART_ALIGN_S)
546+ 1, self.LOADER_MIN_SIZE_S, 1, PART_ALIGN_S)
547
548- command = super(AndroidMx53LoCoConfig, cls).get_sfdisk_cmd(
549+ command = super(AndroidMx53LoCoConfig, self).get_sfdisk_cmd(
550 should_align_boot_part=True, start_addr=loader_end,
551 extra_part=True)
552
553 return '%s,%s,0xDA\n%s' % (
554 loader_start, loader_len, command)
555
556- @classmethod
557- def install_boot_loader(cls, boot_partition, boot_device_or_file):
558+ def install_boot_loader(self, boot_partition, boot_device_or_file):
559 install_mx5_boot_loader(
560 os.path.join(boot_device_or_file, "u-boot.imx"),
561- boot_partition, cls.LOADER_MIN_SIZE_S)
562+ boot_partition, self.LOADER_MIN_SIZE_S)
563
564
565 class AndroidMx6QSabreliteConfig(AndroidMx53LoCoConfig):
566- bootloader_flavor = 'mx6qsabrelite'
567- kernel_addr = '0x10000000'
568- initrd_addr = '0x12000000'
569- load_addr = '0x10008000'
570- dtb_addr = '0x11ff0000'
571- dtb_name = 'board.dtb'
572+ """Placeholder class for Mx6Q Sabrelite configuration inheritance."""
573+ def __init__(self):
574+ super(AndroidMx6QSabreliteConfig, self).__init__()
575+ self.dtb_name = 'board.dtb'
576+ self.bootloader_flavor = 'mx6qsabrelite'
577+ self.kernel_addr = '0x10000000'
578+ self.initrd_addr = '0x12000000'
579+ self.load_addr = '0x10008000'
580+ self.dtb_addr = '0x11ff0000'
581
582
583 class AndroidSamsungConfig(AndroidBoardConfig):
584- dtb_name = None
585-
586- @classmethod
587- def get_sfdisk_cmd(cls, should_align_boot_part=False):
588- loaders_min_len = (
589- cls.samsung_bl1_start + cls.samsung_bl1_len + cls.samsung_bl2_len +
590- cls.samsung_env_len)
591+ def get_sfdisk_cmd(self, should_align_boot_part=False):
592+ loaders_min_len = (self.samsung_bl1_start + self.samsung_bl1_len +
593+ self.samsung_bl2_len + self.samsung_env_len)
594
595 loader_start, loader_end, loader_len = align_partition(
596 1, loaders_min_len, 1, PART_ALIGN_S)
597
598- command = super(AndroidSamsungConfig, cls).get_sfdisk_cmd(
599+ command = super(AndroidSamsungConfig, self).get_sfdisk_cmd(
600 should_align_boot_part=False, start_addr=loader_end,
601 extra_part=True)
602
603@@ -339,40 +458,67 @@
604
605
606 class AndroidSMDKV310Config(AndroidSamsungConfig, SMDKV310Config):
607- _extra_serial_opts = 'console=tty0 console=ttySAC1,115200n8'
608- android_specific_args = 'init=/init androidboot.console=ttySAC1'
609- dtb_name = None
610+ """Placeholder class for SMDKV310 configuration inheritance."""
611+ def __init__(self):
612+ super(AndroidSMDKV310Config, self).__init__()
613+ self._extra_serial_opts = 'console=tty0 console=ttySAC1,115200n8'
614+ self._android_specific_args = 'init=/init androidboot.console=ttySAC1'
615
616
617 class AndroidOrigenConfig(AndroidSamsungConfig, OrigenConfig):
618- _extra_serial_opts = 'console=tty0 console=ttySAC2,115200n8'
619- android_specific_args = 'init=/init androidboot.console=ttySAC2'
620- dtb_name = None
621+ """Placeholder class for Origen configuration inheritance."""
622+ def __init__(self):
623+ super(AndroidOrigenConfig, self).__init__()
624+ self._extra_serial_opts = 'console=tty0 console=ttySAC2,115200n8'
625+ self._android_specific_args = 'init=/init androidboot.console=ttySAC2'
626
627
628 class AndroidOrigenQuadConfig(AndroidSamsungConfig, OrigenQuadConfig):
629- _extra_serial_opts = 'console=tty0 console=ttySAC2,115200n8'
630- android_specific_args = 'init=/init androidboot.console=ttySAC2'
631- dtb_name = None
632+ def __init__(self):
633+ super(AndroidOrigenQuadConfig, self).__init__()
634+ self._extra_serial_opts = 'console=tty0 console=ttySAC2,115200n8'
635+ self._android_specific_args = 'init=/init androidboot.console=ttySAC2'
636
637
638 class AndroidVexpressConfig(AndroidBoardConfig, VexpressConfig):
639- _extra_serial_opts = 'console=tty0 console=ttyAMA0,38400n8'
640- android_specific_args = 'init=/init androidboot.console=ttyAMA0'
641- dtb_name = None
642-
643-
644+ """Placeholder class for Vexpress configuration inheritance."""
645+ def __init__(self):
646+ super(AndroidVexpressConfig, self).__init__()
647+ self._extra_serial_opts = 'console=tty0 console=ttyAMA0,38400n8'
648+ self._android_specific_args = 'init=/init androidboot.console=ttyAMA0'
649+
650+
651+# This dictionary is composed as follows:
652+# <device_name>: <class>
653+# The <device_name> is the command line argument passed to l-a-m-c, the
654+# <class> is the corresponding config class in this file (not the instance).
655+# If a new device does not have special needs, it is possible to use the
656+# general AndroidBoardConfig class.
657 android_board_configs = {
658 'beagle': AndroidBeagleConfig,
659- 'panda': AndroidPandaConfig,
660- 'snowball_sd': AndroidSnowballSdConfig,
661- 'snowball_emmc': AndroidSnowballEmmcConfig,
662- 'smdkv310': AndroidSMDKV310Config,
663+ 'iMX53': AndroidMx53LoCoConfig,
664 'mx53loco': AndroidMx53LoCoConfig,
665- 'iMX53': AndroidMx53LoCoConfig,
666 'mx6qsabrelite': AndroidMx6QSabreliteConfig,
667 'origen': AndroidOrigenConfig,
668 'origen_quad': AndroidOrigenQuadConfig,
669+ 'panda': AndroidPandaConfig,
670+ 'smdkv310': AndroidSMDKV310Config,
671+ 'snowball_emmc': AndroidSnowballEmmcConfig,
672+ 'snowball_sd': AndroidSnowballSdConfig,
673 'vexpress': AndroidVexpressConfig,
674 'vexpress-a9': AndroidVexpressConfig,
675 }
676+
677+
678+def get_board_config(board):
679+ """Get the board configuration for the specified board.
680+
681+ :param board: The name of the board to get the configuration of.
682+ :type board: str
683+ """
684+ clazz = android_board_configs.get(board, None)
685+ if clazz:
686+ return clazz()
687+ else:
688+ raise BoardConfigException("Board name '%s' has no configuration "
689+ "available." % board)

Subscribers

People subscribed via source and target branches