Xialin Liu | feee26f | 2024-07-29 17:10:16 -0500 | [diff] [blame] | 1 | TF-A CoT dt2c Tool |
| 2 | ================== |
| 3 | |
| 4 | This tool is used to automatically generate the corresponding c file for a |
| 5 | CoT DT file. Since currently TF-A support two type of CoT file: static c file |
| 6 | and CoT DT binding. This is error prone and hard to maintain, therefore this |
| 7 | tool can generate the c file for the platform that does not support CoT DT |
| 8 | binding, given the CoT DT file so the c file can be deprecated. |
| 9 | |
| 10 | Prerequisites |
| 11 | ~~~~~~~~~~~~~ |
| 12 | |
| 13 | #. Python (3.8 or later) |
| 14 | #. `Poetry`_ Python package manager |
| 15 | |
Xialin Liu | feee26f | 2024-07-29 17:10:16 -0500 | [diff] [blame] | 16 | Getting Started |
| 17 | ~~~~~~~~~~~~~~~ |
| 18 | |
Manish V Badarkhe | d544f05 | 2024-08-27 10:48:38 +0100 | [diff] [blame] | 19 | ``cot-dt2c`` is installed by default with TF-A's poetry environment. All of it's |
| 20 | dependencies are listed in `tools/cot_dt2c/pyproject.toml`_. |
Xialin Liu | feee26f | 2024-07-29 17:10:16 -0500 | [diff] [blame] | 21 | |
Manish V Badarkhe | d544f05 | 2024-08-27 10:48:38 +0100 | [diff] [blame] | 22 | ``cot-dt2c`` requires a standard DTS file without #ifdef, macros, or other |
| 23 | preprocessor directives. Therefore, you need to provide a preprocessed device |
| 24 | tree source(DTS) as input to the tool. |
Xialin Liu | feee26f | 2024-07-29 17:10:16 -0500 | [diff] [blame] | 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 | |
Xialin Liu | feee26f | 2024-07-29 17:10:16 -0500 | [diff] [blame] | 48 | Convert CoT descriptors to C file |
| 49 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 50 | |
| 51 | To convert the CoT descriptors |
| 52 | |
| 53 | This command is for the platform that does not use CoT DT parser, |
| 54 | which can generate the C file given the CoT descriptors. Before |
| 55 | the conversion to C file, the tool will do an implicit checks on |
| 56 | the validity of the CoT DT file. |
| 57 | |
| 58 | .. code:: |
| 59 | |
Manish V Badarkhe | d544f05 | 2024-08-27 10:48:38 +0100 | [diff] [blame] | 60 | cot-dt2c convert-to-c [INPUT DTS PATH] [OUTPUT C PATH] |
Xialin Liu | feee26f | 2024-07-29 17:10:16 -0500 | [diff] [blame] | 61 | cot-dt2c convert-to-c fdts/tbbr_cot_descriptors.dtsi test.c |
| 62 | |
| 63 | |
| 64 | Validate CoT descriptors |
| 65 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 66 | |
| 67 | To validate the certificate |
| 68 | |
| 69 | The tests folder in the tool folder provides some bad-example of the |
| 70 | DT file, and the tool will print out "not a valid CoT DT file" on console. |
| 71 | |
| 72 | The 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 | |
| 79 | Currently the validation is specifically for checking the CoT DT file |
| 80 | |
| 81 | .. code:: |
| 82 | |
Manish V Badarkhe | d544f05 | 2024-08-27 10:48:38 +0100 | [diff] [blame] | 83 | cot-dt2c validate-cot [INPUT DTS PATH] |
Xialin Liu | feee26f | 2024-07-29 17:10:16 -0500 | [diff] [blame] | 84 | cot-dt2c validate-cot fdts/tbbr_cot_descriptors.dtsi |
| 85 | |
| 86 | |
| 87 | Visualize CoT descriptors |
| 88 | ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 89 | |
| 90 | This command create a HTML to visualize the relationship between |
| 91 | the certificates and the image of a CoT DT file. |
| 92 | |
| 93 | .. code:: |
| 94 | |
Manish V Badarkhe | d544f05 | 2024-08-27 10:48:38 +0100 | [diff] [blame] | 95 | cot-dt2c visualize-cot [INPUT DTS PATH] |
Xialin Liu | feee26f | 2024-07-29 17:10:16 -0500 | [diff] [blame] | 96 | cot-dt2c visualize-cot fdts/tbbr_cot_descriptors.dtsi |
| 97 | |
| 98 | |
| 99 | Validate Other DT files |
| 100 | ~~~~~~~~~~~~~~~~~~~~~~~ |
| 101 | |
| 102 | The command will transform the dtsi/dts file into a more standard |
| 103 | dtsi/dts file inside /tmp folder that can be used as input to dt-schema |
| 104 | for further validation. Currently the tool will perform some basic validation |
| 105 | for the file (syntax) and dt-schema can be used for advance checks. dt-schema |
| 106 | is 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 Badarkhe | d544f05 | 2024-08-27 10:48:38 +0100 | [diff] [blame] | 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 |
Xialin Liu | feee26f | 2024-07-29 17:10:16 -0500 | [diff] [blame] | 119 | .. _Poetry: https://python-poetry.org/docs/ |