User:GNUtoo/normal.sh

From coreboot
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
#!/bin/sh
# In the cases where this work is copyrightable, it falls under the GPLv2
# or later license that is available here:
# https://www.gnu.org/licenses/gpl-2.0.txt

image="$1"
if [ $# -ne 1 ] ; then
	echo "Usage $0 <image>"
	exit 1
fi

die()
{
  echo "$1 Failed"
  exit 1
}

cbfs_add()
{
  name=$1
  file=$2
  cbfs_remove ${name}
  ./util/cbfstool/cbfstool ./build/coreboot.rom add -n ${name} -t raw -f ${file}
}

cbfs_remove()
{
  name=$1
  ./util/cbfstool/cbfstool ./build/coreboot.rom remove -n ${name}
}

cbfs_reuse_payload()
{
  ./util/cbfstool/cbfstool ./build/coreboot.rom extract -f ./build/payload.elf -n fallback/payload
  ./util/cbfstool/cbfstool ./build/coreboot.rom add -f ./build/payload.elf -n normal/payload -t payload
}

check_config()
{
  grep "^CONFIG_CBFS_PREFIX=\"normal\"$" .config > /dev/null || die "Not using normal cbfs prefix"
  grep "^CONFIG_UPDATE_IMAGE=y$" .config > /dev/null || die "Not using CONFIG_UPDATE_IMAGE"
  grep "^CONFIG_SKIP_MAX_REBOOT_CNT_CLEAR=y" .config > /dev/null || die "Not using CONFIG_SKIP_MAX_REBOOT_CNT_CLEAR"
}

check_config
make oldconfig || die "make oldconfig"
make clean || die "clean"
mkdir build/ || die "mkdir build"

cp ${image} ./build/coreboot.rom || die "cp"

cbfs_remove normal/romstage
cbfs_remove normal/ramstage
cbfs_remove normal/payload
cbfs_remove normal/dsdt.aml
cbfs_remove config
cbfs_remove revision

# it now adds it automatically
cbfs_remove etc/ps2-keyboard-spinup
 
make || die "make"

# uncomment if you want to reuse fallback's payload
# cbfs_reuse_payload

./util/cbfstool/cbfstool ./build/coreboot.rom print