diff mbox series

[6/9] binman: Add support for RISC-V OpenSBI fw_dynamic blob

Message ID 20210505141557.23901-7-bmeng.cn@gmail.com
State Superseded
Delegated to: Andes
Headers show
Series riscv: Partially move to binman to generate u-boot.itb | expand

Commit Message

Bin Meng May 5, 2021, 2:15 p.m. UTC
Add an entry for RISC-V OpenSBI's 'fw_dynamic' firmware payload.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 tools/binman/entries.rst          | 13 +++++++++++++
 tools/binman/etype/opensbi.py     | 23 +++++++++++++++++++++++
 tools/binman/ftest.py             |  7 +++++++
 tools/binman/test/201_opensbi.dts | 16 ++++++++++++++++
 4 files changed, 59 insertions(+)
 create mode 100644 tools/binman/etype/opensbi.py
 create mode 100644 tools/binman/test/201_opensbi.dts

Comments

Simon Glass May 5, 2021, 11:37 p.m. UTC | #1
Hi Bin,

On Wed, 5 May 2021 at 07:16, Bin Meng <bmeng.cn@gmail.com> wrote:
>
> Add an entry for RISC-V OpenSBI's 'fw_dynamic' firmware payload.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
>  tools/binman/entries.rst          | 13 +++++++++++++
>  tools/binman/etype/opensbi.py     | 23 +++++++++++++++++++++++
>  tools/binman/ftest.py             |  7 +++++++
>  tools/binman/test/201_opensbi.dts | 16 ++++++++++++++++
>  4 files changed, 59 insertions(+)
>  create mode 100644 tools/binman/etype/opensbi.py
>  create mode 100644 tools/binman/test/201_opensbi.dts

Is it possible to use a default filename for this, instead of having
to specify it?

>
> diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
> index f1c3b7de7a..dcac700c46 100644
> --- a/tools/binman/entries.rst
> +++ b/tools/binman/entries.rst
> @@ -761,6 +761,19 @@ binman.
>
>
>
> +Entry: opensbi: RISC-V OpenSBI fw_dynamic blob
> +----------------------------------------------
> +
> +Properties / Entry arguments:
> +    - opensbi-path: Filename of file to read into entry. This is typically
> +        called fw_dynamic.bin
> +
> +This entry holds the run-time firmware, typically started by U-Boot SPL.
> +See the U-Boot README for your architecture or board for how to use it. See
> +https://github.com/riscv/opensbi for more information about OpenSBI.
> +
> +
> +
>  Entry: powerpc-mpc85xx-bootpg-resetvec: PowerPC mpc85xx bootpg + resetvec code for U-Boot
>  -----------------------------------------------------------------------------------------
>
> diff --git a/tools/binman/etype/opensbi.py b/tools/binman/etype/opensbi.py
> new file mode 100644
> index 0000000000..74d473d535
> --- /dev/null
> +++ b/tools/binman/etype/opensbi.py
> @@ -0,0 +1,23 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +#
> +# Copyright (C) 2021, Bin Meng <bmeng.cn@gmail.com>
> +#
> +# Entry-type module for RISC-V OpenSBI binary blob
> +#
> +
> +from binman.etype.blob_named_by_arg import Entry_blob_named_by_arg
> +
> +class Entry_opensbi(Entry_blob_named_by_arg):
> +    """RISC-V OpenSBI fw_dynamic blob
> +
> +    Properties / Entry arguments:
> +        - opensbi-path: Filename of file to read into entry. This is typically
> +            called fw_dynamic.bin
> +
> +    This entry holds the run-time firmware, typically started by U-Boot SPL.
> +    See the U-Boot README for your architecture or board for how to use it. See
> +    https://github.com/riscv/opensbi for more information about OpenSBI.
> +    """
> +    def __init__(self, section, etype, node):
> +        super().__init__(section, etype, node, 'opensbi')
> +        self.external = True
> diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
> index b0daccbc3b..5383eec489 100644
> --- a/tools/binman/ftest.py
> +++ b/tools/binman/ftest.py
> @@ -76,6 +76,7 @@ FSP_M_DATA            = b'fsp_m'
>  FSP_S_DATA            = b'fsp_s'
>  FSP_T_DATA            = b'fsp_t'
>  ATF_BL31_DATA         = b'bl31'
> +OPENSBI_DATA          = b'opensbi'
>  SCP_DATA              = b'scp'
>  TEST_FDT1_DATA        = b'fdt1'
>  TEST_FDT2_DATA        = b'test-fdt2'
> @@ -178,6 +179,7 @@ class TestFunctional(unittest.TestCase):
>          TestFunctional._MakeInputFile('compress', COMPRESS_DATA)
>          TestFunctional._MakeInputFile('compress_big', COMPRESS_DATA_BIG)
>          TestFunctional._MakeInputFile('bl31.bin', ATF_BL31_DATA)
> +        TestFunctional._MakeInputFile('fw_dynamic.bin', OPENSBI_DATA)
>          TestFunctional._MakeInputFile('scp.bin', SCP_DATA)
>
>          # Add a few .dtb files for testing
> @@ -4535,5 +4537,10 @@ class TestFunctional(unittest.TestCase):
>          expected += tools.GetBytes(0, 88 - len(expected)) + U_BOOT_NODTB_DATA
>          self.assertEqual(expected, data)
>
> +    def testPackOpenSBI(self):
> +        """Test that an image with an OpenSBI binary can be created"""
> +        data = self._DoReadFile('201_opensbi.dts')
> +        self.assertEqual(OPENSBI_DATA, data[:len(OPENSBI_DATA)])
> +
>  if __name__ == "__main__":
>      unittest.main()
> diff --git a/tools/binman/test/201_opensbi.dts b/tools/binman/test/201_opensbi.dts
> new file mode 100644
> index 0000000000..16c01a946a
> --- /dev/null
> +++ b/tools/binman/test/201_opensbi.dts
> @@ -0,0 +1,16 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +
> +/dts-v1/;
> +
> +/ {
> +       #address-cells = <1>;
> +       #size-cells = <1>;
> +
> +       binman {
> +               size = <16>;

Can you drop that?

> +
> +               opensbi {
> +                       filename = "fw_dynamic.bin";
> +               };
> +       };
> +};
> --
> 2.25.1
>

Regards,
Simon
Bin Meng May 8, 2021, 1:29 a.m. UTC | #2
Hi Simon,

On Thu, May 6, 2021 at 7:37 AM Simon Glass <sjg@chromium.org> wrote:
>
> Hi Bin,
>
> On Wed, 5 May 2021 at 07:16, Bin Meng <bmeng.cn@gmail.com> wrote:
> >
> > Add an entry for RISC-V OpenSBI's 'fw_dynamic' firmware payload.
> >
> > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> > ---
> >
> >  tools/binman/entries.rst          | 13 +++++++++++++
> >  tools/binman/etype/opensbi.py     | 23 +++++++++++++++++++++++
> >  tools/binman/ftest.py             |  7 +++++++
> >  tools/binman/test/201_opensbi.dts | 16 ++++++++++++++++
> >  4 files changed, 59 insertions(+)
> >  create mode 100644 tools/binman/etype/opensbi.py
> >  create mode 100644 tools/binman/test/201_opensbi.dts
>
> Is it possible to use a default filename for this, instead of having
> to specify it?

I don't get what you meant. Would you please clarify?

Regards,
Bin
Simon Glass May 8, 2021, 1:42 a.m. UTC | #3
Hi Bin,

On Fri, 7 May 2021 at 18:29, Bin Meng <bmeng.cn@gmail.com> wrote:
>
> Hi Simon,
>
> On Thu, May 6, 2021 at 7:37 AM Simon Glass <sjg@chromium.org> wrote:
> >
> > Hi Bin,
> >
> > On Wed, 5 May 2021 at 07:16, Bin Meng <bmeng.cn@gmail.com> wrote:
> > >
> > > Add an entry for RISC-V OpenSBI's 'fw_dynamic' firmware payload.
> > >
> > > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> > > ---
> > >
> > >  tools/binman/entries.rst          | 13 +++++++++++++
> > >  tools/binman/etype/opensbi.py     | 23 +++++++++++++++++++++++
> > >  tools/binman/ftest.py             |  7 +++++++
> > >  tools/binman/test/201_opensbi.dts | 16 ++++++++++++++++
> > >  4 files changed, 59 insertions(+)
> > >  create mode 100644 tools/binman/etype/opensbi.py
> > >  create mode 100644 tools/binman/test/201_opensbi.dts
> >
> > Is it possible to use a default filename for this, instead of having
> > to specify it?
>
> I don't get what you meant. Would you please clarify?

I mean adding a GetDefaultFilename() argument. But I see that you are
using a -a parameter, so perhaps there is no point.

Reviewed-by: Simon Glass <sjg@chromium.org>

Regards,
Simon
diff mbox series

Patch

diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst
index f1c3b7de7a..dcac700c46 100644
--- a/tools/binman/entries.rst
+++ b/tools/binman/entries.rst
@@ -761,6 +761,19 @@  binman.
 
 
 
+Entry: opensbi: RISC-V OpenSBI fw_dynamic blob
+----------------------------------------------
+
+Properties / Entry arguments:
+    - opensbi-path: Filename of file to read into entry. This is typically
+        called fw_dynamic.bin
+
+This entry holds the run-time firmware, typically started by U-Boot SPL.
+See the U-Boot README for your architecture or board for how to use it. See
+https://github.com/riscv/opensbi for more information about OpenSBI.
+
+
+
 Entry: powerpc-mpc85xx-bootpg-resetvec: PowerPC mpc85xx bootpg + resetvec code for U-Boot
 -----------------------------------------------------------------------------------------
 
diff --git a/tools/binman/etype/opensbi.py b/tools/binman/etype/opensbi.py
new file mode 100644
index 0000000000..74d473d535
--- /dev/null
+++ b/tools/binman/etype/opensbi.py
@@ -0,0 +1,23 @@ 
+# SPDX-License-Identifier: GPL-2.0+
+#
+# Copyright (C) 2021, Bin Meng <bmeng.cn@gmail.com>
+#
+# Entry-type module for RISC-V OpenSBI binary blob
+#
+
+from binman.etype.blob_named_by_arg import Entry_blob_named_by_arg
+
+class Entry_opensbi(Entry_blob_named_by_arg):
+    """RISC-V OpenSBI fw_dynamic blob
+
+    Properties / Entry arguments:
+        - opensbi-path: Filename of file to read into entry. This is typically
+            called fw_dynamic.bin
+
+    This entry holds the run-time firmware, typically started by U-Boot SPL.
+    See the U-Boot README for your architecture or board for how to use it. See
+    https://github.com/riscv/opensbi for more information about OpenSBI.
+    """
+    def __init__(self, section, etype, node):
+        super().__init__(section, etype, node, 'opensbi')
+        self.external = True
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index b0daccbc3b..5383eec489 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -76,6 +76,7 @@  FSP_M_DATA            = b'fsp_m'
 FSP_S_DATA            = b'fsp_s'
 FSP_T_DATA            = b'fsp_t'
 ATF_BL31_DATA         = b'bl31'
+OPENSBI_DATA          = b'opensbi'
 SCP_DATA              = b'scp'
 TEST_FDT1_DATA        = b'fdt1'
 TEST_FDT2_DATA        = b'test-fdt2'
@@ -178,6 +179,7 @@  class TestFunctional(unittest.TestCase):
         TestFunctional._MakeInputFile('compress', COMPRESS_DATA)
         TestFunctional._MakeInputFile('compress_big', COMPRESS_DATA_BIG)
         TestFunctional._MakeInputFile('bl31.bin', ATF_BL31_DATA)
+        TestFunctional._MakeInputFile('fw_dynamic.bin', OPENSBI_DATA)
         TestFunctional._MakeInputFile('scp.bin', SCP_DATA)
 
         # Add a few .dtb files for testing
@@ -4535,5 +4537,10 @@  class TestFunctional(unittest.TestCase):
         expected += tools.GetBytes(0, 88 - len(expected)) + U_BOOT_NODTB_DATA
         self.assertEqual(expected, data)
 
+    def testPackOpenSBI(self):
+        """Test that an image with an OpenSBI binary can be created"""
+        data = self._DoReadFile('201_opensbi.dts')
+        self.assertEqual(OPENSBI_DATA, data[:len(OPENSBI_DATA)])
+
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/test/201_opensbi.dts b/tools/binman/test/201_opensbi.dts
new file mode 100644
index 0000000000..16c01a946a
--- /dev/null
+++ b/tools/binman/test/201_opensbi.dts
@@ -0,0 +1,16 @@ 
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		size = <16>;
+
+		opensbi {
+			filename = "fw_dynamic.bin";
+		};
+	};
+};