2021-10-04 11:14:48 +00:00
|
|
|
# Maintainer: Alexey Minnekhanov <alexeymin@postmarketos.org>
|
|
|
|
pkgname=lk2nd
|
2024-06-03 19:17:46 +00:00
|
|
|
pkgver=0.16.0
|
|
|
|
pkgrel=0
|
2021-10-04 11:14:48 +00:00
|
|
|
pkgdesc="Secondary little kernel (lk) bootloader for several Qualcomm devices"
|
|
|
|
arch="armv7 aarch64"
|
|
|
|
url="https://github.com/msm8916-mainline/lk2nd"
|
2022-03-29 12:43:29 +00:00
|
|
|
license="MIT AND BSD-3-Clause AND GPL-2.0-only"
|
2021-10-04 11:14:48 +00:00
|
|
|
makedepends="dtc dtc-dev gcc-arm-none-eabi python3 py3-libfdt"
|
2024-06-03 19:17:46 +00:00
|
|
|
source="
|
|
|
|
$pkgname-$pkgver.tar.gz::https://github.com/msm8916-mainline/lk2nd/archive/refs/tags/$pkgver.tar.gz
|
|
|
|
0001-build-fixes.patch
|
|
|
|
"
|
2021-10-04 11:14:48 +00:00
|
|
|
options="!check !archcheck !tracedeps !strip pmb:cross-native"
|
|
|
|
# This APKBUILD builds bare metal executable; options are very specific!
|
|
|
|
# * there are no tests (how do you even test the bootloader?);
|
|
|
|
# * binaries are "arch-independent"; aarch64 build also produces armv7 binary,
|
|
|
|
# because ARM CPUs boot in 32-bit mode;
|
|
|
|
# * there are no depends for bootloader, it's a kernel and OS in one binary;
|
|
|
|
# * stripping of unused sections is done in lk2nd's own ld script.
|
|
|
|
|
|
|
|
subpackages="
|
|
|
|
$pkgname-msm8916
|
2021-10-27 19:06:33 +00:00
|
|
|
$pkgname-msm8916-appended:msm8916_appended
|
2021-10-04 11:14:48 +00:00
|
|
|
"
|
|
|
|
|
2023-03-07 12:15:47 +00:00
|
|
|
if [ "$CARCH" = "armv7" ]; then
|
|
|
|
subpackages="
|
|
|
|
$subpackages
|
|
|
|
$pkgname-msm8226
|
|
|
|
$pkgname-msm8226-appended:msm8226_appended
|
2023-09-27 09:52:55 +00:00
|
|
|
$pkgname-msm8226-htc-memul:msm8226_htc_memul
|
2023-05-13 09:39:22 +00:00
|
|
|
$pkgname-msm8974
|
|
|
|
$pkgname-msm8974-appended:msm8974_appended
|
|
|
|
"
|
2023-03-07 12:15:47 +00:00
|
|
|
fi
|
|
|
|
|
2023-09-27 09:52:55 +00:00
|
|
|
_build() {
|
2021-10-04 11:14:48 +00:00
|
|
|
# This builds baremetal executable; distro-specific compiler flags
|
|
|
|
# and optimizations can't be set by build system.
|
|
|
|
unset CFLAGS
|
|
|
|
unset CXXFLAGS
|
|
|
|
unset CPPFLAGS
|
|
|
|
unset LDFLAGS
|
|
|
|
unset CROSS_COMPILE
|
|
|
|
unset CC
|
|
|
|
unset CXX
|
|
|
|
|
|
|
|
# ccache and crossdirect "gcc"s are in PATH, get rid of them too,
|
|
|
|
# redefine PATH to be bare minimum
|
|
|
|
unset PATH
|
|
|
|
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
|
|
|
|
2023-09-27 09:52:55 +00:00
|
|
|
local project="$1"; shift
|
|
|
|
|
|
|
|
make LK2ND_VERSION="$pkgver-r$pkgrel-postmarketos" TOOLCHAIN_PREFIX=arm-none-eabi- "$@" "$project"
|
|
|
|
}
|
|
|
|
|
|
|
|
build() {
|
|
|
|
_build lk2nd-msm8916
|
2023-03-07 12:15:47 +00:00
|
|
|
if [ "$CARCH" = "armv7" ]; then
|
2023-09-27 09:52:55 +00:00
|
|
|
_build lk2nd-msm8974
|
|
|
|
_build lk2nd-msm8226
|
|
|
|
_build lk2nd-msm8226 BOOTLOADER_OUT=htc-memul SCRATCH_ADDR=0x20000000 SCRATCH_ADDR_512MAP=0x20000000 SCRATCH_SIZE_512MAP=0x10000000
|
2023-03-07 12:15:47 +00:00
|
|
|
fi
|
2021-10-04 11:14:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
package() {
|
|
|
|
# main package is empty
|
|
|
|
mkdir -p "$pkgdir"
|
|
|
|
}
|
|
|
|
|
|
|
|
msm8916() {
|
2022-03-02 21:11:02 +00:00
|
|
|
install -Dm644 "$builddir"/build-lk2nd-msm8916/lk2nd.img -t \
|
2021-10-04 11:14:48 +00:00
|
|
|
"$subpkgdir"/boot
|
|
|
|
}
|
|
|
|
|
2021-10-27 19:06:33 +00:00
|
|
|
msm8916_appended() {
|
2022-03-02 21:11:02 +00:00
|
|
|
install -Dm644 "$builddir"/build-lk2nd-msm8916/lk2nd-appended-dtb.img \
|
2021-10-27 19:06:33 +00:00
|
|
|
"$subpkgdir"/boot/lk2nd.img
|
|
|
|
}
|
|
|
|
|
2021-10-04 11:14:48 +00:00
|
|
|
msm8974() {
|
2022-03-02 21:11:02 +00:00
|
|
|
install -Dm644 "$builddir"/build-lk2nd-msm8974/lk2nd.img -t \
|
2021-10-04 11:14:48 +00:00
|
|
|
"$subpkgdir"/boot
|
|
|
|
}
|
|
|
|
|
2023-05-13 09:39:22 +00:00
|
|
|
msm8974_appended() {
|
|
|
|
install -Dm644 "$builddir"/build-lk2nd-msm8974/lk2nd-appended-dtb.img \
|
|
|
|
"$subpkgdir"/boot/lk2nd.img
|
|
|
|
}
|
|
|
|
|
2022-10-17 09:53:56 +00:00
|
|
|
msm8226() {
|
|
|
|
install -Dm644 "$builddir"/build-lk2nd-msm8226/lk2nd.img \
|
|
|
|
"$subpkgdir"/boot/lk2nd.img
|
|
|
|
}
|
|
|
|
|
2021-10-27 19:06:33 +00:00
|
|
|
msm8226_appended() {
|
2022-03-02 21:11:02 +00:00
|
|
|
install -Dm644 "$builddir"/build-lk2nd-msm8226/lk2nd-appended-dtb.img \
|
2021-10-27 19:06:33 +00:00
|
|
|
"$subpkgdir"/boot/lk2nd.img
|
2021-10-04 11:14:48 +00:00
|
|
|
}
|
|
|
|
|
2023-09-27 09:52:55 +00:00
|
|
|
msm8226_htc_memul() {
|
|
|
|
install -Dm644 "$builddir"/htc-memul/build-lk2nd-msm8226/lk2nd.img \
|
|
|
|
"$subpkgdir"/boot/lk2nd.img
|
|
|
|
}
|
|
|
|
|
2021-10-04 11:14:48 +00:00
|
|
|
sha512sums="
|
2024-06-03 19:17:46 +00:00
|
|
|
e3708b02f7bf677c60b9f09e75d70c05438466c62378294b31109c9085bfaf5e25598c91a841dc2756367b5cb069e10d9df56c1d1b174ba07b8fd2017487c5c2 lk2nd-0.16.0.tar.gz
|
|
|
|
e0ff876f69950cd3026d0168edc7e32d1f671a448153ee3c1dcf8906aed3c67b91bdd3e1ea73e789c7d85fbf2bebd42054dd89ae486d1921df456f606a7e82d2 0001-build-fixes.patch
|
2021-10-04 11:14:48 +00:00
|
|
|
"
|