• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1TF-A CoT dt2c Tool
2==================
3
4This tool is used to automatically generate the corresponding c file for a
5CoT DT file. Since currently TF-A support two type of CoT file: static c file
6and CoT DT binding. This is error prone and hard to maintain, therefore this
7tool can generate the c file for the platform that does not support CoT DT
8binding, given the CoT DT file so the c file can be deprecated.
9
10Prerequisites
11~~~~~~~~~~~~~
12
13#. Python (3.8 or later)
14#. `Poetry`_ Python package manager
15
16Getting Started
17~~~~~~~~~~~~~~~
18
19``cot-dt2c`` is installed by default with TF-A's poetry environment. All of it's
20dependencies are listed in `tools/cot_dt2c/pyproject.toml`_.
21
22``cot-dt2c`` requires a standard DTS file without #ifdef, macros, or other
23preprocessor directives. Therefore, you need to provide a preprocessed device
24tree source(DTS) as input to the tool.
25
26#. Usage of the tool
27
28    .. code::
29
30        cot-dt2c
31
32    This command will output the following as usage for this command
33
34    .. code-block:: text
35
36        Usage: cot-dt2c [OPTIONS] COMMAND [ARGS]...
37
38        Options:
39        --version  Show the version and exit.
40        --help     Show this message and exit.
41
42        Commands:
43        convert-to-c
44        validate-cot
45        visualize-cot
46        validate-dt
47
48Convert CoT descriptors to C file
49~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50
51To convert the CoT descriptors
52
53This command is for the platform that does not use CoT DT parser,
54which can generate the C file given the CoT descriptors. Before
55the conversion to C file, the tool will do an implicit checks on
56the validity of the CoT DT file.
57
58.. code::
59
60    cot-dt2c convert-to-c [INPUT DTS PATH] [OUTPUT C PATH]
61    cot-dt2c convert-to-c fdts/tbbr_cot_descriptors.dtsi test.c
62
63
64Validate CoT descriptors
65~~~~~~~~~~~~~~~~~~~~~~~~~
66
67To validate the certificate
68
69The tests folder in the tool folder provides some bad-example of the
70DT file, and the tool will print out "not a valid CoT DT file" on console.
71
72The command will check the format of the CoT file
73
74#. The open bracket
75#. The open ifdef macro
76#. The missing mandatory attribute
77#. Malformed DT file (cert missing parent, missing root certs. etc.)
78
79Currently the validation is specifically for checking the CoT DT file
80
81.. code::
82
83    cot-dt2c validate-cot [INPUT DTS PATH]
84    cot-dt2c validate-cot fdts/tbbr_cot_descriptors.dtsi
85
86
87Visualize CoT descriptors
88~~~~~~~~~~~~~~~~~~~~~~~~~
89
90This command create a HTML to visualize the relationship between
91the certificates and the image of a CoT DT file.
92
93.. code::
94
95    cot-dt2c visualize-cot [INPUT DTS PATH]
96    cot-dt2c visualize-cot fdts/tbbr_cot_descriptors.dtsi
97
98
99Validate Other DT files
100~~~~~~~~~~~~~~~~~~~~~~~
101
102The command will transform the dtsi/dts file into a more standard
103dtsi/dts file inside /tmp folder that can be used as input to dt-schema
104for further validation. Currently the tool will perform some basic validation
105for the file (syntax) and dt-schema can be used for advance checks. dt-schema
106is not installed along with the tool.
107
108.. code::
109
110    cot-dt2c validate-dt [INPUT DTS PATH or INPUT DTS folder]
111    cot-dt2c validate-dt fdts/
112    cot-dt2c validate-dt fdts/fvp-bsae-gicv3.dtsi
113
114--------------
115
116*Copyright (c) 2024, Arm Limited. All rights reserved.*
117
118.. _tools/cot_dt2c/pyproject.toml: https://review.trustedfirmware.org/plugins/gitiles/TF-A/trusted-firmware-a/+/refs/heads/integration/tools/cot_dt2c/pyproject.toml
119.. _Poetry: https://python-poetry.org/docs/
120