Index | Thread | Search

From:
Mark Kettenis <mark.kettenis@xs4all.nl>
Subject:
sysutils/crust: SCP firmware for Allwinner SoCs
To:
ports@openbsd.org
Cc:
patrick@openbsd.org, jsg@openbsd.org, sthen@openbsd.org
Date:
Mon, 19 Feb 2024 22:18:58 +0100

Download raw body.

Thread
This will be used in an upcoming u-boot update for Allwinner's 64-bit
SoCs.  This will bring "proper" S3-like suspend/resume on selected
boards.

ok?


diff --git a/sysutils/crust/Makefile b/sysutils/crust/Makefile
new file mode 100644
index 00000000000..3b187598161
--- /dev/null
+++ b/sysutils/crust/Makefile
@@ -0,0 +1,57 @@
+PKG_ARCH=	*
+
+COMMENT=	Libre SCP firmware for Allwinner sunxi SoCs
+
+GH_ACCOUNT=	crust-firmware
+GH_PROJECT=	crust
+GH_TAGNAME=	v0.6
+
+CATEGORIES=	sysutils
+
+# BSD
+PERMIT_PACKAGE=	Yes
+
+BUILD_DEPENDS+=	devel/or1k-elf/gcc
+
+MAKE_ENV+= CROSS_COMPILE="or1k-unknown-elf-"
+
+NO_TEST=	Yes
+USE_GMAKE=	Yes
+
+BOARDS=\
+	a64-olinuxino \
+	nanopi_a64 \
+	orangepi_pc2 \
+	orangepi_win \
+	orangepi_zero_plus \
+	pine64-lts \
+	pine64_plus \
+	pine_h64 \
+	pinebook
+
+do-build:
+.for BOARD in ${BOARDS}
+	cd ${WRKSRC} && \
+	    mkdir -p build/${BOARD} && \
+	    ${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} ${MAKE_FLAGS} \
+	        OBJ="build/${BOARD}" \
+	        -f ${MAKE_FILE} "${BOARD}"_defconfig
+	cd ${WRKSRC} && \
+	    ${SETENV} ${MAKE_ENV} \
+		${MAKE_PROGRAM} ${MAKE_FLAGS} OBJ="build/${BOARD}" \
+	        -f ${MAKE_FILE} ${ALL_TARGET}
+.endfor
+
+do-install:
+	${INSTALL_DATA_DIR} ${PREFIX}/share/crust
+.for BOARD in ${BOARDS}
+	@[ -d ${WRKSRC}/build/${BOARD}/scp ] && \
+	echo ${INSTALL_DATA_DIR} ${PREFIX}/share/crust/${BOARD} && \
+	${INSTALL_DATA_DIR} ${PREFIX}/share/crust/${BOARD} && \
+	echo cd ${WRKSRC}/build/${BOARD}/scp && \
+	cd ${WRKSRC}/build/${BOARD}/scp && \
+	echo ${INSTALL_DATA} scp.bin ${PREFIX}/share/crust/${BOARD}/; \
+	${INSTALL_DATA} scp.bin ${PREFIX}/share/crust/${BOARD}/
+.endfor
+
+.include <bsd.port.mk>
diff --git a/sysutils/crust/distinfo b/sysutils/crust/distinfo
new file mode 100644
index 00000000000..2987fe1882f
--- /dev/null
+++ b/sysutils/crust/distinfo
@@ -0,0 +1,2 @@
+SHA256 (crust-0.6.tar.gz) = Q7iVhd17bwIiAL14ipeoWoMf7/qYiv/AS8oYdXoTPv0=
+SIZE (crust-0.6.tar.gz) = 193461
diff --git a/sysutils/crust/patches/patch-3rdparty_kconfig_confdata_c b/sysutils/crust/patches/patch-3rdparty_kconfig_confdata_c
new file mode 100644
index 00000000000..96ed0b17872
--- /dev/null
+++ b/sysutils/crust/patches/patch-3rdparty_kconfig_confdata_c
@@ -0,0 +1,12 @@
+Index: 3rdparty/kconfig/confdata.c
+--- 3rdparty/kconfig/confdata.c.orig
++++ 3rdparty/kconfig/confdata.c
+@@ -71,7 +71,7 @@ static bool is_same(const char *file1, const char *fil
+ 	if (map2 == MAP_FAILED)
+ 		goto close2;
+ 
+-	if (bcmp(map1, map2, st1.st_size))
++	if (memcmp(map1, map2, st1.st_size))
+ 		goto close2;
+ 
+ 	ret = true;
diff --git a/sysutils/crust/patches/patch-Makefile b/sysutils/crust/patches/patch-Makefile
new file mode 100644
index 00000000000..0fbc0cfc7de
--- /dev/null
+++ b/sysutils/crust/patches/patch-Makefile
@@ -0,0 +1,11 @@
+Index: Makefile
+--- Makefile.orig
++++ Makefile
+@@ -27,7 +27,6 @@ COMMON_CFLAGS	 = -Os -pipe -std=c11 \
+ 		   -ffunction-sections \
+ 		   -fno-builtin \
+ 		   -fno-common \
+-		   -fvar-tracking-assignments \
+ 		   -g$(if $(CONFIG_DEBUG_INFO),gdb,0) \
+ 		   -Wall -Wextra -Wformat=2 -Wpedantic -Wshadow \
+ 		   -Werror=implicit-function-declaration \
diff --git a/sysutils/crust/pkg/DESCR b/sysutils/crust/pkg/DESCR
new file mode 100644
index 00000000000..950e67150a9
--- /dev/null
+++ b/sysutils/crust/pkg/DESCR
@@ -0,0 +1,11 @@
+Libre SCP firmware for Allwinner sunxi SoCs.
+
+Crust improves battery life and thermal performance by implementing a
+deep sleep state. During deep sleep, the CPU cores, the DRAM
+controller, and most onboard peripherals are powered down, reducing
+power consumption by 80% or more compared to an idle device. On boards
+without a PMIC, Crust is also responsible for orderly power-off and
+power-on of the device.
+
+This package provides SCP firware builds for boards supported by
+OpenBSD.
diff --git a/sysutils/crust/pkg/PLIST b/sysutils/crust/pkg/PLIST
new file mode 100644
index 00000000000..6bafc43d2dd
--- /dev/null
+++ b/sysutils/crust/pkg/PLIST
@@ -0,0 +1,19 @@
+share/crust/
+share/crust/a64-olinuxino/
+share/crust/a64-olinuxino/scp.bin
+share/crust/nanopi_a64/
+share/crust/nanopi_a64/scp.bin
+share/crust/orangepi_pc2/
+share/crust/orangepi_pc2/scp.bin
+share/crust/orangepi_win/
+share/crust/orangepi_win/scp.bin
+share/crust/orangepi_zero_plus/
+share/crust/orangepi_zero_plus/scp.bin
+share/crust/pine64-lts/
+share/crust/pine64-lts/scp.bin
+share/crust/pine64_plus/
+share/crust/pine64_plus/scp.bin
+share/crust/pine_h64/
+share/crust/pine_h64/scp.bin
+share/crust/pinebook/
+share/crust/pinebook/scp.bin