helper 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #!/bin/bash
  2. # helper script: create ROM images for a given system, with GRUB
  3. #
  4. # Copyright (C) 2014, 2015 Francis Rowe <info@gluglug.org.uk>
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. # This script assumes that the working directory is the root
  20. # of libreboot_src or git
  21. [ "x${DEBUG+set}" = 'xset' ] && set -v
  22. set -u -e
  23. if (( $# != 1 )); then
  24. printf "Usage: ./buildrom-withgrub boardname\n"
  25. printf "Example: ./buildrom-withgrub x60\n"
  26. printf "You need to specify exactly 1 argument\n"
  27. exit 1
  28. fi
  29. printf "Helper script: build ROM images for '%s'\n" "${1}"
  30. cd "coreboot/"
  31. if [ -f "../version" ]; then
  32. # _src release archive is being used
  33. version="$(cat ../version)"
  34. else
  35. # git repo is being used
  36. version="$(git describe --tags HEAD)"
  37. fi
  38. printf '%s\n' "${version}" >"lbversion"
  39. # Build ROM images with text-mode and corebootfb modes.
  40. # ---------------------------------------------------------------------------------------------------------------
  41. if [ "${1}" = "qemu_i440fx_piix4" ] || [ "${1}" = "qemu_q35_ich9" ]
  42. then
  43. # assume that the default config enable framebuffer mode, duplicate and patch for text-mode
  44. # necessary, otherwise it will ask you to enter the Y/X resolution of the framebuffer at build time
  45. cp "../resources/libreboot/config/${1}/config" "config_vesafb"
  46. sed 's/CONFIG_FRAMEBUFFER_KEEP_VESA_MODE=y/# CONFIG_FRAMEBUFFER_KEEP_VESA_MODE is not set/' < "config_vesafb" > "config_txtmode"
  47. else
  48. # assume that the default config enables text-mode, duplicate and patch for framebuffer mode
  49. cp "../resources/libreboot/config/${1}/config" "config_txtmode"
  50. sed 's/# CONFIG_FRAMEBUFFER_KEEP_VESA_MODE is not set/CONFIG_FRAMEBUFFER_KEEP_VESA_MODE=y/' < "config_txtmode" > "config_vesafb"
  51. fi
  52. for romtype in txtmode vesafb
  53. do
  54. if [ "${1}" = "x200_8mb" ] || [ "${1}" = "x200_4mb" ] || [ "${1}" = "r400_8mb" ] || [ "${1}" = "r400_4mb" ] || [ "${1}" = "t400_8mb" ] || [ "${1}" = "t400_4mb" ] || [ "${1}" = "t500_8mb" ] || [ "${1}" = "t500_4mb" ]
  55. then
  56. if [ "${romtype}" = "txtmode" ]
  57. then
  58. printf "Text mode graphics is currently broken on X200, R400, T400 and T500. Only framebuffer mode works.\n"
  59. printf "TODO: offending coreboot commit found (see docs/release.html). Fix text-mode graphics initialization.\n"
  60. continue
  61. fi
  62. fi
  63. # Build coreboot ROM image
  64. make clean
  65. mv "config_${romtype}" ".config"
  66. mv "grub_${romtype}.elf" "grub.elf"
  67. make
  68. mv "grub.elf" "grub_${romtype}.elf"
  69. mv "build/coreboot.rom" "${1}_${romtype}.rom"
  70. # .config no longer needed
  71. rm -f ".config"
  72. # Add version information to this image
  73. ./util/cbfstool/cbfstool ${1}_${romtype}.rom add -f lbversion -n lbversion -t raw
  74. # Add the background image
  75. if [ "$romtype" = "vesafb" ]
  76. then
  77. if [ "$1" = "macbook21" ] || [ "$1" = "x200_4mb" ] || [ "$1" = "x200_8mb" ] || [ "$1" = "r400_4mb" ] || [ "$1" = "r400_8mb" ] || [ "$1" = "t400_4mb" ] || [ "$1" = "t400_8mb" ] || [ "$1" = "t500_4mb" ] || [ "$1" = "t500_8mb" ]
  78. then
  79. ./util/cbfstool/cbfstool ${1}_${romtype}.rom add -f ../resources/grub/background/background1280x800.png -n background.png -t raw
  80. else
  81. ./util/cbfstool/cbfstool ${1}_${romtype}.rom add -f ../resources/grub/background/background1024x768.png -n background.png -t raw
  82. fi
  83. fi
  84. # Add the correct GRUB configuration file for this image.
  85. for keymap in $(ls ../resources/utilities/grub-assemble/keymap/original)
  86. do
  87. # copy the images based on the keymap
  88. cp "${1}_${romtype}.rom" "${1}_${keymap}_${romtype}.rom"
  89. # Insert grub config into the image
  90. ./util/cbfstool/cbfstool ${1}_${keymap}_${romtype}.rom add -f grub_${keymap}_${romtype}.cfg -n grub.cfg -t raw
  91. # Insert grub test config into the image (for the user to test modifications to before modifying the main one)
  92. ./util/cbfstool/cbfstool ${1}_${keymap}_${romtype}.rom add -f grub_${keymap}_${romtype}_test.cfg -n grubtest.cfg -t raw
  93. done
  94. # This config-less ROM is no longer needed
  95. rm -f "${1}_${romtype}.rom"
  96. done
  97. # Now we clean up and prepare the bin directory containing all the images
  98. # ----------------------------------------------------------------------------------------------------------------------------
  99. # prepare directory for new ROM images
  100. rm -Rf "${1}/"
  101. mkdir "${1}/"
  102. # move the ROM's into the newly created directory
  103. mv "${1}"*.rom "${1}/"
  104. # delete the old ROM's from ../bin
  105. rm -Rf "../bin/${1}/"
  106. # now put the new ROM's in ./bin
  107. mv "${1}/" "../bin"
  108. # libreboot version file no longer needed
  109. rm -f "lbversion"
  110. # go back to main source directory
  111. cd "../"
  112. printf "\n\n"