blob: 8a3981adc8908fdfe234b4ce667166d944fabd1c [file] [log] [blame]
Marek Vasut96e614e2024-05-21 12:48:23 +02001# SPDX-License-Identifier: GPL-2.0+
2# Copyright 2024 Marek Vasut <marex@denx.de>
3#
4"""Bintool implementation for cst"""
5
6import re
7
8from binman import bintool
9
10class Bintoolcst(bintool.Bintool):
11 """Image generation for U-Boot
12
13 This bintool supports running `cst` with some basic parameters as
14 needed by binman.
Leonard Anderweit302e0212025-02-26 22:05:01 +010015
16 cst (imx code signing tool) is used for sigining bootloader binaries for
17 various i.MX SoCs.
18
19 See `Code Signing Tool Users Guide`_ for more information.
20
21 .. _`Code Signing Tool Users Guide`:
22 https://community.nxp.com/pwmxy87654/attachments/pwmxy87654/imx-processors/202591/1/CST_UG.pdf
Marek Vasut96e614e2024-05-21 12:48:23 +020023 """
24 def __init__(self, name):
25 super().__init__(name, 'Sign NXP i.MX image')
26
27 # pylint: disable=R0913
28 def run(self, output_fname=None):
29 """Run cst
30
31 Args:
32 output_fname: Output filename to write to
33 """
34 args = []
35 if output_fname:
36 args += ['-o', output_fname]
37 return self.run_cmd(*args)
38
39 def fetch(self, method):
Leonard Anderweit302e0212025-02-26 22:05:01 +010040 """Build cst from git"""
41 if method != bintool.FETCH_BUILD:
Marek Vasut96e614e2024-05-21 12:48:23 +020042 return None
Leonard Anderweit302e0212025-02-26 22:05:01 +010043
44 from platform import architecture
45 arch = 'linux64' if architecture()[0] == '64bit' else 'linux32'
46 result = self.build_from_git(
47 'https://gitlab.apertis.org/pkg/imx-code-signing-tool',
48 ['all'],
49 f'code/obj.{arch}/cst',
50 flags=[f'OSTYPE={arch}', 'ENCRYPTION=yes'],
51 git_branch='debian/unstable',
52 make_path=f'code/obj.{arch}/')
53 return result