Skip to content

Commit 3a1f044

Browse files
committed
starlabs: make compact profiles self-contained
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
1 parent 09d54e1 commit 3a1f044

5 files changed

Lines changed: 78 additions & 18 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ define define_module =
470470
$(eval $1_module_file = $(or $($1_module_file),$1))
471471

472472
ifneq ("$($1_repo)","")
473-
$(eval $1_patch_name = $1$(if $($1_patch_version),-$($1_patch_version),))
473+
$(eval $1_patch_name = $(or $($1_patch_name_override),$1$(if $($1_patch_version),-$($1_patch_version),)))
474474
# First time:
475475
# Checkout the tree instead and create the canary file with repo and
476476
# revision so that we know that the files are all present and their
@@ -559,7 +559,7 @@ define define_module =
559559
# the version a second time. (The '-' separator is also omitted then.)
560560
# $1_patch_version can still be defined manually.
561561
$(eval $1_patch_version ?= $(if $(filter %-$($1_version),$1),,$($1_version)))
562-
$(eval $1_patch_name = $1$(if $($1_patch_version),-,)$($1_patch_version))
562+
$(eval $1_patch_name = $(or $($1_patch_name_override),$1$(if $($1_patch_version),-,)$($1_patch_version)))
563563
# Fetch and verify the source tar file
564564
# wget creates it early, so we have to cleanup if it fails
565565
$(packages)/$($1_tar):

initrd/bin/kexec-boot.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ if [ -x /bin/io386 -a "$CONFIG_FINALIZE_PLATFORM_LOCKING" = "y" ]; then
212212
lock_chip.sh
213213
fi
214214

215-
if [ "$CONFIG_BRAND_NAME" = "Heads" ]; then
215+
if [ "$CONFIG_BRAND_NAME" = "Heads" ] && [ -x /bin/qrenc ]; then
216216
STATUS_OK "Heads firmware job done - handing off to your OS. Consider donating: https://opencollective.com/insurgo"
217217
qrenc "https://opencollective.com/insurgo"
218218
else

modules/busybox

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,43 @@
11
# Busybox is always included, unless explicitly turned off
22
CONFIG_BUSYBOX ?= y
3-
modules-$(CONFIG_BUSYBOX) += busybox
4-
5-
busybox_version := 1.36.1
6-
busybox_dir := busybox-$(busybox_version)
7-
busybox_tar := busybox-$(busybox_version).tar.bz2
8-
busybox_url := https://busybox.net/downloads/$(busybox_tar)
9-
busybox_hash := b8cc24c9574d809e7279c3be349795c5d5ceb6fdf19ca709f80cde50e47de314
10-
11-
busybox_configure := $(MAKE) CC="$(heads_cc)" oldconfig
12-
busybox_config := config/busybox.config
13-
busybox_output := busybox
14-
busybox_target := \
3+
4+
ifeq "$(CONFIG_BUSYBOX_COMPACT)" "y"
5+
busybox_module := busybox-compact
6+
else
7+
busybox_module := busybox
8+
endif
9+
10+
modules-$(CONFIG_BUSYBOX) += $(busybox_module)
11+
12+
$(busybox_module)_version := 1.36.1
13+
$(busybox_module)_dir := $(busybox_module)-$($(busybox_module)_version)
14+
$(busybox_module)_tar := busybox-$($(busybox_module)_version).tar.bz2
15+
$(busybox_module)_url := https://busybox.net/downloads/$($(busybox_module)_tar)
16+
$(busybox_module)_hash := b8cc24c9574d809e7279c3be349795c5d5ceb6fdf19ca709f80cde50e47de314
17+
$(busybox_module)_module_file := busybox
18+
$(busybox_module)_patch_name_override := busybox-1.36.1
19+
$(busybox_module)_depends := $(musl_dep)
20+
21+
$(busybox_module)_configure := \
22+
$(if $(filter y,$(CONFIG_BUSYBOX_COMPACT)), \
23+
for symbol in \
24+
I2CGET I2CSET I2CDUMP I2CDETECT \
25+
ARP IFCONFIG IP NC NSLOOKUP NTPD PING ROUTE SSL_CLIENT \
26+
TFTP TLS VCONFIG WGET UDHCPC; do \
27+
sed -i "s/^CONFIG_$$$${symbol}=y$$$$/# CONFIG_$$$${symbol} is not set/" .config; \
28+
done; \
29+
sed -i 's/^# CONFIG_LSPCI is not set$$$$/CONFIG_LSPCI=y/' .config; \
30+
) \
31+
$(MAKE) CC="$(heads_cc)" oldconfig
32+
$(busybox_module)_config := config/busybox.config
33+
$(busybox_module)_output := busybox
34+
$(busybox_module)_target := \
1535
$(CROSS_TOOLS) \
1636
$(MAKE_JOBS) \
1737
SOURCE_DATE_EPOCH=0 \
1838

39+
busybox_dir := $($(busybox_module)_dir)
40+
1941
# For reproducibility, busybox is linked without --gc-sections.
2042
# SEE: patches/busybox-1.36.1/0004-trylink-reproducible.patch
2143
# patches scripts/trylink to skip --gc-sections when SOURCE_DATE_EPOCH
@@ -52,6 +74,3 @@ $(initrd_bin_dir)/busybox: $(build)/$(busybox_dir)/.build
5274
$(VERBOSE_REDIRECT) \
5375
)
5476
@touch $< # ensure that our build file is still newer
55-
56-
57-
busybox_depends := $(musl_dep)

modules/pciutils

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
modules-$(CONFIG_PCIUTILS) += pciutils
2+
modules-$(CONFIG_PCIUTILS_LIB_ONLY) += pciutils
23

34
pciutils_depends := $(musl_dep)
45

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
# SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
set -euo pipefail
5+
6+
repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)
7+
8+
grep -F 'modules-$(CONFIG_PCIUTILS_LIB_ONLY) += pciutils' \
9+
"$repo_root/modules/pciutils" >/dev/null
10+
grep -F 'busybox_module := busybox-compact' \
11+
"$repo_root/modules/busybox" >/dev/null
12+
grep -F '$(busybox_module)_patch_name_override := busybox-1.36.1' \
13+
"$repo_root/modules/busybox" >/dev/null
14+
grep -F '$(busybox_module)_depends := $(musl_dep)' \
15+
"$repo_root/modules/busybox" >/dev/null
16+
grep -F 'CONFIG_LSPCI=y' "$repo_root/modules/busybox" >/dev/null
17+
18+
for applet in ARP I2CGET PING TLS WGET UDHCPC; do
19+
grep -qw "$applet" "$repo_root/modules/busybox"
20+
done
21+
22+
grep -F 'if [ "$CONFIG_BRAND_NAME" = "Heads" ] && [ -x /bin/qrenc ]; then' \
23+
"$repo_root/initrd/bin/kexec-boot.sh" >/dev/null
24+
25+
while IFS=: read -r config size; do
26+
if (( size > 0x1000000 )); then
27+
echo "$config exceeds the 16 MiB CBFS decode window" >&2
28+
exit 1
29+
fi
30+
done < <(grep -H '^CONFIG_CBFS_SIZE=' \
31+
"$repo_root"/config/coreboot-starlabs_*.config | \
32+
sed 's/:CONFIG_CBFS_SIZE=/:/')
33+
34+
if grep -R -q '^export CONFIG_CBFS_VIA_FLASHPROG=y' \
35+
"$repo_root/boards/starlabs"; then
36+
echo "Star Labs boards must keep CBFS in the memory-mapped window" >&2
37+
exit 1
38+
fi
39+
40+
echo "Star Labs compact profile tests passed"

0 commit comments

Comments
 (0)