Skip to content

Instantly share code, notes, and snippets.

@TheBrokenRail
Last active November 17, 2023 07:47
Show Gist options
  • Save TheBrokenRail/069bd0eb23ed3967fb96be7e9a7742c1 to your computer and use it in GitHub Desktop.
Save TheBrokenRail/069bd0eb23ed3967fb96be7e9a7742c1 to your computer and use it in GitHub Desktop.
Cross-compile a Linux kernel with FunctionFS for the PinePhone running postmarketOS v23.06.
#!/bin/sh
set -e
# Setup
sudo apk update
abuild-keygen -a -i -n
cp ~/.abuild/*.rsa.pub /data/out
# Clone Repository
git clone https://gitlab.com/postmarketOS/pmaports.git -b "${PMOS_VERSION}"
cd pmaports
patch -p1 < /data/pmaports.patch
# Build
cd device/main/linux-postmarketos-allwinner
abuild checksum
abuild -r
# Copy Output
cp -r ~/packages /data/out/packages
# Change this when changing the postmarketOS version!
FROM arm64v8/alpine:3.18
# The postmarketOS Version
ENV PMOS_VERSION="v23.06"
# Use postmarketOS
RUN \
echo "https://mirror.postmarketos.org/postmarketos/${PMOS_VERSION}" > temp && \
cat /etc/apk/repositories >> temp && \
cat temp > /etc/apk/repositories && \
rm -f temp && \
apk add --update --no-cache --no-progress --allow-untrusted postmarketos-keys
# Install Dependencies
RUN apk add --update --no-cache --no-progress alpine-sdk git sudo
# Create User
RUN \
addgroup -g 1000 user && \
adduser -D -u 1000 -G user -s /bin/bash user && \
adduser user abuild && \
echo 'user ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# Switch To User
USER user
WORKDIR /home/user
--- a/device/main/linux-postmarketos-allwinner/APKBUILD
+++ b/device/main/linux-postmarketos-allwinner/APKBUILD
@@ -32,7 +32,7 @@ options="!strip !check !tracedeps
pmb:cross-native
pmb:kconfigcheck-community
"
-source="$pkgname-$_tag.tar.gz::https://github.com/megous/linux/archive/$_tag.tar.gz
+source="$pkgname-$_tag.tar.gz::https://codeberg.org/megi/linux/archive/$_tag.tar.gz
config-$_flavor.aarch64
config-$_flavor.armv7
0001-dts-add-dontbeevil-pinephone-devkit.patch
@@ -48,7 +48,7 @@ source="$pkgname-$_tag.tar.gz::https://github.com/megous/linux/archive/$_tag.tar
0011-sunxi-mmc-h6-fix.patch
0012-arm64-dts-allwinner-orangepi-3-fix-ethernet.patch
"
-builddir="$srcdir/linux-$_tag"
+builddir="$srcdir/linux"
case "$CARCH" in
aarch64*) _carch="arm64" ;;
--- a/device/main/linux-postmarketos-allwinner/config-postmarketos-allwinner.aarch64
+++ b/device/main/linux-postmarketos-allwinner/config-postmarketos-allwinner.aarch64
@@ -4442,7 +4442,7 @@ CONFIG_USB_CONFIGFS_F_TCM=y
# CONFIG_USB_ETH is not set
# CONFIG_USB_G_NCM is not set
# CONFIG_USB_GADGETFS is not set
-# CONFIG_USB_FUNCTIONFS is not set
+CONFIG_USB_FUNCTIONFS=m
# CONFIG_USB_MASS_STORAGE is not set
# CONFIG_USB_GADGET_TARGET is not set
# CONFIG_USB_G_SERIAL is not set
#!/bin/sh
set -e
# Build Docker Image
docker build -t pinephone-kernel-build .
# Create Output Directory
rm -rf out
mkdir out
# Run
docker run --rm -v "$(pwd):/data" pinephone-kernel-build /data/build.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment