Imported files

This commit is contained in:
Lux Aliaga 2021-08-21 20:32:11 -04:00
parent e83f2bdb33
commit 2c0b55ec7c
10 changed files with 6192 additions and 1 deletions

View File

@ -1,3 +1,5 @@
# xiaomi-laurel_sprout-pmOS
APKBUILDs for laurel_sprout
Build templates for Xiaomi Mi A3 (laurel_sprout). **NOT BOOTING** as of now, so if anyone wants to contribute, you're free to commit potential fixes.
![Mi A3 on Fastboot](device.png)

View File

@ -0,0 +1,29 @@
# Reference: <https://postmarketos.org/devicepkg>
pkgname=device-xiaomi-laurel_sprout
pkgdesc="Xiaomi Mi A3"
pkgver=0.1
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
options="!check !archcheck"
depends="
linux-xiaomi-laurel_sprout
mesa-dri-gallium
mkbootimg
postmarketos-base
"
makedepends="devicepkg-dev"
source="deviceinfo"
build() {
devicepkg_build $startdir $pkgname
}
package() {
devicepkg_package $startdir $pkgname
}
sha512sums="
ab9a6d1aaa755700547a0b7fae25772a340322dd1a48b2488b375a487dad2a0b0bb18018b491c12d5b8a5ff41e760d48f565b1a0f38a4527dfe7a1a6fa26af44 deviceinfo
"

View File

@ -0,0 +1,38 @@
# 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 Mi A3"
deviceinfo_manufacturer="Xiaomi"
deviceinfo_codename="xiaomi-laurel_sprout"
deviceinfo_year="2019"
deviceinfo_dtb=""
deviceinfo_modules_initfs=""
deviceinfo_arch="aarch64"
# Device related
deviceinfo_chassis="handset"
deviceinfo_keyboard="false"
deviceinfo_external_storage="true"
deviceinfo_screen_width="1560"
deviceinfo_screen_height="720"
deviceinfo_no_framebuffer="true"
deviceinfo_getty="ttyMSM0;115200"
# Bootloader related
deviceinfo_flash_method="fastboot"
deviceinfo_flash_fastboot_partition_vbmeta="vbmeta"
deviceinfo_flash_sparse=true
deviceinfo_kernel_cmdline="console=ttyMSM0,115200n8 androidboot.hardware=qcom androidboot.console=ttyMSM0 androidboot.memcg=1 lpm_levels.sleep_disabled=1 video=vfb:640x400,bpp=32,memsize=3072000 msm_rtb.filter=0x237 service_locator.enable=1 swiotlb=1 earlycon=msm_geni_serial,0x4a90000 loop.max_part=7 cgroup.memory=nokmem,nosocket buildvariant=user"
deviceinfo_generate_bootimg="true"
deviceinfo_bootimg_qcdt="false"
deviceinfo_bootimg_mtk_mkimage="false"
deviceinfo_bootimg_dtb_second="false"
deviceinfo_flash_pagesize="4096"
deviceinfo_flash_offset_base="0x00000000"
deviceinfo_flash_offset_kernel="0x00008000"
deviceinfo_flash_offset_ramdisk="0x01000000"
deviceinfo_flash_offset_second="0x00f00000"
deviceinfo_flash_offset_tags="0x00000100"
deviceinfo_rootfs_image_sector_size="4096"

BIN
device.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

View File

@ -0,0 +1,24 @@
From 4995be221047acf5b40610e5c4eacf4b75434500 Mon Sep 17 00:00:00 2001
From: NeKit <nekit1000@gmail.com>
Date: Mon, 18 Mar 2019 22:02:40 +0100
Subject: [PATCH] (hybris) always boot to initramfs
---
init/initramfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/init/initramfs.c b/init/initramfs.c
index 52059169..54768fd3 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -612,7 +612,9 @@ static int __init skip_initramfs_param(char *str)
{
if (*str)
return 0;
- do_skip_initramfs = 1;
+ // Halium: always boot to initramfs
+ //do_skip_initramfs = 1;
+ do_skip_initramfs = 0;
return 1;
}
__setup("skip_initramfs", skip_initramfs_param);

View File

@ -0,0 +1,18 @@
diff --git a/init/initramfs.c b/init/initramfs.c
index bf3af10c500a..1c74b6d70e5e 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -622,11 +622,11 @@ static int __init populate_rootfs(void)
{
char *err;
- if (do_skip_initramfs) {
+ /*if (do_skip_initramfs) {
if (initrd_start)
free_initrd();
return default_rootfs();
- }
+ }*/
err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
if (err)

View File

@ -0,0 +1,80 @@
From 92e3310d2db157deacb86ef5db8c8c8d38251312 Mon Sep 17 00:00:00 2001
From: Alexey Min <alexey.min@gmail.com>
Date: Wed, 11 Sep 2019 21:51:40 +0300
Subject: [PATCH 3/6] Add config option to fix bootloader cmdline args
Android bootloader passes some arguments in kernel command
line, that make booting custom OSes harder:
* skip_initramfs
* root=PARTUUID=...
* init=/init
Those parameters override default boot partition to hardcoded,
set init binary to /init, disable booting from initramfs.
If enabled, those parameters will be erased from bootloader's
command line, and custom OS can boot the way it likes.
Signed-off-by: Alexey Min <alexey.min@gmail.com>
---
arch/arm64/Kconfig | 17 +++++++++++++++++
drivers/of/fdt.c | 14 ++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 2829edba6aa5..bd9f05f83c7e 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1125,6 +1125,23 @@ config CMDLINE_FORCE
command-line options your boot loader passes to the kernel.
endchoice
+config CMDLINE_DROP_DANGEROUS_ANDROID_OPTIONS
+ bool "Drop certain dangerous options from cmdline"
+ default n
+ help
+ Android bootloader passes some arguments in kernel command
+ line, that make booting custom OSes harder:
+
+ * skip_initramfs
+ * root=PARTUUID=...
+ * init=/init
+
+ Those parameters override default boot partition to hardcoded,
+ set init binary to /init, disable booting from initramfs.
+
+ If enabled, those parameters will be erased from bootloader's
+ command line, and custom OS can boot the way it likes.
+
config EFI_STUB
bool
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index ca175710c4c8..fd8257589648 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -1012,6 +1012,20 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname,
pr_debug("Command line is: %s\n", (char*)data);
+#ifdef CONFIG_CMDLINE_DROP_DANGEROUS_ANDROID_OPTIONS
+ pr_err("Replacing dangerous cmdline options...");
+ cmdline = strstr((const char *)data, "skip_initramfs");
+ if (cmdline)
+ *cmdline = '_';
+ cmdline = strstr((const char *)data, "root=");
+ if (cmdline)
+ *cmdline = '_';
+ cmdline = strstr((const char *)data, "init=");
+ if (cmdline)
+ *cmdline = '_';
+ pr_err("Command line now is: %s\n", (char*)data);
+#endif
+
/* break now */
return 1;
}
--
2.24.1

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,69 @@
# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/arm64/configs/(CHANGEME!)
pkgname=linux-xiaomi-laurel_sprout
pkgver=4.14.117
pkgrel=0
pkgdesc="Xiaomi Mi A3 kernel fork"
arch="aarch64"
_carch="arm64"
_flavor="xiaomi-laurel_sprout"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps pmb:cross-native"
makedepends="
bash
bc
bison
devicepkg-dev
flex
openssl-dev
linux-headers
perl
clang
"
# Source
_repository="android_kernel_xiaomi_laurel_sprout"
_commit="18cce7c37b08cf3b8cb013ac648f03a7361ac215"
_config="config-$_flavor.$arch"
source="
$pkgname-$_commit.tar.gz::https://github.com/AOSPA/$_repository/archive/$_commit.tar.gz
$_config
0001-always_boot_to_initramfs.patch
0002-disable_skip_initramfs.patch
0003-remove_bootloader_cmdline_opts.patch
0004-selinux_include_generated_headers.patch
"
builddir="$srcdir/$_repository-$_commit"
_outdir="out"
prepare() {
default_prepare
REPLACE_GCCH=0
. downstreamkernel_prepare
}
build() {
unset LDFLAGS
make O="$_outdir" ARCH="$_carch" CC="clang" HOSTCC="clang" \
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS"
}
package() {
downstreamkernel_package "$builddir" "$pkgdir" "$_carch" "$_flavor" "$_outdir"
# Modules
unset LDFLAGS
make O="$_outdir" ARCH="$_carch" CC="clang" \
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS" \
INSTALL_MOD_PATH="$pkgdir" modules_install
}
sha512sums="
2cebedae30ffc2ff16b5f8d6b93f7edeb7d28e88cbecdf7835dcdd3ceaabc61a3b5aee3085fea385e4644aaadd371e0109356eb0a21135d97fcfe6bf6a4c8b04 linux-xiaomi-laurel_sprout-18cce7c37b08cf3b8cb013ac648f03a7361ac215.tar.gz
65b37d0298dd9121cd014dc9e15ad02148d306e6161c4f8d091757722d1cdc00447a52c9a06e6303d63e49b169c1992cc12f78ff81de3062600acd62495c17f9 config-xiaomi-laurel_sprout.aarch64
e2a7a404a7bd404dbda08663ca5f96c38e04e58bd781024c6904115a4775e089775a552583347ab8e2f745d5ab5653a63c08070b3b43b8b4a2f23696e747311e 0001-always_boot_to_initramfs.patch
65048fb6474fd543b14bc99d9d95cfe5297da239af211d327a8509f7777d489bd01dd911364e0c62ec0e68f4c22ebb3b145eabfe01cad2abf57cf46896a1e58f 0002-disable_skip_initramfs.patch
9ce867c4254b537ef5d2485780c26b72da8a3a8767ba71557f3b48d6c550e0e14c8c3e575b31bf65d2878f08a8a4926e48a1c2f1be534bf80a7a57f58313b0fd 0003-remove_bootloader_cmdline_opts.patch
6ab9db01d35f7f5cc2c19ebe5f65a7dc479a1c68de587300cdde9a6c759d34610666c72f0f321cd450cf56c13df3b54a774e0f7ebdbf0f8608fbfd66b49d04e7 0004-selinux_include_generated_headers.patch
"

File diff suppressed because it is too large Load Diff