blob: e8bb1aced2089b5f0ad14a095c3fdbdea3727b7e [file] [log] [blame]
Xialin Liufeee26f2024-07-29 17:10:16 -05001TF-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
Xialin Liufeee26f2024-07-29 17:10:16 -050016Getting Started
17~~~~~~~~~~~~~~~
18
Manish V Badarkhed544f052024-08-27 10:48:38 +010019``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`_.
Xialin Liufeee26f2024-07-29 17:10:16 -050021
Manish V Badarkhed544f052024-08-27 10:48:38 +010022``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.
Xialin Liufeee26f2024-07-29 17:10:16 -050025
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
Xialin Liufeee26f2024-07-29 17:10:16 -050048Convert 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
Manish V Badarkhed544f052024-08-27 10:48:38 +010060 cot-dt2c convert-to-c [INPUT DTS PATH] [OUTPUT C PATH]
Xialin Liufeee26f2024-07-29 17:10:16 -050061 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
Manish V Badarkhed544f052024-08-27 10:48:38 +010083 cot-dt2c validate-cot [INPUT DTS PATH]
Xialin Liufeee26f2024-07-29 17:10:16 -050084 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
Manish V Badarkhed544f052024-08-27 10:48:38 +010095 cot-dt2c visualize-cot [INPUT DTS PATH]
Xialin Liufeee26f2024-07-29 17:10:16 -050096 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
Manish V Badarkhed544f052024-08-27 10:48:38 +0100118.. _tools/cot_dt2c/pyproject.toml: https://review.trustedfirmware.org/plugins/gitiles/TF-A/trusted-firmware-a/+/refs/heads/integration/tools/cot_dt2c/pyproject.toml
Xialin Liufeee26f2024-07-29 17:10:16 -0500119.. _Poetry: https://python-poetry.org/docs/