withseabios_helper 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #!/bin/bash
  2. # helper script: create ROM images for a given system, with SeaBIOS
  3. #
  4. # Copyright (C) 2014, 2015, 2016 Leah Rowe <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: ./oldbuild rom withseabios boardname\n"
  37. printf "Example: ./oldbuild rom 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 *{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" ] || [ "${boardtarget}" = "d945gclf" ]; then
  67. if [ "${romtype}" = "vesafb" ]; then
  68. printf "Only text-mode is reported to work on KGPE-D16, KCMA-D8, d945gclf\n"
  69. continue
  70. fi
  71. fi
  72. if [ "${boardtarget}" = "qemu_i440fx_piix4" ] || [ "${boardtarget}" = "qemu_q35_ich9" ]
  73. then
  74. # assume that the default config enable framebuffer mode, duplicate and patch for text-mode
  75. # necessary, otherwise it will ask you to enter the Y/X resolution of the framebuffer at build time
  76. cp "../../../resources/libreboot/config/seabios/${boardtarget}/config" "config_vesafb"
  77. sed 's/CONFIG_FRAMEBUFFER_KEEP_VESA_MODE=y/# CONFIG_FRAMEBUFFER_KEEP_VESA_MODE is not set/' < "config_vesafb" > "config_txtmode"
  78. else
  79. # assume that the default config enables text-mode, duplicate and patch for framebuffer mode
  80. cp "../../../resources/libreboot/config/seabios/${boardtarget}/config" "config_txtmode"
  81. sed 's/# CONFIG_FRAMEBUFFER_KEEP_VESA_MODE is not set/CONFIG_FRAMEBUFFER_KEEP_VESA_MODE=y/' < "config_txtmode" > "config_vesafb"
  82. fi
  83. # Build coreboot ROM image
  84. make clean
  85. cp "../../../seabios/out/bios.bin.vga.elf" "payload.elf"
  86. mv "config_${romtype}" .config
  87. make -j${cores}
  88. rm -f "payload.elf"
  89. mv "build/coreboot.rom" "${boardtarget}_${romtype}.rom"
  90. # Now add SeaVGABIOS (SeaBIOS wrapper for coreboot native video init)
  91. ./util/cbfstool/cbfstool "${boardtarget}_${romtype}.rom" add -f ../../../seabios/out/vgabios.bin -n vgaroms/vgabios.bin -t raw
  92. # Add a file to CBFS that tells SeaBIOS not to load option ROMs
  93. ./util/cbfstool/cbfstool "${boardtarget}_${romtype}.rom" add-int -i 0 -n etc/pci-optionrom-exec || "already exists"
  94. # .config no longer needed
  95. rm -f ".config"
  96. done
  97. # Clean up and prepare bin/ containing all ROM images
  98. # move ROM images into the newly created directory
  99. rm -Rf "${boardtarget:?}/"
  100. mkdir "${boardtarget}/"
  101. mv "${boardtarget}"*.rom "${boardtarget}/"
  102. # delete old ROM images
  103. rm -Rf "../../../bin/seabios/${boardtarget}/"
  104. # put new ROM images in ../bin/grub/
  105. [ -d "../../../bin/seabios/" ] || mkdir -p "../../../bin/seabios/"
  106. mv "${boardtarget}/" "../../../bin/seabios/"
  107. # version info file no longer needed
  108. rm -f ".coreboot-version"
  109. git checkout master
  110. (
  111. cd "3rdparty/vboot/"
  112. git checkout master
  113. )
  114. )
  115. printf "\n\n"