roms_helper 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. #!/usr/bin/env bash
  2. # helper script: create ROM images for a given mainboard
  3. #
  4. # Copyright (C) 2020,2021 Leah Rowe <info@minifree.org>
  5. # Copyright (C) 2021 Vitali64 <vitali64pmemail@protonmail.com>
  6. # Copyright (C) 2022 Alper Nebi Yasak <alpernebiyasak@gmail.com>
  7. #
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. #
  21. # This script assumes that the working directory is the root
  22. # of git or release archive
  23. [ "x${DEBUG+set}" = 'xset' ] && set -v
  24. set -u -e
  25. projectname="$(cat projectname)"
  26. if (( $# != 1 )); then
  27. printf "Usage: ./build boot roms boardname\n"
  28. printf "Example: ./build boot roms x60\n"
  29. printf "Example: ./build boot roms x60 x200_8mb\n"
  30. printf "Example: ./build boot roms all\n"
  31. printf "You need to specify exactly 1 argument\n"
  32. exit 1
  33. fi
  34. board="${1}"
  35. if [ ! -d "resources/coreboot/${board}" ]; then
  36. printf "build/roms: Target %s does not exist in the %s build system. Skipping build.\n" "${projectname}" "${board}"
  37. exit 1
  38. fi
  39. if [ ! -f "resources/coreboot/${board}/board.cfg" ]; then
  40. printf "build/roms: Target %s does not have a board.cfg. Skipping build.\n" "${board}"
  41. exit 1
  42. fi
  43. # Workaround to grub's slow boot
  44. grub_scan_disk="undefined" # both: scan ata and ahci (slow), there is ata and ahci too
  45. # as an option
  46. cbtree="undefined"
  47. romtype="normal" # optional parameter in board.cfg. "normal" is default
  48. arch="undefined"
  49. # Disable all payloads by default.
  50. # board.cfg files have to specifically enable [a] payload(s)
  51. payload_grub="n"
  52. payload_grub_withseabios="n" # seabios chainloaded from grub
  53. payload_seabios="n"
  54. payload_seabios_withgrub="n" # i386-coreboot grub accessible from SeaBIOS boot menu
  55. seabios_opromloadonly="0"
  56. payload_memtest="n"
  57. payload_uboot="n"
  58. uboot_config="undefined"
  59. # Override the above defaults using board.cfg
  60. source "resources/coreboot/${board}/board.cfg"
  61. if [ "${grub_scan_disk}" = "undefined" ]; then
  62. printf "build/roms: Target %s does not define grub_scan_disk. Defaulting to 'both'.\n" "${board}"
  63. grub_scan_disk="both"
  64. fi
  65. if [ "${grub_scan_disk}" != "both" ] && \
  66. [ "${grub_scan_disk}" != "ata" ] && \
  67. [ "${grub_scan_disk}" != "ahci" ]; then
  68. printf "build/roms: Target %s defines an invalid grub_scan_disk setting. Defaulting to 'both'.\n" "${board}"
  69. grub_scan_disk="both"
  70. # erroring out would be silly. just use the default
  71. fi
  72. if [ "${cbtree}" = "undefined" ]; then
  73. printf "build/roms: Target %s does not define a coreboot tree. Skipping build.\n" "${board}"
  74. exit 1
  75. fi
  76. if [ "${arch}" = "undefined" ]; then
  77. printf "build/roms: Target %s does not define a CPU type. Skipping build.\n" "${board}"
  78. exit 1
  79. fi
  80. if [ "${seabios_opromloadonly}" != "0" ] && \
  81. [ "${seabios_opromloadonly}" != "1" ]; then
  82. seabios_opromloadonly="0"
  83. fi
  84. if [ "${payload_memtest}" != "n" ] && \
  85. [ "${payload_memtest}" != "y" ]; then
  86. payload_memtest="n"
  87. fi
  88. if [ "${payload_grub_withseabios}" = "y" ]; then
  89. payload_grub="y"
  90. fi
  91. if [ "${payload_grub_withseabios}" = "y" ]; then
  92. payload_seabios="y"
  93. payload_seabios_withgrub="y" # if grub-first works, then seabios-with-grub will also work
  94. fi
  95. if [ "${payload_seabios_withgrub}" = "y" ]; then
  96. payload_seabios="y" # if seabios-with-grub works, then SeaBIOS-alone should also work
  97. fi
  98. # NOTE: reverse logic must not be applied. If SeaBIOS-with-GRUB works, that doesn't
  99. # necessarily mean GRUB-with-SeaBIOS will work nicely. for example, the board might
  100. # only have an add-on GPU available, where it's recommended to boot SeaBIOS first
  101. if [ "${payload_grub}" != "y" ] && [ "${payload_seabios}" != "y" ] && [ "${payload_uboot}" != "y" ]; then
  102. while true; do
  103. for configfile in "resources/coreboot/${board}/config/"*; do
  104. if [ -f "${configfile}" ]; then
  105. printf "ERROR build/roms: Target '%s' does not define a payload. Exiting.\n" "${board}"
  106. exit 1
  107. fi
  108. done
  109. break
  110. done
  111. fi
  112. if [ "${payload_uboot}" != "n" ] && \
  113. [ "${payload_uboot}" != "y" ]; then
  114. payload_uboot="n"
  115. fi
  116. if [ "${payload_uboot}" = "y" ] && \
  117. [ "${uboot_config}" = "undefined" ]; then
  118. uboot_config="default"
  119. fi
  120. if [ "${payload_memtest}" = "y" ]; then
  121. if [ ! -f "memtest86plus/memtest" ]; then
  122. ./build module memtest86plus
  123. fi
  124. fi
  125. romdir="bin/${board}"
  126. cbdir="coreboot/${board}"
  127. if [ "${board}" != "${cbtree}" ]; then
  128. cbdir="coreboot/${cbtree}"
  129. fi
  130. cbfstool="${cbdir}/util/cbfstool/cbfstool"
  131. corebootrom="${cbdir}/build/coreboot.rom"
  132. seavgabiosrom="payload/seabios/seavgabios.bin"
  133. if [ ! -d "${cbdir}" ]; then
  134. ./download coreboot ${cbtree}
  135. fi
  136. if [ "${arch}" = "x86_32" ] || [ "${arch}" = "x86_64" ]; then
  137. if [ ! -d "${cbdir}/util/crossgcc/xgcc/i386-elf/" ]; then
  138. (
  139. cat version > "${cbdir}/.coreboot-version"
  140. cd "${cbdir}"
  141. make crossgcc-i386 CPUS=$(nproc) # even for 64-bit machines, coreboot builds
  142. # 32-bit ROM images, so we only need to worry about i386-elf
  143. )
  144. fi
  145. elif [ "${arch}" = "ARMv7" ]; then
  146. (
  147. cat version > "${cbdir}/.coreboot-version"
  148. cd "${cbdir}"
  149. make crossgcc-arm CPUS=$(nproc) # This is for armv7, doesn't apply to aarch64
  150. )
  151. elif [ "${arch}" = "AArch64" ]; then
  152. (
  153. cat version > "${cbdir}/.coreboot-version"
  154. cd "${cbdir}"
  155. make crossgcc-arm crossgcc-aarch64 CPUS=$(nproc) # This is for aarch64, doesn't apply to armv7
  156. )
  157. fi
  158. if [ ! -f "${cbfstool}" ]; then
  159. ./build module cbutils ${cbtree}
  160. fi
  161. if [ ! -f "${seavgabiosrom}" ] \
  162. || [ ! -f payload/seabios/seabios_libgfxinit.elf ] \
  163. || [ ! -f payload/seabios/seabios_vgarom.elf ]; then
  164. if [ "${payload_seabios}" = "y" ]; then
  165. ./build payload seabios
  166. elif [ "${payload_grub}" = "y" ] \
  167. && [ "${payload_grub_withseabios}" = "y" ]; then
  168. ./build payload seabios
  169. fi
  170. fi
  171. [ -d "${romdir}/" ] || mkdir -p "${romdir}/"
  172. rm -f "${romdir}"/*
  173. if [ "${payload_grub}" = "y" ] || [ "${payload_seabios_withgrub}" = "y" ]; then
  174. if [ -f "payload/grub/grub_usqwerty.cfg" ]; then
  175. grubrefchecksum="$(sha1sum resources/grub/config/grub.cfg)"
  176. grubrefchecksum="${grubrefchecksum% resources/grub/config/grub.cfg}"
  177. grubbuildchecksum="$(sha1sum payload/grub/grub_usqwerty.cfg)"
  178. grubbuildchecksum="${grubbuildchecksum% payload/grub/grub_usqwerty.cfg}"
  179. if [ "${grubrefchecksum}" != "${grubbuildchecksum}" ]; then
  180. rm -Rf payload/grub/
  181. printf "Changes detected to GRUB. Re-building now:\n"
  182. fi
  183. else
  184. printf "Required GRUB payloads not yet built. Building now:\n"
  185. rm -Rf payload/grub/ # just in case
  186. fi
  187. for keymapfile in resources/grub/keymap/*; do
  188. if [ ! -f "${keymapfile}" ]; then
  189. continue
  190. fi
  191. keymap="${keymapfile##*/}"
  192. keymap="${keymap%.gkb}"
  193. grubelf="payload/grub/grub_${keymap}.elf"
  194. grubcfg="payload/grub/grub_${keymap}.cfg"
  195. grubtestcfg="payload/grub/grub_${keymap}_test.cfg"
  196. if [ ! -f "${grubelf}" ] || [ ! -f "${grubcfg}" ] || \
  197. [ ! -f "${grubtestcfg}" ]; then
  198. ./build payload grub
  199. fi
  200. done
  201. fi
  202. if [ "${payload_uboot}" = "y" ]; then
  203. if [ "${uboot_config}" = "default" ] && \
  204. [ -f "payload/u-boot/${board}/u-boot.elf" ]; then
  205. ubootelf="payload/u-boot/${board}/u-boot.elf"
  206. else
  207. ubootelf="payload/u-boot/${board}/${uboot_config}/u-boot.elf"
  208. fi
  209. if [ ! -f "${ubootelf}" ]; then
  210. printf "Required U-Boot payloads not yet built. Building now:\n"
  211. rm -Rf "payload/u-boot/${board}" # just in case
  212. ./build payload u-boot "${board}"
  213. fi
  214. fi
  215. # it is assumed that no other work will be done on the ROM
  216. # after calling this function. therefore this function is "final"
  217. moverom() {
  218. rompath="$1"
  219. newrompath="$2"
  220. cuttype="$3"
  221. printf "\nCreating new ROM image: %s\n" "${newrompath}"
  222. if [ "${cuttype}" = "4MiB IFD BIOS region" ]; then
  223. dd if=${rompath} of=${newrompath} bs=1 skip=$[$(stat -c %s ${rompath}) - 0x400000] count=4194304
  224. else
  225. cp ${rompath} ${newrompath}
  226. fi
  227. # pike2008 cards cause a system hang when loading the option rom in seabios
  228. # if there is an empty option rom in cbfs, no option rom will be loaded
  229. if [ "${cuttype}" = "d8d16sas" ]; then
  230. emptyrom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
  231. rm -f "${emptyrom}"
  232. touch "${emptyrom}"
  233. for deviceID in "0072" "3050"; do
  234. "${cbfstool}" "${newrompath}" add -f "${emptyrom}" -n pci1000,${deviceID}.rom -t raw
  235. done
  236. rm -f "${emptyrom}"
  237. fi
  238. for romsize in 4 8 16; do
  239. if [ "${cuttype}" = "${romsize}MiB ICH9 IFD NOR flash" ]; then
  240. if [ ! -f "descriptors/ich9m/ich9fdgbe_${romsize}m.bin" ]; then
  241. ./build descriptors ich9m
  242. fi
  243. dd if=descriptors/ich9m/ich9fdgbe_${romsize}m.bin of=${newrompath} bs=1 count=12k conv=notrunc
  244. fi
  245. if [ "${cuttype}" = "${romsize}MiB ICH9 IFD NOGBE NOR flash" ]; then
  246. if [ ! -f "descriptors/ich9m/ich9fdnogbe_${romsize}m.bin" ]; then
  247. ./build descriptors ich9m
  248. fi
  249. dd if=descriptors/ich9m/ich9fdnogbe_${romsize}m.bin of=${newrompath} bs=1 count=4k conv=notrunc
  250. fi
  251. done
  252. if [ "${cuttype}" = "i945 laptop" ]; then
  253. dd if=${newrompath} of=top64k.bin bs=1 skip=$[$(stat -c %s ${newrompath}) - 0x10000] count=64k
  254. dd if=top64k.bin of=${newrompath} bs=1 seek=$[$(stat -c %s ${newrompath}) - 0x20000] count=64k conv=notrunc
  255. rm -f top64k.bin
  256. fi
  257. }
  258. # expected: configs must not specify a payload
  259. mkCoreboot() {
  260. cbdir="${1}" # e.g. coreboot/default
  261. cbcfgpath="${2}" # e.g. resources/coreboot/x200_8mb/config/libgfxinit_txtmode
  262. if [ ! -f "${cbcfgpath}" ]; then
  263. printf "\nmkCoreboot: Coreboot config '%s' does not exist. Skipping build.\n" \
  264. "${cbcfgpath}"
  265. return 0
  266. fi
  267. printf "%s-%s\n" "$(cat projectname)" "$(cat version)" > "${cbdir}/.coreboot-version"
  268. (
  269. cd "${cbdir}"
  270. make distclean
  271. )
  272. cp "${cbcfgpath}" "${cbdir}"/.config
  273. ./build module cbutils ${cbdir#coreboot/}
  274. (
  275. cd "${cbdir}"
  276. make -j$(nproc)
  277. )
  278. }
  279. # make a rom in /tmp/ and then print the path of that ROM
  280. make_seabios_rom() {
  281. target_cbrom="${1}" # rom to insert seabios in. this rom won't be touched
  282. # a tmpfile will be made instead
  283. target_seabios_cbfs_path="${2}" # e.g. fallback/payload
  284. target_opromloadonly="${3}" # 0 or 1. if 1, only load but don't execute oproms
  285. target_initmode="${4}" # e.g. libgfxinit
  286. cbfstool_path="${5}"
  287. if [ "${target_initmode}" = "normal" ]; then
  288. target_seabioself="payload/seabios/seabios_vgarom.elf"
  289. # if normal, etc/pci-optionrom-exec will be set to 2
  290. else
  291. target_seabioself="payload/seabios/seabios_${target_initmode}.elf"
  292. # if libgfxinit, etc/pci-optionrom-exec will be set to 2
  293. # if vgarom, etc/pci-optionrom-exec will be set to 0
  294. fi
  295. target_seavgabios_rom="payload/seabios/seavgabios.bin"
  296. tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
  297. cp "${target_cbrom}" "${tmprom}"
  298. "${cbfstool}" "${tmprom}" add-payload -f "${target_seabioself}" -n ${target_seabios_cbfs_path} -c lzma
  299. "${cbfstool}" "${tmprom}" add-int -i 3000 -n etc/ps2-keyboard-spinup
  300. if [ "${target_initmode}" = "normal" ] || [ "${target_initmode}" = "libgfxinit" ]; then
  301. "${cbfstool}" "${tmprom}" add-int -i 2 -n etc/pci-optionrom-exec
  302. elif [ "${target_initmode}" = "vgarom" ]; then
  303. "${cbfstool}" "${tmprom}" add-int -i 0 -n etc/pci-optionrom-exec
  304. fi # for undefined modes, don't add this integer. rely on SeaBIOS defaults
  305. "${cbfstool}" "${tmprom}" add-int -i 0 -n etc/optionroms-checksum
  306. "${cbfstool}" "${tmprom}" add-int -i ${target_opromloadonly} -n etc/only-load-option-roms
  307. if [ "${target_initmode}" = "libgfxinit" ]; then
  308. "${cbfstool_path}" "${tmprom}" add -f "${target_seavgabios_rom}" -n vgaroms/seavgabios.bin -t raw
  309. fi
  310. printf "%s\n" "${tmprom}"
  311. }
  312. # make a rom in /tmp/ and then print the path of that ROM
  313. make_uboot_payload_rom() {
  314. target_cbrom="${1}" # rom to insert u-boot in. this rom won't be touched
  315. # a tmpfile will be made instead
  316. target_uboot_cbfs_path="${2}" # e.g. fallback/payload
  317. target_uboot_config="${3}"
  318. cbfstool_path="${4}"
  319. if [ "${target_uboot_config}" = "default" ]; then
  320. target_ubootelf="payload/u-boot/${board}/u-boot.elf"
  321. else
  322. target_ubootelf="payload/u-boot/${board}/${target_uboot_config}/u-boot.elf"
  323. fi
  324. tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
  325. cp "${target_cbrom}" "${tmprom}"
  326. "${cbfstool}" "${tmprom}" add-payload -f "${target_ubootelf}" -n ${target_uboot_cbfs_path} -c lzma
  327. printf "%s\n" "${tmprom}"
  328. }
  329. # make a rom in /tmp/ and then print the path of that ROM
  330. make_grubrom_from_keymap() {
  331. target_keymap="${1}"
  332. target_cbrom="${2}"
  333. cbfstool_path="${3}"
  334. target_grubelf_cbfs_path="${4}" # e.g. fallback/payload
  335. grubelf="payload/grub/grub_${target_keymap}.elf"
  336. grubcfg="payload/grub/grub_${target_keymap}.cfg"
  337. grubtestcfg="payload/grub/grub_${target_keymap}_test.cfg"
  338. tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
  339. cp "${target_cbrom}" "${tmprom}"
  340. "${cbfstool_path}" "${tmprom}" add-payload -f "${grubelf}" -n ${target_grubelf_cbfs_path} -c lzma
  341. tmpgrubcfg=$(mktemp -t grub.cfg.XXXXXXXXXX)
  342. tmpgrubtestcfg=$(mktemp -t grubtest.cfg.XXXXXXXXXX)
  343. if [ "${grub_scan_disk}" = "ahci" ]; then
  344. sed 's/set\ grub_scan_disk=\"both\"/set\ grub_scan_disk=\"ahci\"/' "${grubcfg}" > "${tmpgrubcfg}"
  345. sed 's/set\ grub_scan_disk=\"both\"/set\ grub_scan_disk=\"ahci\"/' "${grubtestcfg}" > "${tmpgrubtestcfg}"
  346. elif [ "${grub_scan_disk}" = "ata" ]; then
  347. sed 's/set\ grub_scan_disk=\"both\"/set\ grub_scan_disk=\"ata\"/' "${grubcfg}" > "${tmpgrubcfg}"
  348. sed 's/set\ grub_scan_disk=\"both\"/set\ grub_scan_disk=\"ata\"/' "${grubtestcfg}" > "${tmpgrubtestcfg}"
  349. else
  350. cp "${grubcfg}" "${tmpgrubcfg}"
  351. cp "${grubtestcfg}" "${tmpgrubtestcfg}"
  352. fi
  353. "${cbfstool_path}" "${tmprom}" add -f "${tmpgrubcfg}" -n grub.cfg -t raw
  354. "${cbfstool_path}" "${tmprom}" add -f "${tmpgrubtestcfg}" -n grubtest.cfg -t raw
  355. rm -f "${tmpgrubcfg}" "${tmpgrubtestcfg}"
  356. backgroundfile="background1280x800.png"
  357. if [ "${board}" = "x60" ] || [ "${board}" = "t60_intelgpu" ]; then
  358. # TODO: don't hardcode this check. do it in board.cfg per board
  359. backgroundfile="background1024x768.png"
  360. fi
  361. backgroundfile="resources/grub/background/${backgroundfile}"
  362. "${cbfstool_path}" "${tmprom}" add -f ${backgroundfile} -n background.png -t raw
  363. printf "%s\n" "${tmprom}"
  364. }
  365. # Make separate ROM images with GRUB payload, for each supported keymap
  366. mkRomsWithGrub() {
  367. tmprompath="${1}"
  368. initmode="${2}"
  369. displaymode="${3}"
  370. firstpayloadname="${4}" # allow values: grub, seabios, seabios_withgrub, seabios_grubfirst
  371. if [ "${payload_grub_withseabios}" = "y" ] && [ "${firstpayloadname}" = "grub" ]; then
  372. mv "$(make_seabios_rom "${tmprompath}" "seabios.elf" "${seabios_opromloadonly}" "${initmode}" "${cbfstool}")" "${tmprompath}"
  373. elif [ "${payload_seabios_withgrub}" ] && [ "${firstpayloadname}" != "grub" ]; then
  374. mv "$(make_seabios_rom "${tmprompath}" "fallback/payload" "${seabios_opromloadonly}" "${initmode}" "${cbfstool}")" "${tmprompath}"
  375. if [ "${firstpayloadname}" = "seabios_grubfirst" ]; then
  376. tmpbootorder=$(mktemp -t coreboot_rom.XXXXXXXXXX)
  377. printf "/rom@img/grub2\n" > "${tmpbootorder}"
  378. "${cbfstool}" "${tmprompath}" add -f "${tmpbootorder}" -n bootorder -t raw
  379. rm -f "${tmpbootorder}"
  380. "${cbfstool}" "${tmprompath}" add-int -i 0 -n etc/show-boot-menu
  381. fi
  382. fi
  383. for keymapfile in resources/grub/keymap/*; do
  384. if [ ! -f "${keymapfile}" ]; then
  385. continue
  386. fi
  387. keymap="${keymapfile##*/}"
  388. keymap="${keymap%.gkb}"
  389. grub_path_in_cbfs="fallback/payload"
  390. if [ "${firstpayloadname}" != "grub" ]; then
  391. grub_path_in_cbfs="img/grub2"
  392. fi
  393. tmpgrubrom="$(make_grubrom_from_keymap "${keymap}" "${tmprompath}" "${cbfstool}" "${grub_path_in_cbfs}")"
  394. if [ "${initmode}" = "normal" ]; then
  395. newrompath="${romdir}/${firstpayloadname}_${board}_${initmode}_${keymap}.rom"
  396. else
  397. newrompath="${romdir}/${firstpayloadname}_${board}_${initmode}_${displaymode}_${keymap}.rom"
  398. fi
  399. moverom "${tmpgrubrom}" "${newrompath}" "${romtype}"
  400. rm -f "${tmpgrubrom}"
  401. done
  402. }
  403. # Main ROM building function. This calls all other functions
  404. mkRoms() {
  405. cbcfgpath="${1}"
  406. displaymode="${2}"
  407. initmode="${3}"
  408. if [ ! -f "${cbcfgpath}" ]; then
  409. printf "'%s' does not exist. Skipping build for %s %s %s\n" \
  410. "${cbcfgpath}" "${board}" "${displaymode}" "${initmode}"
  411. return 0
  412. fi
  413. mkCoreboot "${cbdir}" "${cbcfgpath}"
  414. if [ "${displaymode}" = "txtmode" ] && [ "${payload_memtest}" = "y" ]; then
  415. "${cbfstool}" "${corebootrom}" add-payload -f memtest86plus/memtest -n img/memtest -c lzma
  416. fi
  417. if [ "${payload_seabios}" = "y" ]; then
  418. if [ "${payload_seabios_withgrub}" = "n" ]; then
  419. tmpseabiosrom="$(make_seabios_rom "${corebootrom}" "fallback/payload" "${seabios_opromloadonly}" "${initmode}" "${cbfstool}")"
  420. if [ "${initmode}" = "normal" ]; then
  421. newrompath="${romdir}/seabios_${board}_${initmode}.rom"
  422. else
  423. newrompath="${romdir}/seabios_${board}_${initmode}_${displaymode}.rom"
  424. fi
  425. moverom "${tmpseabiosrom}" "${newrompath}" "${romtype}"
  426. rm -f "${tmpseabiosrom}"
  427. else
  428. tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
  429. cp "${corebootrom}" "${tmprom}"
  430. mkRomsWithGrub "${tmprom}" "${initmode}" "${displaymode}" "seabios_withgrub"
  431. cp "${corebootrom}" "${tmprom}"
  432. mkRomsWithGrub "${tmprom}" "${initmode}" "${displaymode}" "seabios_grubfirst"
  433. rm -f "${tmprom}"
  434. fi
  435. fi
  436. if [ "${payload_grub}" = "y" ]; then
  437. mkRomsWithGrub "${corebootrom}" "${initmode}" "${displaymode}" "grub"
  438. fi
  439. if [ "${payload_uboot}" = "y" ]; then
  440. tmpubootrom="$(make_uboot_payload_rom "${corebootrom}" "fallback/payload" "${uboot_config}" "${cbfstool}")"
  441. if [ "${initmode}" = "normal" ]; then
  442. newrompath="${romdir}/uboot_payload_${board}_${initmode}.rom"
  443. else
  444. newrompath="${romdir}/uboot_payload_${board}_${initmode}_${displaymode}.rom"
  445. fi
  446. moverom "${tmpubootrom}" "${newrompath}" "${romtype}"
  447. rm -f "${tmpubootrom}"
  448. fi
  449. }
  450. initmode="libgfxinit"
  451. for displaymode in corebootfb txtmode; do
  452. cbcfgpath="resources/coreboot/${board}/config/${initmode}_${displaymode}"
  453. mkRoms "${cbcfgpath}" "${displaymode}" "${initmode}"
  454. done
  455. initmode="vgarom"
  456. for displaymode in vesafb txtmode; do
  457. cbcfgpath="resources/coreboot/${board}/config/${initmode}_${displaymode}"
  458. mkRoms "${cbcfgpath}" "${displaymode}" "${initmode}"
  459. done
  460. initmode="normal"
  461. displaymode="txtmode"
  462. cbcfgpath="resources/coreboot/${board}/config/${initmode}"
  463. mkRoms "${cbcfgpath}" "${displaymode}" "${initmode}"
  464. (
  465. cd "${cbdir}"
  466. make distclean
  467. )