U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] binman: build_from_git: Add argument specifying branch
@ 2025-02-26 21:04 Leonard Anderweit
  2025-02-26 21:05 ` [PATCH v2 2/3] binman: build_from_git: Add optional make path inside git repo Leonard Anderweit
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Leonard Anderweit @ 2025-02-26 21:04 UTC (permalink / raw)
  To: u-boot
  Cc: Simon Glass, Alper Nebi Yasak, Tom Rini, Leonard Anderweit,
	Marek Vasut, Tim Harvey, upstream

Add optional argument git_branch to build_from_git. The new argument
allows specifying which branch of the repo to use.

Signed-off-by: Leonard Anderweit <l.anderweit@phytec.de>
---
 tools/binman/bintool.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/binman/bintool.py b/tools/binman/bintool.py
index 3c4ad1adbb9e..7280ee4f8cd9 100644
--- a/tools/binman/bintool.py
+++ b/tools/binman/bintool.py
@@ -328,7 +328,8 @@ class Bintool:
             return result.stdout
 
     @classmethod
-    def build_from_git(cls, git_repo, make_targets, bintool_path, flags=None):
+    def build_from_git(cls, git_repo, make_targets, bintool_path,
+            flags=None, git_branch=None):
         """Build a bintool from a git repo
 
         This clones the repo in a temporary directory, builds it with 'make',
@@ -341,6 +342,7 @@ class Bintool:
             bintool_path (str): Relative path of the tool in the repo, after
                 build is complete
             flags (list of str): Flags or variables to pass to make, or None
+            git_branch (str): Branch of git repo, or None to use the default
 
         Returns:
             tuple:
@@ -350,7 +352,11 @@ class Bintool:
         """
         tmpdir = tempfile.mkdtemp(prefix='binmanf.')
         print(f"- clone git repo '{git_repo}' to '{tmpdir}'")
-        tools.run('git', 'clone', '--depth', '1', git_repo, tmpdir)
+        if git_branch:
+            tools.run('git', 'clone', '--depth', '1', '--branch', git_branch,
+                      git_repo, tmpdir)
+        else:
+            tools.run('git', 'clone', '--depth', '1', git_repo, tmpdir)
         for target in make_targets:
             print(f"- build target '{target}'")
             cmd = ['make', '-C', tmpdir, '-j', f'{multiprocessing.cpu_count()}',
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/3] binman: build_from_git: Add optional make path inside git repo
  2025-02-26 21:04 [PATCH v2 1/3] binman: build_from_git: Add argument specifying branch Leonard Anderweit
@ 2025-02-26 21:05 ` Leonard Anderweit
  2025-03-05 14:15   ` Simon Glass
  2025-02-26 21:05 ` [PATCH v2 3/3] binman: cst: Build from source Leonard Anderweit
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Leonard Anderweit @ 2025-02-26 21:05 UTC (permalink / raw)
  To: u-boot
  Cc: Simon Glass, Alper Nebi Yasak, Tom Rini, Leonard Anderweit,
	Marek Vasut, Tim Harvey, upstream

Add optional argument make_path to build_from git. The new argument
allows specifying the path to a Makefile in case it is not in the root
of the git repo.
Also adjust the corresponding test.

Signed-off-by: Leonard Anderweit <l.anderweit@phytec.de>
---
v2: fix tests
---
 tools/binman/bintool.py      | 9 +++++++--
 tools/binman/bintool_test.py | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/binman/bintool.py b/tools/binman/bintool.py
index 7280ee4f8cd9..81872db377f9 100644
--- a/tools/binman/bintool.py
+++ b/tools/binman/bintool.py
@@ -329,7 +329,7 @@ class Bintool:
 
     @classmethod
     def build_from_git(cls, git_repo, make_targets, bintool_path,
-            flags=None, git_branch=None):
+            flags=None, git_branch=None, make_path=None):
         """Build a bintool from a git repo
 
         This clones the repo in a temporary directory, builds it with 'make',
@@ -343,6 +343,8 @@ class Bintool:
                 build is complete
             flags (list of str): Flags or variables to pass to make, or None
             git_branch (str): Branch of git repo, or None to use the default
+            make_path (str): Relative path inside git repo containing the
+                Makefile, or None
 
         Returns:
             tuple:
@@ -359,7 +361,10 @@ class Bintool:
             tools.run('git', 'clone', '--depth', '1', git_repo, tmpdir)
         for target in make_targets:
             print(f"- build target '{target}'")
-            cmd = ['make', '-C', tmpdir, '-j', f'{multiprocessing.cpu_count()}',
+            makedir = tmpdir
+            if make_path:
+                makedir = os.path.join(tmpdir, make_path)
+            cmd = ['make', '-C', makedir, '-j', f'{multiprocessing.cpu_count()}',
                    target]
             if flags:
                 cmd += flags
diff --git a/tools/binman/bintool_test.py b/tools/binman/bintool_test.py
index f9b16d4c73b5..949d6f4c8a90 100644
--- a/tools/binman/bintool_test.py
+++ b/tools/binman/bintool_test.py
@@ -303,6 +303,7 @@ class TestBintool(unittest.TestCase):
                 # See Bintool.build_from_git()
                 tmpdir = cmd[2]
                 self.fname = os.path.join(tmpdir, 'pathname')
+                os.makedirs(os.path.dirname(tmpdir), exist_ok=True)
                 tools.write_file(self.fname, b'hello')
 
         expected = b'this is a test'
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 3/3] binman: cst: Build from source
  2025-02-26 21:04 [PATCH v2 1/3] binman: build_from_git: Add argument specifying branch Leonard Anderweit
  2025-02-26 21:05 ` [PATCH v2 2/3] binman: build_from_git: Add optional make path inside git repo Leonard Anderweit
@ 2025-02-26 21:05 ` Leonard Anderweit
  2025-03-05 14:15   ` Simon Glass
  2025-03-05 14:15 ` [PATCH v2 1/3] binman: build_from_git: Add argument specifying branch Simon Glass
  2025-03-12 19:43 ` Tom Rini
  3 siblings, 1 reply; 7+ messages in thread
From: Leonard Anderweit @ 2025-02-26 21:05 UTC (permalink / raw)
  To: u-boot
  Cc: Simon Glass, Alper Nebi Yasak, Tom Rini, Leonard Anderweit,
	Marek Vasut, Tim Harvey, upstream

Build the imx code singing tool from source instead of relying on the
distro to provide the tool.
Use the debian/unstable branch because the default branch is outdated.
The binary is supposed to be build with docker, work around that by selecting
the correct Makefile directly.
Also append the description and add a link to documentation.

Signed-off-by: Leonard Anderweit <l.anderweit@phytec.de>
---
v2: add documentation
---
 tools/binman/bintools.rst |  8 ++++++++
 tools/binman/btool/cst.py | 37 +++++++++++++++++++++----------------
 2 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/tools/binman/bintools.rst b/tools/binman/bintools.rst
index cd05ad8cb26d..9f6cab544a5e 100644
--- a/tools/binman/bintools.rst
+++ b/tools/binman/bintools.rst
@@ -52,6 +52,14 @@ Bintool: cst: Image generation for U-Boot
 This bintool supports running `cst` with some basic parameters as
 needed by binman.
 
+cst (imx code signing tool) is used for sigining bootloader binaries for
+various i.MX SoCs.
+
+See `Code Signing Tool Users Guide`_ for more information.
+
+.. _`Code Signing Tool Users Guide`:
+    https://community.nxp.com/pwmxy87654/attachments/pwmxy87654/imx-processors/202591/1/CST_UG.pdf
+
 
 
 Bintool: fdt_add_pubkey: Add public key to control dtb (spl or u-boot proper)
diff --git a/tools/binman/btool/cst.py b/tools/binman/btool/cst.py
index 30e78bdbbd9d..8a3981adc890 100644
--- a/tools/binman/btool/cst.py
+++ b/tools/binman/btool/cst.py
@@ -12,6 +12,14 @@ class Bintoolcst(bintool.Bintool):
 
     This bintool supports running `cst` with some basic parameters as
     needed by binman.
+
+    cst (imx code signing tool) is used for sigining bootloader binaries for
+    various i.MX SoCs.
+
+    See `Code Signing Tool Users Guide`_ for more information.
+
+    .. _`Code Signing Tool Users Guide`:
+        https://community.nxp.com/pwmxy87654/attachments/pwmxy87654/imx-processors/202591/1/CST_UG.pdf
     """
     def __init__(self, name):
         super().__init__(name, 'Sign NXP i.MX image')
@@ -29,20 +37,17 @@ class Bintoolcst(bintool.Bintool):
         return self.run_cmd(*args)
 
     def fetch(self, method):
-        """Fetch handler for cst
-
-        This installs cst using the apt utility.
-
-        Args:
-            method (FETCH_...): Method to use
-
-        Returns:
-            True if the file was fetched and now installed, None if a method
-            other than FETCH_BIN was requested
-
-        Raises:
-            Valuerror: Fetching could not be completed
-        """
-        if method != bintool.FETCH_BIN:
+        """Build cst from git"""
+        if method != bintool.FETCH_BUILD:
             return None
-        return self.apt_install('imx-code-signing-tool')
+
+        from platform import architecture
+        arch = 'linux64' if architecture()[0] == '64bit' else 'linux32'
+        result = self.build_from_git(
+            'https://gitlab.apertis.org/pkg/imx-code-signing-tool',
+            ['all'],
+            f'code/obj.{arch}/cst',
+            flags=[f'OSTYPE={arch}', 'ENCRYPTION=yes'],
+            git_branch='debian/unstable',
+            make_path=f'code/obj.{arch}/')
+        return result
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/3] binman: build_from_git: Add argument specifying branch
  2025-02-26 21:04 [PATCH v2 1/3] binman: build_from_git: Add argument specifying branch Leonard Anderweit
  2025-02-26 21:05 ` [PATCH v2 2/3] binman: build_from_git: Add optional make path inside git repo Leonard Anderweit
  2025-02-26 21:05 ` [PATCH v2 3/3] binman: cst: Build from source Leonard Anderweit
@ 2025-03-05 14:15 ` Simon Glass
  2025-03-12 19:43 ` Tom Rini
  3 siblings, 0 replies; 7+ messages in thread
From: Simon Glass @ 2025-03-05 14:15 UTC (permalink / raw)
  To: Leonard Anderweit
  Cc: u-boot, Alper Nebi Yasak, Tom Rini, Marek Vasut, Tim Harvey,
	upstream

On Wed, 26 Feb 2025 at 14:05, Leonard Anderweit <l.anderweit@phytec.de> wrote:
>
> Add optional argument git_branch to build_from_git. The new argument
> allows specifying which branch of the repo to use.
>
> Signed-off-by: Leonard Anderweit <l.anderweit@phytec.de>
> ---
>  tools/binman/bintool.py | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/3] binman: build_from_git: Add optional make path inside git repo
  2025-02-26 21:05 ` [PATCH v2 2/3] binman: build_from_git: Add optional make path inside git repo Leonard Anderweit
@ 2025-03-05 14:15   ` Simon Glass
  0 siblings, 0 replies; 7+ messages in thread
From: Simon Glass @ 2025-03-05 14:15 UTC (permalink / raw)
  To: Leonard Anderweit
  Cc: u-boot, Alper Nebi Yasak, Tom Rini, Marek Vasut, Tim Harvey,
	upstream

On Wed, 26 Feb 2025 at 14:05, Leonard Anderweit <l.anderweit@phytec.de> wrote:
>
> Add optional argument make_path to build_from git. The new argument
> allows specifying the path to a Makefile in case it is not in the root
> of the git repo.
> Also adjust the corresponding test.
>
> Signed-off-by: Leonard Anderweit <l.anderweit@phytec.de>
> ---
> v2: fix tests
> ---
>  tools/binman/bintool.py      | 9 +++++++--
>  tools/binman/bintool_test.py | 1 +
>  2 files changed, 8 insertions(+), 2 deletions(-)

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 3/3] binman: cst: Build from source
  2025-02-26 21:05 ` [PATCH v2 3/3] binman: cst: Build from source Leonard Anderweit
@ 2025-03-05 14:15   ` Simon Glass
  0 siblings, 0 replies; 7+ messages in thread
From: Simon Glass @ 2025-03-05 14:15 UTC (permalink / raw)
  To: Leonard Anderweit
  Cc: u-boot, Alper Nebi Yasak, Tom Rini, Marek Vasut, Tim Harvey,
	upstream

On Wed, 26 Feb 2025 at 14:05, Leonard Anderweit <l.anderweit@phytec.de> wrote:
>
> Build the imx code singing tool from source instead of relying on the
> distro to provide the tool.
> Use the debian/unstable branch because the default branch is outdated.
> The binary is supposed to be build with docker, work around that by selecting
> the correct Makefile directly.
> Also append the description and add a link to documentation.
>
> Signed-off-by: Leonard Anderweit <l.anderweit@phytec.de>
> ---
> v2: add documentation
> ---
>  tools/binman/bintools.rst |  8 ++++++++
>  tools/binman/btool/cst.py | 37 +++++++++++++++++++++----------------
>  2 files changed, 29 insertions(+), 16 deletions(-)
>

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/3] binman: build_from_git: Add argument specifying branch
  2025-02-26 21:04 [PATCH v2 1/3] binman: build_from_git: Add argument specifying branch Leonard Anderweit
                   ` (2 preceding siblings ...)
  2025-03-05 14:15 ` [PATCH v2 1/3] binman: build_from_git: Add argument specifying branch Simon Glass
@ 2025-03-12 19:43 ` Tom Rini
  3 siblings, 0 replies; 7+ messages in thread
From: Tom Rini @ 2025-03-12 19:43 UTC (permalink / raw)
  To: u-boot, Leonard Anderweit
  Cc: Simon Glass, Alper Nebi Yasak, Marek Vasut, Tim Harvey, upstream

On Wed, 26 Feb 2025 22:04:59 +0100, Leonard Anderweit wrote:

> Add optional argument git_branch to build_from_git. The new argument
> allows specifying which branch of the repo to use.
> 
> 

Applied to u-boot/next, thanks!

[1/3] binman: build_from_git: Add argument specifying branch
      commit: 5f2096d2bc58ac265110777d08673a0e4b27cd84
[2/3] binman: build_from_git: Add optional make path inside git repo
      commit: b48bc416206788da990c34ddcf92d5c3816247ea
[3/3] binman: cst: Build from source
      commit: 326b7ea9823a74a83b3a7ef6ee3f4927eb36987e
-- 
Tom



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-03-12 19:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-26 21:04 [PATCH v2 1/3] binman: build_from_git: Add argument specifying branch Leonard Anderweit
2025-02-26 21:05 ` [PATCH v2 2/3] binman: build_from_git: Add optional make path inside git repo Leonard Anderweit
2025-03-05 14:15   ` Simon Glass
2025-02-26 21:05 ` [PATCH v2 3/3] binman: cst: Build from source Leonard Anderweit
2025-03-05 14:15   ` Simon Glass
2025-03-05 14:15 ` [PATCH v2 1/3] binman: build_from_git: Add argument specifying branch Simon Glass
2025-03-12 19:43 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox