diff mbox series

[4/5] btool: mkeficapsule: Add support for EFI empty capsule generation

Message ID 20231004112722.416877-5-sughosh.ganu@linaro.org
State New
Headers show
Series Support for dumping capsule headers and empty capsules | expand

Commit Message

Sughosh Ganu Oct. 4, 2023, 11:27 a.m. UTC
Add a method to the mkeficapsule bintool to generate empty
capsules. These are capsules needed for the FWU A/B update feature.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
---
 tools/binman/btool/mkeficapsule.py | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

Comments

Simon Glass Oct. 7, 2023, 11:09 p.m. UTC | #1
Hi Sugosh,

On Wed, 4 Oct 2023 at 05:27, Sughosh Ganu <sughosh.ganu@linaro.org> wrote:
>
> Add a method to the mkeficapsule bintool to generate empty
> capsules. These are capsules needed for the FWU A/B update feature.
>
> Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> ---
>  tools/binman/btool/mkeficapsule.py | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
>
> diff --git a/tools/binman/btool/mkeficapsule.py b/tools/binman/btool/mkeficapsule.py
> index 61179747ff..89c0adfc9f 100644
> --- a/tools/binman/btool/mkeficapsule.py
> +++ b/tools/binman/btool/mkeficapsule.py
> @@ -80,6 +80,35 @@ class Bintoolmkeficapsule(bintool.Bintool):
>
>          return self.run_cmd(*args)
>
> +    def generate_empty_capsule(self, accept, revert, image_guid,

Instead of two separate bools, how about an 'operation' param, a
string which is either accept or revert? Or perhaps just have 'accept'
 and pass True or False?

> +                               output_fname):
> +        """Generate empty capsules for FWU A/B updates
> +
> +        Args:
> +            accept (int): Generate an accept capsule
> +            revert (int): Generate a revert capsule
> +            image_guid (str): GUID used for identifying the image
> +            output_fname (str): Path to the output capsule file
> +
> +        Returns:
> +            str: Tool output
> +        """
> +        if accept:
> +            args = [
> +                f'--guid={image_guid}',
> +                '--fw-accept'
> +            ]
> +        elif revert:
> +            args = [
> +                '--fw-revert'
> +            ]

That can be on none line

> +
> +        args += [
> +            output_fname
> +        ]

Same here

> +
> +        return self.run_cmd(*args)
> +
>      def fetch(self, method):
>          """Fetch handler for mkeficapsule
>
> --
> 2.34.1
>

Regards,
Simon
Sughosh Ganu Oct. 9, 2023, 7:46 a.m. UTC | #2
hi Simon,

On Sun, 8 Oct 2023 at 04:42, Simon Glass <sjg@chromium.org> wrote:
>
> Hi Sugosh,
>
> On Wed, 4 Oct 2023 at 05:27, Sughosh Ganu <sughosh.ganu@linaro.org> wrote:
> >
> > Add a method to the mkeficapsule bintool to generate empty
> > capsules. These are capsules needed for the FWU A/B update feature.
> >
> > Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
> > ---
> >  tools/binman/btool/mkeficapsule.py | 29 +++++++++++++++++++++++++++++
> >  1 file changed, 29 insertions(+)
> >
> > diff --git a/tools/binman/btool/mkeficapsule.py b/tools/binman/btool/mkeficapsule.py
> > index 61179747ff..89c0adfc9f 100644
> > --- a/tools/binman/btool/mkeficapsule.py
> > +++ b/tools/binman/btool/mkeficapsule.py
> > @@ -80,6 +80,35 @@ class Bintoolmkeficapsule(bintool.Bintool):
> >
> >          return self.run_cmd(*args)
> >
> > +    def generate_empty_capsule(self, accept, revert, image_guid,
>
> Instead of two separate bools, how about an 'operation' param, a
> string which is either accept or revert? Or perhaps just have 'accept'
>  and pass True or False?

Okay incorporate this and the other two review comments on this patch. Thanks.

-sughosh

>
> > +                               output_fname):
> > +        """Generate empty capsules for FWU A/B updates
> > +
> > +        Args:
> > +            accept (int): Generate an accept capsule
> > +            revert (int): Generate a revert capsule
> > +            image_guid (str): GUID used for identifying the image
> > +            output_fname (str): Path to the output capsule file
> > +
> > +        Returns:
> > +            str: Tool output
> > +        """
> > +        if accept:
> > +            args = [
> > +                f'--guid={image_guid}',
> > +                '--fw-accept'
> > +            ]
> > +        elif revert:
> > +            args = [
> > +                '--fw-revert'
> > +            ]
>
> That can be on none line
>
> > +
> > +        args += [
> > +            output_fname
> > +        ]
>
> Same here
>
> > +
> > +        return self.run_cmd(*args)
> > +
> >      def fetch(self, method):
> >          """Fetch handler for mkeficapsule
> >
> > --
> > 2.34.1
> >
>
> Regards,
> Simon
diff mbox series

Patch

diff --git a/tools/binman/btool/mkeficapsule.py b/tools/binman/btool/mkeficapsule.py
index 61179747ff..89c0adfc9f 100644
--- a/tools/binman/btool/mkeficapsule.py
+++ b/tools/binman/btool/mkeficapsule.py
@@ -80,6 +80,35 @@  class Bintoolmkeficapsule(bintool.Bintool):
 
         return self.run_cmd(*args)
 
+    def generate_empty_capsule(self, accept, revert, image_guid,
+                               output_fname):
+        """Generate empty capsules for FWU A/B updates
+
+        Args:
+            accept (int): Generate an accept capsule
+            revert (int): Generate a revert capsule
+            image_guid (str): GUID used for identifying the image
+            output_fname (str): Path to the output capsule file
+
+        Returns:
+            str: Tool output
+        """
+        if accept:
+            args = [
+                f'--guid={image_guid}',
+                '--fw-accept'
+            ]
+        elif revert:
+            args = [
+                '--fw-revert'
+            ]
+
+        args += [
+            output_fname
+        ]
+
+        return self.run_cmd(*args)
+
     def fetch(self, method):
         """Fetch handler for mkeficapsule