k3_fit_atf.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. if [ ! -z "$IS_HS" ]; then
  20. HS_APPEND=_HS
  21. fi
  22. cat << __HEADER_EOF
  23. /dts-v1/;
  24. / {
  25. description = "Configuration to load ATF and SPL";
  26. #address-cells = <1>;
  27. images {
  28. atf {
  29. description = "ARM Trusted Firmware";
  30. data = /incbin/("$ATF");
  31. type = "firmware";
  32. arch = "arm64";
  33. compression = "none";
  34. os = "arm-trusted-firmware";
  35. load = <0x70000000>;
  36. entry = <0x70000000>;
  37. };
  38. tee {
  39. description = "OPTEE";
  40. data = /incbin/("$TEE");
  41. type = "tee";
  42. arch = "arm64";
  43. compression = "none";
  44. os = "tee";
  45. load = <0x9e800000>;
  46. entry = <0x9e800000>;
  47. };
  48. spl {
  49. description = "SPL (64-bit)";
  50. data = /incbin/("spl/u-boot-spl-nodtb.bin$HS_APPEND");
  51. type = "standalone";
  52. os = "U-Boot";
  53. arch = "arm64";
  54. compression = "none";
  55. load = <0x80080000>;
  56. entry = <0x80080000>;
  57. };
  58. __HEADER_EOF
  59. for dtname in $*
  60. do
  61. cat << __FDT_IMAGE_EOF
  62. $(basename $dtname) {
  63. description = "$(basename $dtname .dtb)";
  64. data = /incbin/("$dtname$HS_APPEND");
  65. type = "flat_dt";
  66. arch = "arm";
  67. compression = "none";
  68. };
  69. __FDT_IMAGE_EOF
  70. done
  71. cat << __CONF_HEADER_EOF
  72. };
  73. configurations {
  74. default = "$(basename $1)";
  75. __CONF_HEADER_EOF
  76. for dtname in $*
  77. do
  78. cat << __CONF_SECTION_EOF
  79. $(basename $dtname) {
  80. description = "$(basename $dtname .dtb)";
  81. firmware = "atf";
  82. loadables = "tee", "spl";
  83. fdt = "$(basename $dtname)";
  84. };
  85. __CONF_SECTION_EOF
  86. done
  87. cat << __ITS_EOF
  88. };
  89. };
  90. __ITS_EOF