# SPDX-License-Identifier: GPL-2.0+ # Copyright (c) 2022-2023 Texas Instruments Incorporated - https://www.ti.com/ # Written by Neha Malcom Francis # # Entry-type module for generating schema validated TI board # configuration binary # import os import struct import yaml import yamllint from collections import OrderedDict from jsonschema import validate from shutil import copyfileobj from binman.entry import Entry from binman.etype.section import Entry_section from dtoc import fdt_util from u_boot_pylib import tools from yamllint import config BOARDCFG = 0xB BOARDCFG_SEC = 0xD BOARDCFG_PM = 0xE BOARDCFG_RM = 0xC BOARDCFG_NUM_ELEMS = 4 class Entry_ti_board_config(Entry_section): """An entry containing a TI schema validated board config binary This etype supports generation of two kinds of board configuration binaries: singular board config binary as well as combined board config binary. Properties / Entry arguments: - config-file: File containing board configuration data in YAML - schema-file: File containing board configuration YAML schema against which the config file is validated Output files: - board config binary: File containing board configuration binary These above parameters are used only when the generated binary is intended to be a single board configuration binary. Example:: my-ti-board-config { ti-board-config { config = "board-config.yaml"; schema = "schema.yaml"; }; }; To generate a combined board configuration binary, we pack the needed individual binaries into a ti-board-config binary. In this case, the available supported subnode names are board-cfg, pm-cfg, sec-cfg and rm-cfg. The final binary is prepended with a header containing details about the included board config binaries. Example:: my-combined-ti-board-config { ti-board-config { board-cfg { config = "board-cfg.yaml"; schema = "schema.yaml"; }; sec-cfg { config = "sec-cfg.yaml"; schema = "schema.yaml"; }; } } """ def __init__(self, section, etype, node): super().__init__(section, etype, node) self._config = None self._schema = None self._entries = OrderedDict() self._num_elems = BOARDCFG_NUM_ELEMS self._fmt = '