withseabios_helper 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #!/bin/bash
  2. # helper script: create ROM images for a given system, with SeaBIOS
  3. #
  4. # Copyright (C) 2014, 2015, 2016 Leah Woods <info@minifree.org>
  5. # Copyright (C) 2015 Klemens Nanni <contact@autoboot.org>
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. # This script assumes that the working directory is the root
  21. # of git or release archive
  22. [ "x${DEBUG+set}" = 'xset' ] && set -v
  23. set -u -e
  24. if [ -z ${NPROC+x} ]; then
  25. cores="$(nproc)"
  26. else
  27. case ${NPROC} in
  28. ''|*[!0-9]*)
  29. printf "value '%s' for NPROC is invalid. non-numeric. Exiting.\n" "${NPROC}"
  30. exit 1
  31. ;;
  32. esac
  33. cores="${NPROC}"
  34. fi
  35. if (( $# != 1 )); then
  36. printf "Usage: ./buildrom-withseabios boardname\n"
  37. printf "Example: ./buildrom-withseabios x60\n"
  38. printf "You need to specify exactly 1 argument\n"
  39. exit 1
  40. fi
  41. boardtarget="${1}"
  42. if [ -f "version" ]; then
  43. # release archive is being used
  44. version="$(cat version)"
  45. else
  46. # git repo is being used
  47. version="$(git describe --tags HEAD)"
  48. fi
  49. printf "SeaBIOS Helper script: build ROM images for '%s'\n" "${boardtarget}"
  50. (
  51. cbrevision="$(cat resources/libreboot/config/seabios/${boardtarget}/cbrevision)"
  52. vbootrevision="$(cat resources/libreboot/config/seabios/${boardtarget}/vbootrevision)"
  53. branchname="seabios_${boardtarget}"
  54. cd "coreboot/${cbrevision}/${cbrevision}/"
  55. git checkout ${branchname}
  56. (
  57. cd "3rdparty/vboot/"
  58. git checkout ${branchname}
  59. )
  60. # Make sure to remove these first
  61. rm -f "seabios."*{elf,cfg}
  62. printf 'libreboot-%s\n' "${version}" > ".coreboot-version" # needed for reproducible builds in coreboot
  63. # Build ROM images with text-mode and corebootfb modes.
  64. for romtype in txtmode vesafb
  65. do
  66. if [ "${boardtarget}" = "kgpe-d16" ] || [ "${boardtarget}" = "kcma-d8" ]; then
  67. if [ "${romtype}" = "vesafb" ]; then
  68. printf "Only text-mode is reported to work on KGPE-D16, KCMA-D8\n"
  69. printf "TODO: get tpearson to fix it\n"
  70. continue
  71. fi
  72. fi
  73. if [ "${boardtarget}" = "qemu_i440fx_piix4" ] || [ "${boardtarget}" = "qemu_q35_ich9" ]
  74. then
  75. # assume that the default config enable framebuffer mode, duplicate and patch for text-mode
  76. # necessary, otherwise it will ask you to enter the Y/X resolution of the framebuffer at build time
  77. cp "../../../resources/libreboot/config/seabios/${boardtarget}/config" "config_vesafb"
  78. sed 's/CONFIG_FRAMEBUFFER_KEEP_VESA_MODE=y/# CONFIG_FRAMEBUFFER_KEEP_VESA_MODE is not set/' < "config_vesafb" > "config_txtmode"
  79. else
  80. # assume that the default config enables text-mode, duplicate and patch for framebuffer mode
  81. cp "../../../resources/libreboot/config/seabios/${boardtarget}/config" "config_txtmode"
  82. sed 's/# CONFIG_FRAMEBUFFER_KEEP_VESA_MODE is not set/CONFIG_FRAMEBUFFER_KEEP_VESA_MODE=y/' < "config_txtmode" > "config_vesafb"
  83. fi
  84. # Build coreboot ROM image
  85. make clean
  86. cp "../../../seabios/out/bios.bin.elf" "seabios.elf"
  87. mv "config_${romtype}" .config
  88. make -j${cores}
  89. rm -f "seabios.elf"
  90. mv "build/coreboot.rom" "${boardtarget}_${romtype}.rom"
  91. # Now add SeaVGABIOS (SeaBIOS wrapper for coreboot native video init)
  92. ./util/cbfstool/cbfstool "${boardtarget}_${romtype}.rom" add -f ../../../seabios/out/vgabios.bin -n vgaroms/vgabios.bin -t raw
  93. # .config no longer needed
  94. rm -f ".config"
  95. done
  96. # Clean up and prepare bin/ containing all ROM images
  97. # move ROM images into the newly created directory
  98. rm -Rf "${boardtarget:?}/"
  99. mkdir "${boardtarget}/"
  100. mv "${boardtarget}"*.rom "${boardtarget}/"
  101. # delete old ROM images
  102. rm -Rf "../../../bin/seabios/${boardtarget}/"
  103. # put new ROM images in ../bin/grub/
  104. [ -d "../../../bin/seabios/" ] || mkdir -p "../../../bin/seabios/"
  105. mv "${boardtarget}/" "../../../bin/seabios/"
  106. # version info file no longer needed
  107. rm -f ".coreboot-version"
  108. git checkout master
  109. (
  110. cd "3rdparty/vboot/"
  111. git checkout master
  112. )
  113. )
  114. printf "\n\n"