1*b95f398eSXialin LiuTF-A CoT dt2c Tool 2*b95f398eSXialin Liu================== 3*b95f398eSXialin Liu 4*b95f398eSXialin LiuThis tool is used to automatically generate the corresponding c file for a 5*b95f398eSXialin LiuCoT DT file. Since currently TF-A support two type of CoT file: static c file 6*b95f398eSXialin Liuand CoT DT binding. This is error prone and hard to maintain, therefore this 7*b95f398eSXialin Liutool can generate the c file for the platform that does not support CoT DT 8*b95f398eSXialin Liubinding, given the CoT DT file so the c file can be deprecated. 9*b95f398eSXialin Liu 10*b95f398eSXialin LiuPrerequisites 11*b95f398eSXialin Liu~~~~~~~~~~~~~ 12*b95f398eSXialin Liu 13*b95f398eSXialin Liu#. Python (3.8 or later) 14*b95f398eSXialin Liu#. `Poetry`_ Python package manager 15*b95f398eSXialin Liu 16*b95f398eSXialin Liu 17*b95f398eSXialin LiuGetting Started 18*b95f398eSXialin Liu~~~~~~~~~~~~~~~ 19*b95f398eSXialin Liu 20*b95f398eSXialin Liu#. Install the tool 21*b95f398eSXialin Liu 22*b95f398eSXialin Liu .. code:: 23*b95f398eSXialin Liu 24*b95f398eSXialin Liu make install 25*b95f398eSXialin Liu 26*b95f398eSXialin Liu 27*b95f398eSXialin Liu#. Verify that the tool runs correctly 28*b95f398eSXialin Liu 29*b95f398eSXialin Liu .. code:: 30*b95f398eSXialin Liu 31*b95f398eSXialin Liu make test 32*b95f398eSXialin Liu 33*b95f398eSXialin Liu 34*b95f398eSXialin Liu#. Usage of the tool 35*b95f398eSXialin Liu 36*b95f398eSXialin Liu .. code:: 37*b95f398eSXialin Liu 38*b95f398eSXialin Liu cot-dt2c 39*b95f398eSXialin Liu 40*b95f398eSXialin Liu This command will output the following as usage for this command 41*b95f398eSXialin Liu 42*b95f398eSXialin Liu .. code-block:: text 43*b95f398eSXialin Liu 44*b95f398eSXialin Liu Usage: cot-dt2c [OPTIONS] COMMAND [ARGS]... 45*b95f398eSXialin Liu 46*b95f398eSXialin Liu Options: 47*b95f398eSXialin Liu --version Show the version and exit. 48*b95f398eSXialin Liu --help Show this message and exit. 49*b95f398eSXialin Liu 50*b95f398eSXialin Liu Commands: 51*b95f398eSXialin Liu convert-to-c 52*b95f398eSXialin Liu validate-cot 53*b95f398eSXialin Liu visualize-cot 54*b95f398eSXialin Liu validate-dt 55*b95f398eSXialin Liu 56*b95f398eSXialin Liu#. Uninstall the tool 57*b95f398eSXialin Liu .. code:: 58*b95f398eSXialin Liu 59*b95f398eSXialin Liu make uninstall 60*b95f398eSXialin Liu 61*b95f398eSXialin Liu This command will uninstall the tool 62*b95f398eSXialin Liu 63*b95f398eSXialin Liu 64*b95f398eSXialin Liu#. Uninstall the tool and clean all the build file 65*b95f398eSXialin Liu .. code:: 66*b95f398eSXialin Liu 67*b95f398eSXialin Liu make clean 68*b95f398eSXialin Liu 69*b95f398eSXialin Liu This command will clean all the build file and implicitly uninstall the tool 70*b95f398eSXialin Liu 71*b95f398eSXialin Liu 72*b95f398eSXialin Liu#. Call the make file from TF-A root directory 73*b95f398eSXialin Liu .. code:: 74*b95f398eSXialin Liu 75*b95f398eSXialin Liu make -C tools/cot-dt2c install 76*b95f398eSXialin Liu make -C tools/cot-dt2c uninstall 77*b95f398eSXialin Liu make -C tools/cot-dt2c clean 78*b95f398eSXialin Liu 79*b95f398eSXialin LiuConvert CoT descriptors to C file 80*b95f398eSXialin Liu~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 81*b95f398eSXialin Liu 82*b95f398eSXialin LiuTo convert the CoT descriptors 83*b95f398eSXialin Liu 84*b95f398eSXialin LiuThis command is for the platform that does not use CoT DT parser, 85*b95f398eSXialin Liuwhich can generate the C file given the CoT descriptors. Before 86*b95f398eSXialin Liuthe conversion to C file, the tool will do an implicit checks on 87*b95f398eSXialin Liuthe validity of the CoT DT file. 88*b95f398eSXialin Liu 89*b95f398eSXialin Liu.. code:: 90*b95f398eSXialin Liu 91*b95f398eSXialin Liu cot-dt2c convert-to-c [INPUT DTB PATH] [OUTPUT C PATH] 92*b95f398eSXialin Liu cot-dt2c convert-to-c fdts/tbbr_cot_descriptors.dtsi test.c 93*b95f398eSXialin Liu 94*b95f398eSXialin Liu 95*b95f398eSXialin LiuValidate CoT descriptors 96*b95f398eSXialin Liu~~~~~~~~~~~~~~~~~~~~~~~~~ 97*b95f398eSXialin Liu 98*b95f398eSXialin LiuTo validate the certificate 99*b95f398eSXialin Liu 100*b95f398eSXialin LiuThe tests folder in the tool folder provides some bad-example of the 101*b95f398eSXialin LiuDT file, and the tool will print out "not a valid CoT DT file" on console. 102*b95f398eSXialin Liu 103*b95f398eSXialin LiuThe command will check the format of the CoT file 104*b95f398eSXialin Liu 105*b95f398eSXialin Liu#. The open bracket 106*b95f398eSXialin Liu#. The open ifdef macro 107*b95f398eSXialin Liu#. The missing mandatory attribute 108*b95f398eSXialin Liu#. Malformed DT file (cert missing parent, missing root certs. etc.) 109*b95f398eSXialin Liu 110*b95f398eSXialin LiuCurrently the validation is specifically for checking the CoT DT file 111*b95f398eSXialin Liu 112*b95f398eSXialin Liu.. code:: 113*b95f398eSXialin Liu 114*b95f398eSXialin Liu cot-dt2c validate-cot [INPUT DTB PATH] 115*b95f398eSXialin Liu cot-dt2c validate-cot fdts/tbbr_cot_descriptors.dtsi 116*b95f398eSXialin Liu 117*b95f398eSXialin Liu 118*b95f398eSXialin LiuVisualize CoT descriptors 119*b95f398eSXialin Liu~~~~~~~~~~~~~~~~~~~~~~~~~ 120*b95f398eSXialin Liu 121*b95f398eSXialin LiuThis command create a HTML to visualize the relationship between 122*b95f398eSXialin Liuthe certificates and the image of a CoT DT file. 123*b95f398eSXialin Liu 124*b95f398eSXialin Liu.. code:: 125*b95f398eSXialin Liu 126*b95f398eSXialin Liu cot-dt2c visualize-cot [INPUT DTB PATH] 127*b95f398eSXialin Liu cot-dt2c visualize-cot fdts/tbbr_cot_descriptors.dtsi 128*b95f398eSXialin Liu 129*b95f398eSXialin Liu 130*b95f398eSXialin LiuValidate Other DT files 131*b95f398eSXialin Liu~~~~~~~~~~~~~~~~~~~~~~~ 132*b95f398eSXialin Liu 133*b95f398eSXialin LiuThe command will transform the dtsi/dts file into a more standard 134*b95f398eSXialin Liudtsi/dts file inside /tmp folder that can be used as input to dt-schema 135*b95f398eSXialin Liufor further validation. Currently the tool will perform some basic validation 136*b95f398eSXialin Liufor the file (syntax) and dt-schema can be used for advance checks. dt-schema 137*b95f398eSXialin Liuis not installed along with the tool. 138*b95f398eSXialin Liu 139*b95f398eSXialin Liu.. code:: 140*b95f398eSXialin Liu 141*b95f398eSXialin Liu cot-dt2c validate-dt [INPUT DTS PATH or INPUT DTS folder] 142*b95f398eSXialin Liu cot-dt2c validate-dt fdts/ 143*b95f398eSXialin Liu cot-dt2c validate-dt fdts/fvp-bsae-gicv3.dtsi 144*b95f398eSXialin Liu 145*b95f398eSXialin Liu-------------- 146*b95f398eSXialin Liu 147*b95f398eSXialin Liu*Copyright (c) 2024, Arm Limited. All rights reserved.* 148*b95f398eSXialin Liu 149*b95f398eSXialin Liu.. _Poetry: https://python-poetry.org/docs/ 150