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