mksunxi_fit_atf.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/bin/sh
  2. #
  3. # script to generate FIT image source for 64-bit sunxi boards with
  4. # ARM Trusted Firmware and multiple device trees (given on the command line)
  5. #
  6. # usage: $0 <dt_name> [<dt_name> [<dt_name] ...]
  7. [ -z "$BL31" ] && BL31="bl31.bin"
  8. if [ ! -f $BL31 ]; then
  9. echo "WARNING: BL31 file $BL31 NOT found, resulting binary is non-functional" >&2
  10. echo "Please read the section on ARM Trusted Firmware (ATF) in board/sunxi/README.sunxi64" >&2
  11. BL31=/dev/null
  12. fi
  13. if grep -q "^CONFIG_MACH_SUN50I_H6=y" .config; then
  14. BL31_ADDR=0x104000
  15. else
  16. BL31_ADDR=0x44000
  17. fi
  18. cat << __HEADER_EOF
  19. /dts-v1/;
  20. / {
  21. description = "Configuration to load ATF before U-Boot";
  22. #address-cells = <1>;
  23. images {
  24. uboot {
  25. description = "U-Boot (64-bit)";
  26. data = /incbin/("u-boot-nodtb.bin");
  27. type = "standalone";
  28. arch = "arm64";
  29. compression = "none";
  30. load = <0x4a000000>;
  31. };
  32. atf {
  33. description = "ARM Trusted Firmware";
  34. data = /incbin/("$BL31");
  35. type = "firmware";
  36. arch = "arm64";
  37. compression = "none";
  38. load = <$BL31_ADDR>;
  39. entry = <$BL31_ADDR>;
  40. };
  41. __HEADER_EOF
  42. cnt=1
  43. for dtname in $*
  44. do
  45. cat << __FDT_IMAGE_EOF
  46. fdt_$cnt {
  47. description = "$(basename $dtname .dtb)";
  48. data = /incbin/("$dtname");
  49. type = "flat_dt";
  50. compression = "none";
  51. };
  52. __FDT_IMAGE_EOF
  53. cnt=$((cnt+1))
  54. done
  55. cat << __CONF_HEADER_EOF
  56. };
  57. configurations {
  58. default = "config_1";
  59. __CONF_HEADER_EOF
  60. cnt=1
  61. for dtname in $*
  62. do
  63. cat << __CONF_SECTION_EOF
  64. config_$cnt {
  65. description = "$(basename $dtname .dtb)";
  66. firmware = "uboot";
  67. loadables = "atf";
  68. fdt = "fdt_$cnt";
  69. };
  70. __CONF_SECTION_EOF
  71. cnt=$((cnt+1))
  72. done
  73. cat << __ITS_EOF
  74. };
  75. };
  76. __ITS_EOF