mkimage_fit_atf.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0+
  3. #
  4. # script to generate FIT image source for i.MX8MQ boards with
  5. # ARM Trusted Firmware and multiple device trees (given on the command line)
  6. #
  7. # usage: $0 <dt_name> [<dt_name> [<dt_name] ...]
  8. [ -z "$BL31" ] && BL31="bl31.bin"
  9. [ -z "$TEE_LOAD_ADDR" ] && TEE_LOAD_ADDR="0xfe000000"
  10. [ -z "$ATF_LOAD_ADDR" ] && ATF_LOAD_ADDR="0x00910000"
  11. [ -z "$BL33_LOAD_ADDR" ] && BL33_LOAD_ADDR="0x40200000"
  12. if [ ! -f $BL31 ]; then
  13. echo "ERROR: BL31 file $BL31 NOT found" >&2
  14. exit 0
  15. else
  16. echo "$BL31 size: " >&2
  17. ls -lct $BL31 | awk '{print $5}' >&2
  18. fi
  19. BL32="tee.bin"
  20. if [ ! -f $BL32 ]; then
  21. BL32=/dev/null
  22. else
  23. echo "Building with TEE support, make sure your $BL31 is compiled with spd. If you do not want tee, please delete $BL31" >&2
  24. echo "$BL32 size: " >&2
  25. ls -lct $BL32 | awk '{print $5}' >&2
  26. fi
  27. BL33="u-boot-nodtb.bin"
  28. if [ ! -f $BL33 ]; then
  29. echo "ERROR: $BL33 file NOT found" >&2
  30. exit 0
  31. else
  32. echo "u-boot-nodtb.bin size: " >&2
  33. ls -lct u-boot-nodtb.bin | awk '{print $5}' >&2
  34. fi
  35. for dtname in $*
  36. do
  37. echo "$dtname size: " >&2
  38. ls -lct $dtname | awk '{print $5}' >&2
  39. done
  40. cat << __HEADER_EOF
  41. /dts-v1/;
  42. / {
  43. description = "Configuration to load ATF before U-Boot";
  44. images {
  45. uboot@1 {
  46. description = "U-Boot (64-bit)";
  47. os = "u-boot";
  48. data = /incbin/("$BL33");
  49. type = "standalone";
  50. arch = "arm64";
  51. compression = "none";
  52. load = <$BL33_LOAD_ADDR>;
  53. };
  54. __HEADER_EOF
  55. cnt=1
  56. for dtname in $*
  57. do
  58. cat << __FDT_IMAGE_EOF
  59. fdt@$cnt {
  60. description = "$(basename $dtname .dtb)";
  61. data = /incbin/("$dtname");
  62. type = "flat_dt";
  63. compression = "none";
  64. };
  65. __FDT_IMAGE_EOF
  66. cnt=$((cnt+1))
  67. done
  68. cat << __HEADER_EOF
  69. atf@1 {
  70. description = "ARM Trusted Firmware";
  71. os = "arm-trusted-firmware";
  72. data = /incbin/("$BL31");
  73. type = "firmware";
  74. arch = "arm64";
  75. compression = "none";
  76. load = <$ATF_LOAD_ADDR>;
  77. entry = <$ATF_LOAD_ADDR>;
  78. };
  79. __HEADER_EOF
  80. if [ -f $BL32 ]; then
  81. cat << __HEADER_EOF
  82. tee@1 {
  83. description = "TEE firmware";
  84. data = /incbin/("$BL32");
  85. type = "firmware";
  86. arch = "arm64";
  87. compression = "none";
  88. load = <$TEE_LOAD_ADDR>;
  89. entry = <$TEE_LOAD_ADDR>;
  90. };
  91. __HEADER_EOF
  92. fi
  93. cat << __CONF_HEADER_EOF
  94. };
  95. configurations {
  96. default = "config@1";
  97. __CONF_HEADER_EOF
  98. cnt=1
  99. for dtname in $*
  100. do
  101. if [ -f $BL32 ]; then
  102. cat << __CONF_SECTION_EOF
  103. config@$cnt {
  104. description = "$(basename $dtname .dtb)";
  105. firmware = "uboot@1";
  106. loadables = "atf@1", "tee@1";
  107. fdt = "fdt@$cnt";
  108. };
  109. __CONF_SECTION_EOF
  110. else
  111. cat << __CONF_SECTION1_EOF
  112. config@$cnt {
  113. description = "$(basename $dtname .dtb)";
  114. firmware = "uboot@1";
  115. loadables = "atf@1";
  116. fdt = "fdt@$cnt";
  117. };
  118. __CONF_SECTION1_EOF
  119. fi
  120. cnt=$((cnt+1))
  121. done
  122. cat << __ITS_EOF
  123. };
  124. };
  125. __ITS_EOF