google-crosshatch: add WIP mainline kernel (!226)

This is tested to boot on google-crosshatch, following these
instructions:

$ pmbootstrap init, choose the mainline kernel
$ pmbootstrap install --no-fde
$ pmbootstrap initfs hook_add debug-shell
(enter fastboot mode on the device)
$ fastboot set_active a
$ fastboot flash dtbo_a ~/.local/var/pmbootstrap/chroot_rootfs_google-crosshatch/boot/dtbo-google-crosshatch-mainline.img
$ pmbootstrap flasher boot

And you should get telnet after a while. This kernel takes a long time
to build, so [skip ci]. I can confirm it builds locally.

Note that this patch adds the mainline dtb path to deviceinfo. But the
parameter gets ignored on the downstream kernel, so it's fine to keep it
in the shared deviceinfo.

Mainlining this device is work in progress, details at:
https://gitlab.com/postmarketOS/pmaports/issues/153
This commit is contained in:
Zhuowei Zhang 2019-02-16 22:00:28 -08:00 committed by Oliver Smith
parent 2f06979a09
commit ba902038ca
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
6 changed files with 7176 additions and 4 deletions

View file

@ -2,14 +2,18 @@
pkgname="device-google-crosshatch"
pkgdesc="Google Pixel 3 XL"
pkgver=0.1
pkgrel=1
pkgrel=2
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
options="!check !archcheck"
depends="postmarketos-base linux-google-crosshatch mkbootimg mesa-dri-swrast"
depends="postmarketos-base mkbootimg mesa-dri-swrast"
makedepends="devicepkg-dev"
source="deviceinfo"
subpackages="
$pkgname-kernel-downstream:kernel_downstream
$pkgname-kernel-mainline:kernel_mainline
"
build() {
devicepkg_build $startdir $pkgname
@ -19,5 +23,16 @@ package() {
devicepkg_package $startdir $pkgname
}
kernel_downstream() {
pkgdesc="LineageOS downstream kernel (recommended)"
depends="linux-google-crosshatch"
mkdir "$subpkgdir"
}
sha512sums="0e8267e176ec2ddb6f68694c4233be4b1a9c6c0a0a8ee0920070ab75af6a4ee396d57a92c119887ceeb9d454762bc15fa45e79f28a53089a79772c493f1b8db7 deviceinfo"
kernel_mainline() {
pkgdesc="Attempt at mainlining. DO NOT USE: doesn't work (only USB networking is supported)"
depends="linux-google-crosshatch-mainline firmware-google-crosshatch-mainline-dtbo"
mkdir "$subpkgdir"
}
sha512sums="67bfa71f40a1fc761a7fc18d208d05d6da23f9cc7ff0b05c23cc9cb1dbc2be68a6cb77fedfc39938eaf2c41f8cbe9095c7f38ff587d9828d80a4c958d27dfd9a deviceinfo"

View file

@ -6,7 +6,7 @@ deviceinfo_name="Google Pixel 3 XL"
deviceinfo_manufacturer="Google"
deviceinfo_codename="google-crosshatch"
deviceinfo_date=""
deviceinfo_dtb=""
deviceinfo_dtb="qcom/sdm845-crosshatch"
deviceinfo_modules_initfs=""
deviceinfo_arch="aarch64"

View file

@ -0,0 +1,191 @@
# Kernel config based on: arch/arm64/configs/defconfig
# APKBUILD based on linux-postmarketos-mainline
# See: https://gitlab.com/postmarketOS/pmaports/issues/153
_flavor=google-crosshatch-mainline
_config="config-${_flavor}.${CARCH}"
pkgname=linux-${_flavor}
pkgver=5.0_rc5
_pkgver=${pkgver/_/-}
_kernver=${pkgver%_rc*}
_mainver=${_kernver%.*}
_patchlevel=${_kernver/$_mainver./}
_basever=${_mainver}.$((_patchlevel-1))
pkgrel=0
arch="aarch64"
pkgdesc="Google Pixel 3 XL mainline kernel; only USB networking works, nothing else"
url="https://kernel.org/"
depends=""
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev openssl-dev file bison flex"
options="!strip !check !tracedeps"
install=
_repository="linux"
_commit="b14ca253ec25cde39c7b07ac3a3542838672fc15"
source="
$pkgname-$_commit.tar.gz::https://github.com/Pixel3Dev/${_repository}/archive/${_commit}.tar.gz
config-${_flavor}.aarch64
"
subpackages="$pkgname-dev"
license="GPL2"
_abi_release=$_pkgver
_carch=${CARCH}
case "$_carch" in
aarch64*) _carch="arm64" ;;
arm*) _carch="arm" ;;
ppc*) _carch="powerpc" ;;
s390*) _carch="s390" ;;
esac
HOSTCC="${CC:-gcc}"
HOSTCC="${HOSTCC#${CROSS_COMPILE}}"
builddir="$srcdir/linux-$_commit"
prepare() {
local _patch_failed=
cd "$builddir"
# first apply patches in specified order
for i in $source; do
case $i in
*.patch|*.patch::*)
_patch=${i%::*}
msg "Applying $_patch..."
if ! patch -s -p1 -N -i "$srcdir"/$_patch; then
echo $_patch >>failed
_patch_failed=1
fi
;;
esac
done
if ! [ -z "$_patch_failed" ]; then
error "The following patches failed:"
cat failed
return 1
fi
mkdir -p "$srcdir"/build
cp -v "$srcdir"/$_config "$srcdir"/build/.config
make -C "$builddir" O="$srcdir"/build ARCH="$_carch" HOSTCC="$HOSTCC" \
olddefconfig
}
build() {
cd "$srcdir"/build
unset LDFLAGS
make ARCH="$_carch" CC="${CC:-gcc}" \
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-${_flavor}" \
CFLAGS_MODULE=-fno-pic
}
package() {
cd "$srcdir/build/arch/${_carch}/boot"
if [ "$CARCH" == "aarch64" ]; then
install -Dm644 "$srcdir/build/arch/${_carch}/boot/Image.gz" \
"$pkgdir/boot/vmlinuz-$_flavor"
else
install -Dm644 "$srcdir/build/arch/${_carch}/boot/"*zImage \
"$pkgdir/boot/vmlinuz-$_flavor"
fi
install -D "$srcdir/build/include/config/kernel.release" \
"$pkgdir/usr/share/kernel/$_flavor/kernel.release"
cd "$srcdir"/build
local _install
case "$CARCH" in
aarch64*|arm*) _install="modules_install dtbs_install" ;;
*) _install="modules_install" ;;
esac
make -j1 $_install \
ARCH="$_carch" \
INSTALL_MOD_PATH="$pkgdir" \
INSTALL_DTBS_PATH="$pkgdir/usr/share/dtb"
}
dev() {
# copy the only the parts that we really need for build 3rd party
# kernel modules and install those as /usr/src/linux-headers,
# simlar to what ubuntu does
#
# this way you dont need to install the 300-400 kernel sources to
# build a tiny kernel module
#
pkgdesc="Headers and script for third party modules for postmarketos kernel"
depends="gmp-dev bash perl"
local dir="$subpkgdir"/usr/src/linux-headers-${_abi_release}
# first we import config, run prepare to set up for building
# external modules, and create the scripts
mkdir -p "$dir"
cp "$srcdir"/$_config "$dir"/.config
make -j1 -C "$builddir" O="$dir" ARCH="$_carch" HOSTCC="$HOSTCC" \
olddefconfig prepare modules_prepare scripts
# needed for 3rd party modules
# https://bugzilla.kernel.org/show_bug.cgi?id=11143
case "$CARCH" in
ppc*) (cd "$dir" && make arch/powerpc/lib/crtsavres.o);;
esac
# remove the stuff that points to real sources. we want 3rd party
# modules to believe this is the soruces
rm "$dir"/Makefile "$dir"/source
# copy the needed stuff from real sources
#
# this is taken from ubuntu kernel build script
# http://kernel.ubuntu.com/git/ubuntu/ubuntu-zesty.git/tree/debian/rules.d/3-binary-indep.mk
cd "$builddir"
find . -path './include/*' -prune \
-o -path './scripts/*' -prune -o -type f \
\( -name 'Makefile*' -o -name 'Kconfig*' -o -name 'Kbuild*' -o \
-name '*.sh' -o -name '*.pl' -o -name '*.lds' \) \
-print | cpio -pdm "$dir"
cp -a scripts include "$dir"
find $(find arch -name include -type d -print) -type f \
| cpio -pdm "$dir"
install -Dm644 "$srcdir"/build/Module.symvers \
"$dir"/Module.symvers
mkdir -p "$subpkgdir"/lib/modules/${_abi_release}
ln -sf /usr/src/linux-headers-${_abi_release} \
"$subpkgdir"/lib/modules/${_abi_release}/build
# cross-compiling: delete binaries with host arch and replace them with
# symlinks to binaries with the target arch (packaged in kernel-scripts)
if [ -n "$CROSS_COMPILE" ]; then
msg "Symlinking binary scripts..."
depends="$depends kernel-scripts"
local found="false"
cd "$dir/scripts"
local i
for i in $(find . -type f); do
local type="$(file -b --mime-type "$i")"
[ "$type" != "application/x-pie-executable" ] && continue
local native="/usr/bin/kernel-scripts/$(echo "$i" | cut -d '/' -f 2-)"
ln -svf "$native" "$i"
found="true"
done
if [ "$found" = "false" ]; then
error "Failed to symlink binary scripts!"
error "Did the mime-type change (see #1659)?"
return 1
fi
fi
}
sha512sums="027d5a16ca9299bc3b5b51c6a6e00295c6a31f1a0f01604482bcfc93f6ce87eaa1623998b560acd4980266deedce320f0a96cf6043905c7da8136925c8900fea linux-google-crosshatch-mainline-b14ca253ec25cde39c7b07ac3a3542838672fc15.tar.gz
947d7ca37c57335aae5137a9dc40e983c28ddd7f2bd4ef2ec21feb5d609809a6e96e52a989e1273f466ed8d655f717e84b649a81d0c4309d7d360172faa38e6d config-google-crosshatch-mainline.aarch64"

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,32 @@
pkgname=firmware-google-crosshatch-mainline-dtbo
pkgver=1
pkgrel=0
pkgdesc="dtbo.img needed to boot mainline"
url="https://gitlab.com/zhuowei/dtbo-google-crosshatch-mainline"
arch="noarch"
license="GPL-2.0"
depends=""
makedepends="dtc android-mkdtimg"
install=""
_commit="20324c21169622e7c68eb36524c74fb1da8837d5"
source="
https://gitlab.com/zhuowei/dtbo-google-crosshatch-mainline/-/archive/$_commit/$_commit.tar.gz
"
builddir="$srcdir/dtbo-google-crosshatch-mainline-$_commit"
build() {
cd "$builddir"
dtc -O dtb -o sdm845-c1-dvt1.1.dtbo -b 0 -@ sdm845-c1-dvt1.1.dts
mkdtimg cfg_create dtbo.img dtboimg.cfg
}
check() {
cd "$builddir"
}
package() {
install -D -m644 "$builddir"/dtbo.img \
"$pkgdir"/boot/dtbo-google-crosshatch-mainline.img
}
sha512sums="620bc391a82a427bf91c394bbf300451ad7cf452144a27f9fe40322459e6ac473ba85be5cf7e7ebab49d439d3b84b5c1c224883094c1bad5c8f5246abb6db71f 20324c21169622e7c68eb36524c74fb1da8837d5.tar.gz"

View file

@ -0,0 +1,37 @@
pkgname=android-mkdtimg
pkgver=1
pkgrel=0
pkgdesc="Tool to create dtbo images"
url="https://android.googlesource.com/platform/system/libufdt/"
arch="all"
license="Apache-2.0"
depends="libfdt"
makedepends="dtc-dev"
install=""
subpackages=""
# android-o-mr1-iot-release-smart-display-r4
_commit="f7b3c0ec3ab51b8000de5a5cb7485e91ef35370b"
source="
https://gitlab.com/zhuowei/android-mkdtimg/-/archive/$_commit/$_commit.tar.gz
"
builddir="$srcdir/android-mkdtimg-$_commit"
build() {
cd "$builddir"
$CC -o mkdtimg -Wall -Os -I sysdeps/include \
utils/src/mkdtimg.c utils/src/mkdtimg_cfg_create.c \
utils/src/mkdtimg_core.c utils/src/mkdtimg_create.c \
utils/src/mkdtimg_dump.c utils/src/dt_table.c \
sysdeps/libufdt_sysdeps_posix.c -lfdt
}
check() {
cd "$builddir"
}
package() {
install -D -m755 "$builddir"/mkdtimg \
"$pkgdir"/usr/bin/mkdtimg
}
sha512sums="7f4ccc7046b969a86ab933c52165db3fcf5d821cf9c177f644b87062525ade694beb2de22e83449d89bb2a4d061a4c8efcbd251b11acb9235ee0105295a7a322 f7b3c0ec3ab51b8000de5a5cb7485e91ef35370b.tar.gz"