summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/git.sh2
-rw-r--r--include/lib.sh35
-rw-r--r--include/rom.sh23
-rw-r--r--include/vendor.sh21
4 files changed, 53 insertions, 28 deletions
diff --git a/include/git.sh b/include/git.sh
index 77a22763..aaeabcd4 100644
--- a/include/git.sh
+++ b/include/git.sh
@@ -115,7 +115,7 @@ tmpclone()
git_am_patches "$3" "$5"
) || repofail="y"
- [ "$repofail" = "y" ] && [ $# -lt 6 ] && tmpclone $@ retry
+ [ "$repofail" = "y" ] && [ $# -lt 6 ] && tmpclone "$@" retry
[ "$repofail" = "y" ] && $err "!clone $1 $2 $3 $4 $5"; :
}
diff --git a/include/lib.sh b/include/lib.sh
index 92651c84..4e56b34a 100644
--- a/include/lib.sh
+++ b/include/lib.sh
@@ -10,14 +10,15 @@ _ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
ifdtool="elf/ifdtool/default/ifdtool"
cbfstool="elf/cbfstool/default/cbfstool"
+rmodtool="elf/cbfstool/default/rmodtool"
tmpgit="$PWD/tmp/gitclone"
grubdata="config/data/grub"
err="err_"
pyver="2"
python="python3"
-which python3 1>/dev/null || python="python"
-which $python 1>/dev/null || pyver=""
+command -v python3 1>/dev/null || python="python"
+command -v $python 1>/dev/null || pyver=""
[ -n "$pyver" ] && pyver="$($python --version | awk '{print $2}')"
if [ "${pyver%%.*}" != "3" ]; then
printf "Wrong python version, or python missing. Must be v 3.x.\n" 1>&2
@@ -45,7 +46,7 @@ chkvars()
}
eval `setvars "" _nogit board xbmk_parent versiondate projectsite projectname \
- aur_notice configdir datadir version relname`
+ aur_notice configdir datadir version relname reinstall`
for fv in projectname projectsite version versiondate; do
eval "[ ! -f "$fv" ] || read -r $fv < \"$fv\" || :"
@@ -72,6 +73,8 @@ e()
install_packages()
{
[ $# -lt 2 ] && $err "fewer than two arguments"
+ [ $# -gt 2 ] && reinstall="$3"
+
eval `setcfg "config/dependencies/$2"`
$pkg_add $pkglist || $err "Cannot install packages"
@@ -80,32 +83,36 @@ install_packages()
printf "You need AUR packages: %s\n" "$aur_notice" 1>&2; return 0
}
if [ $# -gt 0 ] && [ "$1" = "dependencies" ]; then
- install_packages $@ || exit 1
+ install_packages "$@" || exit 1
exit 0
fi
id -u 1>/dev/null 2>/dev/null || $err "suid check failed (id -u)"
[ "$(id -u)" != "0" ] || $err "this command as root is not permitted"
+# XBMK_CACHE is a directory, for caching downloads and git repositories
+[ -z "${XBMK_CACHE+x}" ] && export XBMK_CACHE="$PWD/cache"
+[ -z "$XBMK_CACHE" ] && export XBMK_CACHE="$PWD/cache"
+[ -L "$XBMK_CACHE" ] && [ "$XBMK_CACHE" = "$PWD/cache" ] && \
+ $err "cachedir is default, $PWD/cache, but it exists and is a symlink"
+[ -L "$XBMK_CACHE" ] && export XBMK_CACHE="$PWD/cache"
+[ -f "$XBMK_CACHE" ] && $err "cachedir '$XBMK_CACHE' exists but it's a file"
+
+# unify all temporary files/directories in a single TMPDIR
[ -z "${TMPDIR+x}" ] || [ "${TMPDIR%_*}" = "/tmp/xbmk" ] || unset TMPDIR
[ -n "${TMPDIR+x}" ] && export TMPDIR="$TMPDIR"
-
if [ -z "${TMPDIR+x}" ]; then
[ -f "lock" ] && $err "$PWD/lock exists. Is a build running?"
export TMPDIR="/tmp"
export TMPDIR="$(mktemp -d -t xbmk_XXXXXXXX)"
touch lock || $err "cannot create 'lock' file"
+ rm -Rf "$XBMK_CACHE/xbmkpath" || $err "cannot remove xbmkpath"
+ mkdir -p "$XBMK_CACHE/xbmkpath" || $err "cannot create xbmkpath"
+ export PATH="$XBMK_CACHE/xbmkpath:$PATH" || \
+ $err "Can't create xbmkpath"
xbmk_parent="y"
fi
-# XBMK_CACHE is a directory, for caching downloads and git repositories
-[ -z "${XBMK_CACHE+x}" ] && export XBMK_CACHE="$PWD/cache"
-[ -z "$XBMK_CACHE" ] && export XBMK_CACHE="$PWD/cache"
-[ -L "$XBMK_CACHE" ] && [ "$XBMK_CACHE" = "$PWD/cache" ] && \
- $err "cachedir is default, $PWD/cache, but it exists and is a symlink"
-[ -L "$XBMK_CACHE" ] && export XBMK_CACHE="$PWD/cache"
-[ -f "$XBMK_CACHE" ] && $err "cachedir '$XBMK_CACHE' exists but it's a file"
-
# if "y": a coreboot target won't be built if target.cfg says release="n"
# (this is used to exclude certain build targets from releases)
[ -z "${XBMK_RELEASE+x}" ] && export XBMK_RELEASE="n"
@@ -116,7 +123,7 @@ expr "X$XBMK_THREADS" : "X-\{0,1\}[0123456789][0123456789]*$" \
1>/dev/null 2>/dev/null || export XBMK_THREADS=1 # user gave a non-integer
x_() {
- [ $# -lt 1 ] || $@ || \
+ [ $# -lt 1 ] || "$@" || \
$err "Unhandled non-zero exit: $(echo "$@")"; return 0
}
diff --git a/include/rom.sh b/include/rom.sh
index ec2ad650..01a8607f 100644
--- a/include/rom.sh
+++ b/include/rom.sh
@@ -3,7 +3,7 @@
# Copyright (c) 2021-2022 Ferass El Hafidi <vitali64pmemail@protonmail.com>
# Copyright (c) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
# Copyright (c) 2022-2023 Alper Nebi Yasak <alpernebiyasak@gmail.com>
-# Copyright (c) 2023 Riku Viitanen <riku.viitanen@protonmail.com>
+# Copyright (c) 2023-2024 Riku Viitanen <riku.viitanen@protonmail.com>
mkserprog()
{
@@ -11,7 +11,14 @@ mkserprog()
basename -as .h "$serdir/"*.h > "$TMPDIR/ser" || $err "!mk $1 $TMPDIR"
while read -r sertarget; do
- [ "$1" = "rp2040" ] && x_ cmake -DPICO_BOARD="$sertarget" \
+ [ "$1" = "pico" ] &&
+ x_ rm -rf "$sersrc/build" \
+ && (pt=$(x_ grep "pico_cmake_set" \
+ "$picosdk/src/boards/include/boards/$sertarget.h" \
+ | grep "PICO_PLATFORM" | cut -d= -f2 | tr -d [:blank:])
+ mkdir -p "$sersrc/build_$pt"
+ ln -srf "$sersrc/build_$pt/" "$sersrc/build") \
+ && x_ cmake -DPICO_BOARD="$sertarget" \
-DPICO_SDK_PATH="$picosdk" -B "$sersrc/build" "$sersrc" \
&& x_ cmake --build "$sersrc/build"
[ "$1" = "stm32" ] && x_ make -C "$sersrc" \
@@ -77,10 +84,14 @@ check_coreboot_utils()
utilmode="" && [ -n "$mode" ] && utilmode="clean"
x_ make -C "$utilsrcdir" $utilmode -j$XBMK_THREADS $makeargs
- [ -z "$mode" ] && [ ! -f "$utilelfdir/$util" ] && \
- x_ mkdir -p "$utilelfdir" && \
- x_ cp "$utilsrcdir/$util" "elf/$util/$1"
- [ -z "$mode" ] || x_ rm -Rf "$utilelfdir"; continue
+ if [ -z "$mode" ] && [ ! -f "$utilelfdir/$util" ]; then
+ x_ mkdir -p "$utilelfdir"
+ x_ cp "$utilsrcdir/$util" "$utilelfdir"
+ [ "$util" = "cbfstool" ] || continue
+ x_ cp "$utilsrcdir/rmodtool" "$utilelfdir"
+ elif [ -n "$mode" ]; then
+ x_ rm -Rf "$utilelfdir"
+ fi; continue
done; return 0
}
diff --git a/include/vendor.sh b/include/vendor.sh
index aa7256c4..5fad62fb 100644
--- a/include/vendor.sh
+++ b/include/vendor.sh
@@ -375,13 +375,15 @@ detect_board()
readcfg()
{
if [ "$board" = "serprog_rp2040" ] || \
- [ "$board" = "serprog_stm32" ]; then
+ [ "$board" = "serprog_stm32" ] || \
+ [ "$board" = "serprog_pico" ]; then
return 1
fi; boarddir="$cbcfgsdir/$board"
eval `setcfg "$boarddir/target.cfg"`; chkvars vcfg tree
cbdir="src/coreboot/$tree"
cbfstool="elf/cbfstool/$tree/cbfstool"
+ rmodtool="elf/cbfstool/$tree/rmodtool"
mecleaner="$PWD/$cbdir/util/me_cleaner/me_cleaner.py"
kbc1126_ec_dump="$PWD/$cbdir/util/kbc1126/kbc1126_ec_dump"
cbfstool="elf/cbfstool/$tree/cbfstool"
@@ -424,10 +426,10 @@ patch_rom()
rom="$1"
readkconfig || return 1
- [ "$CONFIG_HAVE_MRC" = "y" ] && inject "mrc.bin" "$CONFIG_MRC_FILE" \
- "mrc" "0xfffa0000"
[ -n "$CONFIG_HAVE_REFCODE_BLOB" ] && inject "fallback/refcode" \
"$CONFIG_REFCODE_BLOB_FILE" "stage"
+ [ "$CONFIG_HAVE_MRC" = "y" ] && inject "mrc.bin" "$CONFIG_MRC_FILE" \
+ "mrc" "0xfffa0000"
[ "$CONFIG_HAVE_ME_BIN" = "y" ] && inject IFD "$CONFIG_ME_BIN_PATH" me
[ "$CONFIG_KBC1126_FIRMWARE" = "y" ] && inject ecfw1.bin \
"$CONFIG_KBC1126_FW1" raw "$CONFIG_KBC1126_FW1_OFFSET" && inject \
@@ -486,10 +488,15 @@ inject()
"$cbfstool" "$rom" remove -n "$cbfsname" || \
$err "inject $rom: can't remove $cbfsname"; return 0
fi
- [ "$_t" != "stage" ] || "$cbfstool" "$rom" add-stage -f \
- "$_dest" -n "$cbfsname" -t stage -c lzma || $err "$rom: !add ref"
- [ "$_t" = "stage" ] || "$cbfstool" "$rom" add -f "$_dest" \
- -n "$cbfsname" -t $_t $_offset || $err "$rom !add $_t ($_dest)"; :
+ if [ "$_t" = "stage" ]; then # the only stage we handle in refcode
+ x_ mkdir -p tmp; x_ rm -f "tmp/refcode"
+ "$rmodtool" -i "$_dest" -o "tmp/refcode" || "!reloc refcode"
+ "$cbfstool" "$rom" add-stage -f "tmp/refcode" -n "$cbfsname" \
+ -t stage || $err "$rom: !add ref"
+ else
+ "$cbfstool" "$rom" add -f "$_dest" -n "$cbfsname" \
+ -t $_t $_offset || $err "$rom !add $_t ($_dest)"
+ fi; :
}
modify_gbe()