Compare commits

...

12 Commits

Author SHA1 Message Date
Leah Rowe 17b5cb2749 further modify the README (stragglers)
again, canoeboot is a fsdg coreboot distro

it should talk like one

Signed-off-by: Leah Rowe <info@minifree.org>
2024-05-10 05:35:25 +01:00
Leah Rowe 628e91a3b9 build: further prevent non-cbmk-work-directory
this is a follow-up to the previous commit

again, there's no posix way to check the path to the
file at argument 0, because readlink (utility) isn't
defined in posix (the C function is defined, but not
the utility included on many unices)

check whether "build" (file) exists, and whether it
is a symlink; if the latter, then we are definitely
not in the cbmk work directory!

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-10 05:31:50 +01:00
Leah Rowe e761a494c8 build: exit if not running from cbmk directory
there's no portable(posix) way to check when running
from a symlink to cbmk in the current work directory

for example:

ln -s cbmk/build cbmktest
./cbmktest roms list

this would pass the new test, and first try to
include option.sh. in practise, the user probably  doesn't
happen to have include/option.sh in their current path

i can use readlink here, but again not portable

the current check will suffice. it also works when
the symlink is called from $PATH

e.g. /usr/bin/cbmktest exists and you do:
cbmktest roms list

Signed-off-by: Leah Rowe <leah@libreboot.org>
Signed-off-by: Leah Rowe <info@minifree.org>
2024-05-10 05:31:09 +01:00
Leah Rowe eb8a02e808 build/roms: print serprog help
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-10 05:29:53 +01:00
Leah Rowe a398011180 merge script/build/serprog with script/build/roms
previous command:

./build serprog

now it is:

./build roms serprog

after that, it's the same arguments e.g.

./build roms serprog stm32
./build roms serprog rp2040

further cleanup to commence

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-10 05:29:25 +01:00
Leah Rowe cd5c2573ac build/roms: remove unnecessary command
there is no need to return 0 at the end of a function.

sh does that anyway

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-10 05:29:14 +01:00
Leah Rowe da748de455 merge include/err.sh with include/option.sh
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-10 05:25:23 +01:00
Leah Rowe 3acac46536 err.sh: correct copyright info
i replaced 2022, 2023 with 2022, 2024 when updating
the years, as per modifications, but the 2023 copyright
doesn't become invalidated

change it to 2022-2024 instead, which is correct

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-10 05:20:02 +01:00
Leah Rowe 6bdbb70dbc build/roms: don't rely on x in handle_target
x is part of the for loop in main() and may or not
still be available from handle_target, depending on
your implementation of sh, but this should not be assumed

do it properly

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-10 05:19:53 +01:00
Leah Rowe 1c84d0fc9d build/roms: don't use exit status from skip_board
the printf could potentially return non-zero, which might
make the script not skip a given target

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-10 05:19:48 +01:00
Leah Rowe 0ada63b629 build/roms: split up main()
it's starting to get a big big, so break it up

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-10 05:19:34 +01:00
Leah Rowe 5cecd9e394 build/roms: allow searching status by mismatch
for example:

./build roms list stable

this lists all images that are marked "stable"

now:

./build roms list _stable

this lists all images that are *not* marked stable

this will help me keep track during development

Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-10 05:19:24 +01:00
8 changed files with 227 additions and 221 deletions

View File

@ -13,10 +13,7 @@ via [\#canoeboot IRC](https://web.libera.chat/#canoeboot)
on [Libera](https://libera.chat/) IRC.
Canoeboot is maintained in parallel with Libreboot, by the same developer.
You are strongly advised to use *Libreboot*, but a certain minority may
prefer Canoeboot, which is essentially a *censored* Libreboot (no binary
blobs allowed, so only few boards supported whereas Libreboot supports more
boards while minimising the number of blobs to zero when possible).
Strictly speaking, it is a *fork* of Libreboot, but with a twist:
Canoeboot is provided for the purists who absolutely wish to have no proprietary
software of any kind. Regardless of any other firmware that exists outside of it,

6
build
View File

@ -7,7 +7,11 @@
set -u -e
. "include/err.sh"
if [ "./${0##*/}" != "${0}" ] || [ ! -f "build" ] || [ -L "build" ]; then
printf "You must run this in the cbmk work directory.\n" 1>&2
exit 1
fi
. "include/option.sh"
eval "$(setvars "" option aur_notice)"

View File

@ -1,95 +0,0 @@
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2022, 2024 Leah Rowe <leah@libreboot.org>
export LC_COLLATE=C
export LC_ALL=C
version=""; versiondate=""; projectname=""; _nogit=""
err="err_"; tmpdir=""; cbmk_status=""
# 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)
cbmk_release=
set | grep CBMK_RELEASE 1>/dev/null 2>/dev/null || cbmk_release="n" || :
[ -z "$cbmk_release" ] && cbmk_release="$CBMK_RELEASE"
[ "$cbmk_release" = "n" ] || [ "$cbmk_release" = "y" ] || cbmk_release="n"
export CBMK_RELEASE="$cbmk_release"
# if set to n via export, status checks will be skipped during
# all builds, and all targets will be built regardless of status.
# this replicates the old behaviour of cbmk, prior to the checks.
set | grep CBMK_STATUS 1>/dev/null 2>/dev/null && cbmk_status="$CBMK_STATUS"
[ "$cbmk_status" = "y" ] || [ "$cbmk_status" = "n" ] || cbmk_status="y"
export CBMK_STATUS="$cbmk_status"
tmpdir_was_set="y"
set | grep TMPDIR 1>/dev/null 2>/dev/null || tmpdir_was_set="n"
if [ "${tmpdir_was_set}" = "y" ]; then
[ "${TMPDIR%_*}" = "/tmp/cbmk" ] || tmpdir_was_set="n"
fi
if [ "${tmpdir_was_set}" = "n" ]; then
export TMPDIR="/tmp"
tmpdir="$(mktemp -d -t cbmk_XXXXXXXX)"
export TMPDIR="${tmpdir}"
else
export TMPDIR="${TMPDIR}"
tmpdir="${TMPDIR}"
fi
x_() {
[ $# -lt 1 ] || ${@} || $err "Unhandled non-zero exit: $@"; return 0
}
check_git()
{
which git 1>/dev/null 2>/dev/null || \
git_err "git not installed. please install git-scm."
git config --global user.name 1>/dev/null 2>/dev/null || \
git_err "git config --global user.name \"John Doe\""
git config --global user.email 1>/dev/null 2>/dev/null || \
git_err "git config --global user.email \"john.doe@example.com\""
}
git_err()
{
printf "You need to set git name/email, like so:\n%s\n\n" "$1" 1>&2
$err "Git name/email not configured"
}
check_project()
{
read -r projectname < projectname || :
[ ! -f version ] || read -r version < version || :
version_="${version}"
[ ! -e ".git" ] || version="$(git describe --tags HEAD 2>&1)" || \
version="git-$(git rev-parse HEAD 2>&1)" || version="${version_}"
[ ! -f versiondate ] || read -r versiondate < versiondate || :
versiondate_="${versiondate}"
[ ! -e ".git" ] || versiondate="$(git show --no-patch --no-notes \
--pretty='%ct' HEAD)" || versiondate="${versiondate_}"
for p in projectname version versiondate; do
eval "[ -n \"\$$p\" ] || $err \"$p unset\""
eval "x_ printf \"%s\\n\" \"\$$p\" > $p"
done
export LOCALVERSION="-${projectname}-${version%%-*}"
}
setvars()
{
_setvars=""
[ $# -lt 2 ] && $err "setvars: too few arguments"
val="${1}" && shift 1
for var in $@; do
_setvars="${var}=\"${val}\"; ${_setvars}"
done
printf "%s\n" "${_setvars% }"
}
err_()
{
printf "ERROR %s: %s\n" "${0}" "${1}" 1>&2
exit 1
}

View File

@ -3,6 +3,10 @@
# SPDX-FileCopyrightText: 2022 Ferass El Hafidi <vitali64pmemail@protonmail.com>
# SPDX-FileCopyrightText: 2020-2024 Leah Rowe <leah@libreboot.org>
export LC_COLLATE=C
export LC_ALL=C
tmpdir_was_set="y"
cbdir="src/coreboot/default"
cbcfgsdir="config/coreboot"
ifdtool="cbutils/default/ifdtool"
@ -11,16 +15,58 @@ grubcfgsdir="config/grub"
layoutdir="/boot/grub/layouts"
. "${grubcfgsdir}/modules.list"
tmpgit="${PWD}/tmp/gitclone"
err="err_"
eval "$(setvars "" board boarddir)"
err_()
{
printf "ERROR %s: %s\n" "${0}" "${1}" 1>&2
exit 1
}
setvars()
{
_setvars=""
[ $# -lt 2 ] && $err "setvars: too few arguments"
val="${1}" && shift 1
for var in $@; do
_setvars="${var}=\"${val}\"; ${_setvars}"
done
printf "%s\n" "${_setvars% }"
}
eval "$(setvars "" _nogit _dest board boarddir cbmk_release cbmk_status threads \
version versiondate projectname)"
# 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)
set | grep CBMK_RELEASE 1>/dev/null 2>/dev/null || cbmk_release="n" || :
[ -z "$cbmk_release" ] && cbmk_release="$CBMK_RELEASE"
[ "$cbmk_release" = "n" ] || [ "$cbmk_release" = "y" ] || cbmk_release="n"
export CBMK_RELEASE="$cbmk_release"
# if set to n via export, status checks will be skipped during
# all builds, and all targets will be built regardless of status.
# this replicates the old behaviour of cbmk, prior to the checks.
set | grep CBMK_STATUS 1>/dev/null 2>/dev/null && cbmk_status="$CBMK_STATUS"
[ "$cbmk_status" = "y" ] || [ "$cbmk_status" = "n" ] || cbmk_status="y"
export CBMK_STATUS="$cbmk_status"
set | grep TMPDIR 1>/dev/null 2>/dev/null || tmpdir_was_set="n"
if [ "${tmpdir_was_set}" = "y" ]; then
[ "${TMPDIR%_*}" = "/tmp/cbmk" ] || tmpdir_was_set="n"
fi
if [ "${tmpdir_was_set}" = "n" ]; then
export TMPDIR="/tmp"
tmpdir="$(mktemp -d -t cbmk_XXXXXXXX)"
export TMPDIR="${tmpdir}"
else
export TMPDIR="${TMPDIR}"
tmpdir="${TMPDIR}"
fi
threads=
set | grep CBMK_THREADS 1>/dev/null 2>/dev/null && threads="$CBMK_THREADS"
[ -z "$threads" ] && threads=1
expr "X$threads" : "X-\{0,1\}[0123456789][0123456789]*$" \
1>/dev/null 2>/dev/null || threads=1 # user specified a non-integer
export CBMK_THREADS="$threads"
items()
@ -84,3 +130,44 @@ remkdir()
rm -Rf "${1}" || $err "remkdir: !rm -Rf \"${1}\""
mkdir -p "${1}" || $err "remkdir: !mkdir -p \"${1}\""
}
x_() {
[ $# -lt 1 ] || ${@} || $err "Unhandled non-zero exit: $@"; return 0
}
check_git()
{
which git 1>/dev/null 2>/dev/null || \
git_err "git not installed. please install git-scm."
git config --global user.name 1>/dev/null 2>/dev/null || \
git_err "git config --global user.name \"John Doe\""
git config --global user.email 1>/dev/null 2>/dev/null || \
git_err "git config --global user.email \"john.doe@example.com\""
}
git_err()
{
printf "You need to set git name/email, like so:\n%s\n\n" "$1" 1>&2
$err "Git name/email not configured"
}
check_project()
{
read -r projectname < projectname || :
[ ! -f version ] || read -r version < version || :
version_="${version}"
[ ! -e ".git" ] || version="$(git describe --tags HEAD 2>&1)" || \
version="git-$(git rev-parse HEAD 2>&1)" || version="${version_}"
[ ! -f versiondate ] || read -r versiondate < versiondate || :
versiondate_="${versiondate}"
[ ! -e ".git" ] || versiondate="$(git show --no-patch --no-notes \
--pretty='%ct' HEAD)" || versiondate="${versiondate_}"
for p in projectname version versiondate; do
eval "[ -n \"\$$p\" ] || $err \"$p unset\""
eval "x_ printf \"%s\\n\" \"\$$p\" > $p"
done
export LOCALVERSION="-${projectname}-${version%%-*}"
}

View File

@ -8,13 +8,16 @@
set -u -e
. "include/err.sh"
. "include/option.sh"
serprog_usage="usage: ./build roms serprog <rp2040|stm32> [board]"
seavgabiosrom="elf/seabios/default/libgfxinit/vgabios.bin"
grub_background="background1280x800.png"
grubelf="elf/grub/grub.elf"
cfgsdir="config/coreboot"
pico_src_dir="src/pico-serprog"
pico_sdk_dir="src/pico-sdk"
stm32_src_dir="src/stm32-vserprog"
# Disable all payloads by default.
# target.cfg files have to specifically enable [a] payload(s)
@ -22,16 +25,15 @@ pv="payload_grub payload_grub_withseabios payload_seabios payload_memtest t"
pv="${pv} payload_seabios_withgrub payload_seabios_grubonly payload_uboot memtest_bin"
v="romdir cbrom initmode displaymode cbcfg targetdir tree keymaps release"
v="${v} grub_timeout ubdir board grub_scan_disk uboot_config status"
eval "$(setvars "n" ${pv})"
eval "$(setvars "n" ${pv} serprog)"
eval "$(setvars "" ${v} boards _displaymode _payload _keyboard all targets \
skipped listboards list_type)"
skipped listboards list_type serprog_boards_dir)"
main()
{
check_project
while [ $# -gt 0 ]; do
if [ "$listboards" = "y" ]; then
list_type="$list_type $1"
list_type="${list_type# }"
@ -47,6 +49,9 @@ main()
$err "Cannot generate list of boards for list"
listboards="y"
shift 1; continue ;;
serprog)
serprog="y"
shift 1; break ;;
-d) _displaymode="${2}" ;;
-p) _payload="${2}" ;;
-k) _keyboard="${2}" ;;
@ -58,38 +63,16 @@ main()
shift 2
done
[ "${all}" != "y" ] || boards=$(items config/coreboot) || \
$err "Cannot generate list of boards for building"
for x in ${boards}; do
eval "$(setvars "n" ${pv}) $(setvars "" ${v})"
grub_background="background1280x800.png"
board="${x}"
status="unknown"
configure_target
[ "$board" = "$tree" ] && \
continue
if [ "$listboards" = "y" ]; then
[ -z "$list_type" ] && printf "%s\n" "$board"
for _list_type in $list_type; do
[ "$status" != "$_list_type" ] && continue
printf "%s\n" "$board"
done; continue
fi
# exclude certain targets from the release
skip_board && \
printf "Skip target %s(%s)\n" "$board" "$status" && \
skipped="* $board($status)\n$skipped" && continue
build_payloads
build_target_mainboard
[ -d "bin/${board}" ] || continue
targets="* bin/${board}\n${targets}"
done
if [ "$serprog" = "y" ]; then
handle_serprog $@
return 0
else
[ "${all}" != "y" ] || boards=$(items config/coreboot) || \
$err "Cannot generate list of boards for building"
for x in ${boards}; do
handle_coreboot_target "$x"
done
fi
[ "$listboards" = "y" ] && return 0
@ -107,6 +90,93 @@ main()
printf "DO NOT flash images from elf/ - please use bin/ instead.\n"
}
handle_serprog()
{
[ -z "${1+x}" ] && $err "${serprog_usage}"
[ "$1" != "rp2040" ] && [ "$1" != "stm32" ] && $err "$serprog_usage"
if [ "${1}" = "rp2040" ]; then
serprog_boards_dir=${pico_sdk_dir}/src/boards/include/boards
[ -d "$pico_src_dir" ] || x_ ./update trees -f "pico-serprog"
elif [ "${1}" = "stm32" ]; then
serprog_boards_dir=${stm32_src_dir}/boards
[ -d "$stm32_src_dir" ] || x_ ./update trees -f "stm32-vserprog"
fi
x_ mkdir -p "bin/serprog_${1}"
if [ $# -gt 1 ] && [ "${2}" = "list" ]; then
print_serprog_boards ${serprog_boards_dir}
elif [ $# -gt 1 ]; then
build_${1}_rom "${2}"
else
printf "Building all serprog targets\n"
list_serprog_boards "${serprog_boards_dir}" | \
while read -r board; do
build_${1}_rom "${board}"
done
fi
}
build_rp2040_rom()
{
board=${1}
printf "Building pico-serprog for %s\n" "${board}"
x_ cmake -DPICO_BOARD="$board" -DPICO_SDK_PATH="$pico_sdk_dir" \
-B "${pico_src_dir}/build" "${pico_src_dir}"
x_ cmake --build "${pico_src_dir}/build"
x_ mv ${pico_src_dir}/build/pico_serprog.uf2 \
bin/serprog_rp2040/serprog_${board}.uf2
printf "output to bin/serprog_rp2040/serprog_%s.uf2\n" "$board"
}
build_stm32_rom()
{
board=${1}
printf "Building stm32-vserprog for %s\n" "${board}"
x_ make -C $stm32_src_dir libopencm3-just-make BOARD=$board
x_ make -C ${stm32_src_dir} BOARD=${board}
x_ mv ${stm32_src_dir}/stm32-vserprog.hex \
bin/serprog_stm32/serprog_${board}.hex
printf "output to bin/serprog_stm32/serprog_%s.hex\n" "$board"
}
print_serprog_boards()
{
printf "Available boards:\n"
list_serprog_boards "${1}"
}
list_serprog_boards()
{
basename -a -s .h "${1}/"*.h || $err "list_boards $1: can't list boards"
}
handle_coreboot_target()
{
eval "$(setvars "n" ${pv}) $(setvars "" ${v})"
grub_background="background1280x800.png"
board="$1"
status="unknown"
configure_target
[ "$board" = "$tree" ] && \
return 0
print_target_name && return 0
# exclude certain targets from the release
if skip_board; then
printf "Skip target %s(%s)\n" "$board" "$status"
skipped="* $board($status)\n$skipped"
return 0
fi
build_payloads
build_target_mainboard
[ -d "bin/${board}" ] || return 0
targets="* bin/${board}\n${targets}"
}
configure_target()
{
targetdir="${cfgsdir}/${board}"
@ -155,6 +225,25 @@ configure_target()
eval "payload_${_payload}=y"
}
print_target_name()
{
[ "$listboards" = "y" ] || return 1
[ -z "$list_type" ] && printf "%s\n" "$board"
for _list_type in $list_type; do
if [ "${_list_type#_}" = "$_list_type" ]; then
[ "$status" != "$_list_type" ] && \
continue
printf "%s\n" "$board"
break
elif [ "$status" != "${_list_type#_}" ]; then
printf "%s\n" "$board"
break
fi
done
}
skip_board()
{
if [ "$listboards" != "y" ] && [ "$status" != "stable" ]; then
@ -469,6 +558,9 @@ usage()
./build roms list
Can also build serprog images:
${serprog_usage}
to see targets of only a given status (stable, unstable,
broken, untested and unknown), try e.g.

View File

@ -1,77 +0,0 @@
#!/usr/bin/env sh
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2023 Riku Viitanen <riku.viitanen@protonmail.com>
# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org>
set -u -e
. "include/err.sh"
eval "$(setvars "" pico_sdk_dir pico_src_dir stm32_src_dir boards_dir)"
pico_src_dir=src/pico-serprog
pico_sdk_dir=src/pico-sdk
stm32_src_dir=src/stm32-vserprog
usage="usage: ./build firmware serprog <rp2040|stm32> [board]"
main()
{
[ -z "${1+x}" ] && $err "${usage}"
[ "$1" != "rp2040" ] && [ "$1" != "stm32" ] && $err "$usage"
if [ "${1}" = "rp2040" ]; then
boards_dir=${pico_sdk_dir}/src/boards/include/boards
[ -d "$pico_src_dir" ] || x_ ./update trees -f "pico-serprog"
elif [ "${1}" = "stm32" ]; then
boards_dir=${stm32_src_dir}/boards
[ -d "$stm32_src_dir" ] || x_ ./update trees -f "stm32-vserprog"
fi
x_ mkdir -p "bin/serprog_${1}"
if [ $# -gt 1 ] && [ "${2}" = "list" ]; then
print_boards ${boards_dir}
elif [ $# -gt 1 ]; then
build_${1}_rom "${2}"
else
printf "Building all serprog targets\n"
list_boards "${boards_dir}" | while read -r board; do
build_${1}_rom "${board}"
done
fi
}
build_rp2040_rom()
{
board=${1}
printf "Building pico-serprog for %s\n" "${board}"
x_ cmake -DPICO_BOARD="$board" -DPICO_SDK_PATH="$pico_sdk_dir" \
-B "${pico_src_dir}/build" "${pico_src_dir}"
x_ cmake --build "${pico_src_dir}/build"
x_ mv ${pico_src_dir}/build/pico_serprog.uf2 \
bin/serprog_rp2040/serprog_${board}.uf2
printf "output to bin/serprog_rp2040/serprog_%s.uf2\n" "$board"
}
build_stm32_rom()
{
board=${1}
printf "Building stm32-vserprog for %s\n" "${board}"
x_ make -C $stm32_src_dir libopencm3-just-make BOARD=$board
x_ make -C ${stm32_src_dir} BOARD=${board}
x_ mv ${stm32_src_dir}/stm32-vserprog.hex \
bin/serprog_stm32/serprog_${board}.hex
printf "output to bin/serprog_stm32/serprog_%s.hex\n" "$board"
}
print_boards()
{
printf "Available boards:\n"
list_boards "${1}"
}
list_boards()
{
basename -a -s .h "${1}/"*.h || $err "list_boards $1: can't list boards"
}
main $@

View File

@ -4,7 +4,6 @@
set -u -e
. "include/err.sh"
. "include/option.sh"
eval "$(setvars "" vdir relname src_dirname srcdir _xm target romdir mode)"
@ -107,8 +106,8 @@ fetch_trees()
mkrom_images()
{
./build roms all || $err "${_xm}: roms-all"
./build serprog rp2040 || $err "${_xm}: rp2040"
./build serprog stm32 || $err "${_xm}: stm32"
./build roms serprog rp2040 || $err "${_xm}: rp2040"
./build roms serprog stm32 || $err "${_xm}: stm32"
for rombuild in bin/*; do
[ -d "${rombuild}" ] || continue

View File

@ -6,7 +6,6 @@
set -u -e
. "include/err.sh"
. "include/option.sh"
. "include/git.sh"