Merge lp:~jeremychang/linaro-image-tools/android-boottarball into lp:linaro-image-tools/11.11
- android-boottarball
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | James Westby |
Approved revision: | 330 |
Merged at revision: | 328 |
Proposed branch: | lp:~jeremychang/linaro-image-tools/android-boottarball |
Merge into: | lp:linaro-image-tools/11.11 |
Diff against target: |
503 lines (+201/-129) (has conflicts) 5 files modified
linaro-android-media-create (+14/-19) linaro_image_tools/media_create/__init__.py (+6/-14) linaro_image_tools/media_create/android_boards.py (+158/-0) linaro_image_tools/media_create/boards.py (+0/-53) linaro_image_tools/media_create/partitions.py (+23/-43) Text conflict in linaro-android-media-create |
To merge this branch: | bzr merge lp:~jeremychang/linaro-image-tools/android-boottarball |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Westby (community) | Approve | ||
Review via email: mp+58545@code.launchpad.net |
Commit message
Description of the change
The change is dedicated on android tarballs deployment.
Some functions/fixes are list below:
* Android boot tarball deployment added.
* fix bug, https:/
James Westby (james-w) wrote : | # |
Alexander Sack (asac) wrote : | # |
this is needed for next week android beta release. please merge and file bugs for us to follow up on comments.
Alexander Sack (asac) wrote : | # |
let me test ....
Alexander Sack (asac) wrote : | # |
--dev panda spits out a warning after formatting, but seems to work.
This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
mkfs.vfat 3.0.9 (31 Jan 2010)
Image Name: boot script
Created: Fri Apr 22 12:23:05 2011
Image Type: ARM Linux Script (uncompressed)
Data Size: 330 Bytes = 0.32 kB = 0.00 MB
Load Address: 00000000
Entry Point: 00000000
Contents:
Image 0: 322 Bytes = 0.31 kB = 0.00 MB
umount: /tmp/tmpESyiEo/
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
- 328. By Jeremy Chang
-
Use import to replace the duplicatd code
- 329. By Jeremy Chang
-
Fix umount error
Fix the error of umount: device is busy by close the file
- 330. By Jeremy Chang
-
Share more between the two bootscript
Jeremy Chang (jeremychang) wrote : | # |
Hi, Alexander:
I fixed the umount error. Thanks for the feedback.
Hi, James:
Thanks for your review and suggestion. I improved the code to
share more in between and pushed.
If there's more could be better or comments, please let me know.
Thanks,
--
-Jeremy
On Fri, Apr 22, 2011 at 7:03 PM, Alexander Sack <email address hidden> wrote:
> --dev panda spits out a warning after formatting, but seems to work.
>
> This filesystem will be automatically checked every 23 mounts or
> 180 days, whichever comes first. Use tune2fs -c or -i to override.
> mkfs.vfat 3.0.9 (31 Jan 2010)
> Image Name: boot script
> Created: Fri Apr 22 12:23:05 2011
> Image Type: ARM Linux Script (uncompressed)
> Data Size: 330 Bytes = 0.32 kB = 0.00 MB
> Load Address: 00000000
> Entry Point: 00000000
> Contents:
> Image 0: 322 Bytes = 0.31 kB = 0.00 MB
> umount: /tmp/tmpESyiEo/
> (In some cases useful info about processes that use
> the device is found by lsof(8) or fuser(1))
> --
> https:/
> You are the owner of lp:~jeremychang/linaro-image-tools/android-boottarball.
>
James Westby (james-w) : | # |
Preview Diff
1 | === modified file 'linaro-android-media-create' | |||
2 | --- linaro-android-media-create 2011-04-22 07:42:34 +0000 | |||
3 | +++ linaro-android-media-create 2011-04-22 15:11:32 +0000 | |||
4 | @@ -25,10 +25,13 @@ | |||
5 | 25 | 25 | ||
6 | 26 | from linaro_image_tools import cmd_runner | 26 | from linaro_image_tools import cmd_runner |
7 | 27 | 27 | ||
9 | 28 | from linaro_image_tools.media_create.boards import android_board_configs | 28 | from linaro_image_tools.media_create.android_boards import android_board_configs |
10 | 29 | from linaro_image_tools.media_create.check_device import ( | 29 | from linaro_image_tools.media_create.check_device import ( |
11 | 30 | confirm_device_selection_and_ensure_it_is_ready) | 30 | confirm_device_selection_and_ensure_it_is_ready) |
12 | 31 | <<<<<<< TREE | ||
13 | 31 | from linaro_image_tools.media_create.chroot_utils import install_hwpacks | 32 | from linaro_image_tools.media_create.chroot_utils import install_hwpacks |
14 | 33 | ======= | ||
15 | 34 | >>>>>>> MERGE-SOURCE | ||
16 | 32 | from linaro_image_tools.media_create.partitions import ( | 35 | from linaro_image_tools.media_create.partitions import ( |
17 | 33 | Media, | 36 | Media, |
18 | 34 | setup_partitions, | 37 | setup_partitions, |
19 | @@ -46,9 +49,7 @@ | |||
20 | 46 | 49 | ||
21 | 47 | # Just define the global variables | 50 | # Just define the global variables |
22 | 48 | TMP_DIR = None | 51 | TMP_DIR = None |
23 | 49 | ROOTFS_DIR = None | ||
24 | 50 | BOOT_DISK = None | 52 | BOOT_DISK = None |
25 | 51 | ROOT_DISK = None | ||
26 | 52 | SYSTEM_DISK = None | 53 | SYSTEM_DISK = None |
27 | 53 | CACHE_DISK = None | 54 | CACHE_DISK = None |
28 | 54 | DATA_DISK = None | 55 | DATA_DISK = None |
29 | @@ -61,11 +62,11 @@ | |||
30 | 61 | def cleanup_tempdir(): | 62 | def cleanup_tempdir(): |
31 | 62 | """Remove TEMP_DIR with all its contents. | 63 | """Remove TEMP_DIR with all its contents. |
32 | 63 | 64 | ||
34 | 64 | Before doing so, make sure BOOT_DISK and ROOT_DISK are not mounted. | 65 | Before doing so, make sure DISKs are not mounted. |
35 | 65 | """ | 66 | """ |
36 | 66 | devnull = open('/dev/null', 'w') | 67 | devnull = open('/dev/null', 'w') |
37 | 67 | # ignore non-zero return codes | 68 | # ignore non-zero return codes |
39 | 68 | for disk in BOOT_DISK, ROOT_DISK, SYSTEM_DISK, CACHE_DISK, DATA_DISK, \ | 69 | for disk in BOOT_DISK, SYSTEM_DISK, CACHE_DISK, DATA_DISK, \ |
40 | 69 | SDCARD_DISK: | 70 | SDCARD_DISK: |
41 | 70 | if disk is not None: | 71 | if disk is not None: |
42 | 71 | try: | 72 | try: |
43 | @@ -86,10 +87,6 @@ | |||
44 | 86 | if not is_arm_host(): | 87 | if not is_arm_host(): |
45 | 87 | required_commands.append('qemu-arm-static') | 88 | required_commands.append('qemu-arm-static') |
46 | 88 | required_commands.append('qemu-img') | 89 | required_commands.append('qemu-img') |
47 | 89 | if args.rootfs in ['ext2', 'ext3', 'ext4']: | ||
48 | 90 | required_commands.append('mkfs.%s' % args.rootfs) | ||
49 | 91 | else: | ||
50 | 92 | required_commands.append('mkfs.btrfs') | ||
51 | 93 | for command in required_commands: | 90 | for command in required_commands: |
52 | 94 | ensure_command(command) | 91 | ensure_command(command) |
53 | 95 | 92 | ||
54 | @@ -108,12 +105,11 @@ | |||
55 | 108 | # If --help was specified this won't execute. | 105 | # If --help was specified this won't execute. |
56 | 109 | # Create temp dir and initialize rest of path vars. | 106 | # Create temp dir and initialize rest of path vars. |
57 | 110 | TMP_DIR = tempfile.mkdtemp() | 107 | TMP_DIR = tempfile.mkdtemp() |
59 | 111 | ROOT_DIR = os.path.join(TMP_DIR, 'root') | 108 | BOOT_DIR = os.path.join(TMP_DIR, 'boot') |
60 | 112 | SYSTEM_DIR = os.path.join(TMP_DIR, 'system') | 109 | SYSTEM_DIR = os.path.join(TMP_DIR, 'system') |
61 | 113 | DATA_DIR = os.path.join(TMP_DIR, 'data') | 110 | DATA_DIR = os.path.join(TMP_DIR, 'data') |
62 | 114 | 111 | ||
63 | 115 | BOOT_DISK = os.path.join(TMP_DIR, 'boot-disc') | 112 | BOOT_DISK = os.path.join(TMP_DIR, 'boot-disc') |
64 | 116 | ROOT_DISK = os.path.join(TMP_DIR, 'root-disc') | ||
65 | 117 | SYSTEM_DISK = os.path.join(TMP_DIR, 'system-disc') | 113 | SYSTEM_DISK = os.path.join(TMP_DIR, 'system-disc') |
66 | 118 | CACHE_DISK = os.path.join(TMP_DIR, 'cache-disc') | 114 | CACHE_DISK = os.path.join(TMP_DIR, 'cache-disc') |
67 | 119 | DATA_DISK = os.path.join(TMP_DIR, 'userdata-disc') | 115 | DATA_DISK = os.path.join(TMP_DIR, 'userdata-disc') |
68 | @@ -135,23 +131,22 @@ | |||
69 | 135 | # All good, move on. | 131 | # All good, move on. |
70 | 136 | pass | 132 | pass |
71 | 137 | 133 | ||
74 | 138 | 134 | cmd_runner.run(['mkdir', '-p', BOOT_DIR]).wait() | |
73 | 139 | cmd_runner.run(['mkdir', '-p', ROOT_DIR]).wait() | ||
75 | 140 | cmd_runner.run(['mkdir', '-p', SYSTEM_DIR]).wait() | 135 | cmd_runner.run(['mkdir', '-p', SYSTEM_DIR]).wait() |
76 | 141 | cmd_runner.run(['mkdir', '-p', DATA_DIR]).wait() | 136 | cmd_runner.run(['mkdir', '-p', DATA_DIR]).wait() |
77 | 142 | 137 | ||
79 | 143 | unpack_android_binary_tarball(args.root, ROOT_DIR) | 138 | unpack_android_binary_tarball(args.boot, BOOT_DIR) |
80 | 144 | unpack_android_binary_tarball(args.system, SYSTEM_DIR) | 139 | unpack_android_binary_tarball(args.system, SYSTEM_DIR) |
81 | 145 | unpack_android_binary_tarball(args.userdata, DATA_DIR) | 140 | unpack_android_binary_tarball(args.userdata, DATA_DIR) |
82 | 146 | 141 | ||
83 | 147 | # Create partitions | 142 | # Create partitions |
85 | 148 | boot_partition, root_partition, system_partition, cache_partition, \ | 143 | boot_partition, system_partition, cache_partition, \ |
86 | 149 | data_partition, sdcard_partition = setup_android_partitions( \ | 144 | data_partition, sdcard_partition = setup_android_partitions( \ |
90 | 150 | board_config, media, args.boot_label, args.rfs_label, | 145 | board_config, media, args.boot_label, args.should_create_partitions, |
91 | 151 | args.rootfs, args.should_create_partitions, args.should_format_bootfs, | 146 | args.should_align_boot_part) |
89 | 152 | args.should_format_rootfs, args.should_align_boot_part) | ||
92 | 153 | 147 | ||
94 | 154 | populate_partition(ROOT_DIR, ROOT_DISK, root_partition) | 148 | populate_partition(BOOT_DIR + "/boot", BOOT_DISK, boot_partition) |
95 | 149 | board_config.populate_boot_script(boot_partition, BOOT_DISK, args.consoles) | ||
96 | 155 | populate_partition(SYSTEM_DIR + "/system", SYSTEM_DISK, system_partition) | 150 | populate_partition(SYSTEM_DIR + "/system", SYSTEM_DISK, system_partition) |
97 | 156 | populate_partition(DATA_DIR + "/data", DATA_DISK, data_partition) | 151 | populate_partition(DATA_DIR + "/data", DATA_DISK, data_partition) |
98 | 157 | print "Done creating Linaro Android image on %s" % args.device | 152 | print "Done creating Linaro Android image on %s" % args.device |
99 | 158 | 153 | ||
100 | === modified file 'linaro_image_tools/media_create/__init__.py' | |||
101 | --- linaro_image_tools/media_create/__init__.py 2011-03-31 19:03:31 +0000 | |||
102 | +++ linaro_image_tools/media_create/__init__.py 2011-04-22 15:11:32 +0000 | |||
103 | @@ -20,7 +20,7 @@ | |||
104 | 20 | import argparse | 20 | import argparse |
105 | 21 | 21 | ||
106 | 22 | from linaro_image_tools.media_create.boards import board_configs | 22 | from linaro_image_tools.media_create.boards import board_configs |
108 | 23 | from linaro_image_tools.media_create.boards import android_board_configs | 23 | from linaro_image_tools.media_create.android_boards import android_board_configs |
109 | 24 | 24 | ||
110 | 25 | 25 | ||
111 | 26 | KNOWN_BOARDS = board_configs.keys() | 26 | KNOWN_BOARDS = board_configs.keys() |
112 | @@ -122,14 +122,12 @@ | |||
113 | 122 | '--dev', required=True, dest='board', choices=ANDROID_KNOWN_BOARDS, | 122 | '--dev', required=True, dest='board', choices=ANDROID_KNOWN_BOARDS, |
114 | 123 | help='Generate an SD card or image for the given board.') | 123 | help='Generate an SD card or image for the given board.') |
115 | 124 | parser.add_argument( | 124 | parser.add_argument( |
116 | 125 | '--rootfs', default='ext4', choices=['ext3', 'ext4'], | ||
117 | 126 | help='Type of filesystem to use for the rootfs') | ||
118 | 127 | parser.add_argument( | ||
119 | 128 | '--rfs_label', default='rootfs', | ||
120 | 129 | help='Label to use for the root filesystem.') | ||
121 | 130 | parser.add_argument( | ||
122 | 131 | '--boot_label', default='boot', | 125 | '--boot_label', default='boot', |
123 | 132 | help='Label to use for the boot filesystem.') | 126 | help='Label to use for the boot filesystem.') |
124 | 127 | parser.add_argument( | ||
125 | 128 | '--console', action='append', dest='consoles', default=[], | ||
126 | 129 | help=('Add a console to kernel boot parameter; this parameter can be ' | ||
127 | 130 | 'defined multiple times.')) | ||
128 | 133 | 131 | ||
129 | 134 | parser.add_argument( | 132 | parser.add_argument( |
130 | 135 | '--system', default='system.tar.bz2', required=True, | 133 | '--system', default='system.tar.bz2', required=True, |
131 | @@ -138,16 +136,10 @@ | |||
132 | 138 | '--userdata', default='userdata.tar.bz2', required=True, | 136 | '--userdata', default='userdata.tar.bz2', required=True, |
133 | 139 | help=('The tarball containing the Android data paritition')) | 137 | help=('The tarball containing the Android data paritition')) |
134 | 140 | parser.add_argument( | 138 | parser.add_argument( |
136 | 141 | '--root', default='root.tar.bz2', required=True, | 139 | '--boot', default='boot.tar.bz2', required=True, |
137 | 142 | help=('The tarball containing the Android root partition')) | 140 | help=('The tarball containing the Android root partition')) |
138 | 143 | 141 | ||
139 | 144 | parser.add_argument( | 142 | parser.add_argument( |
140 | 145 | '--no-rootfs', dest='should_format_rootfs', action='store_false', | ||
141 | 146 | help='Do not deploy the root filesystem.') | ||
142 | 147 | parser.add_argument( | ||
143 | 148 | '--no-bootfs', dest='should_format_bootfs', action='store_false', | ||
144 | 149 | help='Do not deploy the boot filesystem.') | ||
145 | 150 | parser.add_argument( | ||
146 | 151 | '--no-part', dest='should_create_partitions', action='store_false', | 143 | '--no-part', dest='should_create_partitions', action='store_false', |
147 | 152 | help='Reuse existing partitions on the given media.') | 144 | help='Reuse existing partitions on the given media.') |
148 | 153 | parser.add_argument( | 145 | parser.add_argument( |
149 | 154 | 146 | ||
150 | === added file 'linaro_image_tools/media_create/android_boards.py' | |||
151 | --- linaro_image_tools/media_create/android_boards.py 1970-01-01 00:00:00 +0000 | |||
152 | +++ linaro_image_tools/media_create/android_boards.py 2011-04-22 15:11:32 +0000 | |||
153 | @@ -0,0 +1,158 @@ | |||
154 | 1 | # Copyright (C) 2011 Linaro | ||
155 | 2 | # | ||
156 | 3 | # Author: Jeremy Chang <jeremy.chang@linaro.org> | ||
157 | 4 | # | ||
158 | 5 | # This file is part of Linaro Image Tools. | ||
159 | 6 | # | ||
160 | 7 | # Linaro Image Tools is free software: you can redistribute it and/or modify | ||
161 | 8 | # it under the terms of the GNU General Public License as published by | ||
162 | 9 | # the Free Software Foundation, either version 3 of the License, or | ||
163 | 10 | # (at your option) any later version. | ||
164 | 11 | # | ||
165 | 12 | # Linaro Image Tools is distributed in the hope that it will be useful, | ||
166 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
167 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
168 | 15 | # GNU General Public License for more details. | ||
169 | 16 | # | ||
170 | 17 | # You should have received a copy of the GNU General Public License | ||
171 | 18 | # along with Linaro Image Tools. If not, see <http://www.gnu.org/licenses/>. | ||
172 | 19 | |||
173 | 20 | """Configuration for boards supported by linaro-android-media-create. | ||
174 | 21 | |||
175 | 22 | To add support for a new board, you need to create a subclass of | ||
176 | 23 | AndroidBoardConfig, set appropriate values for its variables and add it to | ||
177 | 24 | android_board_configs at the bottom of this file. | ||
178 | 25 | """ | ||
179 | 26 | |||
180 | 27 | from linaro_image_tools.media_create.partitions import SECTOR_SIZE | ||
181 | 28 | from linaro_image_tools.media_create.boards import PART_ALIGN_S | ||
182 | 29 | from linaro_image_tools.media_create.boards import BeagleConfig | ||
183 | 30 | from linaro_image_tools.media_create.boards import PandaConfig | ||
184 | 31 | from linaro_image_tools.media_create.boards import ( | ||
185 | 32 | align_up, | ||
186 | 33 | align_partition, | ||
187 | 34 | make_boot_script | ||
188 | 35 | ) | ||
189 | 36 | |||
190 | 37 | from linaro_image_tools import cmd_runner | ||
191 | 38 | import os | ||
192 | 39 | |||
193 | 40 | class AndroidBoardConfig(object): | ||
194 | 41 | @classmethod | ||
195 | 42 | def _get_bootargs(cls, consoles): | ||
196 | 43 | """Get the bootargs for this board. | ||
197 | 44 | |||
198 | 45 | In general subclasses should not have to override this. | ||
199 | 46 | """ | ||
200 | 47 | boot_args_options = 'rootwait ro' | ||
201 | 48 | if cls.extra_boot_args_options is not None: | ||
202 | 49 | boot_args_options += ' %s' % cls.extra_boot_args_options | ||
203 | 50 | boot_args_options += ' %s' % cls.android_specific_args | ||
204 | 51 | serial_opts = cls._extra_serial_opts | ||
205 | 52 | for console in consoles: | ||
206 | 53 | serial_opts += ' console=%s' % console | ||
207 | 54 | |||
208 | 55 | replacements = dict( | ||
209 | 56 | serial_opts=serial_opts, | ||
210 | 57 | boot_args_options=boot_args_options) | ||
211 | 58 | return ( | ||
212 | 59 | "%(serial_opts)s " | ||
213 | 60 | "%(boot_args_options)s" | ||
214 | 61 | % replacements) | ||
215 | 62 | |||
216 | 63 | @classmethod | ||
217 | 64 | def _get_boot_env(cls, consoles): | ||
218 | 65 | """Get the boot environment for this board. | ||
219 | 66 | |||
220 | 67 | In general subclasses should not have to override this. | ||
221 | 68 | """ | ||
222 | 69 | boot_env = {} | ||
223 | 70 | boot_env["bootargs"] = cls._get_bootargs(consoles) | ||
224 | 71 | boot_env["bootcmd"] = cls._get_bootcmd(None) | ||
225 | 72 | return boot_env | ||
226 | 73 | |||
227 | 74 | @classmethod | ||
228 | 75 | def populate_boot_script(cls, boot_partition, boot_disk, consoles): | ||
229 | 76 | cmd_runner.run(['mkdir', '-p', boot_disk]).wait() | ||
230 | 77 | cmd_runner.run(['mount', boot_partition, boot_disk], | ||
231 | 78 | as_root=True).wait() | ||
232 | 79 | |||
233 | 80 | boot_env = cls._get_boot_env(consoles) | ||
234 | 81 | cmdline_filepath = os.path.join(boot_disk, "cmdline") | ||
235 | 82 | cmdline_file = open(cmdline_filepath, 'r') | ||
236 | 83 | android_kernel_cmdline = cmdline_file.read() | ||
237 | 84 | boot_env['bootargs'] = boot_env['bootargs'] + ' ' + \ | ||
238 | 85 | android_kernel_cmdline | ||
239 | 86 | cmdline_file.close() | ||
240 | 87 | |||
241 | 88 | boot_dir = boot_disk | ||
242 | 89 | boot_script_path = os.path.join(boot_dir, cls.boot_script) | ||
243 | 90 | make_boot_script(boot_env, boot_script_path) | ||
244 | 91 | |||
245 | 92 | cmd_runner.run(['sync']).wait() | ||
246 | 93 | try: | ||
247 | 94 | cmd_runner.run(['umount', boot_disk], as_root=True).wait() | ||
248 | 95 | except cmd_runner.SubcommandNonZeroReturnValue: | ||
249 | 96 | pass | ||
250 | 97 | |||
251 | 98 | @classmethod | ||
252 | 99 | def get_sfdisk_cmd(cls, should_align_boot_part=False): | ||
253 | 100 | if cls.fat_size == 32: | ||
254 | 101 | partition_type = '0x0C' | ||
255 | 102 | else: | ||
256 | 103 | partition_type = '0x0E' | ||
257 | 104 | |||
258 | 105 | BOOT_MIN_SIZE_S = align_up(128 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE | ||
259 | 106 | SYSTEM_MIN_SIZE_S = align_up(256 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE | ||
260 | 107 | CACHE_MIN_SIZE_S = align_up(256 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE | ||
261 | 108 | USERDATA_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE | ||
262 | 109 | SDCARD_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE | ||
263 | 110 | |||
264 | 111 | # align on sector 63 for compatibility with broken versions of x-loader | ||
265 | 112 | # unless align_boot_part is set | ||
266 | 113 | boot_align = 63 | ||
267 | 114 | if should_align_boot_part: | ||
268 | 115 | boot_align = PART_ALIGN_S | ||
269 | 116 | |||
270 | 117 | # can only start on sector 1 (sector 0 is MBR / partition table) | ||
271 | 118 | boot_start, boot_end, boot_len = align_partition( | ||
272 | 119 | 1, BOOT_MIN_SIZE_S, boot_align, PART_ALIGN_S) | ||
273 | 120 | # apparently OMAP3 ROMs require the vfat length to be an even number | ||
274 | 121 | # of sectors (multiple of 1 KiB); decrease the length if it's odd, | ||
275 | 122 | # there should still be enough room | ||
276 | 123 | boot_len = boot_len - boot_len % 2 | ||
277 | 124 | boot_end = boot_start + boot_len - 1 | ||
278 | 125 | |||
279 | 126 | system_start, _system_end, _system_len = align_partition( | ||
280 | 127 | boot_end + 1, SYSTEM_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) | ||
281 | 128 | cache_start, _cache_end, _cache_len = align_partition( | ||
282 | 129 | _system_end + 1, CACHE_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) | ||
283 | 130 | userdata_start, _userdata_end, _userdata_len = align_partition( | ||
284 | 131 | _cache_end + 1, USERDATA_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) | ||
285 | 132 | sdcard_start, _sdcard_end, _sdcard_len = align_partition( | ||
286 | 133 | _userdata_end + 1, SDCARD_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) | ||
287 | 134 | |||
288 | 135 | return '%s,%s,%s,*\n%s,%s,L\n%s,%s,L\n%s,-,E\n%s,%s,L\n%s,,,-' % ( | ||
289 | 136 | boot_start, boot_len, partition_type, system_start, _system_len, | ||
290 | 137 | cache_start, _cache_len, userdata_start, userdata_start, | ||
291 | 138 | _userdata_len, sdcard_start) | ||
292 | 139 | |||
293 | 140 | |||
294 | 141 | class AndroidOmapConfig(AndroidBoardConfig): | ||
295 | 142 | pass | ||
296 | 143 | |||
297 | 144 | |||
298 | 145 | class AndroidBeagleConfig(AndroidOmapConfig, BeagleConfig): | ||
299 | 146 | _extra_serial_opts = 'console=tty0 console=ttyO2,115200n8' | ||
300 | 147 | android_specific_args = 'init=/init androidboot.console=ttyO2' | ||
301 | 148 | |||
302 | 149 | |||
303 | 150 | class AndroidPandaConfig(AndroidOmapConfig, PandaConfig): | ||
304 | 151 | _extra_serial_opts = 'console=tty0 console=ttyO2,115200n8' | ||
305 | 152 | android_specific_args = 'init=/init androidboot.console=ttyO2' | ||
306 | 153 | |||
307 | 154 | |||
308 | 155 | android_board_configs = { | ||
309 | 156 | 'beagle': AndroidBeagleConfig, | ||
310 | 157 | 'panda': AndroidPandaConfig, | ||
311 | 158 | } | ||
312 | 0 | 159 | ||
313 | === modified file 'linaro_image_tools/media_create/boards.py' | |||
314 | --- linaro_image_tools/media_create/boards.py 2011-04-21 13:12:57 +0000 | |||
315 | +++ linaro_image_tools/media_create/boards.py 2011-04-22 15:11:32 +0000 | |||
316 | @@ -193,54 +193,6 @@ | |||
317 | 193 | return '%s,%s,%s,*\n%s,,,-' % ( | 193 | return '%s,%s,%s,*\n%s,,,-' % ( |
318 | 194 | boot_start, boot_len, partition_type, root_start) | 194 | boot_start, boot_len, partition_type, root_start) |
319 | 195 | 195 | ||
320 | 196 | # TODO: Create separate config classes for android and move this method | ||
321 | 197 | # into them, also renaming it to get_sfdisk_cmd() so that we don't need | ||
322 | 198 | # the image_type check in partitions.py. | ||
323 | 199 | @classmethod | ||
324 | 200 | def get_android_sfdisk_cmd(cls, should_align_boot_part=False): | ||
325 | 201 | if cls.fat_size == 32: | ||
326 | 202 | partition_type = '0x0C' | ||
327 | 203 | else: | ||
328 | 204 | partition_type = '0x0E' | ||
329 | 205 | |||
330 | 206 | BOOT_MIN_SIZE_S = align_up(128 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE | ||
331 | 207 | ROOT_MIN_SIZE_S = align_up(128 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE | ||
332 | 208 | SYSTEM_MIN_SIZE_S = align_up(256 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE | ||
333 | 209 | CACHE_MIN_SIZE_S = align_up(256 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE | ||
334 | 210 | USERDATA_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE | ||
335 | 211 | SDCARD_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE | ||
336 | 212 | |||
337 | 213 | # align on sector 63 for compatibility with broken versions of x-loader | ||
338 | 214 | # unless align_boot_part is set | ||
339 | 215 | boot_align = 63 | ||
340 | 216 | if should_align_boot_part: | ||
341 | 217 | boot_align = PART_ALIGN_S | ||
342 | 218 | |||
343 | 219 | # can only start on sector 1 (sector 0 is MBR / partition table) | ||
344 | 220 | boot_start, boot_end, boot_len = align_partition( | ||
345 | 221 | 1, BOOT_MIN_SIZE_S, boot_align, PART_ALIGN_S) | ||
346 | 222 | # apparently OMAP3 ROMs require the vfat length to be an even number | ||
347 | 223 | # of sectors (multiple of 1 KiB); decrease the length if it's odd, | ||
348 | 224 | # there should still be enough room | ||
349 | 225 | boot_len = boot_len - boot_len % 2 | ||
350 | 226 | boot_end = boot_start + boot_len - 1 | ||
351 | 227 | |||
352 | 228 | root_start, _root_end, _root_len = align_partition( | ||
353 | 229 | boot_end + 1, ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) | ||
354 | 230 | system_start, _system_end, _system_len = align_partition( | ||
355 | 231 | _root_end + 1, SYSTEM_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) | ||
356 | 232 | cache_start, _cache_end, _cache_len = align_partition( | ||
357 | 233 | _system_end + 1, CACHE_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) | ||
358 | 234 | userdata_start, _userdata_end, _userdata_len = align_partition( | ||
359 | 235 | _cache_end + 1, USERDATA_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) | ||
360 | 236 | sdcard_start, _sdcard_end, _sdcard_len = align_partition( | ||
361 | 237 | _userdata_end + 1, SDCARD_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S) | ||
362 | 238 | |||
363 | 239 | return '%s,%s,%s,*\n%s,%s,L\n%s,%s,L\n%s,-,E\n%s,%s,L\n%s,%s,L\n%s,,,-' % ( | ||
364 | 240 | boot_start, boot_len, partition_type, root_start, _root_len, | ||
365 | 241 | system_start, _system_len, cache_start, cache_start, _cache_len, | ||
366 | 242 | userdata_start, _userdata_len, sdcard_start) | ||
367 | 243 | |||
368 | 244 | @classmethod | 196 | @classmethod |
369 | 245 | def _get_bootcmd(cls, d_img_data): | 197 | def _get_bootcmd(cls, d_img_data): |
370 | 246 | """Get the bootcmd for this board. | 198 | """Get the bootcmd for this board. |
371 | @@ -743,11 +695,6 @@ | |||
372 | 743 | 'smdkv310': SMDKV310Config, | 695 | 'smdkv310': SMDKV310Config, |
373 | 744 | } | 696 | } |
374 | 745 | 697 | ||
375 | 746 | android_board_configs = { | ||
376 | 747 | 'beagle': BeagleConfig, | ||
377 | 748 | 'panda': PandaConfig, | ||
378 | 749 | } | ||
379 | 750 | |||
380 | 751 | 698 | ||
381 | 752 | def _dd(input_file, output_file, block_size=SECTOR_SIZE, count=None, seek=None, | 699 | def _dd(input_file, output_file, block_size=SECTOR_SIZE, count=None, seek=None, |
382 | 753 | skip=None): | 700 | skip=None): |
383 | 754 | 701 | ||
384 | === modified file 'linaro_image_tools/media_create/partitions.py' | |||
385 | --- linaro_image_tools/media_create/partitions.py 2011-04-05 11:06:49 +0000 | |||
386 | +++ linaro_image_tools/media_create/partitions.py 2011-04-22 15:11:32 +0000 | |||
387 | @@ -42,40 +42,28 @@ | |||
388 | 42 | 42 | ||
389 | 43 | 43 | ||
390 | 44 | def setup_android_partitions(board_config, media, bootfs_label, | 44 | def setup_android_partitions(board_config, media, bootfs_label, |
394 | 45 | rootfs_label, rootfs_type, should_create_partitions, | 45 | should_create_partitions, should_align_boot_part=False): |
392 | 46 | should_format_bootfs, should_format_rootfs, | ||
393 | 47 | should_align_boot_part=False): | ||
395 | 48 | cylinders = None | 46 | cylinders = None |
396 | 49 | 47 | ||
397 | 50 | if should_create_partitions: | 48 | if should_create_partitions: |
398 | 51 | create_partitions( | 49 | create_partitions( |
399 | 52 | board_config, media, HEADS, SECTORS, cylinders, | 50 | board_config, media, HEADS, SECTORS, cylinders, |
401 | 53 | should_align_boot_part=should_align_boot_part, image_type="ANDROID") | 51 | should_align_boot_part=should_align_boot_part) |
402 | 54 | 52 | ||
404 | 55 | bootfs, rootfs, system, cache, data, sdcard = \ | 53 | bootfs, system, cache, data, sdcard = \ |
405 | 56 | get_android_partitions_for_media (media, board_config) | 54 | get_android_partitions_for_media (media, board_config) |
406 | 57 | ensure_partition_is_not_mounted(bootfs) | 55 | ensure_partition_is_not_mounted(bootfs) |
407 | 58 | ensure_partition_is_not_mounted(rootfs) | ||
408 | 59 | ensure_partition_is_not_mounted(system) | 56 | ensure_partition_is_not_mounted(system) |
409 | 60 | ensure_partition_is_not_mounted(cache) | 57 | ensure_partition_is_not_mounted(cache) |
410 | 61 | ensure_partition_is_not_mounted(data) | 58 | ensure_partition_is_not_mounted(data) |
411 | 62 | ensure_partition_is_not_mounted(sdcard) | 59 | ensure_partition_is_not_mounted(sdcard) |
412 | 63 | 60 | ||
428 | 64 | if should_format_bootfs: | 61 | print "\nFormating boot partition\n" |
429 | 65 | print "\nFormating boot partition\n" | 62 | proc = cmd_runner.run( |
430 | 66 | proc = cmd_runner.run( | 63 | ['mkfs.vfat', '-F', str(board_config.fat_size), bootfs, '-n', |
431 | 67 | ['mkfs.vfat', '-F', str(board_config.fat_size), bootfs, '-n', | 64 | bootfs_label], |
432 | 68 | bootfs_label], | 65 | as_root=True) |
433 | 69 | as_root=True) | 66 | proc.wait() |
419 | 70 | proc.wait() | ||
420 | 71 | |||
421 | 72 | if should_format_rootfs: | ||
422 | 73 | print "\nFormating root partition\n" | ||
423 | 74 | mkfs = 'mkfs.%s' % rootfs_type | ||
424 | 75 | proc = cmd_runner.run( | ||
425 | 76 | [mkfs, rootfs, '-L', rootfs_label], | ||
426 | 77 | as_root=True) | ||
427 | 78 | proc.wait() | ||
434 | 79 | 67 | ||
435 | 80 | ext4_partitions = {"system": system, "cache": cache, "userdata": data} | 68 | ext4_partitions = {"system": system, "cache": cache, "userdata": data} |
436 | 81 | for label, dev in ext4_partitions.iteritems(): | 69 | for label, dev in ext4_partitions.iteritems(): |
437 | @@ -91,7 +79,7 @@ | |||
438 | 91 | as_root=True) | 79 | as_root=True) |
439 | 92 | proc.wait() | 80 | proc.wait() |
440 | 93 | 81 | ||
442 | 94 | return bootfs, rootfs, system, cache, data, sdcard | 82 | return bootfs, system, cache, data, sdcard |
443 | 95 | 83 | ||
444 | 96 | # I wonder if it'd make sense to convert this into a small shim which calls | 84 | # I wonder if it'd make sense to convert this into a small shim which calls |
445 | 97 | # the appropriate function for the given type of device? I think it's still | 85 | # the appropriate function for the given type of device? I think it's still |
446 | @@ -277,22 +265,20 @@ | |||
447 | 277 | 265 | ||
448 | 278 | boot_partition = _get_device_file_for_partition_number( | 266 | boot_partition = _get_device_file_for_partition_number( |
449 | 279 | media.path, 1 + board_config.mmc_part_offset) | 267 | media.path, 1 + board_config.mmc_part_offset) |
450 | 280 | root_partition = _get_device_file_for_partition_number( | ||
451 | 281 | media.path, 2 + board_config.mmc_part_offset) | ||
452 | 282 | system_partition = _get_device_file_for_partition_number( | 268 | system_partition = _get_device_file_for_partition_number( |
453 | 269 | media.path, 2 + board_config.mmc_part_offset) | ||
454 | 270 | cache_partition = _get_device_file_for_partition_number( | ||
455 | 283 | media.path, 3 + board_config.mmc_part_offset) | 271 | media.path, 3 + board_config.mmc_part_offset) |
457 | 284 | cache_partition = _get_device_file_for_partition_number( | 272 | data_partition = _get_device_file_for_partition_number( |
458 | 285 | media.path, 5 + board_config.mmc_part_offset) | 273 | media.path, 5 + board_config.mmc_part_offset) |
460 | 286 | data_partition = _get_device_file_for_partition_number( | 274 | sdcard_partition = _get_device_file_for_partition_number( |
461 | 287 | media.path, 6 + board_config.mmc_part_offset) | 275 | media.path, 6 + board_config.mmc_part_offset) |
470 | 288 | sdcard_partition = _get_device_file_for_partition_number( | 276 | |
471 | 289 | media.path, 7 + board_config.mmc_part_offset) | 277 | assert boot_partition is not None, ( |
472 | 290 | 278 | "Could not find boot partition for %s" % media.path) | |
473 | 291 | assert boot_partition is not None and root_partition is not None, ( | 279 | |
474 | 292 | "Could not find boot/root partition for %s" % media.path) | 280 | return boot_partition, system_partition, cache_partition, \ |
475 | 293 | 281 | data_partition, sdcard_partition | |
468 | 294 | return boot_partition, root_partition, system_partition, \ | ||
469 | 295 | cache_partition, data_partition, sdcard_partition | ||
476 | 296 | 282 | ||
477 | 297 | def get_boot_and_root_partitions_for_media(media, board_config): | 283 | def get_boot_and_root_partitions_for_media(media, board_config): |
478 | 298 | """Return the device files for the boot and root partitions of media. | 284 | """Return the device files for the boot and root partitions of media. |
479 | @@ -388,7 +374,7 @@ | |||
480 | 388 | 374 | ||
481 | 389 | 375 | ||
482 | 390 | def create_partitions(board_config, media, heads, sectors, cylinders=None, | 376 | def create_partitions(board_config, media, heads, sectors, cylinders=None, |
484 | 391 | should_align_boot_part=False, image_type=None): | 377 | should_align_boot_part=False): |
485 | 392 | """Partition the given media according to the board requirements. | 378 | """Partition the given media according to the board requirements. |
486 | 393 | 379 | ||
487 | 394 | :param board_config: A BoardConfig class. | 380 | :param board_config: A BoardConfig class. |
488 | @@ -407,14 +393,8 @@ | |||
489 | 407 | ['parted', '-s', media.path, 'mklabel', 'msdos'], as_root=True) | 393 | ['parted', '-s', media.path, 'mklabel', 'msdos'], as_root=True) |
490 | 408 | proc.wait() | 394 | proc.wait() |
491 | 409 | 395 | ||
500 | 410 | # XXX: We should get rid of this by using separate config classes for | 396 | sfdisk_cmd = board_config.get_sfdisk_cmd( |
501 | 411 | # android -- see comment in get_android_sfdisk_cmd() for more details. | 397 | should_align_boot_part=should_align_boot_part) |
494 | 412 | if image_type == "ANDROID": | ||
495 | 413 | sfdisk_cmd = board_config.get_android_sfdisk_cmd( | ||
496 | 414 | should_align_boot_part=should_align_boot_part) | ||
497 | 415 | else: | ||
498 | 416 | sfdisk_cmd = board_config.get_sfdisk_cmd( | ||
499 | 417 | should_align_boot_part=should_align_boot_part) | ||
502 | 418 | 398 | ||
503 | 419 | run_sfdisk_commands(sfdisk_cmd, heads, sectors, cylinders, media.path) | 399 | run_sfdisk_commands(sfdisk_cmd, heads, sectors, cylinders, media.path) |
504 | 420 | 400 |
Hi,
Thanks for the changes.
I'd like to try and reduce some duplication between
boards.py and android_boards.py. In particular the
align_up etc. functions could be shared.
Also, it seems like more could be shared between the
two bootscript etc. implementations.
Thanks,
James