Merge lp:~jeremychang/linaro-image-tools/android-boottarball into lp:linaro-image-tools/11.11

Proposed by Jeremy Chang
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
Reviewer Review Type Date Requested Status
James Westby (community) Approve
Review via email: mp+58545@code.launchpad.net

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://launchpad.net/bugs/752490

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

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

Revision history for this message
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.

Revision history for this message
Alexander Sack (asac) wrote :

let me test ....

Revision history for this message
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/boot-disc: device is busy.
        (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

Revision history for this message
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/boot-disc: device is busy.
>        (In some cases useful info about processes that use
>         the device is found by lsof(8) or fuser(1))
> --
> https://code.launchpad.net/~jeremychang/linaro-image-tools/android-boottarball/+merge/58545
> You are the owner of lp:~jeremychang/linaro-image-tools/android-boottarball.
>

Revision history for this message
James Westby (james-w) :
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 2011-04-22 07:42:34 +0000
+++ linaro-android-media-create 2011-04-22 15:11:32 +0000
@@ -25,10 +25,13 @@
2525
26from linaro_image_tools import cmd_runner26from linaro_image_tools import cmd_runner
2727
28from linaro_image_tools.media_create.boards import android_board_configs28from linaro_image_tools.media_create.android_boards import android_board_configs
29from linaro_image_tools.media_create.check_device import (29from linaro_image_tools.media_create.check_device import (
30 confirm_device_selection_and_ensure_it_is_ready)30 confirm_device_selection_and_ensure_it_is_ready)
31<<<<<<< TREE
31from linaro_image_tools.media_create.chroot_utils import install_hwpacks32from linaro_image_tools.media_create.chroot_utils import install_hwpacks
33=======
34>>>>>>> MERGE-SOURCE
32from linaro_image_tools.media_create.partitions import (35from linaro_image_tools.media_create.partitions import (
33 Media,36 Media,
34 setup_partitions,37 setup_partitions,
@@ -46,9 +49,7 @@
4649
47# Just define the global variables50# Just define the global variables
48TMP_DIR = None51TMP_DIR = None
49ROOTFS_DIR = None
50BOOT_DISK = None52BOOT_DISK = None
51ROOT_DISK = None
52SYSTEM_DISK = None53SYSTEM_DISK = None
53CACHE_DISK = None54CACHE_DISK = None
54DATA_DISK = None55DATA_DISK = None
@@ -61,11 +62,11 @@
61def cleanup_tempdir():62def cleanup_tempdir():
62 """Remove TEMP_DIR with all its contents.63 """Remove TEMP_DIR with all its contents.
6364
64 Before doing so, make sure BOOT_DISK and ROOT_DISK are not mounted.65 Before doing so, make sure DISKs are not mounted.
65 """66 """
66 devnull = open('/dev/null', 'w')67 devnull = open('/dev/null', 'w')
67 # ignore non-zero return codes68 # ignore non-zero return codes
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, \
69 SDCARD_DISK:70 SDCARD_DISK:
70 if disk is not None:71 if disk is not None:
71 try:72 try:
@@ -86,10 +87,6 @@
86 if not is_arm_host():87 if not is_arm_host():
87 required_commands.append('qemu-arm-static')88 required_commands.append('qemu-arm-static')
88 required_commands.append('qemu-img')89 required_commands.append('qemu-img')
89 if args.rootfs in ['ext2', 'ext3', 'ext4']:
90 required_commands.append('mkfs.%s' % args.rootfs)
91 else:
92 required_commands.append('mkfs.btrfs')
93 for command in required_commands:90 for command in required_commands:
94 ensure_command(command)91 ensure_command(command)
9592
@@ -108,12 +105,11 @@
108 # If --help was specified this won't execute.105 # If --help was specified this won't execute.
109 # Create temp dir and initialize rest of path vars.106 # Create temp dir and initialize rest of path vars.
110 TMP_DIR = tempfile.mkdtemp()107 TMP_DIR = tempfile.mkdtemp()
111 ROOT_DIR = os.path.join(TMP_DIR, 'root')108 BOOT_DIR = os.path.join(TMP_DIR, 'boot')
112 SYSTEM_DIR = os.path.join(TMP_DIR, 'system')109 SYSTEM_DIR = os.path.join(TMP_DIR, 'system')
113 DATA_DIR = os.path.join(TMP_DIR, 'data')110 DATA_DIR = os.path.join(TMP_DIR, 'data')
114111
115 BOOT_DISK = os.path.join(TMP_DIR, 'boot-disc')112 BOOT_DISK = os.path.join(TMP_DIR, 'boot-disc')
116 ROOT_DISK = os.path.join(TMP_DIR, 'root-disc')
117 SYSTEM_DISK = os.path.join(TMP_DIR, 'system-disc')113 SYSTEM_DISK = os.path.join(TMP_DIR, 'system-disc')
118 CACHE_DISK = os.path.join(TMP_DIR, 'cache-disc')114 CACHE_DISK = os.path.join(TMP_DIR, 'cache-disc')
119 DATA_DISK = os.path.join(TMP_DIR, 'userdata-disc')115 DATA_DISK = os.path.join(TMP_DIR, 'userdata-disc')
@@ -135,23 +131,22 @@
135 # All good, move on.131 # All good, move on.
136 pass132 pass
137133
138134 cmd_runner.run(['mkdir', '-p', BOOT_DIR]).wait()
139 cmd_runner.run(['mkdir', '-p', ROOT_DIR]).wait()
140 cmd_runner.run(['mkdir', '-p', SYSTEM_DIR]).wait()135 cmd_runner.run(['mkdir', '-p', SYSTEM_DIR]).wait()
141 cmd_runner.run(['mkdir', '-p', DATA_DIR]).wait()136 cmd_runner.run(['mkdir', '-p', DATA_DIR]).wait()
142137
143 unpack_android_binary_tarball(args.root, ROOT_DIR)138 unpack_android_binary_tarball(args.boot, BOOT_DIR)
144 unpack_android_binary_tarball(args.system, SYSTEM_DIR)139 unpack_android_binary_tarball(args.system, SYSTEM_DIR)
145 unpack_android_binary_tarball(args.userdata, DATA_DIR)140 unpack_android_binary_tarball(args.userdata, DATA_DIR)
146141
147 # Create partitions 142 # Create partitions
148 boot_partition, root_partition, system_partition, cache_partition, \143 boot_partition, system_partition, cache_partition, \
149 data_partition, sdcard_partition = setup_android_partitions( \144 data_partition, sdcard_partition = setup_android_partitions( \
150 board_config, media, args.boot_label, args.rfs_label,145 board_config, media, args.boot_label, args.should_create_partitions,
151 args.rootfs, args.should_create_partitions, args.should_format_bootfs,146 args.should_align_boot_part)
152 args.should_format_rootfs, args.should_align_boot_part)
153147
154 populate_partition(ROOT_DIR, ROOT_DISK, root_partition)148 populate_partition(BOOT_DIR + "/boot", BOOT_DISK, boot_partition)
149 board_config.populate_boot_script(boot_partition, BOOT_DISK, args.consoles)
155 populate_partition(SYSTEM_DIR + "/system", SYSTEM_DISK, system_partition)150 populate_partition(SYSTEM_DIR + "/system", SYSTEM_DISK, system_partition)
156 populate_partition(DATA_DIR + "/data", DATA_DISK, data_partition)151 populate_partition(DATA_DIR + "/data", DATA_DISK, data_partition)
157 print "Done creating Linaro Android image on %s" % args.device152 print "Done creating Linaro Android image on %s" % args.device
158153
=== modified file 'linaro_image_tools/media_create/__init__.py'
--- linaro_image_tools/media_create/__init__.py 2011-03-31 19:03:31 +0000
+++ linaro_image_tools/media_create/__init__.py 2011-04-22 15:11:32 +0000
@@ -20,7 +20,7 @@
20import argparse20import argparse
2121
22from linaro_image_tools.media_create.boards import board_configs22from linaro_image_tools.media_create.boards import board_configs
23from linaro_image_tools.media_create.boards import android_board_configs23from linaro_image_tools.media_create.android_boards import android_board_configs
2424
2525
26KNOWN_BOARDS = board_configs.keys()26KNOWN_BOARDS = board_configs.keys()
@@ -122,14 +122,12 @@
122 '--dev', required=True, dest='board', choices=ANDROID_KNOWN_BOARDS,122 '--dev', required=True, dest='board', choices=ANDROID_KNOWN_BOARDS,
123 help='Generate an SD card or image for the given board.')123 help='Generate an SD card or image for the given board.')
124 parser.add_argument(124 parser.add_argument(
125 '--rootfs', default='ext4', choices=['ext3', 'ext4'],
126 help='Type of filesystem to use for the rootfs')
127 parser.add_argument(
128 '--rfs_label', default='rootfs',
129 help='Label to use for the root filesystem.')
130 parser.add_argument(
131 '--boot_label', default='boot',125 '--boot_label', default='boot',
132 help='Label to use for the boot filesystem.')126 help='Label to use for the boot filesystem.')
127 parser.add_argument(
128 '--console', action='append', dest='consoles', default=[],
129 help=('Add a console to kernel boot parameter; this parameter can be '
130 'defined multiple times.'))
133131
134 parser.add_argument(132 parser.add_argument(
135 '--system', default='system.tar.bz2', required=True,133 '--system', default='system.tar.bz2', required=True,
@@ -138,16 +136,10 @@
138 '--userdata', default='userdata.tar.bz2', required=True,136 '--userdata', default='userdata.tar.bz2', required=True,
139 help=('The tarball containing the Android data paritition'))137 help=('The tarball containing the Android data paritition'))
140 parser.add_argument(138 parser.add_argument(
141 '--root', default='root.tar.bz2', required=True,139 '--boot', default='boot.tar.bz2', required=True,
142 help=('The tarball containing the Android root partition'))140 help=('The tarball containing the Android root partition'))
143141
144 parser.add_argument(142 parser.add_argument(
145 '--no-rootfs', dest='should_format_rootfs', action='store_false',
146 help='Do not deploy the root filesystem.')
147 parser.add_argument(
148 '--no-bootfs', dest='should_format_bootfs', action='store_false',
149 help='Do not deploy the boot filesystem.')
150 parser.add_argument(
151 '--no-part', dest='should_create_partitions', action='store_false',143 '--no-part', dest='should_create_partitions', action='store_false',
152 help='Reuse existing partitions on the given media.')144 help='Reuse existing partitions on the given media.')
153 parser.add_argument(145 parser.add_argument(
154146
=== added file 'linaro_image_tools/media_create/android_boards.py'
--- linaro_image_tools/media_create/android_boards.py 1970-01-01 00:00:00 +0000
+++ linaro_image_tools/media_create/android_boards.py 2011-04-22 15:11:32 +0000
@@ -0,0 +1,158 @@
1# Copyright (C) 2011 Linaro
2#
3# Author: Jeremy Chang <jeremy.chang@linaro.org>
4#
5# This file is part of Linaro Image Tools.
6#
7# Linaro Image Tools is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# Linaro Image Tools is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with Linaro Image Tools. If not, see <http://www.gnu.org/licenses/>.
19
20"""Configuration for boards supported by linaro-android-media-create.
21
22To add support for a new board, you need to create a subclass of
23AndroidBoardConfig, set appropriate values for its variables and add it to
24android_board_configs at the bottom of this file.
25"""
26
27from 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 (
32 align_up,
33 align_partition,
34 make_boot_script
35 )
36
37from linaro_image_tools import cmd_runner
38import os
39
40class AndroidBoardConfig(object):
41 @classmethod
42 def _get_bootargs(cls, consoles):
43 """Get the bootargs for this board.
44
45 In general subclasses should not have to override this.
46 """
47 boot_args_options = 'rootwait ro'
48 if cls.extra_boot_args_options is not None:
49 boot_args_options += ' %s' % cls.extra_boot_args_options
50 boot_args_options += ' %s' % cls.android_specific_args
51 serial_opts = cls._extra_serial_opts
52 for console in consoles:
53 serial_opts += ' console=%s' % console
54
55 replacements = dict(
56 serial_opts=serial_opts,
57 boot_args_options=boot_args_options)
58 return (
59 "%(serial_opts)s "
60 "%(boot_args_options)s"
61 % replacements)
62
63 @classmethod
64 def _get_boot_env(cls, consoles):
65 """Get the boot environment for this board.
66
67 In general subclasses should not have to override this.
68 """
69 boot_env = {}
70 boot_env["bootargs"] = cls._get_bootargs(consoles)
71 boot_env["bootcmd"] = cls._get_bootcmd(None)
72 return boot_env
73
74 @classmethod
75 def populate_boot_script(cls, boot_partition, boot_disk, consoles):
76 cmd_runner.run(['mkdir', '-p', boot_disk]).wait()
77 cmd_runner.run(['mount', boot_partition, boot_disk],
78 as_root=True).wait()
79
80 boot_env = cls._get_boot_env(consoles)
81 cmdline_filepath = os.path.join(boot_disk, "cmdline")
82 cmdline_file = open(cmdline_filepath, 'r')
83 android_kernel_cmdline = cmdline_file.read()
84 boot_env['bootargs'] = boot_env['bootargs'] + ' ' + \
85 android_kernel_cmdline
86 cmdline_file.close()
87
88 boot_dir = boot_disk
89 boot_script_path = os.path.join(boot_dir, cls.boot_script)
90 make_boot_script(boot_env, boot_script_path)
91
92 cmd_runner.run(['sync']).wait()
93 try:
94 cmd_runner.run(['umount', boot_disk], as_root=True).wait()
95 except cmd_runner.SubcommandNonZeroReturnValue:
96 pass
97
98 @classmethod
99 def get_sfdisk_cmd(cls, should_align_boot_part=False):
100 if cls.fat_size == 32:
101 partition_type = '0x0C'
102 else:
103 partition_type = '0x0E'
104
105 BOOT_MIN_SIZE_S = align_up(128 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
106 SYSTEM_MIN_SIZE_S = align_up(256 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
107 CACHE_MIN_SIZE_S = align_up(256 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
108 USERDATA_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
109 SDCARD_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
110
111 # align on sector 63 for compatibility with broken versions of x-loader
112 # unless align_boot_part is set
113 boot_align = 63
114 if should_align_boot_part:
115 boot_align = PART_ALIGN_S
116
117 # can only start on sector 1 (sector 0 is MBR / partition table)
118 boot_start, boot_end, boot_len = align_partition(
119 1, BOOT_MIN_SIZE_S, boot_align, PART_ALIGN_S)
120 # apparently OMAP3 ROMs require the vfat length to be an even number
121 # of sectors (multiple of 1 KiB); decrease the length if it's odd,
122 # there should still be enough room
123 boot_len = boot_len - boot_len % 2
124 boot_end = boot_start + boot_len - 1
125
126 system_start, _system_end, _system_len = align_partition(
127 boot_end + 1, SYSTEM_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
128 cache_start, _cache_end, _cache_len = align_partition(
129 _system_end + 1, CACHE_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
130 userdata_start, _userdata_end, _userdata_len = align_partition(
131 _cache_end + 1, USERDATA_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
132 sdcard_start, _sdcard_end, _sdcard_len = align_partition(
133 _userdata_end + 1, SDCARD_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
134
135 return '%s,%s,%s,*\n%s,%s,L\n%s,%s,L\n%s,-,E\n%s,%s,L\n%s,,,-' % (
136 boot_start, boot_len, partition_type, system_start, _system_len,
137 cache_start, _cache_len, userdata_start, userdata_start,
138 _userdata_len, sdcard_start)
139
140
141class AndroidOmapConfig(AndroidBoardConfig):
142 pass
143
144
145class AndroidBeagleConfig(AndroidOmapConfig, BeagleConfig):
146 _extra_serial_opts = 'console=tty0 console=ttyO2,115200n8'
147 android_specific_args = 'init=/init androidboot.console=ttyO2'
148
149
150class AndroidPandaConfig(AndroidOmapConfig, PandaConfig):
151 _extra_serial_opts = 'console=tty0 console=ttyO2,115200n8'
152 android_specific_args = 'init=/init androidboot.console=ttyO2'
153
154
155android_board_configs = {
156 'beagle': AndroidBeagleConfig,
157 'panda': AndroidPandaConfig,
158 }
0159
=== modified file 'linaro_image_tools/media_create/boards.py'
--- linaro_image_tools/media_create/boards.py 2011-04-21 13:12:57 +0000
+++ linaro_image_tools/media_create/boards.py 2011-04-22 15:11:32 +0000
@@ -193,54 +193,6 @@
193 return '%s,%s,%s,*\n%s,,,-' % (193 return '%s,%s,%s,*\n%s,,,-' % (
194 boot_start, boot_len, partition_type, root_start)194 boot_start, boot_len, partition_type, root_start)
195195
196 # TODO: Create separate config classes for android and move this method
197 # into them, also renaming it to get_sfdisk_cmd() so that we don't need
198 # the image_type check in partitions.py.
199 @classmethod
200 def get_android_sfdisk_cmd(cls, should_align_boot_part=False):
201 if cls.fat_size == 32:
202 partition_type = '0x0C'
203 else:
204 partition_type = '0x0E'
205
206 BOOT_MIN_SIZE_S = align_up(128 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
207 ROOT_MIN_SIZE_S = align_up(128 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
208 SYSTEM_MIN_SIZE_S = align_up(256 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
209 CACHE_MIN_SIZE_S = align_up(256 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
210 USERDATA_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
211 SDCARD_MIN_SIZE_S = align_up(512 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
212
213 # align on sector 63 for compatibility with broken versions of x-loader
214 # unless align_boot_part is set
215 boot_align = 63
216 if should_align_boot_part:
217 boot_align = PART_ALIGN_S
218
219 # can only start on sector 1 (sector 0 is MBR / partition table)
220 boot_start, boot_end, boot_len = align_partition(
221 1, BOOT_MIN_SIZE_S, boot_align, PART_ALIGN_S)
222 # apparently OMAP3 ROMs require the vfat length to be an even number
223 # of sectors (multiple of 1 KiB); decrease the length if it's odd,
224 # there should still be enough room
225 boot_len = boot_len - boot_len % 2
226 boot_end = boot_start + boot_len - 1
227
228 root_start, _root_end, _root_len = align_partition(
229 boot_end + 1, ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
230 system_start, _system_end, _system_len = align_partition(
231 _root_end + 1, SYSTEM_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
232 cache_start, _cache_end, _cache_len = align_partition(
233 _system_end + 1, CACHE_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
234 userdata_start, _userdata_end, _userdata_len = align_partition(
235 _cache_end + 1, USERDATA_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
236 sdcard_start, _sdcard_end, _sdcard_len = align_partition(
237 _userdata_end + 1, SDCARD_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
238
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,,,-' % (
240 boot_start, boot_len, partition_type, root_start, _root_len,
241 system_start, _system_len, cache_start, cache_start, _cache_len,
242 userdata_start, _userdata_len, sdcard_start)
243
244 @classmethod196 @classmethod
245 def _get_bootcmd(cls, d_img_data):197 def _get_bootcmd(cls, d_img_data):
246 """Get the bootcmd for this board.198 """Get the bootcmd for this board.
@@ -743,11 +695,6 @@
743 'smdkv310': SMDKV310Config,695 'smdkv310': SMDKV310Config,
744 }696 }
745697
746android_board_configs = {
747 'beagle': BeagleConfig,
748 'panda': PandaConfig,
749 }
750
751698
752def _dd(input_file, output_file, block_size=SECTOR_SIZE, count=None, seek=None,699def _dd(input_file, output_file, block_size=SECTOR_SIZE, count=None, seek=None,
753 skip=None):700 skip=None):
754701
=== modified file 'linaro_image_tools/media_create/partitions.py'
--- linaro_image_tools/media_create/partitions.py 2011-04-05 11:06:49 +0000
+++ linaro_image_tools/media_create/partitions.py 2011-04-22 15:11:32 +0000
@@ -42,40 +42,28 @@
4242
4343
44def setup_android_partitions(board_config, media, bootfs_label,44def setup_android_partitions(board_config, media, bootfs_label,
45 rootfs_label, rootfs_type, should_create_partitions,45 should_create_partitions, should_align_boot_part=False):
46 should_format_bootfs, should_format_rootfs,
47 should_align_boot_part=False):
48 cylinders = None46 cylinders = None
4947
50 if should_create_partitions:48 if should_create_partitions:
51 create_partitions(49 create_partitions(
52 board_config, media, HEADS, SECTORS, cylinders,50 board_config, media, HEADS, SECTORS, cylinders,
53 should_align_boot_part=should_align_boot_part, image_type="ANDROID")51 should_align_boot_part=should_align_boot_part)
5452
55 bootfs, rootfs, system, cache, data, sdcard = \53 bootfs, system, cache, data, sdcard = \
56 get_android_partitions_for_media (media, board_config)54 get_android_partitions_for_media (media, board_config)
57 ensure_partition_is_not_mounted(bootfs)55 ensure_partition_is_not_mounted(bootfs)
58 ensure_partition_is_not_mounted(rootfs)
59 ensure_partition_is_not_mounted(system)56 ensure_partition_is_not_mounted(system)
60 ensure_partition_is_not_mounted(cache)57 ensure_partition_is_not_mounted(cache)
61 ensure_partition_is_not_mounted(data)58 ensure_partition_is_not_mounted(data)
62 ensure_partition_is_not_mounted(sdcard)59 ensure_partition_is_not_mounted(sdcard)
6360
64 if should_format_bootfs:61 print "\nFormating boot partition\n"
65 print "\nFormating boot partition\n"62 proc = cmd_runner.run(
66 proc = cmd_runner.run(63 ['mkfs.vfat', '-F', str(board_config.fat_size), bootfs, '-n',
67 ['mkfs.vfat', '-F', str(board_config.fat_size), bootfs, '-n',64 bootfs_label],
68 bootfs_label],65 as_root=True)
69 as_root=True)66 proc.wait()
70 proc.wait()
71
72 if should_format_rootfs:
73 print "\nFormating root partition\n"
74 mkfs = 'mkfs.%s' % rootfs_type
75 proc = cmd_runner.run(
76 [mkfs, rootfs, '-L', rootfs_label],
77 as_root=True)
78 proc.wait()
7967
80 ext4_partitions = {"system": system, "cache": cache, "userdata": data}68 ext4_partitions = {"system": system, "cache": cache, "userdata": data}
81 for label, dev in ext4_partitions.iteritems():69 for label, dev in ext4_partitions.iteritems():
@@ -91,7 +79,7 @@
91 as_root=True)79 as_root=True)
92 proc.wait()80 proc.wait()
9381
94 return bootfs, rootfs, system, cache, data, sdcard82 return bootfs, system, cache, data, sdcard
9583
96# I wonder if it'd make sense to convert this into a small shim which calls84# I wonder if it'd make sense to convert this into a small shim which calls
97# the appropriate function for the given type of device? I think it's still85# the appropriate function for the given type of device? I think it's still
@@ -277,22 +265,20 @@
277265
278 boot_partition = _get_device_file_for_partition_number(266 boot_partition = _get_device_file_for_partition_number(
279 media.path, 1 + board_config.mmc_part_offset)267 media.path, 1 + board_config.mmc_part_offset)
280 root_partition = _get_device_file_for_partition_number(
281 media.path, 2 + board_config.mmc_part_offset)
282 system_partition = _get_device_file_for_partition_number(268 system_partition = _get_device_file_for_partition_number(
269 media.path, 2 + board_config.mmc_part_offset)
270 cache_partition = _get_device_file_for_partition_number(
283 media.path, 3 + board_config.mmc_part_offset)271 media.path, 3 + board_config.mmc_part_offset)
284 cache_partition = _get_device_file_for_partition_number(272 data_partition = _get_device_file_for_partition_number(
285 media.path, 5 + board_config.mmc_part_offset)273 media.path, 5 + board_config.mmc_part_offset)
286 data_partition = _get_device_file_for_partition_number(274 sdcard_partition = _get_device_file_for_partition_number(
287 media.path, 6 + board_config.mmc_part_offset)275 media.path, 6 + board_config.mmc_part_offset)
288 sdcard_partition = _get_device_file_for_partition_number(276
289 media.path, 7 + board_config.mmc_part_offset)277 assert boot_partition is not None, (
290278 "Could not find boot partition for %s" % media.path)
291 assert boot_partition is not None and root_partition is not None, (279
292 "Could not find boot/root partition for %s" % media.path)280 return boot_partition, system_partition, cache_partition, \
293281 data_partition, sdcard_partition
294 return boot_partition, root_partition, system_partition, \
295 cache_partition, data_partition, sdcard_partition
296282
297def get_boot_and_root_partitions_for_media(media, board_config):283def get_boot_and_root_partitions_for_media(media, board_config):
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.
@@ -388,7 +374,7 @@
388374
389375
390def create_partitions(board_config, media, heads, sectors, cylinders=None,376def create_partitions(board_config, media, heads, sectors, cylinders=None,
391 should_align_boot_part=False, image_type=None):377 should_align_boot_part=False):
392 """Partition the given media according to the board requirements.378 """Partition the given media according to the board requirements.
393379
394 :param board_config: A BoardConfig class.380 :param board_config: A BoardConfig class.
@@ -407,14 +393,8 @@
407 ['parted', '-s', media.path, 'mklabel', 'msdos'], as_root=True)393 ['parted', '-s', media.path, 'mklabel', 'msdos'], as_root=True)
408 proc.wait()394 proc.wait()
409395
410 # XXX: We should get rid of this by using separate config classes for396 sfdisk_cmd = board_config.get_sfdisk_cmd(
411 # android -- see comment in get_android_sfdisk_cmd() for more details.397 should_align_boot_part=should_align_boot_part)
412 if image_type == "ANDROID":
413 sfdisk_cmd = board_config.get_android_sfdisk_cmd(
414 should_align_boot_part=should_align_boot_part)
415 else:
416 sfdisk_cmd = board_config.get_sfdisk_cmd(
417 should_align_boot_part=should_align_boot_part)
418398
419 run_sfdisk_commands(sfdisk_cmd, heads, sectors, cylinders, media.path)399 run_sfdisk_commands(sfdisk_cmd, heads, sectors, cylinders, media.path)
420400

Subscribers

People subscribed via source and target branches