k3_fit_atf.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0+
  3. #
  4. # script to generate FIT image source for K3 Family boards with
  5. # ATF, OPTEE, SPL and multiple device trees (given on the command line).
  6. # Inspired from board/sunxi/mksunxi_fit_atf.sh
  7. #
  8. # usage: $0 <dt_name> [<dt_name> [<dt_name] ...]
  9. [ -z "$ATF" ] && ATF="bl31.bin"
  10. if [ ! -f $ATF ]; then
  11. echo "WARNING ATF file $ATF NOT found, resulting binary is non-functional" >&2
  12. ATF=/dev/null
  13. fi
  14. [ -z "$TEE" ] && TEE="bl32.bin"
  15. if [ ! -f $TEE ]; then
  16. echo "WARNING OPTEE file $TEE NOT found, resulting might be non-functional" >&2
  17. TEE=/dev/null
  18. fi
  19. cat << __HEADER_EOF
  20. /dts-v1/;
  21. / {
  22. description = "Configuration to load ATF and SPL";
  23. #address-cells = <1>;
  24. images {
  25. atf {
  26. description = "ARM Trusted Firmware";
  27. data = /incbin/("$ATF");
  28. type = "firmware";
  29. arch = "arm64";
  30. compression = "none";
  31. os = "arm-trusted-firmware";
  32. load = <0x70000000>;
  33. entry = <0x70000000>;
  34. };
  35. tee {
  36. description = "OPTEE";
  37. data = /incbin/("$TEE");
  38. type = "tee";
  39. arch = "arm64";
  40. compression = "none";
  41. os = "tee";
  42. load = <0x9e800000>;
  43. entry = <0x9e800000>;
  44. };
  45. spl {
  46. description = "SPL (64-bit)";
  47. data = /incbin/("spl/u-boot-spl-nodtb.bin");
  48. type = "standalone";
  49. os = "U-Boot";
  50. arch = "arm64";
  51. compression = "none";
  52. load = <0x80080000>;
  53. entry = <0x80080000>;
  54. };
  55. __HEADER_EOF
  56. for dtname in $*
  57. do
  58. cat << __FDT_IMAGE_EOF
  59. $(basename $dtname) {
  60. description = "$(basename $dtname .dtb)";
  61. data = /incbin/("$dtname");
  62. type = "flat_dt";
  63. arch = "arm";
  64. compression = "none";
  65. };
  66. __FDT_IMAGE_EOF
  67. done
  68. cat << __CONF_HEADER_EOF
  69. };
  70. configurations {
  71. default = "$(basename $1)";
  72. __CONF_HEADER_EOF
  73. for dtname in $*
  74. do
  75. cat << __CONF_SECTION_EOF
  76. $(basename $dtname) {
  77. description = "$(basename $dtname .dtb)";
  78. firmware = "atf";
  79. loadables = "tee", "spl";
  80. fdt = "$(basename $dtname)";
  81. };
  82. __CONF_SECTION_EOF
  83. done
  84. cat << __ITS_EOF
  85. };
  86. };
  87. __ITS_EOF