withgrub 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #!/bin/bash
  2. #
  3. # helper script: build ROM images with GRUB and put them in ./bin/
  4. #
  5. # Copyright (C) 2014, 2015 Francis Rowe <info@gluglug.org.uk>
  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 libreboot_src or git
  22. [ "x${DEBUG+set}" = 'xset' ] && set -v
  23. set -u -e
  24. printf "Building ROM images with the GRUB payload\n"
  25. if [ ! -d "bin/" ]
  26. then
  27. mkdir "bin/"
  28. fi
  29. boards="unknown"
  30. if [ $# -gt 0 ]; then
  31. # build only the ROM images that were requested
  32. boards="$@"
  33. else
  34. # build all ROM images
  35. boards="$(ls resources/libreboot/config/)"
  36. fi
  37. # Put GRUB payloads and config files
  38. # in the coreboot directory, ready for next step
  39. cd "coreboot/"
  40. for romtype in txtmode vesafb
  41. do
  42. cd "../resources/utilities/grub-assemble"
  43. ./gen.sh ${romtype}
  44. rm -f "../../../coreboot/grub_${romtype}.elf"
  45. mv "grub_${romtype}.elf" "../../../coreboot/"
  46. cd "../../../coreboot"
  47. # GRUB configuration files
  48. for keymap in $(ls "../resources/utilities/grub-assemble/keymap/original/")
  49. do
  50. cat "../resources/grub/config/extra/common.cfg" > "grub_${keymap}_${romtype}.cfg"
  51. cat "../resources/grub/config/extra/${romtype}.cfg" >> "grub_${keymap}_${romtype}.cfg"
  52. printf "keymap %s\n" "${keymap}" >> "grub_${keymap}_${romtype}.cfg"
  53. cat "../resources/grub/config/menuentries/common.cfg" >> "grub_${keymap}_${romtype}.cfg"
  54. cat "../resources/grub/config/menuentries/${romtype}.cfg" >> "grub_${keymap}_${romtype}.cfg"
  55. # grubtest.cfg should be able to switch back to grub.cfg
  56. sed 's/grubtest.cfg/grub.cfg/' < "grub_${keymap}_${romtype}.cfg" > "grub_${keymap}_${romtype}_test.cfg"
  57. done
  58. done
  59. cd ../
  60. # Build ROM images for supported boards
  61. for board in ${boards}
  62. do
  63. if [ -f "resources/libreboot/config/${board}/config" ]; then
  64. ./build roms helper ${board}
  65. fi
  66. done
  67. # Needed on i945 systems for the bucts/dd trick (documented)
  68. # This enables the ROM to be flashed over the lenovo bios firmware
  69. for i945board in "x60" "t60"
  70. do
  71. if [ -d "bin/${i945board}/" ]; then
  72. cd "bin/${i945board}/"
  73. for i945rom in $(ls)
  74. do
  75. dd if="${i945rom}" of=top64k.bin bs=1 skip=$[$(stat -c %s "${i945rom}") - 0x10000] count=64k
  76. dd if=top64k.bin of="${i945rom}" bs=1 seek=$[$(stat -c %s "${i945rom}") - 0x20000] count=64k conv=notrunc
  77. rm -f top64k.bin
  78. done
  79. cd "../../"
  80. fi
  81. done
  82. # Build the deblobbed descriptor+gbe regions for GM45/ICH9M targets.
  83. # Then put them in the ROM images.
  84. if [ -d "bin/" ]; then
  85. cd "bin/"
  86. for board in "x200" "r400" "t400" "t500"
  87. do
  88. for romsize in "4m" "8m"
  89. do
  90. if [ -d "${board}_${romsize}b/" ]; then
  91. cd "${board}_${romsize}b/"
  92. ../../resources/utilities/ich9deblob/ich9gen
  93. for rom in $(ls)
  94. do
  95. dd if="ich9fdgbe_${romsize}.bin" of="${rom}" bs=1 count=12k conv=notrunc
  96. done
  97. rm -f "ich9fdgbe_4m.bin"
  98. rm -f "ich9fdgbe_8m.bin"
  99. cd "../"
  100. fi
  101. done
  102. done
  103. cd ../
  104. fi
  105. # The GRUB payloads are no longer needed
  106. rm -f "coreboot/grub_vesafb.elf"
  107. rm -f "coreboot/grub_txtmode.elf"
  108. # The GRUB configs are no longer needed
  109. rm -f coreboot/grub*cfg
  110. printf "\n\n"
  111. # ------------------- DONE ----------------------