build_board.py 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. # @ build_board.py
  2. # Extensions for building SuperMicro using build_bios.py
  3. #
  4. # Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
  5. # SPDX-License-Identifier: BSD-2-Clause-Patent
  6. #
  7. """
  8. This module serves as a sample implementation of the build extension
  9. scripts
  10. """
  11. import os
  12. import sys
  13. def pre_build_ex(config, functions):
  14. """Additional Pre BIOS build function
  15. :param config: The environment variables to be used in the build process
  16. :type config: Dictionary
  17. :param functions: A dictionary of function pointers
  18. :type functions: Dictionary
  19. :returns: nothing
  20. """
  21. print("pre_build_ex")
  22. config["BUILD_DIR_PATH"] = os.path.join(config["WORKSPACE"],
  23. 'Build',
  24. config["PLATFORM_BOARD_PACKAGE"],
  25. "{}_{}".format(
  26. config["TARGET"],
  27. config["TOOL_CHAIN_TAG"]))
  28. # set BUILD_DIR path
  29. config["BUILD_DIR"] = os.path.join('Build',
  30. config["PLATFORM_BOARD_PACKAGE"],
  31. "{}_{}".format(
  32. config["TARGET"],
  33. config["TOOL_CHAIN_TAG"]))
  34. config["BUILD_X64"] = os.path.join(config["BUILD_DIR_PATH"], 'X64')
  35. config["BUILD_IA32"] = os.path.join(config["BUILD_DIR_PATH"], 'IA32')
  36. if not os.path.isdir(config["BUILD_DIR_PATH"]):
  37. try:
  38. os.makedirs(config["BUILD_DIR_PATH"])
  39. except OSError:
  40. print("Error while creating Build folder")
  41. sys.exit(1)
  42. #@todo: Replace this with PcdFspModeSelection
  43. if config.get("API_MODE_FSP_WRAPPER_BUILD", "FALSE") == "TRUE":
  44. config["EXT_BUILD_FLAGS"] += " -D FSP_MODE=0"
  45. else:
  46. config["EXT_BUILD_FLAGS"] += " -D FSP_MODE=1"
  47. if config.get("API_MODE_FSP_WRAPPER_BUILD", "FALSE") == "TRUE":
  48. raise ValueError("FSP API Mode is currently unsupported on Ice Lake Xeon Scalable")
  49. return None
  50. def _merge_files(files, ofile):
  51. with open(ofile, 'wb') as of:
  52. for x in files:
  53. if not os.path.exists(x):
  54. return
  55. with open(x, 'rb') as f:
  56. of.write(f.read())
  57. def build_ex(config, functions):
  58. """Additional BIOS build function
  59. :param config: The environment variables to be used in the build process
  60. :type config: Dictionary
  61. :param functions: A dictionary of function pointers
  62. :type functions: Dictionary
  63. :returns: config dictionary
  64. :rtype: Dictionary
  65. """
  66. print("build_ex")
  67. fv_path = os.path.join(config["BUILD_DIR_PATH"], "FV")
  68. binary_fd = os.path.join(fv_path, "BINARY.fd")
  69. main_fd = os.path.join(fv_path, "MAIN.fd")
  70. secpei_fd = os.path.join(fv_path, "SECPEI.fd")
  71. board_fd = config["BOARD"].upper()
  72. final_fd = os.path.join(fv_path, "{}.fd".format(board_fd))
  73. _merge_files((binary_fd, main_fd, secpei_fd), final_fd)
  74. return None
  75. def post_build_ex(config, functions):
  76. """Additional Post BIOS build function
  77. :param config: The environment variables to be used in the post
  78. build process
  79. :type config: Dictionary
  80. :param functions: A dictionary of function pointers
  81. :type functions: Dictionary
  82. :returns: config dictionary
  83. :rtype: Dictionary
  84. """
  85. print("post_build_ex")
  86. fv_path = os.path.join(config["BUILD_DIR_PATH"], "FV")
  87. board_fd = config["BOARD"].upper()
  88. final_fd = os.path.join(fv_path, "{}.fd".format(board_fd))
  89. final_ifwi = os.path.join(fv_path, "{}.bin".format(board_fd))
  90. ifwi_ingredients_path = os.path.join(config["WORKSPACE_PLATFORM_BIN"], "Ifwi", config["BOARD"])
  91. flash_descriptor = os.path.join(ifwi_ingredients_path, "FlashDescriptor.bin")
  92. intel_me = os.path.join(ifwi_ingredients_path, "Me.bin")
  93. _merge_files((flash_descriptor, intel_me, final_fd), final_ifwi)
  94. if os.path.isfile(final_fd):
  95. print("IFWI image can be found at {}".format(final_ifwi))
  96. return None
  97. def clean_ex(config, functions):
  98. """Additional clean function
  99. :param config: The environment variables to be used in the build process
  100. :type config: Dictionary
  101. :param functions: A dictionary of function pointers
  102. :type functions: Dictionary
  103. :returns: config dictionary
  104. :rtype: Dictionary
  105. """
  106. print("clean_ex")
  107. return None