diff options
author | Joshua Watt <JPEWhacker@gmail.com> | 2020-08-21 14:46:23 -0500 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2020-09-30 05:54:58 -1000 |
commit | b9296bdeaacc1dce97aac9c9bf0d70555bb36646 (patch) | |
tree | 8c0f48d0ebec085279786e5d94e423c6e80070d3 /scripts/lib/wic/ksparser.py | |
parent | 0ff25797126772f40e357a2f3cf81eccf659adaf (diff) | |
download | openembedded-core-contrib-b9296bdeaacc1dce97aac9c9bf0d70555bb36646.tar.gz |
wic: Add 512 Byte alignment to --offset
Allows the --offset argument to use the "s" or "S" suffix to specify
that it is reporting the number of 512 byte sectors.
This is required for some SoCs where the mask ROM looks for an item at a
sector that isn't aligned to a 1KB boundary.
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 938595d1dc4abaf5f7f3a7900add3f0492b805d0)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'scripts/lib/wic/ksparser.py')
-rw-r--r-- | scripts/lib/wic/ksparser.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py index ac6f427564..76cc55b848 100644 --- a/scripts/lib/wic/ksparser.py +++ b/scripts/lib/wic/ksparser.py @@ -51,11 +51,11 @@ class KickStartParser(ArgumentParser): def error(self, message): raise ArgumentError(None, message) -def sizetype(default): +def sizetype(default, size_in_bytes=False): def f(arg): """ Custom type for ArgumentParser - Converts size string in <num>[K|k|M|G] format into the integer value + Converts size string in <num>[S|s|K|k|M|G] format into the integer value """ try: suffix = default @@ -67,12 +67,20 @@ def sizetype(default): except ValueError: raise ArgumentTypeError("Invalid size: %r" % arg) + + if size_in_bytes: + if suffix == 's' or suffix == 'S': + return size * 512 + mult = 1024 + else: + mult = 1 + if suffix == "k" or suffix == "K": - return size + return size * mult if suffix == "M": - return size * 1024 + return size * mult * 1024 if suffix == "G": - return size * 1024 * 1024 + return size * mult * 1024 * 1024 raise ArgumentTypeError("Invalid size: %r" % arg) return f @@ -141,7 +149,7 @@ class KickStart(): part.add_argument('mountpoint', nargs='?') part.add_argument('--active', action='store_true') part.add_argument('--align', type=int) - part.add_argument('--offset', type=sizetype("K")) + part.add_argument('--offset', type=sizetype("K", True)) part.add_argument('--exclude-path', nargs='+') part.add_argument('--include-path', nargs='+') part.add_argument("--extra-space", type=sizetype("M")) |