roms 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #!/usr/bin/env sh
  2. #
  3. # helper script: build coreboot images with various payloads
  4. #
  5. # Copyright (C) 2014, 2015, 2016, 2020, 2021 Leah Rowe <info@minifree.org>
  6. # Copyright (C) 2015 Klemens Nanni <contact@autoboot.org>
  7. # Copyright (C) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
  8. # Copyright (C) 2022 Ferass El Hafidi <vitali64pmemail@protonmail.com>
  9. #
  10. # This program is free software: you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation, either version 3 of the License, or
  13. # (at your option) any later version.
  14. #
  15. # This program is distributed in the hope that it will be useful,
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. # GNU General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU General Public License
  21. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. #
  23. # This script assumes that the working directory is the root
  24. # of git or release archive
  25. [ "x${DEBUG+set}" = 'xset' ] && set -v
  26. set -u -e
  27. projectname="$(cat projectname)"
  28. listboards() {
  29. for boarddir in resources/coreboot/*; do
  30. if [ ! -d "${boarddir}" ]; then continue; fi
  31. board="${boarddir##resources/coreboot/}"
  32. board="${board%/}"
  33. printf '%s\n' "${board##*/}"
  34. done
  35. }
  36. help() {
  37. cat <<- EOF
  38. USAGE: ./build boot roms boardname
  39. To build *all* boards, do this: ./build boot roms all
  40. To list *all* boards, do this: ./build boot roms list
  41. Optional Flags:
  42. -d: displaymode
  43. -p: payload
  44. -k: keyboard layout
  45. Example: ./build boot roms x60
  46. Example: ./build boot roms x200_8mb x60
  47. Example: ./build boot roms x230_12mb -p grub -d corebootfb -k usqwerty
  48. possible values for 'boardname':
  49. $(listboards)
  50. Refer to the ${projectname} documentation for more information.
  51. EOF
  52. }
  53. die() {
  54. printf 'Error: %s\n' "${@}" 1>&2
  55. exit 1
  56. }
  57. # Build ROM images for supported boards
  58. buildrom() {
  59. board="$1"
  60. # Start by building blobs and placing them in the coreboot tree only for boards that need them
  61. ./blobutil download ${board} || exit 1
  62. if [ -d "resources/coreboot/${board}/" ]; then
  63. ./build boot roms_helper "${board}${opts}"
  64. else
  65. die "\nbuild/roms: target not defined in the build system: %s\n" "${board}"
  66. fi
  67. }
  68. if [ $# -gt 0 ]; then
  69. boards=
  70. firstoption="${1}"
  71. if [ "${firstoption}" = "help" ]; then
  72. help
  73. exit 0
  74. fi
  75. if [ "${firstoption}" = "list" ]; then
  76. listboards
  77. exit 0
  78. fi
  79. while [ $# -gt 0 ]; do
  80. case ${1} in
  81. -d)
  82. opts="${opts} -d ${2}"
  83. shift ;;
  84. -p)
  85. opts="${opts} -p ${2}"
  86. shift ;;
  87. -k)
  88. opts="${opts} -k ${2}"
  89. shift ;;
  90. *)
  91. boards="${boards} ${1} " ;;
  92. esac
  93. shift
  94. done
  95. if [ -z ${opts+x} ]; then
  96. opts=""
  97. fi
  98. printf "Building %s ROM images\n" "${projectname}"
  99. if [ "${firstoption}" = "all" ]; then
  100. for boardname in $(listboards); do
  101. buildrom "${boardname}" || die "build/roms: something went wrong"
  102. done
  103. else
  104. for board in ${boards}; do
  105. buildrom "${board}" || die "build/roms: something went wrong"
  106. done
  107. fi
  108. else
  109. help
  110. exit 1
  111. fi
  112. printf "\n\nDone! Your ROMs are in bin/\n\n"