From d1f408f3725aa02bc1d76c4c6aadb4697bd073c0 Mon Sep 17 00:00:00 2001 From: Francis Rowe Date: Sat, 02 Jan 2016 17:10:32 -0500 Subject: Use different coreboot revisions and patches per board The release archives will be bigger, but this is a necessary change that makes libreboot development easier. At present, there are boards maintained in libreboot by different people. By doing it this way, that becomes much easier. This is in contrast to the present situation, where a change to one board potentially affects all other boards, especially when updating to a new version of coreboot. Coreboot-libre scripts, download scripts, build scripts - everything. The entire build system has been modified to reflect this change of development. For reasons of consistency, cbfstool and nvramtool are no longer included in the util archives. --- (limited to 'resources/scripts/helpers') diff --git a/resources/scripts/helpers/build/clean/coreboot b/resources/scripts/helpers/build/clean/coreboot index 135e194..2f7701e 100755 --- a/resources/scripts/helpers/build/clean/coreboot +++ b/resources/scripts/helpers/build/clean/coreboot @@ -2,7 +2,7 @@ # helper script: clean the dependencies that were built in coreboot # -# Copyright (C) 2014, 2015 Francis Rowe +# Copyright (C) 2014, 2015, 2016 Francis Rowe # Copyright (C) 2015 Klemens Nanni # # This program is free software: you can redistribute it and/or modify @@ -29,12 +29,27 @@ set -u -e printf "Cleaning the previous build of coreboot and its utilities\n" # clean coreboot and crossgcc (source archives preserved) -make -C coreboot clean -make -C coreboot crossgcc-clean - -# Clean its utilities as well -for util in {cbfs,ifd,nvram}tool cbmem; do - make -C coreboot/util/"${util}" clean +for payload in coreboot/*; do + for board in "${payload}/"*; do + # Clean coreboot, of course + make -C "${board}/" distclean + + # Clean its utilities as well + for util in {cbfs,ifd,nvram}tool cbmem; do + make -C "${board}/util/${util}/" clean + done + make -C "${board}/payloads/libpayload/" distclean + + # Clean crossgcc + if [ "${payload##*/}" != "crossgcc" ]; then # is a symlink + # delete symlink to crossgcc + rm -f "${board}/util/crossgcc" + else # is the real crossgcc + # payload is crossgcc + # board is not a board, it's a coreboot revision + make -C "${board}/" crossgcc-clean + fi + done done printf "\n\n" diff --git a/resources/scripts/helpers/build/config/dcmodify b/resources/scripts/helpers/build/config/dcmodify index e71af26..90c6578 100755 --- a/resources/scripts/helpers/build/config/dcmodify +++ b/resources/scripts/helpers/build/config/dcmodify @@ -3,7 +3,7 @@ # # helper script: run "make menuconfig" on config(s) to modify them # -# Copyright (C) 2014, 2015 Francis Rowe +# Copyright (C) 2014, 2015, 2016 Francis Rowe # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,25 +25,28 @@ [ "x${DEBUG+set}" = 'xset' ] && set -v set -u -e -configpath="resources/libreboot/config/depthcharge" +payload="depthcharge" +configpath="resources/libreboot/config/${payload}" hackconfig () { - cd "coreboot/" + board="${1}" - printf "Modifying config for %s\n" "${1}" + cd "coreboot/${payload}/${board}/" + + printf "Modifying config for %s (%s payload)\n" "${board}" "${payload}" sleep 2 - if [ ! -d "../${configpath}/${1}/" ]; then - printf "build/config/corebootmodify WARNING: config '%s' does not exist. Skipping.\n" "${1}" - cd "../" + if [ ! -d "../../../${configpath}/${board}/" ]; then + printf "build/config/dcmodify WARNING: config '%s' does not exist. Skipping.\n" "${board}" + cd "../../../" return fi - mv "../${configpath}/${1}/config" ".config" + mv "../../../${configpath}/${board}/config" ".config" make menuconfig - mv ".config" "../${configpath}/${1}/config" + mv ".config" "../../../${configpath}/${board}/config" - cd "../" + cd "../../../" } if [ $# -lt 1 ]; then diff --git a/resources/scripts/helpers/build/config/dcreplace b/resources/scripts/helpers/build/config/dcreplace index 85b765c..13511fc 100755 --- a/resources/scripts/helpers/build/config/dcreplace +++ b/resources/scripts/helpers/build/config/dcreplace @@ -3,7 +3,7 @@ # # helper script: run "make menuconfig" on config(s) to replace them # -# Copyright (C) 2014, 2015 Francis Rowe +# Copyright (C) 2014, 2015, 2016 Francis Rowe # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,20 +25,23 @@ [ "x${DEBUG+set}" = 'xset' ] && set -v set -u -e -configpath="resources/libreboot/config/depthcharge" +payload="depthcharge" +configpath="resources/libreboot/config/${payload}" hackconfig () { - cd "coreboot/" + board="${1}" - printf "Replacing or creating new config for %s\n" "${1}" + cd "coreboot/${payload}/${board}/" + + printf "Replacing or creating new config for %s (%s payload)\n" "${board}" "${payload}" sleep 2 make menuconfig - [ ! -d "../${configpath}/${1}/" ] && mkdir -p "../${configpath}/${1}/" - mv ".config" "../${configpath}/${1}/config" + [ ! -d "../../../${configpath}/${board}/" ] && mkdir -p "../../../${configpath}/${board}/" + mv ".config" "../../../${configpath}/${board}/config" - cd "../" + cd "../../../" } if [ $# -lt 1 ]; then diff --git a/resources/scripts/helpers/build/config/dcupdate b/resources/scripts/helpers/build/config/dcupdate index fd3a99c..cfea022 100755 --- a/resources/scripts/helpers/build/config/dcupdate +++ b/resources/scripts/helpers/build/config/dcupdate @@ -3,7 +3,7 @@ # # helper script: run "make oldconfig" on all coreboot config files # -# Copyright (C) 2014, 2015 Francis Rowe +# Copyright (C) 2014, 2015, 2016 Francis Rowe # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,25 +25,28 @@ [ "x${DEBUG+set}" = 'xset' ] && set -v set -u -e -configpath="resources/libreboot/config/depthcharge" +payload="depthcharge" +configpath="resources/libreboot/config/${payload}" hackconfig () { - cd "coreboot/" + board="${1}" - printf "Updating config for %s\n" "${1}" + cd "coreboot/${payload}/${board}/" + + printf "Updating config for %s (%s payload)\n" "${board}" "${payload}" sleep 2 - if [ ! -d "../${configpath}/${1}/" ]; then - printf "build/config/corebootupdate WARNING: config '%s' does not exist. Skipping.\n" "${1}" - cd "../" + if [ ! -d "../../../${configpath}/${board}/" ]; then + printf "build/config/dcupdate WARNING: config '%s' does not exist. Skipping.\n" "${board}" + cd "../../../" return fi - mv "../${configpath}/${1}/config" ".config" + mv "../../../${configpath}/${board}/config" ".config" make oldconfig - mv ".config" "../${configpath}/${1}/config" + mv ".config" "../../../${configpath}/${board}/config" - cd "../" + cd "../../../" } if [ $# -lt 1 ]; then diff --git a/resources/scripts/helpers/build/config/grubmodify b/resources/scripts/helpers/build/config/grubmodify index dc86653..f05f22e 100755 --- a/resources/scripts/helpers/build/config/grubmodify +++ b/resources/scripts/helpers/build/config/grubmodify @@ -3,7 +3,7 @@ # # helper script: run "make menuconfig" on config(s) to modify them # -# Copyright (C) 2014, 2015 Francis Rowe +# Copyright (C) 2014, 2015, 2016 Francis Rowe # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,25 +25,28 @@ [ "x${DEBUG+set}" = 'xset' ] && set -v set -u -e -configpath="resources/libreboot/config/grub" +payload="grub" +configpath="resources/libreboot/config/${payload}" hackconfig () { - cd "coreboot/" + board="${1}" - printf "Modifying config for %s\n" "${1}" + cd "coreboot/${payload}/${board}/" + + printf "Modifying config for %s (%s payload)\n" "${board}" "${payload}" sleep 2 - if [ ! -d "../${configpath}/${1}/" ]; then - printf "build/config/corebootmodify WARNING: config '%s' does not exist. Skipping.\n" "${1}" - cd "../" + if [ ! -d "../../../${configpath}/${board}/" ]; then + printf "build/config/grubmodify WARNING: config '%s' does not exist. Skipping.\n" "${board}" + cd "../../../" return fi - mv "../${configpath}/${1}/config" ".config" + mv "../../../${configpath}/${board}/config" ".config" make menuconfig - mv ".config" "../${configpath}/${1}/config" + mv ".config" "../../../${configpath}/${board}/config" - cd "../" + cd "../../../" } if [ $# -lt 1 ]; then diff --git a/resources/scripts/helpers/build/config/grubreplace b/resources/scripts/helpers/build/config/grubreplace index 36d4558..87d8959 100755 --- a/resources/scripts/helpers/build/config/grubreplace +++ b/resources/scripts/helpers/build/config/grubreplace @@ -3,7 +3,7 @@ # # helper script: run "make menuconfig" on config(s) to replace them # -# Copyright (C) 2014, 2015 Francis Rowe +# Copyright (C) 2014, 2015, 2016 Francis Rowe # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,20 +25,23 @@ [ "x${DEBUG+set}" = 'xset' ] && set -v set -u -e -configpath="resources/libreboot/config/grub" +payload="grub" +configpath="resources/libreboot/config/${payload}" hackconfig () { - cd "coreboot/" + board="${1}" - printf "Replacing or creating new config for %s\n" "${1}" + cd "coreboot/${payload}/${board}/" + + printf "Replacing or creating new config for %s (%s payload)\n" "${board}" "${payload}" sleep 2 make menuconfig - [ ! -d "../${configpath}/${1}/" ] && mkdir -p "../${configpath}/${1}/" - mv ".config" "../${configpath}/${1}/config" + [ ! -d "../../../${configpath}/${board}/" ] && mkdir -p "../../../${configpath}/${board}/" + mv ".config" "../../../${configpath}/${board}/config" - cd "../" + cd "../../../" } if [ $# -lt 1 ]; then diff --git a/resources/scripts/helpers/build/config/grubupdate b/resources/scripts/helpers/build/config/grubupdate index 6390253..5bb1a57 100755 --- a/resources/scripts/helpers/build/config/grubupdate +++ b/resources/scripts/helpers/build/config/grubupdate @@ -3,7 +3,7 @@ # # helper script: run "make oldconfig" on all coreboot config files # -# Copyright (C) 2014, 2015 Francis Rowe +# Copyright (C) 2014, 2015, 2016 Francis Rowe # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,25 +25,28 @@ [ "x${DEBUG+set}" = 'xset' ] && set -v set -u -e -configpath="resources/libreboot/config/grub" +payload="grub" +configpath="resources/libreboot/config/${payload}" hackconfig () { - cd "coreboot/" + board="${1}" - printf "Updating config for %s\n" "${1}" + cd "coreboot/${payload}/${board}/" + + printf "Updating config for %s (%s payload)\n" "${board}" "${payload}" sleep 2 - if [ ! -d "../${configpath}/${1}/" ]; then - printf "build/config/corebootupdate WARNING: config '%s' does not exist. Skipping.\n" "${1}" - cd "../" + if [ ! -d "../../../${configpath}/${board}/" ]; then + printf "build/config/grubupdate WARNING: config '%s' does not exist. Skipping.\n" "${board}" + cd "../../../" return fi - mv "../${configpath}/${1}/config" ".config" + mv "../../../${configpath}/${board}/config" ".config" make oldconfig - mv ".config" "../${configpath}/${1}/config" + mv ".config" "../../../${configpath}/${board}/config" - cd "../" + cd "../../../" } if [ $# -lt 1 ]; then diff --git a/resources/scripts/helpers/build/module/coreboot b/resources/scripts/helpers/build/module/coreboot index eb99c25..07659cd 100755 --- a/resources/scripts/helpers/build/module/coreboot +++ b/resources/scripts/helpers/build/module/coreboot @@ -2,7 +2,7 @@ # helper script: builds the dependencies that coreboot needs before building a ROM image # -# Copyright (C) 2014, 2015 Francis Rowe +# Copyright (C) 2014, 2015, 2016 Francis Rowe # Copyright (C) 2015 Klemens Nanni # # This program is free software: you can redistribute it and/or modify @@ -30,13 +30,28 @@ set -u -e printf "Building the utilities in coreboot\n" -# crossgcc -# coreboot on x86 is 32-bit, so only build for i386. Also build for ARM -for architecture in i386 arm; do - make -j$(nproc) -BC coreboot crossgcc-${architecture} -done +# clean coreboot and crossgcc (source archives preserved) +for payload in coreboot/*; do + for board in "${payload}/"*; do + + if [ "${payload##*/}" = "crossgcc" ]; then # build crossgcc + + for architecture in i386 arm; do + make -j$(nproc) -BC "${board}/" crossgcc-${architecture} + done + else # build other utils + # cbfstool, cbmem, nvramtool + for util in {cbfs,nvram}tool cbmem; do + make -BC "${board}/util/${util}" + done + # create symlink to crossgcc + ( + boardconfig_path="resources/libreboot/config/${payload##*/}/${board##*/}" + cbrevision="$(cat "${boardconfig_path}/cbrevision")" + cd "${board}/util/" + ln -s "../../../crossgcc/${cbrevision}/util/crossgcc/" crossgcc + ) + fi -# cbfstool, cbmem, nvramtool -for util in {cbfs,nvram}tool cbmem; do - make -BC coreboot/util/${util} + done done diff --git a/resources/scripts/helpers/build/release/util b/resources/scripts/helpers/build/release/util index 3e9910d..fce6420 100755 --- a/resources/scripts/helpers/build/release/util +++ b/resources/scripts/helpers/build/release/util @@ -3,7 +3,7 @@ # # helper script: generate the release archives # -# Copyright (C) 2014, 2015 Francis Rowe +# Copyright (C) 2014, 2015, 2016 Francis Rowe # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -110,41 +110,6 @@ rm -Rf "flashrom/" mv "flashrom_/" "flashrom/" # ---------------- -# cbfstool related -# ---------------- -# build cbfstool, compiled (statically linked) and include the binary - -mkdir -p "${distdir}/cbfstool/${arch}/" - -cd "coreboot/util/" -cp -R "cbfstool" "cbfstool_/" -cd "cbfstool/" -make clean -make SHARED=0 CC='gcc -static' - -mv "cbfstool" "../../../${distdir}/cbfstool/${arch}/" - -if [ "${arch}" = "x86_64" ] - then - # Now build 32-bit binaries - make clean - make SHARED=0 CC='gcc -static -m32' - mkdir "../../../${distdir}/cbfstool/i686" - mv "cbfstool" "../../../${distdir}/cbfstool/i686/" -fi - -# cross-compile for ARM -make clean -make SHARED=0 CC='arm-linux-gnueabi-gcc -static' -mkdir "../../../${distdir}/cbfstool/armv7l/" -mv "cbfstool" "../../../${distdir}/cbfstool/armv7l/" - -cd ../ -rm -Rf "cbfstool/" -mv "cbfstool_/" "cbfstool/" -cd ../../ - -# ---------------- # ich9deblob related # ---------------- # build ich9deblob, compiled (statically linked) and include the binary @@ -185,34 +150,6 @@ rm -Rf "ich9deblob/" mv "ich9deblob_/" "ich9deblob/" cd "../../" -# ----------------- -# nvramtool related -# ----------------- -# build nvramtool, compiled (statically linked) and include the binary -cd "coreboot/util/" -cp -R "nvramtool/" "nvramtool_/" -cd "nvramtool/" -make clean -make SHARED=0 CC='gcc -static' - -mkdir -p "../../../${distdir}/nvramtool/${arch}/" - -mv "nvramtool" "../../../${distdir}/nvramtool/${arch}/" - -if [ "${arch}" = "x86_64" ] - then - # Now build 32-bit binaries - make clean - make SHARED=0 CC='gcc -static -m32' - mkdir "../../../${distdir}/nvramtool/i686/" - mv "nvramtool" "../../../${distdir}/nvramtool/i686/" -fi - -cd "../" -rm -Rf "nvramtool/" -mv "nvramtool_/" "nvramtool/" -cd "../../" - # ------------- # Miscellaneous # ------------- diff --git a/resources/scripts/helpers/build/roms/withdepthcharge b/resources/scripts/helpers/build/roms/withdepthcharge index 1c37102..32e5623 100755 --- a/resources/scripts/helpers/build/roms/withdepthcharge +++ b/resources/scripts/helpers/build/roms/withdepthcharge @@ -2,7 +2,7 @@ # helper script: build ROM images with depthcharge and put them in ./bin/ # -# Copyright (C) 2014, 2015 Francis Rowe +# Copyright (C) 2014, 2015, 2016 Francis Rowe # Copyright (C) 2015 Paul Kocialkowski # # This program is free software: you can redistribute it and/or modify @@ -32,13 +32,23 @@ then mkdir "bin/" fi +if [ -f "version" ]; then + # _src release archive is being used + version="$(cat "version")" +else + # git repo is being used + version="$(git describe --tags HEAD)" # note: in libreboot, coreboot/.git doesn't exist, this uses libreboot .git +fi + # Build libpayload # ------------------------------------------------------------------------------ buildlibpayload() { - family="$1" + family="${1}" + board="${2}" - cd "coreboot/payloads/libpayload" + ( + cd "coreboot/depthcharge/${board}/payloads/libpayload/" make distclean rm -Rf "install/" @@ -46,95 +56,92 @@ buildlibpayload() { make KBUILD_DEFCONFIG="configs/config.$family" defconfig make -j"$(nproc)" make DESTDIR="install" install - - cd "../../../" + ) } # Build depthcharge # ------------------------------------------------------------------------------ builddepthcharge() { - board="$1" + board="${1}" + ( cd "depthcharge/" make distclean - rm -f "../coreboot/depthcharge.elf" + rm -f "../coreboot/depthcharge/${board:?}/depthcharge.elf" - make BOARD="$board" defconfig - make BOARD="$board" LIBPAYLOAD_DIR="$(pwd)/../coreboot/payloads/libpayload/install/libpayload" VB_SOURCE="$(pwd)/../coreboot/3rdparty/vboot" -j"$(nproc)" depthcharge_unified + make BOARD="${board}" defconfig + make BOARD="${board}" LIBPAYLOAD_DIR="$(pwd)/../coreboot/depthcharge/${board}/payloads/libpayload/install/libpayload" VB_SOURCE="$(pwd)/../coreboot/depthcharge/${board}/3rdparty/vboot" -j"$(nproc)" depthcharge_unified - cp "build/depthcharge.elf" "../coreboot/" - - cd "../" + cp "build/depthcharge.elf" "../coreboot/depthcharge/${board}/" + ) } # Build coreboot # ------------------------------------------------------------------------------ buildcoreboot() { - board="$1" + board="${1}" - cd "coreboot/" + ( + cd "coreboot/depthcharge/${board}/" make distclean rm -f ".coreboot-version" rm -f *.img - if [ -f "../version" ]; then - # _src release archive is being used - version="$(cat ../version)" - else - # git repo is being used - version="$(git describe --tags HEAD)" # note: in libreboot, coreboot/.git doesn't exist, this uses libreboot .git - fi printf 'libreboot-%s' "${version}" > "ro-frid" printf 'libreboot-%s\n' "${version}" > ".coreboot-version" # needed for reproducible builds in coreboot - make KBUILD_DEFCONFIG="$(pwd)/../resources/libreboot/config/depthcharge/${board}/config" defconfig + make KBUILD_DEFCONFIG="$(pwd)/../../../resources/libreboot/config/depthcharge/${board}/config" defconfig make -j"$(nproc)" cbfs_size=$( grep CONFIG_CBFS_SIZE ".config" | sed "s/.*[[:space:]]*=[[:space:]]*//g" ) - cbfs_size=$( printf "%d\n" "$cbfs_size" ) + cbfs_size=$( printf "%d\n" "${cbfs_size}" ) cbfs_size=$(( $cbfs_size / 1024 )) - dd if="build/coreboot.rom" of="coreboot.img" bs=1024 count="$cbfs_size" + dd if="build/coreboot.rom" of="coreboot.img" bs=1024 count="${cbfs_size}" objcopy -I binary -O binary --pad-to=0x100 --gap-fill=0x00 "ro-frid" "ro-frid.img" # prepare directory for new images rm -Rf "${board:?}/" - mkdir "$board/" + mkdir "${board}/" # move the images into the newly created directory - mv "coreboot.img" "$board/" - mv "ro-frid.img" "$board/" + mv "coreboot.img" "${board}/" + mv "ro-frid.img" "${board}/" # copy the scripts too - cp "../resources/libreboot/install/depthcharge/cros-flash-replace" "$board/" - cp "../resources/libreboot/install/depthcharge/${board}/layout.txt" "$board/" + cp "../../../resources/libreboot/install/depthcharge/cros-flash-replace" "${board}/" + cp "../../../resources/libreboot/install/depthcharge/${board}/layout.txt" "${board}/" # delete the old images from ../bin - rm -Rf "../bin/depthcharge/${board}/" + rm -Rf "../../../bin/depthcharge/${board}/" # now put the new images in ./bin/depthcharge/ - [ ! -d "../bin/depthcharge/" ] && mkdir -p "../bin/depthcharge/" - mv "$board/" "../bin/depthcharge/" + [ ! -d "../../../bin/depthcharge/" ] && mkdir -p "../../../bin/depthcharge/" + mv "${board}/" "../../../bin/depthcharge/" - cd "../" + # clean this up + rm -f "depthcharge.elf" + rm -f *.img + ) } # Build ROM images for supported boards buildrom() { - board="$1" + board="${1}" + if [ -f "resources/libreboot/config/depthcharge/${board}/config" ]; then family=$( echo ${board} |sed "s/_.*//g" ) - buildlibpayload "$family" - builddepthcharge "$board" - buildcoreboot "$board" + buildlibpayload "${family}" "${board}" + builddepthcharge "${board}" + buildcoreboot "${board}" fi } if [ $# -gt 0 ]; then for board in "${@}"; do - buildrom "$board" + buildrom "${board}" done else for board in resources/libreboot/config/depthcharge/*; do diff --git a/resources/scripts/helpers/build/roms/withgrub b/resources/scripts/helpers/build/roms/withgrub index fd1aa5d..f3c0c05 100755 --- a/resources/scripts/helpers/build/roms/withgrub +++ b/resources/scripts/helpers/build/roms/withgrub @@ -3,7 +3,7 @@ # # helper script: build ROM images with GRUB and put them in ./bin/ # -# Copyright (C) 2014, 2015 Francis Rowe +# Copyright (C) 2014, 2015, 2016 Francis Rowe # Copyright (C) 2015 Klemens Nanni # # This program is free software: you can redistribute it and/or modify @@ -28,6 +28,10 @@ set -u -e printf "Building ROM images with the GRUB payload\n" +# The GRUB files should be deleted first +rm -f "coreboot/grub"*.{elf,cfg} +rm -f "coreboot/"*/*/grub*.{elf,cfg} + [ -d bin ] || mkdir "bin/" # Put GRUB payloads and config files @@ -136,5 +140,6 @@ fi # The GRUB files are no longer needed rm -f "coreboot/grub"*.{elf,cfg} +rm -f "coreboot/"*/*/grub*.{elf,cfg} printf "\n\n" diff --git a/resources/scripts/helpers/build/roms/withgrub_helper b/resources/scripts/helpers/build/roms/withgrub_helper index b952417..009028e 100755 --- a/resources/scripts/helpers/build/roms/withgrub_helper +++ b/resources/scripts/helpers/build/roms/withgrub_helper @@ -2,7 +2,7 @@ # helper script: create ROM images for a given system, with GRUB # -# Copyright (C) 2014, 2015 Francis Rowe +# Copyright (C) 2014, 2015, 2016 Francis Rowe # Copyright (C) 2015 Klemens Nanni # # This program is free software: you can redistribute it and/or modify @@ -36,7 +36,11 @@ boardtarget="${1}" printf "GRUB Helper script: build ROM images for '%s'\n" "${boardtarget}" -cd "coreboot/" +( +cd "coreboot/grub/${boardtarget}/" + +# Make sure to remove these first +rm -f "grub."*{elf,cfg} if [ -f "../version" ]; then # release archive is being used @@ -53,11 +57,11 @@ if [ "${boardtarget}" = "qemu_i440fx_piix4" ] || [ "${boardtarget}" = "qemu_q35_ then # assume that the default config enable framebuffer mode, duplicate and patch for text-mode # necessary, otherwise it will ask you to enter the Y/X resolution of the framebuffer at build time - cp "../resources/libreboot/config/grub/${boardtarget}/config" "config_vesafb" + cp "../../../resources/libreboot/config/grub/${boardtarget}/config" "config_vesafb" sed 's/CONFIG_FRAMEBUFFER_KEEP_VESA_MODE=y/# CONFIG_FRAMEBUFFER_KEEP_VESA_MODE is not set/' < "config_vesafb" > "config_txtmode" else # assume that the default config enables text-mode, duplicate and patch for framebuffer mode - cp "../resources/libreboot/config/grub/${boardtarget}/config" "config_txtmode" + cp "../../../resources/libreboot/config/grub/${boardtarget}/config" "config_txtmode" sed 's/# CONFIG_FRAMEBUFFER_KEEP_VESA_MODE is not set/CONFIG_FRAMEBUFFER_KEEP_VESA_MODE=y/' < "config_txtmode" > "config_vesafb" fi @@ -83,9 +87,9 @@ do # Build coreboot ROM image make clean mv "config_${romtype}" ".config" - mv "grub_${romtype}.elf" "grub.elf" + cp "../../grub_${romtype}.elf" "grub.elf" make -j"$(nproc)" - mv "grub.elf" "grub_${romtype}.elf" + rm -f "grub.elf" mv "build/coreboot.rom" "${boardtarget}_${romtype}.rom" # .config no longer needed rm -f ".config" @@ -95,14 +99,14 @@ do then if [ "$1" = "macbook21" ] || [ "$1" = "x200_4mb" ] || [ "$1" = "x200_8mb" ] || [ "$1" = "r400_4mb" ] || [ "$1" = "r400_8mb" ] || [ "$1" = "r500_4mb" ] || [ "$1" = "r500_8mb" ] || [ "$1" = "t400_4mb" ] || [ "$1" = "t400_8mb" ] || [ "$1" = "t500_4mb" ] || [ "$1" = "t500_8mb" ] then - ./util/cbfstool/cbfstool "${boardtarget}_${romtype}.rom" add -f ../resources/grub/background/background1280x800.png -n background.png -t raw + ./util/cbfstool/cbfstool "${boardtarget}_${romtype}.rom" add -f ../../../resources/grub/background/background1280x800.png -n background.png -t raw else - ./util/cbfstool/cbfstool "${boardtarget}_${romtype}.rom" add -f ../resources/grub/background/background1024x768.png -n background.png -t raw + ./util/cbfstool/cbfstool "${boardtarget}_${romtype}.rom" add -f ../../../resources/grub/background/background1024x768.png -n background.png -t raw fi fi # Add the correct GRUB configuration file for this image. - for keylayout in ../resources/utilities/grub-assemble/keymap/original/* + for keylayout in ../../../resources/utilities/grub-assemble/keymap/original/* do keymap="${keylayout##*/}" @@ -110,9 +114,9 @@ do cp "${boardtarget}_${romtype}.rom" "${boardtarget}_${keymap}_${romtype}.rom" # Insert grub config into the image - ./util/cbfstool/cbfstool "${boardtarget}_${keymap}_${romtype}.rom" add -f "grub_${keymap}_${romtype}.cfg" -n grub.cfg -t raw + ./util/cbfstool/cbfstool "${boardtarget}_${keymap}_${romtype}.rom" add -f ../../"grub_${keymap}_${romtype}.cfg" -n grub.cfg -t raw # Insert grub test config into the image (for the user to test modifications to before modifying the main one) - ./util/cbfstool/cbfstool "${boardtarget}_${keymap}_${romtype}.rom" add -f "grub_${keymap}_${romtype}_test.cfg" -n grubtest.cfg -t raw + ./util/cbfstool/cbfstool "${boardtarget}_${keymap}_${romtype}.rom" add -f ../../"grub_${keymap}_${romtype}_test.cfg" -n grubtest.cfg -t raw done # This config-less ROM is no longer needed @@ -127,15 +131,13 @@ mkdir "${boardtarget}/" mv "${boardtarget}"*.rom "${boardtarget}/" # delete old ROM images -rm -Rf "../bin/grub/${boardtarget}/" +rm -Rf "../../../bin/grub/${boardtarget}/" # put new ROM images in ../bin/grub/ -[ -d "../bin/grub/" ] || mkdir -p "../bin/grub/" -mv "${boardtarget}/" "../bin/grub/" +[ -d "../../../bin/grub/" ] || mkdir -p "../../../bin/grub/" +mv "${boardtarget}/" "../../../bin/grub/" # version info file no longer needed rm -f ".coreboot-version" - -# go back to main source directory -cd "../" +) printf "\n\n" diff --git a/resources/scripts/helpers/download/coreboot b/resources/scripts/helpers/download/coreboot index 9c34e05..a080c84 100755 --- a/resources/scripts/helpers/download/coreboot +++ b/resources/scripts/helpers/download/coreboot @@ -2,7 +2,7 @@ # helper script: downloads coreboot and patches/deblobs it # -# Copyright (C) 2014, 2015 Francis Rowe +# Copyright (C) 2014, 2015, 2016 Francis Rowe # Copyright (C) 2015 Paul Kocialkowski # # This program is free software: you can redistribute it and/or modify @@ -25,6 +25,95 @@ [ "x${DEBUG+set}" = 'xset' ] && set -v set -u -e +if [ -f "version" ]; then + # _src release archive is being used + version="libreboot-$(cat version)" +else + # git repo is being used + version="libreboot-$(git describe --tags HEAD)" +fi + +# sanity check (check for invalid paths in the reused.list patch lists before proceeding) +for payloads in resources/libreboot/config/*; do + + if [ ! -d "${payloads}/" ]; then + continue + fi + + payload="${payloads##*/}" + + for boardconfig in resources/libreboot/config/${payload}/*; do + + if [ ! -d "${boardconfig}/" ]; then + continue + fi + + boardname="${boardconfig##*/}" + cbrevision=$(cat "${boardconfig}/cbrevision") + vbootrevision=$(cat "${boardconfig}/vbootrevision") + + reused_coreboot_patches="resources/libreboot/patch/coreboot/${cbrevision}/${payload}/${boardname}/reused.list" + reused_vboot_patches="resources/libreboot/patch/vboot/${vbootrevision}/${payload}/${boardname}/reused.list" + for reused_patches in "${reused_coreboot_patches}" "${reused_vboot_patches}"; do + if [ -f "${reused_patches}" ]; then + for patch in $(cat "${reused_patches}"); do + if [ ! -f "./${patch}" ]; then + printf "%s listed in %s does not exist\n" "${patch}" "${reused_patches}" + exit 1 + fi + done + fi + done + + done +done + +# in ascending filename order, apply patches from a directory +apply_patches_from_directory() { + patch_directory="${1}" # directory containing the patch files + + if [ -d "${patch_directory}" ]; then + for patch in ${patch_directory}/*.patch; do + + if [ "${patch##*/}" = "*.patch" ]; then # oh so ugly + continue # ugly ugly ugly ugly ugly + fi # most hideous thing you've ever seen + + git am "${patch}" || return 1 + done + fi +} +# files listed in the file (if found) are absolute paths, relative to the root of the libreboot src directory +# the file lists patches patches that should be applied +apply_patches_from_file() { + patch_list="${1}" # file listing the paths to all the patches + libreboot_src_root="${2}" # path to the root of the libreboot_src directory + + if [ -f "${patch_list}" ]; then + for patchname in $(cat "${patch_list}"); do + git am "${libreboot_src_root}/${patchname}" || return 1 + done + fi +} +make_coreboot_src_directory() { + payload="${1}" + boardname="${2}" + firmwarepath="${3}" # libreboot_src/coreboot/ +( + cd "${firmwarepath}/" + # copy coreboot directory there + rm -Rf "${payload:?}/${boardname:?}/" + if [ ! -d "${payload}/" ]; then + mkdir -p "${payload}/" + fi + cp -R "coreboot/" "${payload}/${boardname}/" +) +} +reset_at_revision() { + revision="${1}" + git reset --hard ${revision} +} + printf "Downloading coreboot, patching coreboot and deblobbing coreboot\n" # This grabs current base used, and applies patches @@ -35,6 +124,10 @@ printf "Downloading coreboot, patching coreboot and deblobbing coreboot\n" rm -Rf "coreboot/" +mkdir "coreboot/" + +cd "coreboot/" + # Get latest coreboot: # ------------------------------------------------------------------------------ @@ -44,132 +137,123 @@ git clone http://review.coreboot.org/coreboot # there are modifications required cd "coreboot/" -# reset to previously tested revision -git reset --hard 33fb4cf0ffb01be8bcb6b488872c87eb50e7d77f +# Define a common version (based on the libreboot version) +# Most likely redundant, because the build system needs to update +# this every time when building a ROM image anyway +printf '%s\n' "${version}" >".coreboot-version" # vboot submodule is needed -git submodule update --init --checkout -- 3rdparty/vboot/ - -# there are modifications required -cd "3rdparty/vboot/" - -# reset vboot to last known good revision -git reset --hard fbf631c845c08299f0bcbae3f311c5807d34c0d6 - -# Patch vboot # ------------------------------------------------------------------------------ -printf "firmware: Developer mode timeout delay shortening (down to 3 seconds)\n" -git am "../../../resources/libreboot/patch/vboot/0001-firmware-Developer-mode-timeout-delay-shortening-dow.patch" - -printf "firmware: Text-based screen display in priority\n" -git am "../../../resources/libreboot/patch/vboot/0002-firmware-Text-based-screen-display-in-priority.patch" - -printf "firmware: NV context pointer handoff to VbExDisplayScreen\n" -git am "../../../resources/libreboot/patch/vboot/0003-firmware-NV-context-pointer-handoff-to-VbExDisplaySc.patch" - -printf "firmware: Hold key combination in developer mode\n" -git am "../../../resources/libreboot/patch/vboot/0004-firmware-Hold-key-combination-in-developer-mode.patch" - -printf "firmware: Screen blank and wait at disabled USB boot warning\n" -git am "../../../resources/libreboot/patch/vboot/0005-firmware-Screen-blank-and-wait-at-disabled-USB-boot-.patch" - -printf "firmware: Separate screen and wait at device information screen\n" -git am "../../../resources/libreboot/patch/vboot/0006-firmware-Separate-screen-and-wait-at-device-informat.patch" - -printf "firmware: Localization keys removal\n" -git am "../../../resources/libreboot/patch/vboot/0007-firmware-Localization-keys-removal.patch" - -# leave the vboot tree -cd "../../" - +git submodule update --init --checkout -- 3rdparty/vboot/ -# Get patches from review.coreboot.org +# Create branches, with patches in each branch +# Create separate coreboot source directories *for each board* # ------------------------------------------------------------------------------ -printf "mainboard/lenovo/t400: Add initial hybrid graphics support\n" -git am "../resources/libreboot/patch/misc/0001-mainboard-lenovo-t400-Add-initial-hybrid-graphics-su.patch" -# git fetch http://review.coreboot.org/coreboot refs/changes/19/9319/18 && git cherry-pick FETCH_HEAD +for payloads in ../../resources/libreboot/config/*; do + + if [ ! -d "${payloads}/" ]; then + continue + fi -# not included, but keep an eye on it: -# printf "mainboard/lenovo/t400: Increase backlight frequency to reduce flicker\n" -# git fetch http://review.coreboot.org/coreboot refs/changes/31/9331/14 && git cherry-pick FETCH_HEAD + payload="${payloads##*/}" -printf "NOTFORMERGE: lenovo/t400: hard-code enable integrated-only video\n" -git am "../resources/libreboot/patch/misc/0002-NOTFORMERGE-lenovo-t400-hard-code-enable-integrated-.patch" -# git fetch http://review.coreboot.org/coreboot refs/changes/50/10550/1 && git cherry-pick FETCH_HEAD + for boardconfig in ../../resources/libreboot/config/${payload}/*; do -printf "lenovo/x60: use correct BLC_PWM_CTL value\n" -git am "../resources/libreboot/patch/misc/0003-lenovo-x60-use-correct-BLC_PWM_CTL-value.patch" -# git fetch http://review.coreboot.org/coreboot refs/changes/24/10624/2 && git cherry-pick FETCH_HEAD + if [ ! -d "${boardconfig}/" ]; then + continue + fi -printf "lenovo/t60: Enable brightness controls (native graphics)\n" -git am "../resources/libreboot/patch/misc/0004-lenovo-t60-Enable-brightness-controls-native-graphic.patch" -# git fetch http://review.coreboot.org/coreboot refs/changes/52/10552/2 && git cherry-pick FETCH_HEAD + boardname="${boardconfig##*/}" + cbrevision=$(cat "${boardconfig}/cbrevision") + vbootrevision=$(cat "${boardconfig}/vbootrevision") -printf "ec/lenovo/h8: permanently enable wifi/trackpoint/touchpad/bluetooth/wwan\n" -git am "../resources/libreboot/patch/misc/0005-NOTFORMERGE-ec-lenovo-h8-wlan-trackpoint-touchpad-bl.patch" -# git fetch http://review.coreboot.org/coreboot refs/changes/58/7058/9 && git cherry-pick FETCH_HEAD + make_coreboot_src_directory ${payload} ${boardname} .. -# NOTE: remove this when updating to the latest version of coreboot. this patch -# makes the patch below redundant: https://review.coreboot.org/#/c/12814/ -printf "northbridge/gm45/raminit.c: enable GS45 high-perf (i.e. add X200S support to libreboot)\n" -git am "../resources/libreboot/patch/misc/0006-northbridge-gm45-raminit.c-enable-GS45-high-performa.patch" -# git fetch http://review.coreboot.org/coreboot refs/changes/35/11135/3 && git cherry-pick FETCH_HEAD + # patch that version + ( -# Patch removed for now, affected by this patch: -# http://review.coreboot.org/#/c/11702/ -# printf "fix uneven backlight on X200 (when setting brightness low)\n" -# git fetch http://review.coreboot.org/coreboot refs/changes/79/7979/2 && git cherry-pick FETCH_HEAD + cd "../${payload}/${boardname}/" + reset_at_revision ${cbrevision} -# NOTE: remove this when updating coreboot. This has been merged upstream -printf "ThinkPad R400 support (clone of the T400)\n" -git am "../resources/libreboot/patch/misc/0007-lenovo-r400-Add-clone-of-Lenovo-T400.patch" -# git fetch http://review.coreboot.org/coreboot refs/changes/93/8393/5 && git cherry-pick FETCH_HEAD + # apply patches (coreboot, common to all systems using this revision) + apply_patches_from_directory "../../../resources/libreboot/patch/common/coreboot/${cbrevision}" + # apply patches re-used from other boards, before applying main patches (common patches for similar boards) + apply_patches_from_file "../../../resources/libreboot/patch/coreboot/${cbrevision}/${payload}/${boardname}/reused.list" ../../.. + # apply patches (coreboot, machine-specific for this revision) + apply_patches_from_directory "../../../resources/libreboot/patch/coreboot/${cbrevision}/${payload}/${boardname}" -# NOTE: remove this when updating coreboot. This has been merged upstream -printf "ThinkPad T500 (depends on T400 patch)\n" -git am "../resources/libreboot/patch/misc/0008-lenovo-t500-Add-clone-of-Lenovo-T400.patch" -# git fetch http://review.coreboot.org/coreboot refs/changes/45/10545/1 && git cherry-pick FETCH_HEAD + cd "3rdparty/vboot/" + # reset to known revision (vboot) + reset_at_revision ${vbootrevision} -# CrOS: + # apply patches (vboot, common to all systems using this revision) + apply_patches_from_directory "../../../../../resources/libreboot/patch/common/vboot/${vbootrevision}" + # apply patches re-used from other boards, before applying main patches (common patches for similar boards) + apply_patches_from_file "../../../../../resources/libreboot/patch/vboot/${vbootrevision}/${payload}/${boardname}/reused.list" ../../../../.. + # apply patches (vboot, machine-specific for this revision) + apply_patches_from_directory "../../../../../resources/libreboot/patch/vboot/${vbootrevision}/${payload}/${boardname}" -printf "chromeos: Allow disabling vboot firmware verification when ChromeOS is enabled\n" -git am "../resources/libreboot/patch/cros/0001-chromeos-Allow-disabling-vboot-firmware-verification.patch" + ) + done +done -# KGPE-D16 patches -# new versions can be found at https://raptorengineeringinc.com/coreboot/kgpe-d16-status.php -for i in ../resources/libreboot/patch/kgpe-d16/*; do - git am "${i}" +# prepare directories for crossgcc +for payloads in ../../resources/libreboot/config/*; do + + if [ ! -d "${payloads}/" ]; then + continue + fi + + payload="${payloads##*/}" + + for boardconfig in ../../resources/libreboot/config/${payload}/*; do + + if [ ! -d "${boardconfig}/" ]; then + continue + fi + + boardname="${boardconfig##*/}" + cbrevision=$(cat "${boardconfig}/cbrevision") + vbootrevision=$(cat "${boardconfig}/vbootrevision") + + # Create coreboot directory for compiling crossgcc + if [ ! -d "../crossgcc/${cbrevision}" ]; then + make_coreboot_src_directory crossgcc ${cbrevision} .. + ( + cd "../crossgcc/${cbrevision}/" + # reset to known revision (coreboot) + reset_at_revision ${cbrevision} + # no way to know which vboot revision is used here, so delete 3rdparty + rm -Rf "3rdparty/" + ) + fi + done done -# Temporary fix (TODO: get tpearson to fix properly): -# Remove code from coreboot that adds microcode updates -# git fetch http://review.coreboot.org/coreboot refs/changes/90/12090/1 && git cherry-pick FETCH_HEAD -git am "../resources/libreboot/patch/tmpfix/0001-NOTFORMERGE-don-t-add-CPU-microcode-on-fam10h-to-fam.patch" + +# go back to _src/coreboot/ (containing all coreboot directories) +cd "../" +# delete the gitted one (not needed anymore) +rm -Rf "coreboot/" # Run coreboot-libre deblob scripts # ------------------------------------------------------------------------------ printf "Deleting .git* in coreboot/ (history inside .git contains the blobs that were deleted)\n" -rm -Rf ".git/" -rm -f ".gitreview" -rm -f ".gitmodules" -rm -f ".gitignore" - -rm -Rf 3rdparty/*/.git* - +rm -Rf */*/.git* +rm -Rf */*/3rdparty/*/.git* + +# Delete crossgcc from non-crossgcc coreboot archives +# (the build system will create symlinks later when building the ROM images) +for payload in *; do + if [ "${payload##*/}" != "crossgcc" ]; then + rm -Rf ${payload}/*/util/crossgcc/ + fi +done cd "../" printf "Deblobbing coreboot\n" ./resources/utilities/coreboot-libre/deblob -if [ -f "version" ]; then - # _src release archive is being used - version="libreboot-$(cat version)" -else - # git repo is being used - version="libreboot-$(git describe --tags HEAD)" -fi -printf '%s\n' "${version}" >"coreboot/.coreboot-version" - printf "\n\n" -- cgit v0.9.1