Marek Vasut | 96e614e | 2024-05-21 12:48:23 +0200 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
| 2 | # Copyright 2024 Marek Vasut <marex@denx.de> |
| 3 | # |
| 4 | """Bintool implementation for cst""" |
| 5 | |
| 6 | import re |
| 7 | |
| 8 | from binman import bintool |
| 9 | |
| 10 | class 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 Anderweit | 302e021 | 2025-02-26 22:05:01 +0100 | [diff] [blame^] | 15 | |
| 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 Vasut | 96e614e | 2024-05-21 12:48:23 +0200 | [diff] [blame] | 23 | """ |
| 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 Anderweit | 302e021 | 2025-02-26 22:05:01 +0100 | [diff] [blame^] | 40 | """Build cst from git""" |
| 41 | if method != bintool.FETCH_BUILD: |
Marek Vasut | 96e614e | 2024-05-21 12:48:23 +0200 | [diff] [blame] | 42 | return None |
Leonard Anderweit | 302e021 | 2025-02-26 22:05:01 +0100 | [diff] [blame^] | 43 | |
| 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 |