=== modified file 'linaro-media-create'
@@ -104,9 +104,8 @@
install_hwpacks(ROOTFS_DIR, TMP_DIR, args.hwpack_force_yes, *hwpacks)
boot_partition, root_partition = setup_partitions(
- args.board, media, board_config.fat_size, args.image_size,
- args.boot_label, args.rfs_label, args.rootfs, ROOTFS_UUID,
- args.should_create_partitions,
+ board_config, media, args.image_size, args.boot_label, args.rfs_label,
+ args.rootfs, ROOTFS_UUID, args.should_create_partitions,
args.should_format_bootfs, args.should_format_rootfs)
if args.should_format_bootfs:
=== modified file 'linaro_media_create/boards.py'
@@ -35,6 +35,19 @@
boot_script = None
@classmethod
+ def get_sfdisk_cmd(cls):
+ """Return the sfdisk command to partition the media."""
+ if cls.fat_size == 32:
+ partition_type = '0x0C'
+ else:
+ partition_type = '0x0E'
+
+ # This will create a partition of the given type, containing 9
+ # cylinders (74027520 bytes, ~70 MiB), followed by a Linux-type
+ # partition containing the rest of the free space.
+ return ',9,%s,*\n,,,-' % partition_type
+
+ @classmethod
def _get_boot_cmd(cls, is_live, is_lowmem, consoles):
"""Get the boot command for this board.
@@ -195,6 +208,14 @@
mmc_option = '0:2'
@classmethod
+ def get_sfdisk_cmd(cls):
+ # Create a one cylinder partition for fixed-offset bootloader data at
+ # the beginning of the image (size is one cylinder, so 8224768 bytes
+ # with the first sector for MBR).
+ sfdisk_cmd = super(Mx51evkConfig, cls).get_sfdisk_cmd()
+ return ',1,0xDA\n%s' % sfdisk_cmd
+
+ @classmethod
def _make_boot_files(cls, uboot_parts_dir, boot_cmd, chroot_dir,
boot_dir, boot_script, boot_device_or_file):
uboot_file = os.path.join(
=== modified file 'linaro_media_create/partitions.py'
@@ -24,15 +24,14 @@
# the appropriate function for the given type of device? I think it's still
# small enough that there's not much benefit in doing that, but if it grows we
# might want to do it.
-def setup_partitions(board, media, fat_size, image_size,
- bootfs_label, rootfs_label, rootfs_type, rootfs_uuid,
+def setup_partitions(board_config, media, image_size, bootfs_label,
+ rootfs_label, rootfs_type, rootfs_uuid,
should_create_partitions, should_format_bootfs,
should_format_rootfs):
"""Make sure the given device is partitioned to boot the given board.
- :param board: The board's name, as a string.
+ :param board_config: A BoardConfig class.
:param media: The Media we should partition.
- :param fat_size: The FAT size (16 or 32) for the boot partition.
:param image_size: The size of the image file, in case we're setting up a
QEMU image.
:param should_create_partitions: Whether or not we should erase existing
@@ -49,7 +48,8 @@
proc.wait()
if should_create_partitions:
- create_partitions(board, media, fat_size, HEADS, SECTORS, cylinders)
+ create_partitions(
+ board_config, media, HEADS, SECTORS, cylinders)
if media.is_block_device:
bootfs, rootfs = get_boot_and_root_partitions_for_media(media)
@@ -63,7 +63,8 @@
# filesystem.
ensure_partition_is_not_mounted(bootfs)
proc = cmd_runner.run(
- ['mkfs.vfat', '-F', str(fat_size), bootfs, '-n', bootfs_label],
+ ['mkfs.vfat', '-F', str(board_config.fat_size), bootfs, '-n',
+ bootfs_label],
as_root=True)
proc.wait()
@@ -272,12 +273,11 @@
return proc.communicate("%s\n" % commands)
-def create_partitions(board, media, fat_size, heads, sectors, cylinders=None):
+def create_partitions(board_config, media, heads, sectors, cylinders=None):
"""Partition the given media according to the board requirements.
- :param board: A string with the board type (e.g. beagle, panda, etc)
+ :param board_config: A BoardConfig class.
:param media: A setup_partitions.Media object to partition.
- :param fat_size: The type of FATs used in the boot partition (16 or 32).
:param heads: Number of heads to use in the disk geometry of
partitions.
:param sectors: Number of sectors to use in the disk geometry of
@@ -291,21 +291,7 @@
['parted', '-s', media.path, 'mklabel', 'msdos'], as_root=True)
proc.wait()
- if fat_size == 32:
- partition_type = '0x0C'
- else:
- partition_type = '0x0E'
-
- sfdisk_cmd = ',9,%s,*\n,,,-' % partition_type
- if board == 'mx51evk':
- # Create a one cylinder partition for fixed-offset bootloader data at
- # the beginning of the image (size is one cylinder, so 8224768 bytes
- # with the first sector for MBR).
- sfdisk_cmd = ',1,0xDA\n%s' % sfdisk_cmd
-
- # Create a VFAT or FAT16 partition of 9 cylinders (74027520 bytes, ~70
- # MiB), followed by a Linux-type partition containing the rest of the free
- # space.
+ sfdisk_cmd = board_config.get_sfdisk_cmd()
run_sfdisk_commands(sfdisk_cmd, heads, sectors, cylinders, media.path)
# Sync and sleep to wait for the partition to settle.
=== modified file 'linaro_media_create/tests/test_media_create.py'
@@ -218,6 +218,19 @@
'make_boot_script', 'make_boot_ini']
self.assertEqual(expected, self.funcs_calls)
+
+class TestGetSfdiskCmd(TestCase):
+
+ def test_default(self):
+ self.assertEquals(
+ ',9,0x0C,*\n,,,-', boards.BoardConfig.get_sfdisk_cmd())
+
+ def test_mx51evk(self):
+ self.assertEquals(
+ ',1,0xDA\n,9,0x0C,*\n,,,-',
+ board_configs['mx51evk'].get_sfdisk_cmd())
+
+
class TestGetBootCmd(TestCase):
def test_vexpress(self):
@@ -447,7 +460,8 @@
popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())
- create_partitions('mx51evk', self.media, 32, 255, 63, '')
+ create_partitions(
+ board_configs['mx51evk'], self.media, 255, 63, '')
self.assertEqual(
[['sudo', 'parted', '-s', self.media.path, 'mklabel', 'msdos'],
@@ -464,7 +478,8 @@
popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())
- create_partitions('beagle', self.media, 32, 255, 63, '')
+ create_partitions(
+ board_configs['beagle'], self.media, 255, 63, '')
self.assertEqual(
[['sudo', 'parted', '-s', self.media.path, 'mklabel', 'msdos'],
@@ -479,7 +494,8 @@
sfdisk_fixture = self.useFixture(MockRunSfdiskCommandsFixture())
tempfile = self.createTempFileAsFixture()
- create_partitions('beagle', Media(tempfile), 32, 255, 63, '')
+ create_partitions(
+ board_configs['beagle'], Media(tempfile), 255, 63, '')
# Unlike the test for partitioning of a regular block device, in this
# case parted was not called as there's no existing partition table
@@ -648,8 +664,8 @@
lambda image: ('/dev/loop99', '/dev/loop98')))
uuid = '2e82008e-1af3-4699-8521-3bf5bac1e67a'
bootfs_dev, rootfs_dev = setup_partitions(
- 'beagle', Media(tempfile), 32, '2G', 'boot', 'root', 'ext3',
- uuid, True, True, True)
+ board_configs['beagle'], Media(tempfile), '2G', 'boot',
+ 'root', 'ext3', uuid, True, True, True)
self.assertEqual(
# This is the call that would create the image file.
[['qemu-img', 'create', '-f', 'raw', tempfile, '2G'],
@@ -680,8 +696,8 @@
popen_fixture = self.useFixture(MockCmdRunnerPopenFixture())
uuid = '2e82008e-1af3-4699-8521-3bf5bac1e67a'
bootfs_dev, rootfs_dev = setup_partitions(
- 'beagle', media, 32, '2G', 'boot', 'root', 'ext3', uuid, True,
- True, True)
+ board_configs['beagle'], media, '2G', 'boot', 'root', 'ext3',
+ uuid, True, True, True)
self.assertEqual(
[['sudo', 'parted', '-s', tempfile, 'mklabel', 'msdos'],
['sudo', 'sfdisk', '-D', '-H', '255', '-S', '63', tempfile],