cot-dt2c.rst 3.4 KB

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