pragmatic system distribution guideline compliance

osboot is now part of libreboot, and will soon shut down.
libreboot now conforms to osboot policy.
This commit is contained in:
Leah Rowe
2022-11-14 00:51:12 +00:00
parent b5c25efed4
commit 7af9953463
167 changed files with 17806 additions and 1421 deletions
+151
View File
@@ -0,0 +1,151 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2022 Caleb La Grange <thonkpeasant@protonmail.com>
# SPDX-License-Identifier: GPL-3.0-only
board="${1}"
# A shorthand for each board so as not to duplicate blobs for boards of different sizes
board_short=${board%%_*mb}
# Allow adding only blobs that can be legally redistributed (ifd+gbe)
if [ "${2}" = "redistributable" ]; then
redistributable=true
else
redistributable=false
fi
Download_needed(){
for need in ${needs}; do
case ${need} in
*ME*)
Extract_me || _failed+=" me"
;;
*MRC*)
./download mrc || _failed+=" mrc"
;;
esac
done
if [ ! -z ${_failed+x} ]; then
printf "\nERROR: failed to obtain${_failed}\nrun: './blobutil extract ${board} /path/to/romdump.rom' to extract the remaining blobs\n"
exit 1
fi
}
Extract_me(){
_me_destination=${CONFIG_ME_BIN_PATH#../../}
if [ -f "${_me_destination}" ]; then
printf 'me already downloaded\n'
return 0
fi
if [ -z "${me_dl+x}" ]; then
printf 'no me download available for this board\n'
return 1
fi
if [ ! -d "${_me_destination%/*}" ]; then
mkdir -p ${_me_destination%/*}
fi
printf "Extracting neutered me for ${board}\n"
# Delete old me downloads in case user is building for multiple boards
if [ -f "blobs/me.exe" ]; then
rm blobs/me.exe
fi
if [ -d "blobs/app" ]; then
rm -r blobs/app
fi
curl ${me_dl} > blobs/me.exe || curl ${me_dl_bkup} > blobs/me.exe
if [ ! "$(sha1sum blobs/me.exe)" = "${me_hash} blobs/me.exe" ]; then
printf 'checksum of downloaded me did not mactch\ncorrupted me downloaded or wrong me for board\n'
rm blobs/me.exe
return 1
fi
( cd blobs && innoextract me.exe )
printf 'extracting and stripping intel management engine\n'
./me_cleaner/me_cleaner.py -r -t -O ${_me_destination} blobs/app/*ME*.bin \
|| ./resources/blobs/me7_update_parser.py -O ${_me_destination} blobs/app/ME7*.bin
printf "Truncated and cleaned me output to ${_me_destination}\n"
}
Build_deps(){
if [ ! -d me_cleaner ]; then
printf "downloading me_cleaner\n"
./download me_cleaner
fi
if [ ! -d coreboot/default ]; then
printf "downloading coreboot\n"
./download coreboot default
fi
if [ ! -f "coreboot/default/util/ifdtool/ifdtool" ]; then
printf "building ifdtool from coreboot\n"
( cd coreboot/default/util/ifdtool && make )
fi
}
set -- "resources/coreboot/${board}/config/*"
. ${1} 2>/dev/null
. "resources/coreboot/${board}/board.cfg"
if [ "${CONFIG_HAVE_MRC}" = "y" ]; then
if [ "${redistributable}" = "false" ]; then
printf 'haswell board detected, downloading mrc\n'
needs+=" MRC"
fi
fi
if [ "${CONFIG_HAVE_IFD_BIN}" = "y" ]; then
printf 'board needs intel firmware descriptor\n'
needs+=" IFD"
fi
if [ "${CONFIG_HAVE_ME_BIN}" = "y" ]; then
if [ "${redistributable}" = "false" ]; then
printf 'board needs intel management engine\n'
needs+=" ME"
fi
fi
if [ "${CONFIG_HAVE_GBE_BIN}" = "y" ]; then
printf 'board needs gigabit ethernet firmware\n'
needs+=" GBE"
fi
# Quickly exit without wasting more time if there are no blobs needed (GM45)
if [ -z ${needs+x} ]; then
printf 'No binary blobs needed for this board\n'
exit 0
fi
Build_deps
while read -r line ; do
case ${line} in
ME_hash*)
set ${line}
me_hash=${2}
;;
ME_dl*)
set ${line}
me_dl=${2}
;;
ME_bkup_dl*)
set ${line}
me_dl_bkup=${2}
;;
esac
done <<< $(eval "awk ' /\{.*${board_short}.*}{/ {flag=1;next} /\}/{flag=0} flag { print }' resources/blobs/sources")
Download_needed
+89
View File
@@ -0,0 +1,89 @@
#!/usr/bin/env bash
# script to automate extracting blobs from an existing vendor bios
# SPDX-FileCopyrightText: 2022 Caleb La Grange <thonkpeasant@protonmail.com>
# SPDX-License-Identifier: GPL-3.0-only
board="${1}"
vendor_rom="${2}"
Print_help(){
printf "Usage: ./blobutil extract {boardname} {path/to/vendor_rom}\n"
printf "Example: ./blobutil extract x230 12mb_flash.bin\n"
printf "\nYou need to specify exactly 2 arguments\n"
}
Build_deps(){
if [ ! -d me_cleaner ]; then
printf "downloading me_cleaner\n"
./download me_cleaner
else
printf "me_cleaner already downloaded. Skipping.\n"
printf "run ./download me_cleaner to manually overwrite\n"
fi
if [ ! -d coreboot/default ]; then
printf "downloading coreboot\n"
./download coreboot default
else
printf "coreboot already downloaded. Skipping.\n"
printf "run ./download coreboot to manually overwrite\n"
fi
printf "building ifdtool from coreboot\n"
( cd coreboot/default/util/ifdtool && make )
}
Error_out(){
printf "failed to extract ${1}\nmake sure that your rom dump is valid\n"
exit 1
}
Extract_blobs(){
# TODO: find a better way to know which coreboot config to source
set -- "resources/coreboot/${board}/config/*"
. ${1} 2>/dev/null
. "resources/coreboot/${board}/board.cfg"
if [ "$CONFIG_HAVE_MRC" = "y" ]; then
printf 'haswell board detected, downloading mrc\n'
./download mrc
fi
_me_destination=${CONFIG_ME_BIN_PATH#../../}
_gbe_destination=${CONFIG_GBE_BIN_PATH#../../}
_ifd_destination=${CONFIG_IFD_BIN_PATH#../../}
printf "extracting clean ime and modified ifd\n"
./me_cleaner/me_cleaner.py -D ${_ifd_destination} -M ${_me_destination} ${vendor_rom} -t -r -S || Error_out me
printf "extracting gigabit ethernet firmware"
./coreboot/default/util/ifdtool/ifdtool -x ${vendor_rom}
mv flashregion*gbe.bin ${_gbe_destination} || Error_out gbe
# Cleans up other files extracted with ifdtool
rm flashregion*.bin 2> /dev/null
printf "gbe, ifd, and me extracted to ${_me_destination%/*}\n"
}
if [ ! -f "${vendor_rom}" ] ; then
Print_help
exit 1
fi
if [ ! -d "resources/coreboot/${board}" ]; then
Print_help
printf "build/roms: Target %s does not exist in the %s build system. Skipping build.\n" "${projectname}" "${board}"
exit 1
fi
if [ ! -f "resources/coreboot/${board}/board.cfg" ]; then
Print_help
printf "build/roms: Target %s does not have a board.cfg. Skipping build.\n" "${board}"
exit 1
fi
printf "extracting blobs for ${board} from ${vendor_rom}\n"
Build_deps
Extract_blobs
+152
View File
@@ -0,0 +1,152 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2022 Caleb La Grange <thonkpeasant@protonmail.com>
# SPDX-License-Identifier: GPL-3.0-only
Error_out(){
if [ ! -z ${@+x} ]; then
printf "ERROR: ${@}\n"
fi
cat <<- EOF
USAGE: ./blobutil inject -r [/path/to/rom] -b [boardname] -m [macaddress]
Example: ./blobutil inject -r x230_12mb.rom -b x230_12mb
Adding a macadress to the gbe is optional.
If the [-m] parameter is left blank, the gbe will not be touched.
Type './blobutil inject listboards' to get a list of valid boards
EOF
exit 1
}
Modify_gbe(){
printf "changing mac address in gbe to ${new_mac}\n"
_gbe_location=${CONFIG_GBE_BIN_PATH#../../}
if [ ! -d nvmutils/ ]; then
git clone https://notabug.org/osboot/nvmutils
if [ ! -d nvmutils/ ]; then
printf "E: could not download nvmutils"
exit 1
fi
(
cd nvmutils/
git reset --hard ba9f5ada6a05d7ef8af45e30b700cd627a055867
)
fi
if [ ! -f nvmutils/nvmmac ]; then
( cd nvmutils/ && make )
fi
_gbe_tmp=$(mktemp -t gbeXXXX.bin)
cp ${_gbe_location} ${_gbe_tmp}
./nvmutils/nvmmac ${_gbe_tmp} ${new_mac} || Error_out 'failed to modify mac address\nmake sure the mac address in the correct format'
./coreboot/default/util/ifdtool/ifdtool -i GbE:${_gbe_tmp} ${rom} -O ${rom} || exit 1
rm ${_gbe_tmp}
}
listboards() {
for boarddir in resources/coreboot/*; do
if [ ! -d "${boarddir}" ]; then continue; fi
board="${boarddir##resources/coreboot/}"
board="${board%/}"
printf '%s\n' "${board##*/}"
done
}
# This function tries to determine the board from the filename of the rom.
# It will only succeed if the filename is not changed from the build/download
Detect_board(){
filename=$(basename ${rom})
case ${filename} in
grub_*)
board=$(cut -d '_' -f2-3 <<<${filename})
;;
seabios_grubfirst_*|seabios_withgrub_*)
board=$(cut -d '_' -f3-4 <<<${filename})
;;
*)
return 1
esac
if [ -d "resources/coreboot/${board}/" ]; then
printf '%s\n' "${board}"
else
return 1
fi
}
Patch(){
set -- "resources/coreboot/${board}/config/*"
. ${1} 2>/dev/null
. "resources/coreboot/${board}/board.cfg"
if [ "$CONFIG_HAVE_MRC" = "y" ]; then
printf 'adding mrc\n'
./coreboot/default/util/cbfstool/cbfstool ${rom} add -f mrc/haswell/mrc.bin -n mrc.bin -t mrc || exit 1
fi
if [ "${CONFIG_HAVE_ME_BIN}" = "y" ]; then
_me_location=${CONFIG_ME_BIN_PATH#../../}
printf 'adding intel management engine\n'
./coreboot/default/util/ifdtool/ifdtool -i me:${_me_location} ${rom} -O ${rom} || exit 1
fi
if [ "${modifygbe}" = "true" ]; then
Modify_gbe
fi
}
if [ "${1}" = "listboards" ]; then
listboards
exit 0
fi
# Implementing parameter parsing now so more options can be added later
while getopts r:b:m: option
do
case "${option}"
in
r)rom=${OPTARG};;
b)board=${OPTARG};;
m)
modifygbe=true
new_mac=${OPTARG}
;;
esac
done
if [ -z ${rom+x} ]; then
Error_out 'no rom specified'
elif [ ! -f "${rom}" ]; then
Error_out "${rom} is not a valid path"
elif [ -z ${board+x} ]; then
board=$(Detect_board) || \
Error_out 'no board specified'
fi
if [ ! -d "resources/coreboot/${board}/" ]; then
printf "board ${board} not found\n"
Error_out
fi
if [ ! -d coreboot/default ]; then
printf "downloading coreboot\n"
./download coreboot default
fi
if [ ! -f "coreboot/default/util/ifdtool/ifdtool" ]; then
printf "building ifdtool from coreboot\n"
( cd coreboot/default/util/ifdtool && make )
fi
if [ ! -f "coreboot/default/util/cbfstool/cbfstool" ]; then
printf "building cbfstool from coreboot\n"
( cd coreboot/default/util/cbfstool && make )
fi
./blobutil download ${board} && Patch
+58 -6
View File
@@ -5,6 +5,7 @@
#
# Copyright (C) 2014, 2015, 2016, 2020, 2021 Leah Rowe <info@minifree.org>
# Copyright (C) 2015 Klemens Nanni <contact@autoboot.org>
# Copyright (C) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
#
# 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
@@ -42,12 +43,18 @@ help() {
USAGE: ./build boot roms boardname
To build *all* boards, do this: ./build boot roms all
To list *all* boards, do this: ./build boot roms list
possible values for 'options':
$(listboards)
Optional Flags:
-d: displaymode
-p: payload
-k: keyboard layout
Example: ./build boot roms x60
Example: ./build boot roms x200_8mb x60
Example: ./build boot roms x230_12mb -p grub -d corebootfb -k usqwerty
possible values for 'boardname':
$(listboards)
Refer to the ${projectname} documentation for more information.
EOF
@@ -61,13 +68,33 @@ die() {
# Build ROM images for supported boards
buildrom() {
board="$1"
# Start by building blobs and placing them in the coreboot tree only for boards that need them
./blobutil download ${board} || exit 1
if [ -d "resources/coreboot/${board}/" ]; then
./build boot roms_helper "${board}"
./build boot roms_helper "${board}${opts}"
else
die "\nbuild/roms: target not defined in the build system: %s\n" "${board}"
fi
}
buildrom_release() {
board="$1"
if [ -d "resources/coreboot/${board}/" ]; then
./build release deblob ${board}
if [ "$?" = 2 ]; then
./build boot roms_helper "${board}"
else
./build boot roms_helper deblobbed "${board}"
fi
else
die "\nbuild/roms: target not defined in the build system: %s\n" "${board}"
fi
}
if [ $# -gt 0 ]; then
firstoption="${1}"
if [ "${firstoption}" = "help" ]; then
@@ -78,15 +105,40 @@ if [ $# -gt 0 ]; then
listboards
exit 0
fi
while [[ $# > 0 ]]; do
case ${1} in
-d)
opts+=" -d ${2}"
shift ;;
-p)
opts+=" -p ${2}"
shift ;;
-k)
opts+=" -k ${2}"
shift ;;
*)
boards+="${1} " ;;
esac
shift
done
if [ -z ${opts+x} ]; then
opts=""
fi
printf "Building %s ROM images\n" "${projectname}"
if [ "${firstoption}" = "all" ]; then
if [ "${firstoption}" = "release" ]; then
for boardname in $(listboards); do
buildrom_release "${boardname}" || die "build/roms: something went wrong"
done
elif [ "${firstoption}" = "all" ]; then
for boardname in $(listboards); do
buildrom "${boardname}" || die "build/roms: something went wrong"
done
else
for board in ${@}; do
for board in ${boards}; do
buildrom "${board}" || die "build/roms: something went wrong"
done
fi
+123 -53
View File
@@ -4,6 +4,7 @@
#
# Copyright (C) 2020,2021 Leah Rowe <info@minifree.org>
# Copyright (C) 2021 Vitali64 <vitali64pmemail@protonmail.com>
# Copyright (C) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
# Copyright (C) 2022 Alper Nebi Yasak <alpernebiyasak@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
@@ -23,22 +24,40 @@
# This script assumes that the working directory is the root
# of git or release archive
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
projectname="$(cat projectname)"
if (( $# != 1 )); then
printf "Usage: ./build boot roms boardname\n"
printf "Example: ./build boot roms x60\n"
printf "Example: ./build boot roms x60 x200_8mb\n"
printf "Example: ./build boot roms all\n"
printf "You need to specify exactly 1 argument\n"
exit 1
if [ "${1}" = "deblobbed" ]; then
deblobbed=true
shift
else
deblobbed=false
fi
board="${1}"
displaymodes=""
payloads=""
keyboard_layouts=""
while [[ $# > 0 ]]; do
case ${1} in
-d)
displaymodes+="${2}"
shift ;;
-p)
payloads+="${2}"
shift ;;
-k)
keyboard_layouts+="${2}"
shift ;;
*)
board=${1} ;;
esac
shift
done
echo "board is $board , kb is ${keyboard_layouts} , displaymode is ${displaymodes} , payloads is ${payloads}"
if [ ! -d "resources/coreboot/${board}" ]; then
printf "build/roms: Target %s does not exist in the %s build system. Skipping build.\n" "${projectname}" "${board}"
exit 1
@@ -140,6 +159,21 @@ if [ "${payload_memtest}" = "y" ]; then
fi
fi
# Override all payload directives with cmdline args
if [ ! -z ${payloads} ]; then
echo "setting payloads $payloads"
payload_grub="n"
payload_grub_withseabios="n" # seabios chainloaded from grub
payload_seabios="n"
payload_seabios_withgrub="n" # i386-coreboot grub accessible from SeaBIOS boot menu
seabios_opromloadonly="0"
payload_memtest="n"
for payload in ${payloads} ; do
eval "payload_${payload}=y"
done
fi
romdir="bin/${board}"
cbdir="coreboot/${board}"
if [ "${board}" != "${cbtree}" ]; then
@@ -222,8 +256,8 @@ if [ "${payload_grub}" = "y" ] || [ "${payload_seabios_withgrub}" = "y" ]; then
grubtestcfg="payload/grub/grub_${keymap}_test.cfg"
if [ ! -f "${grubelf}" ] || [ ! -f "${grubcfg}" ] || \
[ ! -f "${grubtestcfg}" ]; then
./build payload grub
[ ! -f "${grubtestcfg}" ]; then
./build payload grub
fi
done
fi
@@ -256,7 +290,7 @@ moverom() {
dd if=${rompath} of=${newrompath} bs=1 skip=$[$(stat -c %s ${rompath}) - 0x400000] count=4194304
else
cp ${rompath} ${newrompath}
fi
fi
# pike2008 cards cause a system hang when loading the option rom in seabios
# if there is an empty option rom in cbfs, no option rom will be loaded
@@ -276,26 +310,30 @@ moverom() {
./build descriptors ich9m
fi
dd if=descriptors/ich9m/ich9fdgbe_${romsize}m.bin of=${newrompath} bs=1 count=12k conv=notrunc
fi
if [ "${cuttype}" = "${romsize}MiB ICH9 IFD NOGBE NOR flash" ]; then
if [ ! -f "descriptors/ich9m/ich9fdnogbe_${romsize}m.bin" ]; then
./build descriptors ich9m
fi
dd if=descriptors/ich9m/ich9fdnogbe_${romsize}m.bin of=${newrompath} bs=1 count=4k conv=notrunc
fi
done
if [ "${cuttype}" = "${romsize}MiB ICH9 IFD NOGBE NOR flash" ]; then
if [ ! -f "descriptors/ich9m/ich9fdnogbe_${romsize}m.bin" ]; then
./build descriptors ich9m
fi
dd if=descriptors/ich9m/ich9fdnogbe_${romsize}m.bin of=${newrompath} bs=1 count=4k conv=notrunc
fi
done
if [ "${cuttype}" = "i945 laptop" ]; then
dd if=${newrompath} of=top64k.bin bs=1 skip=$[$(stat -c %s ${newrompath}) - 0x10000] count=64k
dd if=top64k.bin of=${newrompath} bs=1 seek=$[$(stat -c %s ${newrompath}) - 0x20000] count=64k conv=notrunc
rm -f top64k.bin
fi
}
if [ "${cuttype}" = "i945 laptop" ]; then
dd if=${newrompath} of=top64k.bin bs=1 skip=$[$(stat -c %s ${newrompath}) - 0x10000] count=64k
dd if=top64k.bin of=${newrompath} bs=1 seek=$[$(stat -c %s ${newrompath}) - 0x20000] count=64k conv=notrunc
rm -f top64k.bin
fi
}
# expected: configs must not specify a payload
mkCoreboot() {
cbdir="${1}" # e.g. coreboot/default
cbcfgpath="${2}" # e.g. resources/coreboot/x200_8mb/config/libgfxinit_txtmode
if ${deblobbed} ; then
cbcfgpath="${2}_deblobbed"
else
cbcfgpath="${2}" # e.g. resources/coreboot/x200_8mb/config/libgfxinit_txtmode
fi
if [ ! -f "${cbcfgpath}" ]; then
printf "\nmkCoreboot: Coreboot config '%s' does not exist. Skipping build.\n" \
"${cbcfgpath}"
@@ -303,8 +341,17 @@ mkCoreboot() {
fi
printf "%s-%s\n" "$(cat projectname)" "$(cat version)" > "${cbdir}/.coreboot-version"
(
if [ -f "${cbfstool}" ]; then
mv "${cbfstool}" "${cbdir}/cbfstool"
fi
cd "${cbdir}"
make distclean
make distclean
cd -
if [ -f "${cbdir}/cbfstool" ]; then
mv "${cbdir}/cbfstool" "${cbfstool}"
fi
)
cp "${cbcfgpath}" "${cbdir}"/.config
./build module cbutils ${cbdir#coreboot/}
@@ -321,7 +368,6 @@ make_seabios_rom() {
target_seabios_cbfs_path="${2}" # e.g. fallback/payload
target_opromloadonly="${3}" # 0 or 1. if 1, only load but don't execute oproms
target_initmode="${4}" # e.g. libgfxinit
cbfstool_path="${5}"
if [ "${target_initmode}" = "normal" ]; then
target_seabioself="payload/seabios/seabios_vgarom.elf"
@@ -347,7 +393,7 @@ make_seabios_rom() {
"${cbfstool}" "${tmprom}" add-int -i ${target_opromloadonly} -n etc/only-load-option-roms
if [ "${target_initmode}" = "libgfxinit" ]; then
"${cbfstool_path}" "${tmprom}" add -f "${target_seavgabios_rom}" -n vgaroms/seavgabios.bin -t raw
"${cbfstool}" "${tmprom}" add -f "${target_seavgabios_rom}" -n vgaroms/seavgabios.bin -t raw
fi
printf "%s\n" "${tmprom}"
@@ -379,8 +425,7 @@ make_uboot_payload_rom() {
make_grubrom_from_keymap() {
target_keymap="${1}"
target_cbrom="${2}"
cbfstool_path="${3}"
target_grubelf_cbfs_path="${4}" # e.g. fallback/payload
target_grubelf_cbfs_path="${3}" # e.g. fallback/payload
grubelf="payload/grub/grub_${target_keymap}.elf"
grubcfg="payload/grub/grub_${target_keymap}.cfg"
@@ -389,7 +434,7 @@ make_grubrom_from_keymap() {
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
cp "${target_cbrom}" "${tmprom}"
"${cbfstool_path}" "${tmprom}" add-payload -f "${grubelf}" -n ${target_grubelf_cbfs_path} -c lzma
"${cbfstool}" "${tmprom}" add-payload -f "${grubelf}" -n ${target_grubelf_cbfs_path} -c lzma
tmpgrubcfg=$(mktemp -t grub.cfg.XXXXXXXXXX)
tmpgrubtestcfg=$(mktemp -t grubtest.cfg.XXXXXXXXXX)
@@ -403,8 +448,8 @@ make_grubrom_from_keymap() {
cp "${grubcfg}" "${tmpgrubcfg}"
cp "${grubtestcfg}" "${tmpgrubtestcfg}"
fi
"${cbfstool_path}" "${tmprom}" add -f "${tmpgrubcfg}" -n grub.cfg -t raw
"${cbfstool_path}" "${tmprom}" add -f "${tmpgrubtestcfg}" -n grubtest.cfg -t raw
"${cbfstool}" "${tmprom}" add -f "${tmpgrubcfg}" -n grub.cfg -t raw
"${cbfstool}" "${tmprom}" add -f "${tmpgrubtestcfg}" -n grubtest.cfg -t raw
rm -f "${tmpgrubcfg}" "${tmpgrubtestcfg}"
backgroundfile="background1280x800.png"
@@ -413,7 +458,7 @@ make_grubrom_from_keymap() {
backgroundfile="background1024x768.png"
fi
backgroundfile="resources/grub/background/${backgroundfile}"
"${cbfstool_path}" "${tmprom}" add -f ${backgroundfile} -n background.png -t raw
"${cbfstool}" "${tmprom}" add -f ${backgroundfile} -n background.png -t raw
printf "%s\n" "${tmprom}"
}
@@ -426,9 +471,9 @@ mkRomsWithGrub() {
firstpayloadname="${4}" # allow values: grub, seabios, seabios_withgrub, seabios_grubfirst
if [ "${payload_grub_withseabios}" = "y" ] && [ "${firstpayloadname}" = "grub" ]; then
mv "$(make_seabios_rom "${tmprompath}" "seabios.elf" "${seabios_opromloadonly}" "${initmode}" "${cbfstool}")" "${tmprompath}"
mv "$(make_seabios_rom "${tmprompath}" "seabios.elf" "${seabios_opromloadonly}" "${initmode}")" "${tmprompath}"
elif [ "${payload_seabios_withgrub}" ] && [ "${firstpayloadname}" != "grub" ]; then
mv "$(make_seabios_rom "${tmprompath}" "fallback/payload" "${seabios_opromloadonly}" "${initmode}" "${cbfstool}")" "${tmprompath}"
mv "$(make_seabios_rom "${tmprompath}" "fallback/payload" "${seabios_opromloadonly}" "${initmode}")" "${tmprompath}"
if [ "${firstpayloadname}" = "seabios_grubfirst" ]; then
tmpbootorder=$(mktemp -t coreboot_rom.XXXXXXXXXX)
printf "/rom@img/grub2\n" > "${tmpbootorder}"
@@ -436,9 +481,18 @@ mkRomsWithGrub() {
rm -f "${tmpbootorder}"
"${cbfstool}" "${tmprompath}" add-int -i 0 -n etc/show-boot-menu
fi
fi
fi
for keymapfile in resources/grub/keymap/*; do
keymaps=""
if [ -z ${keyboard_layouts} ]; then
keymaps="resources/grub/keymap/*"
else
for keymapname in ${keyboard_layouts}; do
keymaps+="resources/grub/keymap/${keymapname}.gkb"
done
fi
for keymapfile in ${keymaps}; do
echo "keymaps is $keymaps, keymapfile is $keymapfile"
if [ ! -f "${keymapfile}" ]; then
continue
@@ -452,7 +506,7 @@ mkRomsWithGrub() {
grub_path_in_cbfs="img/grub2"
fi
tmpgrubrom="$(make_grubrom_from_keymap "${keymap}" "${tmprompath}" "${cbfstool}" "${grub_path_in_cbfs}")"
tmpgrubrom="$(make_grubrom_from_keymap "${keymap}" "${tmprompath}" "${grub_path_in_cbfs}")"
if [ "${initmode}" = "normal" ]; then
newrompath="${romdir}/${firstpayloadname}_${board}_${initmode}_${keymap}.rom"
else
@@ -483,7 +537,7 @@ mkRoms() {
if [ "${payload_seabios}" = "y" ]; then
if [ "${payload_seabios_withgrub}" = "n" ]; then
tmpseabiosrom="$(make_seabios_rom "${corebootrom}" "fallback/payload" "${seabios_opromloadonly}" "${initmode}" "${cbfstool}")"
tmpseabiosrom="$(make_seabios_rom "${corebootrom}" "fallback/payload" "${seabios_opromloadonly}" "${initmode}")"
if [ "${initmode}" = "normal" ]; then
newrompath="${romdir}/seabios_${board}_${initmode}.rom"
else
@@ -518,22 +572,38 @@ mkRoms() {
fi
}
initmode="libgfxinit"
for displaymode in corebootfb txtmode; do
cbcfgpath="resources/coreboot/${board}/config/${initmode}_${displaymode}"
if [ -z ${displaymodes} ]; then
initmode="libgfxinit"
for displaymode in corebootfb txtmode; do
cbcfgpath="resources/coreboot/${board}/config/${initmode}_${displaymode}"
mkRoms "${cbcfgpath}" "${displaymode}" "${initmode}"
done
initmode="vgarom"
for displaymode in vesafb txtmode; do
cbcfgpath="resources/coreboot/${board}/config/${initmode}_${displaymode}"
mkRoms "${cbcfgpath}" "${displaymode}" "${initmode}"
done
initmode="normal"
displaymode="txtmode"
cbcfgpath="resources/coreboot/${board}/config/${initmode}"
mkRoms "${cbcfgpath}" "${displaymode}" "${initmode}"
done
initmode="vgarom"
for displaymode in vesafb txtmode; do
cbcfgpath="resources/coreboot/${board}/config/${initmode}_${displaymode}"
mkRoms "${cbcfgpath}" "${displaymode}" "${initmode}"
done
else
echo "special displaymode defined as $displaymodes"
initmode="libgfxinit"
for displaymode in ${displaymodes}; do
cbcfgpath="resources/coreboot/${board}/config/${initmode}_${displaymode}"
mkRoms "${cbcfgpath}" "${displaymode}" "${initmode}"
done
initmode="normal"
displaymode="txtmode"
cbcfgpath="resources/coreboot/${board}/config/${initmode}"
mkRoms "${cbcfgpath}" "${displaymode}" "${initmode}"
initmode="vgarom"
for displaymode in ${displaymodes}; do
cbcfgpath="resources/coreboot/${board}/config/${initmode}_${displaymode}"
mkRoms "${cbcfgpath}" "${displaymode}" "${initmode}"
done
fi
(
cd "${cbdir}"
@@ -3,6 +3,7 @@
# arch script: installs build dependencies for Arch Linux
#
# Copyright (C) 2021 Melissa Goad <mszoopers@protonmail.com>
# Copyright (C) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
#
# 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
@@ -83,3 +84,8 @@ pacman -S --needed --noconfirm base-devel
# ------------------------------------------------------------
pacman -S --needed --noconfirm libpciaccess pciutils zlib libftdi base-devel libusb
# Management engine extraction dependencies
# ------------------------------------------------------------
pacman -S --needed --noconfirm innoextract
+8 -1
View File
@@ -3,6 +3,7 @@
# ubuntu2004 script: installs build dependencies for Ubuntu 20.04
#
# Copyright (C) 2014, 2015, 2021 Leah Rowe <info@minifree.org>
# Copyright (C) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
#
# 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
@@ -80,7 +81,7 @@ apt-get -y install build-essential perl
# Coreboot build dependencies (also requires build-essential and git)
# ------------------------------------------------------------
apt-get -y install libncurses5-dev doxygen iasl gdb flex bison build-essential git libssl-dev gnat
apt-get -y install libncurses5-dev doxygen iasl gdb flex bison build-essential git libssl-dev gnat python-is-python3
# For cross-compiling i686 target on x86_64 host.
[ "${arch}" -eq 0 ] && apt-get -y install lib32ncurses5-dev
@@ -102,3 +103,9 @@ apt-get -y install libpci-dev pciutils zlib1g-dev libftdi-dev build-essential li
# For cross-compiling i686 target on x86_64 host.
[ "${arch}" -eq 0 ] && apt-get -y install lib32z1-dev
# Blobs building dependencies (for me)
# ------------------------------------------------------------
apt-get -y install innoextract
@@ -4,6 +4,7 @@
#
# Copyright (C) 2021 Melody Goad <mszoopers@protonmail.com>
# Copyright (C) 2021 Wei Mingzhi <whistler@member.fsf.org>
# Copyright (C) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
#
# 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
@@ -3,6 +3,7 @@
# ubuntu2004 script: installs build dependencies for Ubuntu 20.04
#
# Copyright (C) 2014, 2015, 2021 Leah Rowe <info@minifree.org>
# Copyright (C) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
#
# 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
@@ -102,3 +103,9 @@ apt-get -y install libpci-dev pciutils zlib1g-dev libftdi-dev build-essential li
# For cross-compiling i686 target on x86_64 host.
[ "${arch}" -eq 0 ] && apt-get -y install lib32z1-dev
# Blobs building dependencies (for me)
# ------------------------------------------------------------
apt-get -y install innoextract
+7 -2
View File
@@ -67,12 +67,12 @@ xbps-install -y base-devel perl
# Coreboot build dependencies (also requires build-essential and git)
# ------------------------------------------------------------
xbps-install -y ncurses doxygen acpica-utils gdb flex bison base-devel git openssl gcc-ada
xbps-install -y ncurses doxygen acpica-utils gdb flex bison base-devel git openssl gcc-ada ncurses-devel
# GRUB build dependencies (also requires build-essential, bison and flex)
# ------------------------------------------------------------
xbps-install -y font-unifont-bdf autogen help2man base-devel bison flex dejavu-fonts-ttf texinfo rsync python3 libusb xz gawk device-mapper fuse gettext freetype
xbps-install -y font-unifont-bdf autogen help2man base-devel bison flex dejavu-fonts-ttf texinfo rsync python3 libusb xz gawk device-mapper fuse gettext gettext-devel freetype
# BucTS build dependencies (external script)
# ------------------------------------------------------------
@@ -83,3 +83,8 @@ xbps-install -y base-devel
# ------------------------------------------------------------
xbps-install -y libpciaccess pciutils zlib libftdi1 base-devel libusb
# Management engine extraction dependencies
# ------------------------------------------------------------
xbps-install -y innoextract
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2022 Caleb La Grange <thonkpeasant@protonmail.com>
# SPDX-License-Identifier: GPL-3.0-only
board="${1}"
board_config_dir="resources/coreboot/${board}/config"
set -- "${board_config_dir}/*"
. ${1} 2>/dev/null
if [ "${CONFIG_HAVE_MRC}" = "y" ] || [ "${CONFIG_HAVE_ME_BIN}" = "y" ]; then
rm ${board_config_dir}/*_deblobbed
for config in ${board_config_dir}/* ; do
grep -v 'CONFIG_HAVE_ME_BIN\|CONFIG_ME_BIN_PATH\|CONFIG_HAVE_MRC\|CONFIG_MRC_FILE' ${config} > "${config}_deblobbed"
done
./blobutil download ${board} redistributable
else
# Quickly exits for boards requiring no blobs
exit 2
fi
+1 -1
View File
@@ -37,7 +37,7 @@ if [ -f versiondate ]; then
fi
if [ ! -d "bin/" ]; then
./build boot roms all
./build boot roms release
fi
[ ! -d "release/" ] && \
+16 -3
View File
@@ -53,9 +53,9 @@ mkdir -p "${srcdir}/"
printf "%s" "${version}" > "${srcdir}"/version
modlist="coreboot flashrom grub memtest86plus seabios ich9utils"
dirlist="resources"
filelist="download build README.md COPYING Makefile update version versiondate projectname .gitcheck"
modlist="coreboot flashrom grub memtest86plus seabios ich9utils me_cleaner"
dirlist="resources" # do not add blobs directory here. it is handled below
filelist="blobutil modify download build README.md COPYING Makefile update version versiondate projectname .gitcheck"
for modname in ${modlist}; do
if [ ! -d "${modname}/" ]; then
@@ -67,6 +67,19 @@ for dir in ${modlist} ${dirlist}; do
cp -R "${dir}/" "${srcdir}/"
done
mkdir -p "${srcdir}"/blobs
# do not copy intel ME etc, but do copy ifd/gbe files
for i in t440p w541 xx20 xx30; do
for j in ifd gbe 16_ifd; do
if [ -f "blobs/${i}/${j}.bin"]; then
if [ ! -e "${srcdir}/blobs/${i}" ]; then
mkdir -p "${srcdir}/blobs/${i}"
fi
cp blobs/${i}/${j}.bin "${srcdir}/blobs/${i}"
fi
done
done
for i in ${filelist}; do
if [ ! -f "${i}" ]; then
printf "build/release/src: ERROR: file '%s' does not exist.\n" "${i}"
+10 -50
View File
@@ -62,19 +62,6 @@ elif [ $# -eq 1 ] && [ "$1" == "--list-boards" ] ; then
exit 0
fi
# set this when you want to modify each coreboot tree
# for example, you want to test custom patches
# NODELETE= ./download coreboot
deletegit="true"
deleteblobs="true"
if [ "x${NODELETE+set}" = 'xset' ]; then
[ "x${NODELETE:-all}" = "xgit" ] && deletegit="false"
[ "x${NODELETE:-all}" = "xall" ] && deleteblobs="false" && deletegit="false"
fi
# Error handling is extreme in this script.
# This script handles the internet, and Git. Both are inherently unreliable.
[[ -f build_error ]] && rm -f build_error
rm -f resources/coreboot/*/seen
@@ -152,25 +139,25 @@ downloadfor() {
if [ ! -d coreboot ]; then
printf "Download coreboot from upstream:\n"
git clone --depth=1 https://review.coreboot.org/coreboot || rm -Rf coreboot
git clone https://review.coreboot.org/coreboot || rm -Rf coreboot
if [ ! -d coreboot ]; then
printf "WARNING: Upstream failed. Trying backup github repository:\n"
git clone --depth=1 https://github.com/coreboot/coreboot.git || rm -Rf coreboot
git clone https://github.com/coreboot/coreboot.git || rm -Rf coreboot
fi
if [ ! -d coreboot ]; then
printf "ERROR: download/coreboot: Problem with git-clone. Network issue?\n"
cd ../; return 1
fi
fi
( cd coreboot/; git fetch --depth=1 origin "${cbrevision}" || touch ../build_error )
if [ -f ../build_error ]; then
printf "ERROR: download/coreboot: Problem with git-fetch. Network issue?\n"
cd ../; return 1
else
( cd coreboot/; git pull || touch ../build_error )
if [ -f ../build_error ]; then
printf "ERROR: download/coreboot: Problem with git-pull. Network issue?\n"
cd ../; return 1
fi
fi
cp -R coreboot "${cbtree}" || touch ../build_error
if [ -f ../build_error ]; then
if [ -d ../build_error ]; then
printf "ERROR: download/coreboot: Unable to copy directory. Check file system permissions or free space.\n"
rm -Rf "${cbtree}/"
cd ../; return 1
@@ -184,7 +171,7 @@ downloadfor() {
cd ../../; return 1
fi
git submodule update --init --depth=1 || touch ../../build_error
git submodule update --init --checkout || touch ../../build_error
if [ -f ../../build_error ]; then
printf "ERROR: download/coreboot: Unable to update submodules for tree '%s'\n" "${cbtree}"
cd ../../; return 1
@@ -243,31 +230,4 @@ rm -f resources/coreboot/*/seen
rm -f "build_error"
printf "\n\n"
if [ "${deleteblobs}" = "true" ]; then
if [ "${deletegit}" = "true" ]; then
rm -Rf coreboot/coreboot/
rm -Rf coreboot/.git* coreboot/*/.git* coreboot/*/3rdparty/*/.git*
rm -Rf coreboot/*/util/nvidia/cbootimage/.git*
fi
for cbdir in coreboot/*; do
if [ ! -d "${cbdir}" ]; then continue; fi
cbtree="${cbdir##coreboot/}"
cbtree="${cbtree%/}"
if [ ! -d "coreboot/${cbtree}" ]; then continue; fi
bloblist="resources/coreboot/${cbtree}/blobs.list"
if [ -f "${bloblist}" ]; then
for blobfile in $(cat "${bloblist}"); do
printf "Deleting blob: 'coreboot/%s/%s'\n" "${cbtree}" "${blobfile}"
rm -f "coreboot/${cbtree}/${blobfile}"
done
fi
rmlist="resources/coreboot/${cbtree}/rm.list"
if [ -f "${rmlist}" ]; then
for rmentry in $(cat "${rmlist}"); do
printf "Deleting directory to save space: 'coreboot/%s/%s'\n" "${cbtree}" "${rmentry}"
rm -Rf "coreboot/${cbtree}/${rmentry}"
done
fi
done
fi
exit 0
+3 -45
View File
@@ -18,51 +18,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
. .revisions
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
usage()
{
progname="./download flashrom"
printf "Usage:\n"
printf "\t%s # %s\n" \
"${progname}" \
"Download flashrom"
printf "\t%s --help # %s\n" \
"${progname}" \
"Prints this help"
}
if [ $# -ne 0 ] ; then
usage
exit 0
fi
# Get flashrom at the last previously tested revision
# Remove the old version that may still exist:
# ------------------------------------------------------------------------------
printf "Downloading flashrom\n"
rm -Rf "flashrom/"
# Get flashrom
# ------------------------------------------------------------------------------
# download it using git
git clone https://review.coreboot.org/flashrom.git
if [ ! -d "flashrom" ]; then
printf "flashrom not downloaded; check network connection?\n\n"
exit 1
fi
(
cd "flashrom/"
# reset to known revision
git reset --hard 11680db4e1251eb842bee11e53b6d1f0ae67767b
)
printf "\n\n"
./download gitmodule flashrom
+88
View File
@@ -0,0 +1,88 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2022 Caleb La Grange <thonkpeasant@protonmail.com>
# SPDX-License-Identifier: GPL-3.0-only
Print_help(){
cat <<- EOF
Usage: ./download gitmodule [name]
Options:
name: The name of the module as specified in resources/git/revisions file
EOF
}
Fail(){
printf "${@}\n"
Print_help
exit 1
}
Check_vars(){
if [ -z "${revision+x}" ]; then
Fail 'Error: revision not set'
fi
if [ -z "${location+x}" ]; then
Fail 'Error: location not set'
fi
if [ -z "${url+x}" ]; then
Fail 'Error: url not set'
fi
}
Patch(){
for patchfile in ${PWD}/${patchdir}/*.patch ; do
( cd ${tmp_dir}
git am ${patchfile} || return 1
)
done
}
Run(){
git clone ${url} ${tmp_dir} || git clone ${bkup_url} ${tmp_dir} || Fail "ERROR: couldn't download ${name}\n Check Network connection"
( cd ${tmp_dir} && git reset --hard ${revision} )
patchdir="resources/${name}/patches"
if [ -d "${patchdir}" ]; then
Patch || Fail "ERROR: Faild to patch ${name}"
fi
mv ${tmp_dir} ${location} || Fail "ERROR: couldn't copy temp to destination\n ${tmp_dir} > ${location} check permissions"
}
if [ -z "${1+x}" ]; then
Fail 'Error: name not set'
else
name=${1}
fi
while read -r line ; do
set ${line} >/dev/null 2>&1
case ${line} in
rev:*)
revision=${2}
;;
loc:*)
location=${2}
;;
url:*)
url=${2}
;;
bkup_url:*)
bkup_url=${2}
;;
esac
done <<< $(eval "awk ' /\{.*${name}.*}{/ {flag=1;next} /\}/{flag=0} flag { print }' resources/git/revisions")
Check_vars
tmp_dir=$(mktemp -dt "${name}_XXXXX")
# clean out old version just in case
if [ -d "${location}" ]; then
rm -rf ${location}
fi
Run
# clean in case of failure
rm -rf ${tmp_dir} >/dev/null 2>&1
+2 -54
View File
@@ -21,57 +21,5 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
usage()
{
progname="./download grub"
printf "Usage:\n"
printf "\t%s # %s\n" \
"${progname}" \
"Download GRUB"
printf "\t%s --help # %s\n" \
"${progname}" \
"Prints this help"
}
if [ $# -ne 0 ] ; then
usage
exit 0
fi
# Remove the old version that may still exist
# ------------------------------------------------------------------------------
printf "Downloading GRUB\n"
rm -Rf "grub/"
# Get latest GRUB
# ------------------------------------------------------------------------------
# download it using git
git clone git://git.savannah.gnu.org/grub.git || git clone http://git.savannah.gnu.org/r/grub.git
if [ ! -d "grub" ]; then
printf "grub not downloaded; check network connection?\n\n"
exit 1
fi
(
# modifications are required
cd "grub/"
# reset to known revision
git reset --hard 50aace6bdb918150ba47e3c16146dcca271c134a
for grubpatch in ../resources/grub/patches/*; do
git am "${grubpatch}"
done
git clone git://git.sv.gnu.org/gnulib gnulib
cd gnulib/
# NOTE: when updating this, make sure it's the version specified
# in bootstrap.conf on that version of GRUB, as specified above
git reset --hard d271f868a8df9bbec29049d01e056481b7a1a263
rm -Rf .git*
)
printf "\n\n"
./download gitmodule grub
./download gitmodule gnulib
+1 -42
View File
@@ -21,46 +21,5 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
usage()
{
progname="./download ich9utils"
printf "Usage:\n"
printf "\t%s # %s\n" \
"${progname}" \
"Download ich9utils"
printf "\t%s --help # %s\n" \
"${progname}" \
"Prints this help"
}
if [ $# -ne 0 ] ; then
usage
exit 0
fi
printf "Downloading ich9utils\n"
if [ -d ich9utils ]; then
printf "ich9utils already downloaded. skipping\n"
exit 0
fi
# Get flashrom
# ------------------------------------------------------------------------------
# download it using git
git clone https://notabug.org/libreboot/ich9utils.git
if [ ! -d "ich9utils" ]; then
printf "ich9utils not downloaded; check network connection?\n\n"
exit 1
fi
(
cd "ich9utils/"
# reset to known revision
git reset --hard 53749b0c6f7c5778bdd1ec2b91cd230626752579
)
printf "\n\n"
./download gitmodule ich9utils
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
#
# Copyright (C) 2020 Leah Rowe <info@minifree.org>
#
# 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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This script assumes that the working directory is the
# root of retroboot_src or retroboot git.
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
./download gitmodule me_cleaner
+1 -37
View File
@@ -23,46 +23,10 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
usage()
{
progname="./download memtest86plus"
printf "Usage:\n"
printf "\t%s # %s\n" \
"${progname}" \
"Download MemTest86+"
printf "\t%s --help # %s\n" \
"${progname}" \
"Prints this help"
}
if [ $# -ne 0 ] ; then
usage
exit 0
fi
# Get the last version of MemTest86+ used, apply patches, build it.
# Remove the old version that may exist
# ------------------------------------------------------------------------------
printf "Downloading MemTest86+\n"
rm -Rf "memtest86plus/"
git clone https://review.coreboot.org/memtest86plus.git
(
cd "memtest86plus/"
git reset --hard a78401b9704cfdd49c89bfb31d2df08f60521d0b
for patchfile in ../resources/memtest86plus/patch/*; do
if [ ! -f "${patchfile}" ]; then
continue
fi
git am "${patchfile}"
done
rm -Rf .git*
)
printf "\n\n"
./download gitmodule memtest86plus
+169
View File
@@ -0,0 +1,169 @@
#!/bin/bash
# Download Intel MRC images
#
# 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
# the Free Software Foundation, version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This script assumes that the working directory is the
# root of osboot_src or osboot git.
# This file is forked from util/chromeos/crosfirmware.sh in coreboot cfc26ce278
# Changes to it in osboot are copyright 2021 Leah Rowe
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
# On some systems, `parted` and `debugfs` are located in /sbin.
export PATH="${PATH}:/sbin"
download_image()
{
_url=${1}
_file=${2}
_sha1sum=${3}
echo "Downloading recovery image"
curl "$_url" > "$_file.zip"
if [ "$(sha1sum ${_file}.zip)" = "${_sha1sum} ${_file}.zip" ]; then
unzip -q "${_file}.zip"
rm "${_file}.zip"
echo "Checksum verification passed for recovery image."
return 0
else
rm "${_file}.zip"
echo "Bad checksum. Recovery image deleted."
return 1
fi
}
extract_partition()
{
NAME=${1}
FILE=${2}
ROOTFS=${3}
_bs=1024
echo "Extracting ROOT-A partition"
ROOTP=$( printf "unit\nB\nprint\nquit\n" | \
parted ${FILE} 2>/dev/null | grep ${NAME} )
START=$(( $( echo ${ROOTP} | cut -f2 -d\ | tr -d "B" ) ))
SIZE=$(( $( echo ${ROOTP} | cut -f4 -d\ | tr -d "B" ) ))
dd if=${FILE} of=${ROOTFS} bs=${_bs} skip=$(( ${START} / ${_bs} )) \
count=$(( ${SIZE} / ${_bs} )) > /dev/null
}
extract_shellball()
{
ROOTFS=${1}
SHELLBALL=${2}
echo "Extracting chromeos-firmwareupdate"
printf "cd /usr/sbin\ndump chromeos-firmwareupdate ${SHELLBALL}\nquit" | \
debugfs ${ROOTFS} > /dev/null 2>&1
}
extract_coreboot()
{
_shellball=${1}
_unpacked=$( mktemp -d )
echo "Extracting coreboot image"
sh ${_shellball} --unpack ${_unpacked} > /dev/null
_version=$( cat ${_unpacked}/VERSION | grep BIOS\ version: | \
cut -f2 -d: | tr -d \ )
cp ${_unpacked}/bios.bin coreboot-${_version}.bin
rm -r "${_unpacked}"
}
check_existing()
{
_mrc_complete_hash="d18de1e3d52c0815b82ea406ca07897c56c65696"
if [ -f mrc/haswell/mrc.bin ]; then
printf 'found existing mrc.bin, checking its hash\n'
if [ "$(sha1sum mrc/haswell/mrc.bin)" = "${_mrc_complete_hash} mrc/haswell/mrc.bin" ]; then
printf 'checksums matched, skipping redownloading image\n'
return 0
else
printf 'hashes did not match, starting over\n'
return 1
fi
else
return 1
fi
}
# Skips redownloading every time the script runs
check_existing && exit 0
if [ ! -d "coreboot/default/" ]; then
./download coreboot default
fi
if [ ! -f "coreboot/default/util/cbfstool/cbfstool" ]; then
./build module cbutils default
fi
# Remove the old version that may still exist
# ------------------------------------------------------------------------------
printf "Downloading Intel MRC blobs\n"
#rm -Rf "mrc/"
mkdir -p mrc/haswell/
(
cd mrc/haswell/
# https://web.archive.org/web/20210211071412/https://dl.google.com/dl/edgedl/chromeos/recovery/recovery.conf
# peppy image used as defined here, mrc.bin extracted from that.
# when wanting to use an updated version later on, just change the url and
# sha1sums and such, in this script, based on a newer version on archive.org.
# For haswell mrc.bin, used on ThinkPad T440p and W541
_board="peppy"
_file="chromeos_12239.92.0_peppy_recovery_stable-channel_mp-v3.bin"
_url="https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_12239.92.0_peppy_recovery_stable-channel_mp-v3.bin.zip"
_url2="https://web.archive.org/web/20200516070928/https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_12239.92.0_peppy_recovery_stable-channel_mp-v3.bin.zip"
_sha1sum="cd5917cbe7f821ad769bf0fd87046898f9e175c8"
download_image ${_url} ${_file} ${_sha1sum}
if [ ! -f ${_file} ]; then
download_image ${_url2} ${_file} ${_sha1sum}
fi
if [ ! -f $_file ]; then
echo "${_file} was not downloaded, or verification failed. Exiting"
exit 1
fi
extract_partition ROOT-A ${_file} root-a.ext2
extract_shellball root-a.ext2 chromeos-firmwareupdate-${_board}
extract_coreboot chromeos-firmwareupdate-${_board}
../../coreboot/default/util/cbfstool/cbfstool coreboot-*.bin extract -f mrc.bin -n mrc.bin -r RO_SECTION
rm -f "chromeos-firmwareupdate-${_board}" coreboot-*.bin "${_file}" "root-a.ext2"
printf "\n\nHaswell mrc.bin file (for T440p and W541) downloaded to mrc/haswell/mrc.bin\n\n"
)
exit 0
+1 -57
View File
@@ -19,23 +19,6 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
usage()
{
progname="./download seabios"
printf "Usage:\n"
printf "\t%s # %s\n" \
"${progname}" \
"Download SeaBIOS"
printf "\t%s --help # %s\n" \
"${progname}" \
"Prints this help"
}
if [ $# -ne 0 ] ; then
usage
exit 0
fi
# Get SeaBIOS, revert to commit last used and apply patches.
# Remove the old version that may still exist
@@ -43,43 +26,4 @@ fi
printf "Downloading SeaBIOS\n"
rm -f build_error
rm -rf "seabios/"
# Get latest SeaBIOS
# ------------------------------------------------------------------------------
# download it using git
git clone https://review.coreboot.org/seabios || git clone https://github.com/coreboot/seabios
if [ ! -d "seabios" ]; then
printf "seabios not downloaded; check network connection?\n\n"
exit 1
fi
(
# modifications are required
cd "seabios/"
# Reset to the last commit that was tested (we use stable releases for seabios)
# ------------------------------------------------------------------------------
git reset --hard 64f37cc530f144e53c190c9e8209a51b58fd5c43
for patchfile in ../resources/seabios/patches/*.patch; do
if [ ! -f "${patchfile}" ]; then continue; fi
git am "${patchfile}" || touch ../build_error
if [ -f ../build_error ]; then
git am --abort
break
fi
done
)
if [ -f build_error ]; then
rm -f build_error
exit 1
fi
exit 0
./download gitmodule seabios
+5 -152
View File
@@ -2,7 +2,6 @@
# helper script: download u-boot
#
# Copyright (C) 2014, 2015, 2016, 2020, 2021 Leah Rowe <info@minifree.org>
# Copyright (C) 2021 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
# Copyright (C) 2022 Alper Nebi Yasak <alpernebiyasak@gmail.com>
#
@@ -23,18 +22,6 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
# set this when you want to modify each u-boot tree
# for example, you want to test custom patches
# NODELETE= ./download u-boot
deletegit="true"
deleteblobs="true"
if [ "x${NODELETE+set}" = 'xset' ]; then
[ "x${NODELETE:-all}" = "xgit" ] && deletegit="false"
[ "x${NODELETE:-all}" = "xall" ] && deleteblobs="false" && deletegit="false"
fi
# Error handling is extreme in this script.
# This script handles the internet, and Git. Both are inherently unreliable.
[[ -f build_error ]] && rm -f build_error
list_supported_boards() {
@@ -125,12 +112,12 @@ downloadfor() {
if [ ! -d "${uboot_dir}" ]; then
printf "Download u-boot from upstream:\n"
git clone --depth=1 https://source.denx.de/u-boot/u-boot.git \
git clone https://source.denx.de/u-boot/u-boot.git \
"${uboot_dir}" || \
rm -Rf "${uboot_dir}"
if [ ! -d "${uboot_dir}" ]; then
printf "WARNING: Upstream failed. Trying backup github repository:\n"
git clone --depth=1 https://github.com/u-boot/u-boot.git \
git clone https://github.com/u-boot/u-boot.git \
"${uboot_dir}" || \
rm -Rf coreboot
fi
@@ -142,7 +129,7 @@ downloadfor() {
fi
fi
git -C "${uboot_dir}" fetch --depth=1 origin "${ubrevision}" || touch build_error
git -C "${uboot_dir}" fetch origin "${ubrevision}" || touch build_error
if [ -f build_error ]; then
printf \
"ERROR: %s: Problem with git-fetch. Network issue?\n" \
@@ -167,7 +154,7 @@ downloadfor() {
return 1
fi
git -C "${ubtree}" submodule update --init --depth=1 || touch build_error
git -C "${ubtree}" submodule update --init || touch build_error
if [ -f build_error ]; then
printf "ERROR: %s: Unable to update submodules for tree '%s'\n" \
"${ubtree}"
@@ -215,79 +202,14 @@ strip_comments()
sed '/^$/d'
}
generate_deblob_script()
{
blob_list_file="$1"
output="$2"
# Add sheebang and copyright headers from this file
awk '{
if ($0 !~ /^#/ && NF > 0) {
stop=1;
}
if (stop !=1) {
printf("%s\n", $0);
}
}' $0 >> ${output}
# Add rm -rf before directories and rm -f before files
awk \
'{
}{
if (NF == 0) {
printf("\n");
} else {
if ($0 !~ /#/ && $NF ~ /\/$/) {
printf("rm -rf %s\n", $0);
} else if ($0 !~ /#/) {
printf("rm -f %s\n", $0);
} else {
# We have comments, try to see if they are
# still valid paths before the comments
comments_found=0
last_field=0
for(i=1; i<=NF; i++) {
if($i ~ /#/) {
comments_found=1;
} else if(comments_found != 1) {
last_field=i;
}
}
if (last_field == 0) {
printf("%s\n", $0);
} else if ($last_field ~ /\/$/) {
printf("rm -rf %s\n", $0);
} else {
printf("rm -f %s\n", $0);
}
}
}
}' "${blob_list_file}" >> "${output}"
}
usage()
{
progname="./download u-boot"
printf "Usage:\n"
printf "\t%s # %s\n" \
"${progname}" \
"Download and deblob u-boot for all boards"
printf "\t%s [board] # %s\n" \
"${progname}" \
"Download and deblob u-boot for the given board"
printf "\t%s --blobs-list # %s\n" \
"${progname}" \
"Print the path of the generic blobs.list file"
printf "\t%s --blobs-list [board] # %s\n" \
"${progname}" \
"Print the path of the blobs.list file for the given board"
printf "\t%s --gen-deblob-script # %s\n" \
"${progname}" \
"Print the path of a generated generic deblob script"
printf "\t%s --gen-deblob-script [board] # %s\n" \
"${progname}" \
"Print the path of a generated deblob script for the given board"
"Download u-boot for the given board"
printf "\t%s --list-boards # %s\n" \
"${progname}" \
"List supported boards"
@@ -307,45 +229,6 @@ download_uboot_board()
rm -f "build_error"
printf "\n\n"
if [ "${deleteblobs}" = "true" ]; then
if [ "${deletegit}" = "true" ]; then
rm -rf "${ubtree}"/.git* "${ubtree}"/*/.git*
fi
blobslist="$(print_blobs_list_path "${board}")"
for blob_path in $(strip_comments "${blobslist}"); do
if echo "${blob_path}" | \
grep '/$' 2>&1 >/dev/null ; then
printf "Deleting blob directory: '%s/%s'\n" \
"${ubtree}" "${blob_path}"
rm -rf "${ubtree}/${blob_path}"
else
printf "Deleting blob file: '%s/%s'\n" \
"${ubtree}" "${blob_path}"
rm -f "${ubtree}/${blob_path}"
fi
done
fi
}
print_blobs_list_path()
{
board="$1"
if [ -f "resources/u-boot/${board}/blobs.list" ]; then
printf "resources/u-boot/${board}/blobs.list\n"
else
printf "resources/u-boot/default/blobs.list\n"
fi
}
print_deblob_script_path()
{
board="$1"
path="$(mktemp)"
generate_deblob_script "$(print_blobs_list_path ${board})" "${path}"
printf "%s\n" ${path}
}
if [ $# -eq 0 ] ; then
@@ -364,36 +247,6 @@ elif [ $# -eq 1 -a "$1" == "--help" ] ; then
elif [ $# -eq 1 -a "$1" == "--list-boards" ] ; then
list_supported_boards
exit 0
elif [ $# -eq 1 -a "$1" == "--blobs-list" ] ; then
print_blobs_list_path "default"
exit 0
elif [ $# -eq 2 -a "$1" == "--blobs-list" ] ; then
found=0
for board in $(list_supported_boards) ; do
if [ "${board}" = "$2" ] ; then
print_blobs_list_path "$2"
exit 0
fi
done
printf "Error: Board '${2}' is not supported\n"
exit 1
elif [ $# -eq 1 -a "$1" == "--gen-deblob-script" ] ; then
print_deblob_script_path "default"
exit 0
elif [ $# -eq 2 -a "$1" == "--gen-deblob-script" ] ; then
found=0
for board in $(list_supported_boards) ; do
if [ "$board" = "$2" ] ; then
print_deblob_script_path "$2"
exit 0
fi
done
printf "Error: Board '${2}' is not supported\n"
exit 1
elif [ $# -eq 1 ] ; then
for board in $(list_supported_boards) ; do
if [ "$board" = "$1" ] ; then
-1
View File
@@ -3,7 +3,6 @@
#
# helper script: modify U-Boot configs (run make menuconfig)
#
# Copyright (C) 2021 Leah Rowe <info@minifree.org>
# Copyright (C) 2022 Alper Nebi Yasak <alpernebiyasak@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
-1
View File
@@ -3,7 +3,6 @@
#
# helper script: update U-Boot configs (run make oldconfig)
#
# Copyright (C) 2021 Leah Rowe <info@minifree.org>
# Copyright (C) 2022 Alper Nebi Yasak <alpernebiyasak@gmail.com>
#
# This program is free software: you can redistribute it and/or modify