xiaomi-merlin: new device (MR 4808)

[ci:skip-build]: already built successfully in CI
This commit is contained in:
Natalia M. Sother 2024-02-07 22:51:24 +01:00 committed by Pablo Correa Gómez
parent 94de94e598
commit fa34a43cfc
No known key found for this signature in database
GPG key ID: 7A342565FF635F79
8 changed files with 5453 additions and 0 deletions

View file

@ -0,0 +1,30 @@
# Maintainer: Natalia M. Sother <meli.soweli@icloud.com>
# Reference: <https://postmarketos.org/devicepkg>
pkgname=device-xiaomi-merlin
pkgdesc="Xiaomi Redmi Note 9"
pkgver=0.1
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
options="!check !archcheck"
depends="
linux-xiaomi-merlin
mkbootimg
postmarketos-base
msm-fb-refresher
"
makedepends="devicepkg-dev"
source="deviceinfo"
build() {
devicepkg_build $startdir $pkgname
}
package() {
devicepkg_package $startdir $pkgname
}
sha512sums="
6f9cec7bd89652c97e2b17a010a87b5749ef68828fabaa0bf63b1b6728ce9452b46ca139a58393912c0180c88d2f5ad68ba97b303a5773056b5abb808f8f7e04 deviceinfo
"

View file

@ -0,0 +1,32 @@
# Reference: <https://postmarketos.org/deviceinfo>
# Please use double quotes only. You can source this file in shell
# scripts.
deviceinfo_format_version="0"
deviceinfo_name="Xiaomi Redmi Note 9"
deviceinfo_manufacturer="Xiaomi"
deviceinfo_codename="xiaomi-merlin"
deviceinfo_year="2020"
deviceinfo_dtb="mediatek/mt6768"
deviceinfo_arch="aarch64"
# Device related
deviceinfo_chassis="handset"
deviceinfo_keyboard="false"
deviceinfo_external_storage="true"
# Bootloader related
deviceinfo_flash_method="fastboot"
deviceinfo_kernel_cmdline="bootopt=64S3,32N2,64N2 buildvariant=userdebug"
deviceinfo_generate_bootimg="true"
deviceinfo_bootimg_qcdt="false"
deviceinfo_bootimg_dtb_second="false"
deviceinfo_flash_pagesize="2048"
deviceinfo_header_version="2"
deviceinfo_append_dtb="false"
deviceinfo_flash_offset_dtb="0x0bc08000"
deviceinfo_flash_offset_base="0x40078000"
deviceinfo_flash_offset_kernel="0x00008000"
deviceinfo_flash_offset_ramdisk="0x07c08000"
deviceinfo_flash_offset_second="0xbff88000"
deviceinfo_flash_offset_tags="0x0bc08000"

View file

@ -0,0 +1,69 @@
# Maintainer: Natalia M. Sother <meli.soweli@icloud.com>
# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/arm64/configs/merlin_defconfig
pkgname=linux-xiaomi-merlin
pkgver=4.14.320
pkgrel=0
pkgdesc="Xiaomi Redmi Note 9 kernel fork"
arch="aarch64"
_carch="arm64"
_flavor="xiaomi-merlin"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native"
makedepends="
bash
bc
bison
devicepkg-dev
findutils
flex
openssl-dev
perl
xz
dtc
"
# Source
_repository="android_kernel_xiaomi_mt6768"
_commit="210ab80b747a65c0a47c0ac59f117e6201fe2374"
_config="config-$_flavor.$arch"
source="
$pkgname-$_commit.tar.gz::https://github.com/LineageOS/$_repository/archive/$_commit.tar.gz
$_config
selinux_include_generated_headers.patch
use_system_cpio.patch
stop-inlining-blk_crypto_flock-and-ksm_flock.patch
use_system_dtc.patch
"
builddir="$srcdir/$_repository-$_commit"
_outdir="out"
prepare() {
default_prepare
REPLACE_GCCH=0 . downstreamkernel_prepare
}
build() {
unset LDFLAGS
make O="$_outdir" ARCH="$_carch" CC="${CC:-gcc}" \
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS"
}
package() {
downstreamkernel_package "$builddir" "$pkgdir" "$_carch" \
"$_flavor" "$_outdir"
make dtbs_install O="$_outdir" ARCH="$_carch" \
INSTALL_DTBS_PATH="$pkgdir"/boot/dtbs
}
sha512sums="
0e1e39e6b96f93ee6a4ccee2e3fc1821187a75bafc28ab68452f0e83ef6043a1ee9ea4c92ecd5e9b58e1711b5bd18110e6f45fa184caa3b7fc9ee2953703ad5d linux-xiaomi-merlin-210ab80b747a65c0a47c0ac59f117e6201fe2374.tar.gz
402a9fe0f0257df1962fd7f2cc1672dad27ff954477bff918adee1f4aed9d1901488f641f355cd5fc5b1d9a750baf4e4c7c842a4dd6b25724a364a4d52466bce config-xiaomi-merlin.aarch64
6ab9db01d35f7f5cc2c19ebe5f65a7dc479a1c68de587300cdde9a6c759d34610666c72f0f321cd450cf56c13df3b54a774e0f7ebdbf0f8608fbfd66b49d04e7 selinux_include_generated_headers.patch
28975f5aac872eab10bdfe2b29a8685b70ddb0d105c6c66a26de88ac912573b430fa20901b65384c9cb99d9740cdff7804cfd95474176f93a5bffbccf8182208 use_system_cpio.patch
e448a1093c09414be36333fbdb0d4a3bc5b59018d571b702c6607cb32927cf1563bf03aa1f2d502e6040490e0b26198dd8204306ebaad41be810ba2d47a2721c stop-inlining-blk_crypto_flock-and-ksm_flock.patch
c9e562403cd572c66def9adea434731b77617f7561f1ce1079e21e8f02e8fd9cc1febd7e52c581e8e4b1c4aca21c5ca8c5813d2006be13051048d681a640ab3d use_system_dtc.patch
"

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,33 @@
Arm64 has generated headers that other arches don't, didn't investigate why this
is able to compile in downstream (our upstream). Possibly due to out-of-tree build.
Note the hacky relative include. May not work in more complicated setups.
diff --git a/scripts/selinux/genheaders/Makefile b/scripts/selinux/genheaders/Makefile
index e8c533140..62475f060 100644
--- a/scripts/selinux/genheaders/Makefile
+++ b/scripts/selinux/genheaders/Makefile
@@ -2,6 +2,8 @@
hostprogs-y := genheaders
HOST_EXTRACFLAGS += \
-I$(srctree)/include/uapi -I$(srctree)/include \
- -I$(srctree)/security/selinux/include
+ -I$(srctree)/security/selinux/include \
+ -I./arch/$(ARCH)/include/generated/uapi \
+ -I$(srctree)/arch/$(ARCH)/include/uapi
always := $(hostprogs-y)
diff --git a/scripts/selinux/mdp/Makefile b/scripts/selinux/mdp/Makefile
index e9c92db7e..09e626fa4 100644
--- a/scripts/selinux/mdp/Makefile
+++ b/scripts/selinux/mdp/Makefile
@@ -2,7 +2,9 @@
hostprogs-y := mdp
HOST_EXTRACFLAGS += \
-I$(srctree)/include/uapi -I$(srctree)/include \
- -I$(srctree)/security/selinux/include
+ -I$(srctree)/security/selinux/include \
+ -I./arch/$(ARCH)/include/generated/uapi \
+ -I$(srctree)/arch/$(ARCH)/include/uapi
always := $(hostprogs-y)
clean-files := policy.* file_contexts

View file

@ -0,0 +1,72 @@
Fixes the following build errors under GCC 11:
In file included from ../block/blk-crypto.c:14:
../block/blk-crypto.c: In function 'blk_crypto_flock':
../include/linux/keyslot-manager.h:101:13: error: inlining failed in call to 'always_inline' 'ksm_flock': function body not available
101 | inline void ksm_flock(struct keyslot_manager *ksm, unsigned int flags);
| ^~~~~~~~~
../block/blk-crypto.c:310:9: note: called from here
310 | ksm_flock(ksm, flags);
| ^~~~~~~~~~~~~~~~~~~~~
In file included from ../drivers/md/dm.c:27:
../drivers/md/dm.c: In function 'dm_derive_raw_secret_callback':
../include/linux/blk-crypto.h:35:13: error: inlining failed in call to 'always_inline' 'blk_crypto_flock': function body not available
35 | inline void blk_crypto_flock(struct keyslot_manager *ksm, unsigned int flags);
| ^~~~~~~~~~~~~~~~
../drivers/md/dm.c:2120:17: note: called from here
2120 | blk_crypto_flock(dev->bdev->bd_queue->ksm, SINGLE_DEPTH_NESTING);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
diff --git a/block/blk-crypto.c b/block/blk-crypto.c
index f15ed0b70ecd..703700d9bf9d 100644
--- a/block/blk-crypto.c
+++ b/block/blk-crypto.c
@@ -305,7 +305,7 @@ int blk_crypto_evict_key(struct request_queue *q,
}
EXPORT_SYMBOL_GPL(blk_crypto_evict_key);
-inline void blk_crypto_flock(struct keyslot_manager *ksm, unsigned int flags)
+void blk_crypto_flock(struct keyslot_manager *ksm, unsigned int flags)
{
ksm_flock(ksm, flags);
}
diff --git a/block/keyslot-manager.c b/block/keyslot-manager.c
index 1ce66f66af20..95afcd9c4874 100644
--- a/block/keyslot-manager.c
+++ b/block/keyslot-manager.c
@@ -681,7 +681,7 @@ EXPORT_SYMBOL_GPL(keyslot_manager_derive_raw_secret);
* detection, set another lock sub-class could avoid it.
*
*/
-inline void ksm_flock(struct keyslot_manager *ksm, unsigned int flags)
+void ksm_flock(struct keyslot_manager *ksm, unsigned int flags)
{
ksm->lock_flags = flags;
}
diff --git a/include/linux/blk-crypto.h b/include/linux/blk-crypto.h
index 43d0dbbeb70f..30ba27226a22 100644
--- a/include/linux/blk-crypto.h
+++ b/include/linux/blk-crypto.h
@@ -32,7 +32,7 @@ int blk_crypto_start_using_mode(enum blk_crypto_mode_num crypto_mode,
int blk_crypto_evict_key(struct request_queue *q,
const struct blk_crypto_key *key);
-inline void blk_crypto_flock(struct keyslot_manager *ksm, unsigned int flags);
+void blk_crypto_flock(struct keyslot_manager *ksm, unsigned int flags);
#else /* CONFIG_BLK_INLINE_ENCRYPTION */
diff --git a/include/linux/keyslot-manager.h b/include/linux/keyslot-manager.h
index e247be8a5d43..dfb1d97d8fb6 100644
--- a/include/linux/keyslot-manager.h
+++ b/include/linux/keyslot-manager.h
@@ -98,7 +98,7 @@ int keyslot_manager_derive_raw_secret(struct keyslot_manager *ksm,
unsigned int wrapped_key_size,
u8 *secret, unsigned int secret_size);
-inline void ksm_flock(struct keyslot_manager *ksm, unsigned int flags);
+void ksm_flock(struct keyslot_manager *ksm, unsigned int flags);
#endif /* CONFIG_BLK_INLINE_ENCRYPTION */

View file

@ -0,0 +1,10 @@
--- a/kernel/gen_kheaders.sh
+++ b/kernel/gen_kheaders.sh
@@ -8,7 +8,7 @@
outdir="$(pwd)"
tarfile=$1
cpio_dir=$outdir/$tarfile.tmp
-cpio=$KBUILD_SRC/tools/build/cpio
+cpio=cpio
dir_list="
include/

View file

@ -0,0 +1,16 @@
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index b442d12ff2fe..5fe57a7d5320 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -312,7 +312,7 @@ $(obj)/%.dtb.S: $(obj)/%.dtb
quiet_cmd_dtc = DTC $@
cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
$(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
- $(srctree)/scripts/dtc/dtc_overlay -@ -O dtb -o $@ -b 0 \
+ dtc -@ -O dtb -o $@ -b 0 \
$(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \
-d $(depfile).dtc.tmp $(dtc-tmp) ; \
cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
--
2.36.1