roms 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. opts=""
  29. listboards() {
  30. for boarddir in resources/coreboot/*; do
  31. if [ ! -d "${boarddir}" ]; then continue; fi
  32. board="${boarddir##resources/coreboot/}"
  33. board="${board%/}"
  34. printf '%s\n' "${board##*/}"
  35. done
  36. }
  37. help() {
  38. cat <<- EOF
  39. USAGE: ./build boot roms boardname
  40. To build *all* boards, do this: ./build boot roms all
  41. To list *all* boards, do this: ./build boot roms list
  42. Optional Flags:
  43. -d: displaymode
  44. -p: payload
  45. -k: keyboard layout
  46. Example: ./build boot roms x60
  47. Example: ./build boot roms x200_8mb x60
  48. Example: ./build boot roms x230_12mb -p grub -d corebootfb -k usqwerty
  49. possible values for 'boardname':
  50. $(listboards)
  51. Refer to the ${projectname} documentation for more information.
  52. EOF
  53. }
  54. die() {
  55. printf 'Error: %s\n' "${@}" 1>&2
  56. exit 1
  57. }
  58. # Build ROM images for supported boards
  59. buildrom() {
  60. board="$1"
  61. # Start by building blobs and placing them in the coreboot tree only for boards that need them
  62. ./blobutil download ${board} || exit 1
  63. if [ -d "resources/coreboot/${board}/" ]; then
  64. ./build boot roms_helper "${board}${opts}"
  65. else
  66. die "\nbuild/roms: target not defined in the build system: %s\n" "${board}"
  67. fi
  68. }
  69. if [ $# -gt 0 ]; then
  70. boards=
  71. firstoption="${1}"
  72. if [ "${firstoption}" = "help" ]; then
  73. help
  74. exit 0
  75. fi
  76. if [ "${firstoption}" = "list" ]; then
  77. listboards
  78. exit 0
  79. fi
  80. while [ $# -gt 0 ]; do
  81. case ${1} in
  82. -d)
  83. opts="${opts} -d ${2}"
  84. shift ;;
  85. -p)
  86. opts="${opts} -p ${2}"
  87. shift ;;
  88. -k)
  89. opts="${opts} -k ${2}"
  90. shift ;;
  91. *)
  92. boards="${boards} ${1} " ;;
  93. esac
  94. shift
  95. done
  96. if [ -z ${opts+x} ]; then
  97. opts=""
  98. fi
  99. printf "Building %s ROM images\n" "${projectname}"
  100. if [ "${firstoption}" = "all" ]; then
  101. for boardname in $(listboards); do
  102. buildrom "${boardname}" || die "build/roms: something went wrong"
  103. done
  104. else
  105. for board in ${boards}; do
  106. buildrom "${board}" || die "build/roms: something went wrong"
  107. done
  108. fi
  109. else
  110. help
  111. exit 1
  112. fi
  113. printf "\n\nDone! Your ROMs are in bin/\n\n"