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
=== modified file 'linaro-android-media-create'
--- linaro-android-media-create 2012-07-26 08:48:15 +0000
+++ linaro-android-media-create 2012-12-27 15:00:31 +0000
@@ -26,7 +26,7 @@
26from linaro_image_tools import cmd_runner26from linaro_image_tools import cmd_runner
2727
28from linaro_image_tools.media_create.android_boards import (28from linaro_image_tools.media_create.android_boards import (
29 android_board_configs,29 get_board_config,
30 )30 )
31from linaro_image_tools.media_create.check_device import (31from linaro_image_tools.media_create.check_device import (
32 confirm_device_selection_and_ensure_it_is_ready)32 confirm_device_selection_and_ensure_it_is_ready)
@@ -40,8 +40,10 @@
40 unpack_android_binary_tarball40 unpack_android_binary_tarball
41 )41 )
42from linaro_image_tools.media_create import get_android_args_parser42from linaro_image_tools.media_create import get_android_args_parser
43from linaro_image_tools.utils import ensure_command43from linaro_image_tools.utils import (
4444 ensure_command,
45 get_logger
46 )
4547
4648
47# Just define the global variables49# Just define the global variables
@@ -89,6 +91,8 @@
89 parser = get_android_args_parser()91 parser = get_android_args_parser()
90 args = parser.parse_args()92 args = parser.parse_args()
9193
94 logger = get_logger(debug=args.debug)
95
92 # If --help was specified this won't execute.96 # If --help was specified this won't execute.
93 # Create temp dir and initialize rest of path vars.97 # Create temp dir and initialize rest of path vars.
94 TMP_DIR = tempfile.mkdtemp()98 TMP_DIR = tempfile.mkdtemp()
@@ -102,13 +106,14 @@
102 DATA_DISK = os.path.join(TMP_DIR, 'userdata-disc')106 DATA_DISK = os.path.join(TMP_DIR, 'userdata-disc')
103 SDCARD_DISK = os.path.join(TMP_DIR, 'sdcard-disc')107 SDCARD_DISK = os.path.join(TMP_DIR, 'sdcard-disc')
104108
105 board_config = android_board_configs[args.dev]109 board_config = get_board_config(args.dev)
106 board_config.add_boot_args(args.extra_boot_args)110 board_config.add_boot_args(args.extra_boot_args)
107 board_config.add_boot_args_from_file(args.extra_boot_args_file)111 board_config.add_boot_args_from_file(args.extra_boot_args_file)
108112
109 if args.dev == 'iMX53':113 if args.dev == 'iMX53':
110 # XXX: remove this and the corresponding entry in android_board_configs114 # XXX: remove this and the corresponding entry in android_board_configs
111 print "DEPRECATION WARNING: iMX53 is deprecated, please use mx53loco."115 logger.warning("DEPRECATION WARNING: iMX53 is deprecated, please "
116 "use mx53loco.")
112117
113 ensure_required_commands(args)118 ensure_required_commands(args)
114119
@@ -117,11 +122,8 @@
117 if not confirm_device_selection_and_ensure_it_is_ready(args.device):122 if not confirm_device_selection_and_ensure_it_is_ready(args.device):
118 sys.exit(1)123 sys.exit(1)
119 elif not args.should_create_partitions:124 elif not args.should_create_partitions:
120 print ("Do not use --no-part in conjunction with --image_file.")125 logger.error("Do not use --no-part in conjunction with --image_file.")
121 sys.exit(1)126 sys.exit(1)
122 else:
123 # All good, move on.
124 pass
125127
126 cmd_runner.run(['mkdir', '-p', BOOT_DIR]).wait()128 cmd_runner.run(['mkdir', '-p', BOOT_DIR]).wait()
127 cmd_runner.run(['mkdir', '-p', SYSTEM_DIR]).wait()129 cmd_runner.run(['mkdir', '-p', SYSTEM_DIR]).wait()
128130
=== modified file 'linaro_image_tools/media_create/android_boards.py'
--- linaro_image_tools/media_create/android_boards.py 2012-12-12 09:35:49 +0000
+++ linaro_image_tools/media_create/android_boards.py 2012-12-27 15:00:31 +0000
@@ -20,45 +20,149 @@
20"""Configuration for boards supported by linaro-android-media-create.20"""Configuration for boards supported by linaro-android-media-create.
2121
22To add support for a new board, you need to create a subclass of22To add support for a new board, you need to create a subclass of
23AndroidBoardConfig, set appropriate values for its variables and add it to23AndroidBoardConfig, create an Android hwpack as explained here:
24android_board_configs at the bottom of this file.24
25https://wiki.linaro.org/AndroidHardwarePacksV3
26
27and add the board to 'android_board_configs' at the end of this file.
25"""28"""
2629
30import os
31import yaml
32import logging
33
34from linaro_image_tools import cmd_runner
27from linaro_image_tools.media_create.partitions import SECTOR_SIZE35from linaro_image_tools.media_create.partitions import SECTOR_SIZE
28from linaro_image_tools.media_create.boards import PART_ALIGN_S
29from linaro_image_tools.media_create.boards import BeagleConfig
30from linaro_image_tools.media_create.boards import PandaConfig
31from linaro_image_tools.media_create.boards import Mx53LoCoConfig
32from linaro_image_tools.media_create.boards import SnowballSdConfig
33from linaro_image_tools.media_create.boards import SnowballEmmcConfig
34from linaro_image_tools.media_create.boards import SMDKV310Config
35from linaro_image_tools.media_create.boards import OrigenConfig
36from linaro_image_tools.media_create.boards import OrigenQuadConfig
37from linaro_image_tools.media_create.boards import VexpressConfig
38from linaro_image_tools.media_create.boards import (36from linaro_image_tools.media_create.boards import (
37 BeagleConfig,
38 BoardConfig,
39 BoardConfigException,
40 Mx53LoCoConfig,
41 OrigenConfig,
42 OrigenQuadConfig,
43 PART_ALIGN_S,
44 PandaConfig,
45 SMDKV310Config,
46 SnowballEmmcConfig,
47 SnowballSdConfig,
48 VexpressConfig,
49 align_partition,
39 align_up,50 align_up,
40 align_partition,51 install_mx5_boot_loader,
41 classproperty,
42 make_boot_script,52 make_boot_script,
43 install_mx5_boot_loader,
44 )53 )
4554from linaro_image_tools.utils import DEFAULT_LOGGER_NAME
46from linaro_image_tools import cmd_runner55
47import os56logger = logging.getLogger(DEFAULT_LOGGER_NAME)
4857
4958BOOT_MIN_SIZE_S = align_up(128 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
50class AndroidBoardConfig(object):59SYSTEM_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
51 @classmethod60CACHE_MIN_SIZE_S = align_up(256 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
52 def _get_bootargs(cls, consoles):61USERDATA_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
62SDCARD_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
63LOADER_MIN_SIZE_S = align_up(1 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
64
65
66class AndroidBoardConfig(BoardConfig):
67
68 def __init__(self):
69 super(AndroidBoardConfig, self).__init__()
70 self.dtb_name = None
71 self._extra_serial_opts = []
72 self._android_specific_args = []
73 self._extra_boot_args_options = []
74 self._live_serial_options = []
75
76 def _get_android_specific_args(self):
77 android_args = self._android_specific_args
78 if isinstance(android_args, list):
79 android_args = ' '.join(self._android_specific_args)
80 return android_args
81
82 def _set_android_specific_args(self, value):
83 self._android_specific_args = value
84
85 android_specific_args = property(_get_android_specific_args,
86 _set_android_specific_args)
87
88 def _get_extra_boot_args_options(self):
89 extra_boot_args = self._extra_boot_args_options
90 if isinstance(extra_boot_args, list):
91 extra_boot_args = ' '.join(self._extra_boot_args_options)
92 return extra_boot_args
93
94 def _set_extra_boot_args_options(self, value):
95 self._extra_boot_args_options = value
96
97 extra_boot_args_options = property(_get_extra_boot_args_options,
98 _set_extra_boot_args_options)
99
100 def _get_extra_serial_opts(self):
101 extra_serial = self._extra_serial_opts
102 if isinstance(extra_serial, list):
103 extra_serial = ' '.join(self._extra_serial_opts)
104 return extra_serial
105
106 def _set_extra_serial_opts(self, value):
107 self._extra_serial_opts = value
108
109 extra_serial_opts = property(_get_extra_serial_opts,
110 _set_extra_serial_opts)
111
112 def _get_live_serial_options(self):
113 serial_options = self._live_serial_options
114 if serial_options:
115 if isinstance(serial_options, list):
116 serial_options = ' '.join(self._live_serial_options)
117 if self._check_placeholder_presence(serial_options, '%s'):
118 serial_options = serial_options % self.serial_tty
119 return serial_options
120
121 def _set_live_serial_options(self, value):
122 self._live_serial_options = value
123
124 live_serial_options = property(_get_live_serial_options,
125 _set_live_serial_options)
126
127 def from_file(self, hwpack):
128 """Loads the Android board configuration from an Android hardware pack
129 configuration file and sets the config attributes with their values.
130
131 :param hwpack: The Android hwpack configuration file.
132 :return The configuration read from the file as a dictionary.
133 """
134 try:
135 config = yaml.safe_load(hwpack)
136 self._set_attributes(config)
137 return config
138 except yaml.YAMLError, ex:
139 logger.debug("Error loading YAML file %s" % hwpack, ex)
140 raise BoardConfigException("Error reading Android hwpack %s"
141 % hwpack)
142
143 def _set_attributes(self, config):
144 """Initialize the class attributes with the values read from the
145 Android hardware pack configuration file.
146
147 :param config: The config read from the Android hwpack.
148 """
149 for name, value in config.iteritems():
150 if hasattr(self, name):
151 setattr(self, name, value)
152 else:
153 logger.warning("Attribute '%s' does not belong to this "
154 "instance of '%s'." % (name, self.__class__))
155
156 def _get_bootargs(self, consoles):
53 """Get the bootargs for this board.157 """Get the bootargs for this board.
54158
55 In general subclasses should not have to override this.159 In general subclasses should not have to override this.
56 """160 """
57 boot_args_options = 'rootwait ro'161 boot_args_options = 'rootwait ro'
58 if cls.extra_boot_args_options is not None:162 if self.extra_boot_args_options:
59 boot_args_options += ' %s' % cls.extra_boot_args_options163 boot_args_options += ' %s' % self.extra_boot_args_options
60 boot_args_options += ' %s' % cls.android_specific_args164 boot_args_options += ' %s' % self.android_specific_args
61 serial_opts = cls._extra_serial_opts165 serial_opts = self.extra_serial_opts
62 for console in consoles:166 for console in consoles:
63 serial_opts += ' console=%s' % console167 serial_opts += ' console=%s' % console
64168
@@ -70,34 +174,32 @@
70 "%(boot_args_options)s"174 "%(boot_args_options)s"
71 % replacements)175 % replacements)
72176
73 @classmethod177 def _get_boot_env(self, consoles):
74 def _get_boot_env(cls, consoles):
75 """Get the boot environment for this board.178 """Get the boot environment for this board.
76179
77 In general subclasses should not have to override this.180 In general subclasses should not have to override this.
78 """181 """
79 boot_env = {}182 boot_env = {}
80 boot_env["bootargs"] = cls._get_bootargs(consoles)183 boot_env["bootargs"] = self._get_bootargs(consoles)
81 initrd = False184 initrd = False
82 if cls.initrd_addr:185 if self.initrd_addr:
83 initrd = True186 initrd = True
84 # On Android, the DTB file is always built as part of the kernel it187 # On Android, the DTB file is always built as part of the kernel it
85 # comes from - and lives in the same directory in the boot tarball, so188 # comes from - and lives in the same directory in the boot tarball, so
86 # here we don't need to pass the whole path to it.189 # here we don't need to pass the whole path to it.
87 boot_env["bootcmd"] = cls._get_bootcmd(initrd, cls.dtb_name)190 boot_env["bootcmd"] = self._get_bootcmd(initrd, self.dtb_name)
88 boot_env["initrd_high"] = cls.initrd_high191 boot_env["initrd_high"] = self.initrd_high
89 boot_env["fdt_high"] = cls.fdt_high192 boot_env["fdt_high"] = self.fdt_high
90 return boot_env193 return boot_env
91194
92 @classmethod195 def populate_boot_script(self, boot_partition, boot_disk, consoles):
93 def populate_boot_script(cls, boot_partition, boot_disk, consoles):
94 cmd_runner.run(['mkdir', '-p', boot_disk]).wait()196 cmd_runner.run(['mkdir', '-p', boot_disk]).wait()
95 # TODO: Use partition_mounted() here to make sure the partition is197 # TODO: Use partition_mounted() here to make sure the partition is
96 # always umounted after we're done.198 # always umounted after we're done.
97 cmd_runner.run(['mount', boot_partition, boot_disk],199 cmd_runner.run(['mount', boot_partition, boot_disk],
98 as_root=True).wait()200 as_root=True).wait()
99201
100 boot_env = cls._get_boot_env(consoles)202 boot_env = self._get_boot_env(consoles)
101 cmdline_filepath = os.path.join(boot_disk, "cmdline")203 cmdline_filepath = os.path.join(boot_disk, "cmdline")
102 cmdline_file = open(cmdline_filepath, 'r')204 cmdline_file = open(cmdline_filepath, 'r')
103 android_kernel_cmdline = cmdline_file.read()205 android_kernel_cmdline = cmdline_file.read()
@@ -106,7 +208,7 @@
106 cmdline_file.close()208 cmdline_file.close()
107209
108 boot_dir = boot_disk210 boot_dir = boot_disk
109 boot_script_path = os.path.join(boot_dir, cls.boot_script)211 boot_script_path = os.path.join(boot_dir, self.boot_script)
110 make_boot_script(boot_env, boot_script_path)212 make_boot_script(boot_env, boot_script_path)
111213
112 cmd_runner.run(['sync']).wait()214 cmd_runner.run(['sync']).wait()
@@ -115,25 +217,13 @@
115 except cmd_runner.SubcommandNonZeroReturnValue:217 except cmd_runner.SubcommandNonZeroReturnValue:
116 pass218 pass
117219
118 @classmethod220 def get_sfdisk_cmd(self, should_align_boot_part=False,
119 def get_sfdisk_cmd(cls, should_align_boot_part=False,
120 start_addr=0, extra_part=False):221 start_addr=0, extra_part=False):
121 if cls.fat_size == 32:222 if self.fat_size == 32:
122 partition_type = '0x0C'223 partition_type = '0x0C'
123 else:224 else:
124 partition_type = '0x0E'225 partition_type = '0x0E'
125226
126 BOOT_MIN_SIZE_S = align_up(
127 128 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
128 SYSTEM_MIN_SIZE_S = align_up(
129 512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
130 CACHE_MIN_SIZE_S = align_up(
131 256 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
132 USERDATA_MIN_SIZE_S = align_up(
133 512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
134 SDCARD_MIN_SIZE_S = align_up(
135 512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
136
137 # align on sector 63 for compatibility with broken versions of x-loader227 # align on sector 63 for compatibility with broken versions of x-loader
138 # unless align_boot_part is set228 # unless align_boot_part is set
139 boot_align = 63229 boot_align = 63
@@ -175,86 +265,89 @@
175 cache_start, _cache_len, userdata_start, userdata_start,265 cache_start, _cache_len, userdata_start, userdata_start,
176 _userdata_len, sdcard_start)266 _userdata_len, sdcard_start)
177267
178 @classmethod268 def populate_raw_partition(self, media, boot_dir):
179 def populate_raw_partition(cls, media, boot_dir):269 super(AndroidBoardConfig, self).populate_raw_partition(media, boot_dir)
180 super(AndroidBoardConfig, cls).populate_raw_partition(media, boot_dir)
181270
182 @classmethod271 def install_boot_loader(self, boot_partition, boot_device_or_file):
183 def install_boot_loader(cls, boot_partition, boot_device_or_file):
184 pass272 pass
185273
186274
187class AndroidOmapConfig(AndroidBoardConfig):275class AndroidOmapConfig(AndroidBoardConfig):
188 dtb_name = None276 """Placeholder class for OMAP configuration inheritance."""
189277
190278
191class AndroidBeagleConfig(AndroidOmapConfig, BeagleConfig):279class AndroidBeagleConfig(AndroidOmapConfig, BeagleConfig):
192 _extra_serial_opts = 'console=tty0 console=ttyO2,115200n8'280 """Placeholder class for Beagle configuration inheritance."""
193 android_specific_args = 'init=/init androidboot.console=ttyO2'281 def __init__(self):
194 dtb_name = None282 super(AndroidBeagleConfig, self).__init__()
195283 self._android_specific_args = 'init=/init androidboot.console=ttyO2'
196284 self._extra_serial_opts = 'console=tty0 console=ttyO2,115200n8'
197class AndroidPandaConfig(AndroidOmapConfig, PandaConfig):285
198 bootloader_flavor = 'omap4_panda'286
199 dtb_addr = '0x815f0000'287class AndroidPandaConfig(AndroidBoardConfig, PandaConfig):
200 dtb_name = 'board.dtb'288 """Placeholder class for Panda configuration inheritance."""
201 _extra_serial_opts = 'console=ttyO2,115200n8'289 def __init__(self):
202 extra_boot_args_options = (290 super(AndroidPandaConfig, self).__init__()
203 'earlyprintk fixrtc nocompcache vram=48M '291 self.dtb_name = 'board.dtb'
204 'omapfb.vram=0:24M,1:24M mem=456M@0x80000000 mem=512M@0xA0000000')292 self._extra_serial_opts = 'console=ttyO2,115200n8'
205 android_specific_args = 'init=/init androidboot.console=ttyO2'293 self._extra_boot_args_options = (
294 'earlyprintk fixrtc nocompcache vram=48M '
295 'omapfb.vram=0:24M,1:24M mem=456M@0x80000000 mem=512M@0xA0000000')
296 self._android_specific_args = 'init=/init androidboot.console=ttyO2'
297 self.dtb_addr = '0x815f0000'
298 self.bootloader_flavor = 'omap4_panda'
206299
207300
208class AndroidSnowballSdConfig(AndroidBoardConfig, SnowballSdConfig):301class AndroidSnowballSdConfig(AndroidBoardConfig, SnowballSdConfig):
209 boot_script = 'boot.scr'302 """Placeholder class for Snowball Sd configuration inheritance."""
210 fdt_high = '0x05000000'303 def __init__(self):
211 initrd_addr = '0x05000000'304 super(AndroidSnowballSdConfig, self).__init__()
212 initrd_high = '0x06000000'305 self.dtb_name = 'board.dtb'
213 extra_boot_args_options = (306 self._android_specific_args = 'init=/init androidboot.console=ttyAMA2'
214 'earlyprintk mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '307 self._extra_boot_args_options = (
215 'mem=22M@360M mem_issw=1M@383M mem=640M@384M vmalloc=500M')308 'earlyprintk mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
216 _extra_serial_opts = 'console=ttyAMA2,115200n8'309 'mem=22M@360M mem_issw=1M@383M mem=640M@384M vmalloc=500M')
217 android_specific_args = 'init=/init androidboot.console=ttyAMA2'310 self._extra_serial_opts = 'console=ttyAMA2,115200n8'
218 dtb_name = 'board.dtb'311 self.boot_script = 'boot.scr'
219 dtb_addr = '0x8000000'312 self.fdt_high = '0x05000000'
313 self.initrd_addr = '0x05000000'
314 self.initrd_high = '0x06000000'
315 self.dtb_addr = '0x8000000'
220316
221317
222class AndroidSnowballEmmcConfig(AndroidBoardConfig, SnowballEmmcConfig):318class AndroidSnowballEmmcConfig(AndroidBoardConfig, SnowballEmmcConfig):
223 boot_script = 'boot.scr'319 """Class for Snowball Emmc configuration inheritance."""
224 fdt_high = '0x05000000'320 def __init__(self):
225 initrd_addr = '0x05000000'321 super(AndroidSnowballEmmcConfig, self).__init__()
226 initrd_high = '0x06000000'322 self.dtb_name = 'board.dtb'
227 extra_boot_args_options = (323 self._extra_boot_args_options = (
228 'earlyprintk mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '324 'earlyprintk mem=128M@0 mali.mali_mem=64M@128M hwmem=168M@192M '
229 'mem=22M@360M mem_issw=1M@383M mem=640M@384M vmalloc=500M')325 'mem=22M@360M mem_issw=1M@383M mem=640M@384M vmalloc=500M')
230 _extra_serial_opts = 'console=ttyAMA2,115200n8'326 self._extra_serial_opts = 'console=ttyAMA2,115200n8'
231 android_specific_args = 'init=/init androidboot.console=ttyAMA2'327 self._android_specific_args = 'init=/init androidboot.console=ttyAMA2'
232 mmc_option = '0:2'328 self.boot_script = 'boot.scr'
233 dtb_name = 'board.dtb'329 self.fdt_high = '0x05000000'
234 dtb_addr = '0x8000000'330 self.initrd_addr = '0x05000000'
235331 self.initrd_high = '0x06000000'
236 @classmethod332 self.mmc_option = '0:2'
237 def get_sfdisk_cmd(cls, should_align_boot_part=False):333 self.dtb_addr = '0x8000000'
238334
239 LOADER_MIN_SIZE_S = align_up(335 def get_sfdisk_cmd(self, should_align_boot_part=False):
240 1 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
241
242 loader_start, loader_end, loader_len = align_partition(336 loader_start, loader_end, loader_len = align_partition(
243 SnowballEmmcConfig.SNOWBALL_LOADER_START_S,337 SnowballEmmcConfig.SNOWBALL_LOADER_START_S,
244 LOADER_MIN_SIZE_S, 1, PART_ALIGN_S)338 LOADER_MIN_SIZE_S, 1, PART_ALIGN_S)
245339
246 command = super(AndroidSnowballEmmcConfig, cls).get_sfdisk_cmd(340 command = super(AndroidSnowballEmmcConfig, self).get_sfdisk_cmd(
247 should_align_boot_part=True, start_addr=loader_end,341 should_align_boot_part=True, start_addr=loader_end,
248 extra_part=True)342 extra_part=True)
249343
250 return '%s,%s,0xDA\n%s' % (344 return '%s,%s,0xDA\n%s' % (
251 loader_start, loader_len, command)345 loader_start, loader_len, command)
252346
253 @classmethod347 def populate_raw_partition(self, media, boot_dir):
254 def populate_raw_partition(cls, media, boot_dir):
255 # To avoid adding a Snowball specific command line option, we assume348 # To avoid adding a Snowball specific command line option, we assume
256 # that the user already has unpacked the startfiles to ./startupfiles349 # that the user already has unpacked the startfiles to ./startupfiles
257 config_files_dir = cls.snowball_config(boot_dir)350 config_files_dir = self.snowball_config(boot_dir)
258 assert os.path.exists(config_files_dir), (351 assert os.path.exists(config_files_dir), (
259 "You need to unpack the Snowball startupfiles to the directory "352 "You need to unpack the Snowball startupfiles to the directory "
260 "'startupfiles' in your current working directory. See "353 "'startupfiles' in your current working directory. See "
@@ -265,72 +358,98 @@
265 for boot_file in boot_files:358 for boot_file in boot_files:
266 cmd_runner.run(['cp', os.path.join(boot_dir, 'boot', boot_file),359 cmd_runner.run(['cp', os.path.join(boot_dir, 'boot', boot_file),
267 config_files_dir], as_root=True).wait()360 config_files_dir], as_root=True).wait()
268 super(AndroidSnowballEmmcConfig, cls).populate_raw_partition(361 super(AndroidSnowballEmmcConfig, self).populate_raw_partition(
269 media, boot_dir)362 media, boot_dir)
270363
271 @classmethod364 def snowball_config(self, chroot_dir):
272 def snowball_config(cls, chroot_dir):
273 # The user is expected to have unpacked the startupfiles to this subdir365 # The user is expected to have unpacked the startupfiles to this subdir
274 # of their working dir.366 # of their working dir.
275 return os.path.join('.', 'startupfiles')367 return os.path.join('.', 'startupfiles')
276368
277 @classproperty369 @property
278 def delete_startupfiles(cls):370 def delete_startupfiles(self):
279 # The startupfiles will have been unpacked to the user's working dir371 # The startupfiles will have been unpacked to the user's working dir
280 # and should not be deleted after they have been installed.372 # and should not be deleted after they have been installed.
281 return False373 return False
282374
283375
284class AndroidMx53LoCoConfig(AndroidBoardConfig, Mx53LoCoConfig):376class AndroidMx53LoCoConfig(AndroidBoardConfig, Mx53LoCoConfig):
285 extra_boot_args_options = (377 """Class for Mx53LoCo configuration inheritance."""
286 'earlyprintk rootdelay=1 fixrtc nocompcache di1_primary tve')378 def __init__(self):
287 _extra_serial_opts = 'console=%s,115200n8' % (379 super(AndroidMx53LoCoConfig, self).__init__()
288 Mx53LoCoConfig.serial_tty)380 self._extra_boot_args_options = (
289 android_specific_args = 'init=/init androidboot.console=%s' % (381 'earlyprintk rootdelay=1 fixrtc nocompcache di1_primary tve')
290 Mx53LoCoConfig.serial_tty)382 self._extra_serial_opts = 'console=%s,115200n8'
291 dtb_name = None383 self._android_specific_args = 'init=/init androidboot.console=%s'
292384
293 @classmethod385 def _get_extra_serial_opts(self):
294 def get_sfdisk_cmd(cls, should_align_boot_part=False):386 serial_opts = self._extra_serial_opts
387 if serial_opts:
388 if isinstance(serial_opts, list):
389 serial_opts = ' '.join(serial_opts)
390 if self._check_placeholder_presence(serial_opts, '%s'):
391 serial_opts = serial_opts % self.serial_tty
392 return serial_opts
393
394 def _set_extra_serial_opts(self, value):
395 self._extra_serial_opts = value
396
397 extra_serial_opts = property(_get_extra_serial_opts,
398 _set_extra_serial_opts)
399
400 def _get_android_specific_args(self):
401 android_args = self._android_specific_args
402 if android_args:
403 if isinstance(android_args, list):
404 android_args = ' '.join(android_args)
405 if self._check_placeholder_presence(android_args, '%s'):
406 android_args = android_args % self.serial_tty
407 return android_args
408
409 def _set_android_specific_args(self, value):
410 self._android_specific_args = value
411
412 android_specific_args = property(_get_android_specific_args,
413 _set_android_specific_args)
414
415 def get_sfdisk_cmd(self, should_align_boot_part=False):
295 loader_start, loader_end, loader_len = align_partition(416 loader_start, loader_end, loader_len = align_partition(
296 1, cls.LOADER_MIN_SIZE_S, 1, PART_ALIGN_S)417 1, self.LOADER_MIN_SIZE_S, 1, PART_ALIGN_S)
297418
298 command = super(AndroidMx53LoCoConfig, cls).get_sfdisk_cmd(419 command = super(AndroidMx53LoCoConfig, self).get_sfdisk_cmd(
299 should_align_boot_part=True, start_addr=loader_end,420 should_align_boot_part=True, start_addr=loader_end,
300 extra_part=True)421 extra_part=True)
301422
302 return '%s,%s,0xDA\n%s' % (423 return '%s,%s,0xDA\n%s' % (
303 loader_start, loader_len, command)424 loader_start, loader_len, command)
304425
305 @classmethod426 def install_boot_loader(self, boot_partition, boot_device_or_file):
306 def install_boot_loader(cls, boot_partition, boot_device_or_file):
307 install_mx5_boot_loader(427 install_mx5_boot_loader(
308 os.path.join(boot_device_or_file, "u-boot.imx"),428 os.path.join(boot_device_or_file, "u-boot.imx"),
309 boot_partition, cls.LOADER_MIN_SIZE_S)429 boot_partition, self.LOADER_MIN_SIZE_S)
310430
311431
312class AndroidMx6QSabreliteConfig(AndroidMx53LoCoConfig):432class AndroidMx6QSabreliteConfig(AndroidMx53LoCoConfig):
313 bootloader_flavor = 'mx6qsabrelite'433 """Placeholder class for Mx6Q Sabrelite configuration inheritance."""
314 kernel_addr = '0x10000000'434 def __init__(self):
315 initrd_addr = '0x12000000'435 super(AndroidMx6QSabreliteConfig, self).__init__()
316 load_addr = '0x10008000'436 self.dtb_name = 'board.dtb'
317 dtb_addr = '0x11ff0000'437 self.bootloader_flavor = 'mx6qsabrelite'
318 dtb_name = 'board.dtb'438 self.kernel_addr = '0x10000000'
439 self.initrd_addr = '0x12000000'
440 self.load_addr = '0x10008000'
441 self.dtb_addr = '0x11ff0000'
319442
320443
321class AndroidSamsungConfig(AndroidBoardConfig):444class AndroidSamsungConfig(AndroidBoardConfig):
322 dtb_name = None445 def get_sfdisk_cmd(self, should_align_boot_part=False):
323446 loaders_min_len = (self.samsung_bl1_start + self.samsung_bl1_len +
324 @classmethod447 self.samsung_bl2_len + self.samsung_env_len)
325 def get_sfdisk_cmd(cls, should_align_boot_part=False):
326 loaders_min_len = (
327 cls.samsung_bl1_start + cls.samsung_bl1_len + cls.samsung_bl2_len +
328 cls.samsung_env_len)
329448
330 loader_start, loader_end, loader_len = align_partition(449 loader_start, loader_end, loader_len = align_partition(
331 1, loaders_min_len, 1, PART_ALIGN_S)450 1, loaders_min_len, 1, PART_ALIGN_S)
332451
333 command = super(AndroidSamsungConfig, cls).get_sfdisk_cmd(452 command = super(AndroidSamsungConfig, self).get_sfdisk_cmd(
334 should_align_boot_part=False, start_addr=loader_end,453 should_align_boot_part=False, start_addr=loader_end,
335 extra_part=True)454 extra_part=True)
336455
@@ -339,40 +458,67 @@
339458
340459
341class AndroidSMDKV310Config(AndroidSamsungConfig, SMDKV310Config):460class AndroidSMDKV310Config(AndroidSamsungConfig, SMDKV310Config):
342 _extra_serial_opts = 'console=tty0 console=ttySAC1,115200n8'461 """Placeholder class for SMDKV310 configuration inheritance."""
343 android_specific_args = 'init=/init androidboot.console=ttySAC1'462 def __init__(self):
344 dtb_name = None463 super(AndroidSMDKV310Config, self).__init__()
464 self._extra_serial_opts = 'console=tty0 console=ttySAC1,115200n8'
465 self._android_specific_args = 'init=/init androidboot.console=ttySAC1'
345466
346467
347class AndroidOrigenConfig(AndroidSamsungConfig, OrigenConfig):468class AndroidOrigenConfig(AndroidSamsungConfig, OrigenConfig):
348 _extra_serial_opts = 'console=tty0 console=ttySAC2,115200n8'469 """Placeholder class for Origen configuration inheritance."""
349 android_specific_args = 'init=/init androidboot.console=ttySAC2'470 def __init__(self):
350 dtb_name = None471 super(AndroidOrigenConfig, self).__init__()
472 self._extra_serial_opts = 'console=tty0 console=ttySAC2,115200n8'
473 self._android_specific_args = 'init=/init androidboot.console=ttySAC2'
351474
352475
353class AndroidOrigenQuadConfig(AndroidSamsungConfig, OrigenQuadConfig):476class AndroidOrigenQuadConfig(AndroidSamsungConfig, OrigenQuadConfig):
354 _extra_serial_opts = 'console=tty0 console=ttySAC2,115200n8'477 def __init__(self):
355 android_specific_args = 'init=/init androidboot.console=ttySAC2'478 super(AndroidOrigenQuadConfig, self).__init__()
356 dtb_name = None479 self._extra_serial_opts = 'console=tty0 console=ttySAC2,115200n8'
480 self._android_specific_args = 'init=/init androidboot.console=ttySAC2'
357481
358482
359class AndroidVexpressConfig(AndroidBoardConfig, VexpressConfig):483class AndroidVexpressConfig(AndroidBoardConfig, VexpressConfig):
360 _extra_serial_opts = 'console=tty0 console=ttyAMA0,38400n8'484 """Placeholder class for Vexpress configuration inheritance."""
361 android_specific_args = 'init=/init androidboot.console=ttyAMA0'485 def __init__(self):
362 dtb_name = None486 super(AndroidVexpressConfig, self).__init__()
363487 self._extra_serial_opts = 'console=tty0 console=ttyAMA0,38400n8'
364488 self._android_specific_args = 'init=/init androidboot.console=ttyAMA0'
489
490
491# This dictionary is composed as follows:
492# <device_name>: <class>
493# The <device_name> is the command line argument passed to l-a-m-c, the
494# <class> is the corresponding config class in this file (not the instance).
495# If a new device does not have special needs, it is possible to use the
496# general AndroidBoardConfig class.
365android_board_configs = {497android_board_configs = {
366 'beagle': AndroidBeagleConfig,498 'beagle': AndroidBeagleConfig,
367 'panda': AndroidPandaConfig,499 'iMX53': AndroidMx53LoCoConfig,
368 'snowball_sd': AndroidSnowballSdConfig,
369 'snowball_emmc': AndroidSnowballEmmcConfig,
370 'smdkv310': AndroidSMDKV310Config,
371 'mx53loco': AndroidMx53LoCoConfig,500 'mx53loco': AndroidMx53LoCoConfig,
372 'iMX53': AndroidMx53LoCoConfig,
373 'mx6qsabrelite': AndroidMx6QSabreliteConfig,501 'mx6qsabrelite': AndroidMx6QSabreliteConfig,
374 'origen': AndroidOrigenConfig,502 'origen': AndroidOrigenConfig,
375 'origen_quad': AndroidOrigenQuadConfig,503 'origen_quad': AndroidOrigenQuadConfig,
504 'panda': AndroidPandaConfig,
505 'smdkv310': AndroidSMDKV310Config,
506 'snowball_emmc': AndroidSnowballEmmcConfig,
507 'snowball_sd': AndroidSnowballSdConfig,
376 'vexpress': AndroidVexpressConfig,508 'vexpress': AndroidVexpressConfig,
377 'vexpress-a9': AndroidVexpressConfig,509 'vexpress-a9': AndroidVexpressConfig,
378 }510 }
511
512
513def get_board_config(board):
514 """Get the board configuration for the specified board.
515
516 :param board: The name of the board to get the configuration of.
517 :type board: str
518 """
519 clazz = android_board_configs.get(board, None)
520 if clazz:
521 return clazz()
522 else:
523 raise BoardConfigException("Board name '%s' has no configuration "
524 "available." % board)

Subscribers

People subscribed via source and target branches