From 467f84e12b96bc977d57575023517dd6f8ef7f29 Mon Sep 17 00:00:00 2001 From: Joshua Watt Date: Tue, 2 Jun 2020 08:42:05 -0500 Subject: wic: Add --offset argument for partitions Add support for an --offset argument when defining a partition. Many SoCs require that boot partitions be located at specific offsets. Prior to this argument, most WKS files were using the --align attribute to specify the location of these fixed partitions but this is not ideal because in the event that the partition couldn't be placed in the specified location, wic would move it to the next sector with that alignment, often preventing the device from booting. Unlike the --align argument, wic will fail if a partition cannot be placed at the exact offset specified with --offset. Changes in V2: * Fixed a small typo that prevented test_fixed_size_error from passing Signed-off-by: Joshua Watt Signed-off-by: Richard Purdie --- scripts/lib/wic/plugins/imager/direct.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'scripts/lib/wic/plugins') diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py index 2d06c242b6f..1f65a7afe56 100644 --- a/scripts/lib/wic/plugins/imager/direct.py +++ b/scripts/lib/wic/plugins/imager/direct.py @@ -428,6 +428,21 @@ class PartitionedImage(): # increase the offset so we actually start the partition on right alignment self.offset += align_sectors + if part.offset is not None: + offset = (part.offset * 1024) // self.sector_size + + if offset * self.sector_size != part.offset * 1024: + raise WicError("Could not place %s%s at offset %dK with sector size %d" % (part.disk, self.numpart, part.offset, self.sector_size)) + + delta = offset - self.offset + if delta < 0: + raise WicError("Could not place %s%s at offset %dK: next free sector is %d (delta: %d)" % (part.disk, self.numpart, part.offset, offset, delta)) + + logger.debug("Skipping %d sectors to place %s%s at offset %dK", + delta, part.disk, self.numpart, part.offset) + + self.offset = offset + part.start = self.offset self.offset += part.size_sec -- cgit 1.2.3-korg