k3_fit_atf.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 <atf_load_addr> <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. [ -z "$DM" ] && DM="dm.bin"
  20. if [ ! -e $DM ]; then
  21. echo "WARNING DM file $DM NOT found, resulting might be non-functional" >&2
  22. DM=/dev/null
  23. fi
  24. if [ ! -z "$IS_HS" ]; then
  25. HS_APPEND=_HS
  26. fi
  27. cat << __HEADER_EOF
  28. /dts-v1/;
  29. / {
  30. description = "Configuration to load ATF and SPL";
  31. #address-cells = <1>;
  32. images {
  33. atf {
  34. description = "ARM Trusted Firmware";
  35. data = /incbin/("$ATF");
  36. type = "firmware";
  37. arch = "arm64";
  38. compression = "none";
  39. os = "arm-trusted-firmware";
  40. load = <$1>;
  41. entry = <$1>;
  42. };
  43. tee {
  44. description = "OPTEE";
  45. data = /incbin/("$TEE");
  46. type = "tee";
  47. arch = "arm64";
  48. compression = "none";
  49. os = "tee";
  50. load = <0x9e800000>;
  51. entry = <0x9e800000>;
  52. };
  53. dm {
  54. description = "DM binary";
  55. data = /incbin/("$DM");
  56. type = "firmware";
  57. arch = "arm32";
  58. compression = "none";
  59. os = "DM";
  60. load = <0x89000000>;
  61. entry = <0x89000000>;
  62. };
  63. spl {
  64. description = "SPL (64-bit)";
  65. data = /incbin/("spl/u-boot-spl-nodtb.bin$HS_APPEND");
  66. type = "standalone";
  67. os = "U-Boot";
  68. arch = "arm64";
  69. compression = "none";
  70. load = <0x80080000>;
  71. entry = <0x80080000>;
  72. };
  73. __HEADER_EOF
  74. # shift through ATF load address in the command line arguments
  75. shift
  76. for dtname in $*
  77. do
  78. cat << __FDT_IMAGE_EOF
  79. $(basename $dtname) {
  80. description = "$(basename $dtname .dtb)";
  81. data = /incbin/("$dtname$HS_APPEND");
  82. type = "flat_dt";
  83. arch = "arm";
  84. compression = "none";
  85. };
  86. __FDT_IMAGE_EOF
  87. done
  88. cat << __CONF_HEADER_EOF
  89. };
  90. configurations {
  91. default = "$(basename $1)";
  92. __CONF_HEADER_EOF
  93. for dtname in $*
  94. do
  95. cat << __CONF_SECTION_EOF
  96. $(basename $dtname) {
  97. description = "$(basename $dtname .dtb)";
  98. firmware = "atf";
  99. loadables = "tee", "dm", "spl";
  100. fdt = "$(basename $dtname)";
  101. };
  102. __CONF_SECTION_EOF
  103. done
  104. cat << __ITS_EOF
  105. };
  106. };
  107. __ITS_EOF