xiaomi-willow: new device (Xiaomi Redmi Note 8T) (MR 1197)

Add support for the Xiaomi Redmi Note 8t.
Works: UART, USB RNDIS, Weston on DRM, touchscreen
Doesn't: fbdev, everything else
This commit is contained in:
eli 2020-04-25 06:54:48 -07:00 committed by Alexey Min
parent 38de3498aa
commit ffcc6acd0c
No known key found for this signature in database
GPG key ID: EBF5ECFFFEE34DED
12 changed files with 6270 additions and 0 deletions

View file

@ -0,0 +1,53 @@
# Maintainer: Eli Riggs <eli@rje.li>
# Reference: <https://postmarketos.org/devicepkg>
pkgname=device-xiaomi-willow
pkgdesc="Xiaomi Redmi Note 8T"
pkgver=0.1
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
options="!check !archcheck"
depends="postmarketos-base linux-xiaomi-willow mkbootimg mesa-dri-gallium"
makedepends="devicepkg-dev"
subpackages="
$pkgname-nonfree-firmware:nonfree_firmware
$pkgname-weston
"
source="
deviceinfo
modules-load.conf
weston.ini
weston-fixes.sh
"
build() {
devicepkg_build $startdir $pkgname
}
package() {
devicepkg_package $startdir $pkgname
}
nonfree_firmware() {
pkgdesc="Touchscreen firmware"
depends="firmware-xiaomi-willow"
mkdir "$subpkgdir"
}
weston() {
install_if="$pkgname weston"
# weston use drm backend, 2x dpi, don't use virtual output
install -Dm644 "$srcdir"/weston.ini \
"$subpkgdir"/etc/xdg/weston/weston.ini
# weston msm_drm hax
install -Dm755 "$srcdir"/weston-fixes.sh \
"$subpkgdir"/etc/X11/xinit/xinitrc.d/00-xiaomi-willow-weston-fixes.sh
}
sha512sums="333eafbe258ddc5948e3ae3edb072a03d4ef19b6d89a7abdb8ca0067b95c4772fbdac4dbf4019ae0c354e5f676b55a6c7e52f159c25eaa8f9353dc05a1e23080 deviceinfo
1689a1294cfca52351f384324a0fc17ccfa520e33d9d8c616e6a000cc44273b72ca560f1407886e105cdb60282a6f096262e1499eb46ebd0c470599cfe639442 modules-load.conf
4fdc188f9cd5c0316959322568916a6e36e67ff316e90fa7bd7c7b642cb137a9ff7002b0475728c6ba53abcbfe8c50d82112e4943460ee424aee4bbfd0efecfe weston.ini
2ecdd4f25c1047071f8f300d177bc1c288e7af6d05c0f2fa821f722494c92381416ee7969d7d4a7aff7eb7c4fa18d988b7a12bd3ba769022fd95987ca3b5f065 weston-fixes.sh"

View file

@ -0,0 +1,37 @@
# 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 8T"
deviceinfo_manufacturer="Xiaomi"
deviceinfo_codename="xiaomi-willow"
deviceinfo_year="2019"
deviceinfo_dtb=""
deviceinfo_modules_initfs=""
deviceinfo_arch="aarch64"
# Device related
deviceinfo_keyboard="false"
deviceinfo_external_storage="true"
deviceinfo_screen_width="1080"
deviceinfo_screen_height="2340"
deviceinfo_no_framebuffer="true"
deviceinfo_getty="ttyMSM0;115200"
# Bootloader related
deviceinfo_flash_method="fastboot"
deviceinfo_flash_fastboot_partition_vbmeta="vbmeta"
deviceinfo_kernel_cmdline="console=ttyMSM0,115200n8 androidboot.hardware=qcom androidboot.console=ttyMSM0 androidboot.memcg=1 lpm_levels.sleep_disabled=1 msm_rtb.filter=0x237 service_locator.enable=1 swiotlb=1 firmware_class.path=/vendor/firmware_mnt/image earlycon=msm_geni_serial,0x4a90000 loop.max_part=7 cgroup.memory=nokmem,nosocket buildvariant=eng"
deviceinfo_generate_bootimg="true"
deviceinfo_bootimg_qcdt="false"
deviceinfo_bootimg_dtb_second="false"
deviceinfo_flash_sparse="true"
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_flash_pagesize="4096"
deviceinfo_usb_idVendor="0x2717" # Xiaomi Communications Co., Ltd.
deviceinfo_usb_idProduct="0xff80" # Mi/Redmi series (RNDIS)

View file

@ -0,0 +1,2 @@
# novatek tianma touchscreen
ts_nt36xxx

View file

@ -0,0 +1,4 @@
#!/bin/sh
echo "sourcing /etc/X11/xinit/xinitrc.d/00-xiaomi-willow-weston-fixes.sh" | logger -t "$(whoami):xiaomi-willow-weston-fixes"
export WESTON_DISABLE_ATOMIC=1
export MESA_LOADER_DRIVER_OVERRIDE=msm

View file

@ -0,0 +1,16 @@
[core]
xwayland=true
backend=drm-backend.so
idle-time=0
[shell]
background-image=/usr/share/wallpapers/postmarketos.jpg
[output]
name=DSI-1
mode=preferred
scale=2
[output]
name=Virtual-1
mode=off

View file

@ -0,0 +1,58 @@
# Maintainer: Eli Riggs <eli@rje.li>
# Reference: <https://postmarketos.org/vendorkernel>
# Kernel config based on: arch/arm64/configs/vendor/willow-perf_defconfig
pkgname=linux-xiaomi-willow
pkgver=4.14.117
pkgrel=0
pkgdesc="Xiaomi Redmi Note 8T kernel fork"
arch="aarch64"
_carch="arm64"
_flavor="xiaomi-willow"
url="https://kernel.org"
license="GPL-2.0-only"
options="!strip !check !tracedeps"
makedepends="bash bc bison devicepkg-dev flex openssl-dev perl"
# Source
_repository="android_kernel_xiaomi_sm6125"
_commit="111707a52c4b7bffbc28d61ee1edb24979725e4d"
_config="config-$_flavor.$arch"
source="
$pkgname-$_commit.tar.gz::https://github.com/Xiaomi-trinket-dev/$_repository/archive/$_commit.tar.gz
$_config
fix_gcc.patch
selinux_include_generated_headers.patch
remove_bootloader_cmdline_opts.patch
touchscreen_nt36xxx_module.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"
# Modules
unset LDFLAGS
make O="$_outdir" ARCH="$_carch" CC="${CC:-gcc}" \
KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-postmarketOS" \
INSTALL_MOD_PATH="$pkgdir" modules_install
}
sha512sums="d0efc7a211f8f3eb4ad034406f27237fe9b7915e1a908e5e94e32c02ce8f8ffc81d041bd82771cb8b1b85f312557fcbc215c6650815c18bd9482d277b84bb6bd linux-xiaomi-willow-111707a52c4b7bffbc28d61ee1edb24979725e4d.tar.gz
59826215a97c1ef51b8eb493237625442fe3c4aa6efd5d4c8ca8cf60eb5f9b28136b2525e2b95cb767f144b1925f43193bc9d5f1ee7a65e6d468d4235d4ddb58 config-xiaomi-willow.aarch64
f9339f17504e0d37c5f7847d09b5e38bf608ef146696a352d3a102fe59cf285984a94b4c5a0c7dad63c11fef82df94213a9c3fe4b3f8ff64b18e99741ed11561 fix_gcc.patch
6ab9db01d35f7f5cc2c19ebe5f65a7dc479a1c68de587300cdde9a6c759d34610666c72f0f321cd450cf56c13df3b54a774e0f7ebdbf0f8608fbfd66b49d04e7 selinux_include_generated_headers.patch
9ce867c4254b537ef5d2485780c26b72da8a3a8767ba71557f3b48d6c550e0e14c8c3e575b31bf65d2878f08a8a4926e48a1c2f1be534bf80a7a57f58313b0fd remove_bootloader_cmdline_opts.patch
c6c03502e89b9038ec929441377f802b1739470260d9aeac2f6763bb12b1758b547acbb3685df4e3038d250139c2fe4a9fd38b7badb15ad5d08847cf7223a5a5 touchscreen_nt36xxx_module.patch"

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,55 @@
diff --git a/Makefile b/Makefile
index 539e4cd3c..e95fc2571 100644
--- a/Makefile
+++ b/Makefile
@@ -677,6 +677,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context)
KBUILD_CFLAGS += $(call cc-disable-warning, attribute-alias)
+KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,)
diff --git a/drivers/char/rdbg.c b/drivers/char/rdbg.c
index 0c623221b..400efb134 100644
--- a/drivers/char/rdbg.c
+++ b/drivers/char/rdbg.c
@@ -136,7 +136,7 @@ struct rdbg_device {
int registers[32] = {0};
static struct rdbg_device g_rdbg_instance = {
- { {0} },
+ {},
NULL,
0,
SMP2P_NUM_PROCS,
Newer GCC doesn't trust that `dbg_buff` can hold `count` for the copy_from_user.
Probably related to unsigned overflow?
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa.c b/drivers/platform/msm/ipa/ipa_v3/ipa.c
index 9c0643d01..e2aa6d9bb 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa.c
@@ -5970,6 +5970,9 @@ static ssize_t ipa3_write(struct file *file, const char __user *buf,
char dbg_buff[32] = { 0 };
+ if (sizeof(dbg_buff) < count)
+ return -EFAULT;
+
if (sizeof(dbg_buff) < count + 1)
return -EFAULT;
diff --git a/techpack/audio/asoc/codecs/wcd_cpe_core.c b/techpack/audio/asoc/codecs/wcd_cpe_core.c
index 2e154e701..9fd3eb7ea 100644
--- a/techpack/audio/asoc/codecs/wcd_cpe_core.c
+++ b/techpack/audio/asoc/codecs/wcd_cpe_core.c
@@ -2257,6 +2257,7 @@ static int fill_cmi_header(struct cmi_hdr *hdr,
return -EINVAL;
}
+ memset(hdr, 0, sizeof(*hdr));
CMI_HDR_SET_SESSION(hdr, session_id);
CMI_HDR_SET_SERVICE(hdr, service_id);
if (version)

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,77 @@
The touchscreen driver expects to have firmware available immediately, but our rootfs
mounts a little too late. These patches are necessary to compile it as a module.
saved_command_line isn't exposed to modules, so we just hardcode the tianma vendor.
diff --git a/drivers/input/touchscreen/nt36xxx_spi_bbb/Kconfig b/drivers/input/touchscreen/nt36xxx_spi_bbb/Kconfig
index e8674dc6a..14ccef8e7 100644
--- a/drivers/input/touchscreen/nt36xxx_spi_bbb/Kconfig
+++ b/drivers/input/touchscreen/nt36xxx_spi_bbb/Kconfig
@@ -12,7 +12,7 @@ config TOUCHSCREEN_NT36xxx_HOSTDL_SPI_BBB
If unsure, say N.
config TOUCHSCREEN_NT36xxx_HOSTDL_SPI_CCC
- bool "Novatek NT36xxx host download SPI driver"
+ tristate "Novatek NT36xxx host download SPI driver"
depends on ( SPI || TOUCHSCREEN_AAAAAA_CCC )
default n
help
diff --git a/drivers/input/touchscreen/nt36xxx_spi_bbb/Makefile b/drivers/input/touchscreen/nt36xxx_spi_bbb/Makefile
index bca7b8a85..9ca3cfc3d 100644
--- a/drivers/input/touchscreen/nt36xxx_spi_bbb/Makefile
+++ b/drivers/input/touchscreen/nt36xxx_spi_bbb/Makefile
@@ -5,4 +5,5 @@
# Each configuration option enables a list of files.
obj-$(CONFIG_TOUCHSCREEN_NT36xxx_HOSTDL_SPI_BBB) += nt36xxx.o nt36xxx_fw_update.o nt36xxx_ext_proc.o nt36xxx_mp_ctrlram.o
-obj-$(CONFIG_TOUCHSCREEN_NT36xxx_HOSTDL_SPI_CCC) += nt36xxx.o nt36xxx_fw_update.o nt36xxx_ext_proc.o nt36xxx_mp_ctrlram.o
+obj-$(CONFIG_TOUCHSCREEN_NT36xxx_HOSTDL_SPI_CCC) += ts_nt36xxx.o
+ts_nt36xxx-y := nt36xxx.o nt36xxx_fw_update.o nt36xxx_ext_proc.o nt36xxx_mp_ctrlram.o
diff --git a/drivers/input/touchscreen/nt36xxx_spi_bbb/nt36xxx.c b/drivers/input/touchscreen/nt36xxx_spi_bbb/nt36xxx.c
index 93f4d0b1c..f48d3fc7b 100644
--- a/drivers/input/touchscreen/nt36xxx_spi_bbb/nt36xxx.c
+++ b/drivers/input/touchscreen/nt36xxx_spi_bbb/nt36xxx.c
@@ -43,8 +43,6 @@
#endif /* #if NVT_TOUCH_ESD_PROTECT */
#ifdef CHECK_TOUCH_VENDOR
-extern char *saved_command_line;
-
//---Touch Vendor ID---
static uint8_t touch_vendor_id = 0;
#endif
@@ -2711,31 +2709,8 @@ static int32_t __init nvt_driver_init(void)
#ifdef CHECK_TOUCH_VENDOR
//Check TP vendor
- if (IS_ERR_OR_NULL(saved_command_line)){
- NVT_ERR("saved_command_line ERROR!\n");
- ret = -ENOMEM;
- goto err_driver;
- } else {
- if (strstr(saved_command_line,"tianma") != NULL) {
- touch_vendor_id = TP_VENDOR_TIANMA;
- NVT_LOG("TP info: [Vendor]tianma [IC]nt36672a\n");
- } else if (strstr(saved_command_line,"shenchao") != NULL) {
- touch_vendor_id = TP_VENDOR_EBBG;
- NVT_LOG("TP info: [Vendor]shenchao [IC]nt36672a\n");
- } else {
- touch_vendor_id = TP_VENDOR_UNKNOW;
- NVT_ERR("Unknow Touch\n");
- ret = -ENODEV;
- goto err_driver;
- }
- }
-
- //Check android mode
- if (strstr(saved_command_line, "androidboot.mode=charger") != NULL) {
- NVT_LOG("androidboot.mode=charger, doesn't support touch in the charging mode!\n");
- ret = -ENODEV;
- goto err_driver;
- }
+ touch_vendor_id = TP_VENDOR_TIANMA;
+ NVT_LOG("TP info: [Vendor]tianma [IC]nt36672a\n");
#endif
//---add spi driver---

View file

@ -0,0 +1,21 @@
# Maintainer: Eli Riggs <eli@rje.li>
pkgname=firmware-xiaomi-willow
pkgver=1
pkgrel=0
pkgdesc="Firmware for Xiaomi Redmi Note 8t"
url="https://github.com/Xiaomi-trinket-dev/vendor_xiaomi_sm6125-common"
arch="aarch64"
license="proprietary"
options="!strip !check !archcheck"
_f="novatek_ts_tianma_fw.bin"
_commit="ea359557ce79ff5233dea82cd155a6afec46a5d6"
_url="$url/raw/$_commit/proprietary/vendor/firmware/"
source="$pkgname-$_commit-$_f::$_url/$_f"
package() {
install -Dm644 "$srcdir/$pkgname-$_commit-$_f" \
"$pkgdir/lib/firmware/postmarketos/$_f"
}
sha512sums="1cb8a1f87306ceaf09ca175ebad9fd7b3b06d8ca8e384ef58183cdbc67dfaeeab2872ab51f3e54e54428c3f0ec16aace51253b60498ff0b7a96bee13c1eb2544 firmware-xiaomi-willow-ea359557ce79ff5233dea82cd155a6afec46a5d6-novatek_ts_tianma_fw.bin"