Merge "db845c: add 64-bit-only build flag TARGET_64BIT_ONLY" into d4a
diff --git a/BoardConfigCommon.mk b/BoardConfigCommon.mk
index 08c5c57..2683711 100644
--- a/BoardConfigCommon.mk
+++ b/BoardConfigCommon.mk
@@ -19,7 +19,10 @@
 TARGET_NO_RECOVERY := true
 
 BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE := erofs
-TARGET_USERIMAGES_USE_EXT4 := true
+TARGET_USERIMAGES_USE_F2FS := true
+BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE := f2fs
+# Currently, f2fs block size must be equal to page size
+BOARD_F2FS_BLOCKSIZE := 4096
 TARGET_COPY_OUT_VENDOR := vendor
 BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := erofs
 TARGET_COPY_OUT_SYSTEM_EXT := system_ext
diff --git a/db845c.mk b/db845c.mk
index 9621a9d..43b5bc5 100644
--- a/db845c.mk
+++ b/db845c.mk
@@ -13,14 +13,23 @@
 $(call inherit-product, device/linaro/dragonboard/shared/graphics/minigbm_msm/device.mk)
 $(call inherit-product, device/linaro/dragonboard/db845c/device.mk)
 
+#Boot with Android boot image header v3
 ifeq ($(TARGET_KERNEL_USE),5.4)
   TARGET_USES_BOOT_HDR_V3 := true
 else
   TARGET_USES_BOOT_HDR_V3 ?= false
 endif
 
+#Boot from mmc-sdcard
 TARGET_SDCARD_BOOT ?= false
 
+#Load kernel modules in parallel
+ifneq ($(filter 5.15 6.1 6.6, $(TARGET_KERNEL_USE)),)
+  TARGET_USES_LMP ?= false
+else
+  TARGET_USES_LMP := false
+endif
+
 # Product overrides
 PRODUCT_NAME := db845c
 PRODUCT_DEVICE := db845c
diff --git a/db845c/BoardConfig.mk b/db845c/BoardConfig.mk
index 580fece..3ee2321 100644
--- a/db845c/BoardConfig.mk
+++ b/db845c/BoardConfig.mk
@@ -45,6 +45,9 @@
     BOARD_BOOTCONFIG += androidboot.boot_devices=soc@0/1d84000.ufshc
     BOARD_BOOTCONFIG += androidboot.hardware=db845c
     BOARD_BOOTCONFIG += androidboot.verifiedbootstate=orange
+    ifeq ($(TARGET_USES_LMP), true)
+      BOARD_BOOTCONFIG += androidboot.load_modules_parallel=true
+    endif
 endif
 BOARD_MKBOOTIMG_ARGS := --header_version $(BOARD_BOOT_HEADER_VERSION)
 BOARD_KERNEL_BASE := 0x80000000
diff --git a/device-common.mk b/device-common.mk
index a197f86..e144ea3 100644
--- a/device-common.mk
+++ b/device-common.mk
@@ -20,9 +20,15 @@
 BOARD_DO_NOT_STRIP_VENDOR_RAMDISK_MODULES := true
 BOARD_DO_NOT_STRIP_GENERIC_RAMDISK_MODULES := true
 ifeq ($(TARGET_SDCARD_BOOT), true)
+  # Do not copy UFS kernel module in vendor_dlkm.img
   # UFS module filename varies from ufs_qcom.ko to ufs-qcom.ko across different kernel versions
-  BOARD_VENDOR_KERNEL_MODULES := $(wildcard $(TARGET_KERNEL_DIR)/ufs*qcom.ko)
-  BOARD_GENERIC_RAMDISK_KERNEL_MODULES := $(filter-out $(BOARD_VENDOR_KERNEL_MODULES),$(TARGET_MODS))
+  UFS_MODULE := $(wildcard $(TARGET_KERNEL_DIR)/ufs*qcom.ko)
+  BOARD_GENERIC_RAMDISK_KERNEL_MODULES := $(filter-out $(UFS_MODULE),$(TARGET_MODS))
+else ifeq ($(TARGET_USES_LMP), true)
+    include device/linaro/dragonboard/shared/utils/dlkm_loader/vendor.modules.list.mk
+    BOARD_VENDOR_KERNEL_MODULES := $(patsubst %,$(TARGET_KERNEL_DIR)/%,$(VENDOR_DLKM_KERNEL_MODULES_LIST))
+    BOARD_VENDOR_RAMDISK_KERNEL_MODULES := $(patsubst %,$(TARGET_KERNEL_DIR)/%,$(VENDOR_RAMDISK_KERNEL_MODULES_LIST))
+    BOARD_SYSTEM_KERNEL_MODULES := $(filter-out $(BOARD_VENDOR_KERNEL_MODULES) $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES), $(wildcard $(TARGET_KERNEL_DIR)/*.ko))
 else
   BOARD_VENDOR_RAMDISK_KERNEL_MODULES := $(TARGET_MODS)
 endif
diff --git a/fstab.common b/fstab.common
index c618b7a..6772e38 100644
--- a/fstab.common
+++ b/fstab.common
@@ -1,5 +1,5 @@
 system		/system		erofs	ro				wait,logical,first_stage_mount,slotselect
-/dev/block/platform/soc@0/1d84000.ufshc/by-name/userdata /data		ext4	discard,noatime,noauto_da_alloc,data=ordered,user_xattr,barrier=1,inlinecrypt	latemount,wait,formattable,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized,keydirectory=/metadata/vold/metadata_encryption,quota
+/dev/block/platform/soc@0/1d84000.ufshc/by-name/userdata	/data		f2fs	nodev,noatime,nosuid,inlinecrypt,reserve_root=32768	latemount,wait,formattable,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized,keydirectory=/metadata/vold/metadata_encryption,quota,check,fscompress,checkpoint=fs
 /dev/block/platform/soc@0/1d84000.ufshc/by-name/metadata	/metadata	ext4	noatime,nosuid,nodev,discard					wait,formattable,first_stage_mount,check
 /dev/block/platform/soc@0/1d84000.ufshc/by-name/misc /misc emmc defaults defaults
 /devices/platform/soc@0/8804000.sdhci/mmc_host/mmc*	auto	auto	defaults	voldmanaged=sdcard1:auto
diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts
index 660539c..7e548db 100644
--- a/sepolicy/file_contexts
+++ b/sepolicy/file_contexts
@@ -23,20 +23,18 @@
 /sys/devices/platform/soc@0/ae00000.mdss						u:object_r:sysfs_gpu:s0
 /sys/devices/platform/soc@0/ae00000.display-subsystem					u:object_r:sysfs_gpu:s0
 
-#wakeups on db845c
-/sys/devices/platform/soc@0/1c00000.pci/pci0000:00/0000:00:00.0/0000:01:00.0/wakeup/wakeup1						u:object_r:sysfs_wakeup:s0
-/sys/devices/platform/soc@0/a6f8800.usb/wakeup/wakeup2											u:object_r:sysfs_wakeup:s0
-/sys/devices/platform/soc@0/a8f8800.usb/wakeup/wakeup3											u:object_r:sysfs_wakeup:s0
-/sys/devices/platform/soc@0/c440000.spmi/spmi-0/0-00/c440000.spmi:pmic@0:pon@800/c440000.spmi:pmic@0:pon@800:pwrkey/wakeup/wakeup4	u:object_r:sysfs_wakeup:s0
-/sys/devices/platform/soc@0/c440000.spmi/spmi-0/0-00/c440000.spmi:pmic@0:pon@800/c440000.spmi:pmic@0:pon@800:resin/wakeup/wakeup5	u:object_r:sysfs_wakeup:s0
-/sys/devices/platform/soc@0/c440000.spmi/spmi-0/0-00/c440000.spmi:pmic@0:rtc@6000/wakeup/wakeup6					u:object_r:sysfs_wakeup:s0
-/sys/devices/platform/soc@0/c440000.spmi/spmi-0/0-00/c440000.spmi:pmic@0:rtc@6000/rtc/rtc0/alarmtimer.2.auto/wakeup/wakeup7		u:object_r:sysfs_wakeup:s0
-
-#wakeups on RB5
-/sys/devices/platform/soc@0/a6f8800.usb/wakeup/wakeup0											u:object_r:sysfs_wakeup:s0
-/sys/devices/platform/soc@0/a8f8800.usb/wakeup/wakeup1											u:object_r:sysfs_wakeup:s0
-/sys/devices/platform/soc@0/c440000.spmi/spmi-0/0-00/c440000.spmi:pmic@0:rtc@6000/wakeup/wakeup3					u:object_r:sysfs_wakeup:s0
-/sys/devices/platform/soc@0/c440000.spmi/spmi-0/0-00/c440000.spmi:pmic@0:rtc@6000/rtc/rtc0/alarmtimer.1.auto/wakeup/wakeup4		u:object_r:sysfs_wakeup:s0
+#wakeups on db845c and rb5
+/sys/devices/platform/remoteproc-adsp/wakeup						u:object_r:sysfs_wakeup:s0
+/sys/devices/platform/remoteproc-cdsp/wakeup						u:object_r:sysfs_wakeup:s0
+/sys/devices/platform/soc@0/17300000.remoteproc/wakeup					u:object_r:sysfs_wakeup:s0
+/sys/devices/platform/soc@0/1c00000.pci/pci0000:00					u:object_r:sysfs_wakeup:s0
+/sys/devices/platform/soc@0/1c00000.pcie/pci0000:00					u:object_r:sysfs_wakeup:s0
+/sys/devices/platform/soc@0/8300000.remoteproc/wakeup					u:object_r:sysfs_wakeup:s0
+/sys/devices/platform/soc@0/a6f8800.usb/wakeup						u:object_r:sysfs_wakeup:s0
+/sys/devices/platform/soc@0/a6f8800.usb/a600000.usb/wakeup				u:object_r:sysfs_wakeup:s0
+/sys/devices/platform/soc@0/a8f8800.usb/wakeup						u:object_r:sysfs_wakeup:s0
+/sys/devices/platform/soc@0/a8f8800.usb/a800000.usb/wakeup				u:object_r:sysfs_wakeup:s0
+/sys/devices/platform/soc@0/c440000.spmi/spmi-0						u:object_r:sysfs_wakeup:s0
 
 /sys/class/remoteproc									u:object_r:sysfs_remoteproc:s0
 /sys/devices/platform/remoteproc-adsp/remoteproc					u:object_r:sysfs_remoteproc:s0
diff --git a/sepolicy/genfs_contexts b/sepolicy/genfs_contexts
index 4d7f4ea..d51b60f 100644
--- a/sepolicy/genfs_contexts
+++ b/sepolicy/genfs_contexts
@@ -10,17 +10,15 @@
 genfscon sysfs   /class/udc									u:object_r:sysfs_udc:s0
 genfscon sysfs   /firmware/devicetree/base/compatible						u:object_r:sysfs_dt_compatible:s0
 
-#wakeups on db845c
-genfscon sysfs   /devices/platform/soc@0/1c00000.pci/pci0000:00/0000:00:00.0/0000:01:00.0/wakeup/wakeup1					u:object_r:sysfs_wakeup:s0
-genfscon sysfs   /devices/platform/soc@0/a6f8800.usb/wakeup/wakeup2										u:object_r:sysfs_wakeup:s0
-genfscon sysfs   /devices/platform/soc@0/a8f8800.usb/wakeup/wakeup3										u:object_r:sysfs_wakeup:s0
-genfscon sysfs   /devices/platform/soc@0/c440000.spmi/spmi-0/0-00/c440000.spmi:pmic@0:pon@800/c440000.spmi:pmic@0:pon@800:pwrkey/wakeup/wakeup4	u:object_r:sysfs_wakeup:s0
-genfscon sysfs   /devices/platform/soc@0/c440000.spmi/spmi-0/0-00/c440000.spmi:pmic@0:pon@800/c440000.spmi:pmic@0:pon@800:resin/wakeup/wakeup5	u:object_r:sysfs_wakeup:s0
-genfscon sysfs   /devices/platform/soc@0/c440000.spmi/spmi-0/0-00/c440000.spmi:pmic@0:rtc@6000/wakeup/wakeup6					u:object_r:sysfs_wakeup:s0
-genfscon sysfs   /devices/platform/soc@0/c440000.spmi/spmi-0/0-00/c440000.spmi:pmic@0:rtc@6000/rtc/rtc0/alarmtimer.2.auto/wakeup/wakeup7	u:object_r:sysfs_wakeup:s0
-
-#wakeups on RB5
-genfscon sysfs   /devices/platform/soc@0/a6f8800.usb/wakeup/wakeup0										u:object_r:sysfs_wakeup:s0
-genfscon sysfs   /devices/platform/soc@0/a8f8800.usb/wakeup/wakeup1										u:object_r:sysfs_wakeup:s0
-genfscon sysfs   /devices/platform/soc@0/c440000.spmi/spmi-0/0-00/c440000.spmi:pmic@0:rtc@6000/wakeup/wakeup3					u:object_r:sysfs_wakeup:s0
-genfscon sysfs   /devices/platform/soc@0/c440000.spmi/spmi-0/0-00/c440000.spmi:pmic@0:rtc@6000/rtc/rtc0/alarmtimer.1.auto/wakeup/wakeup4	u:object_r:sysfs_wakeup:s0
+#wakeups on db845c and rb5
+genfscon sysfs   /devices/platform/remoteproc-adsp/wakeup					u:object_r:sysfs_wakeup:s0
+genfscon sysfs   /devices/platform/remoteproc-cdsp/wakeup					u:object_r:sysfs_wakeup:s0
+genfscon sysfs   /devices/platform/soc@0/17300000.remoteproc/wakeup				u:object_r:sysfs_wakeup:s0
+genfscon sysfs   /devices/platform/soc@0/1c00000.pci/pci0000:00					u:object_r:sysfs_wakeup:s0
+genfscon sysfs   /devices/platform/soc@0/1c00000.pcie/pci0000:00				u:object_r:sysfs_wakeup:s0
+genfscon sysfs   /devices/platform/soc@0/8300000.remoteproc/wakeup				u:object_r:sysfs_wakeup:s0
+genfscon sysfs   /devices/platform/soc@0/a6f8800.usb/wakeup					u:object_r:sysfs_wakeup:s0
+genfscon sysfs   /devices/platform/soc@0/a6f8800.usb/a600000.usb/wakeup				u:object_r:sysfs_wakeup:s0
+genfscon sysfs   /devices/platform/soc@0/a8f8800.usb/wakeup					u:object_r:sysfs_wakeup:s0
+genfscon sysfs   /devices/platform/soc@0/a8f8800.usb/a800000.usb/wakeup				u:object_r:sysfs_wakeup:s0
+genfscon sysfs   /devices/platform/soc@0/c440000.spmi/spmi-0					u:object_r:sysfs_wakeup:s0
diff --git a/sepolicy/hal_health_default.te b/sepolicy/hal_health_default.te
new file mode 100644
index 0000000..d5d490d
--- /dev/null
+++ b/sepolicy/hal_health_default.te
@@ -0,0 +1,2 @@
+allow hal_health_default sysfs_wakeup:dir search;
+allow hal_health_default sysfs_wakeup:file { getattr open read };
diff --git a/sepolicy/rmtfs.te b/sepolicy/rmtfs.te
index 7cef38f..91f8d33 100644
--- a/sepolicy/rmtfs.te
+++ b/sepolicy/rmtfs.te
@@ -11,5 +11,6 @@
 allow rmtfs sysfs_mss:dir { open read search };
 allow rmtfs sysfs_remoteproc:dir { open read search };
 allow rmtfs sysfs_remoteproc:file { open write };
+allow rmtfs sysfs_remoteproc:file read;
 allow rmtfs sysfs_rmtfs:dir search;
 allow rmtfs sysfs_rmtfs:file { open read };
diff --git a/sepolicy/set_ethaddr.te b/sepolicy/set_ethaddr.te
index 86f9ea8..2f92368 100644
--- a/sepolicy/set_ethaddr.te
+++ b/sepolicy/set_ethaddr.te
@@ -6,6 +6,7 @@
 allow set_ethaddr proc_bootconfig:file { open read };
 allow set_ethaddr rootfs:dir { open read };
 allow set_ethaddr self:capability net_admin;
+allow set_ethaddr self:capability sys_module;
 allow set_ethaddr self:udp_socket create_socket_perms;
 allow set_ethaddr vendor_file:file execute_no_trans;
 allow set_ethaddr vendor_toolbox_exec:file execute_no_trans;
diff --git a/sepolicy/system_server.te b/sepolicy/system_server.te
index e801436..5e0af39 100644
--- a/sepolicy/system_server.te
+++ b/sepolicy/system_server.te
@@ -1,3 +1,4 @@
 gpu_access(system_server)
 allow system_server wifi_hal_prop:file {open read getattr map};
 allow system_server vendor_file:dir read;
+allow system_server sysfs_wakeup:file { getattr open read };
diff --git a/shared/utils/dlkm_loader/dlkm_loader.rc b/shared/utils/dlkm_loader/dlkm_loader.rc
index 7af8bac..b1e2c41 100644
--- a/shared/utils/dlkm_loader/dlkm_loader.rc
+++ b/shared/utils/dlkm_loader/dlkm_loader.rc
@@ -1,6 +1,13 @@
 on early-init
     # start module load in the background
     start vendor.dlkm_loader
+    # load "leaf" GKI modules
+    exec u:r:modprobe:s0 -- /system/bin/modprobe -a -d /system/lib/modules zram.ko
+    exec u:r:modprobe:s0 -- /system/bin/modprobe -a -d /system/lib/modules hci_uart.ko
+    # led-class-multicolor.ko as found in android14-5.15 but missing in android13-5.15
+    exec u:r:modprobe:s0 -- /system/bin/modprobe -a -d /system/lib/modules led-class-multicolor.ko
+    # regmap-spmi.ko as found in android13-5.15 but missing in android14-5.15
+    exec u:r:modprobe:s0 -- /system/bin/modprobe -a -d /system/lib/modules regmap-spmi.ko
 
 service vendor.dlkm_loader /vendor/bin/dlkm_loader
     class main
diff --git a/shared/utils/dlkm_loader/sepolicy/dlkm_loader.te b/shared/utils/dlkm_loader/sepolicy/dlkm_loader.te
index be36f35..e6fd7c3 100644
--- a/shared/utils/dlkm_loader/sepolicy/dlkm_loader.te
+++ b/shared/utils/dlkm_loader/sepolicy/dlkm_loader.te
@@ -3,6 +3,7 @@
 init_daemon_domain(dlkm_loader)
 
 # Allow insmod on vendor, system and system_dlkm partitions
+allow dlkm_loader self:capability net_admin;
 allow dlkm_loader self:capability sys_module;
 allow dlkm_loader system_dlkm_file:dir r_dir_perms;
 allow dlkm_loader system_dlkm_file:file r_file_perms;
@@ -11,8 +12,25 @@
 allow dlkm_loader vendor_file:system module_load;
 
 # needed for libmodprobe to read kernel commandline
-allow dlkm_loader proc_cmdline:file r_file_perms;
 allow dlkm_loader proc_bootconfig:file r_file_perms;
+allow dlkm_loader proc_cmdline:file r_file_perms;
+
+# Needed because CONFIG_USB_DUMMY_HCD adds some additional logic to
+# finit_module() syscall, causing that syscall to create/update keyrings.
+# Once we remove CONFIG_USB_DUMMY_HCD config, self:key write permission can be
+# removed.
+allow dlkm_loader self:key write;
+
+# Needed because CONFIG_DMABUF_HEAPS_DEFERRED_FREE calls sched_set_normal()
+# in its module_init() function, which is attributed to dlkm_loader.
+allow dlkm_loader kernel:process setsched;
+allow dlkm_loader self:capability sys_nice;
 
 # Allow writing to kernel log
 allow dlkm_loader kmsg_device:chr_file rw_file_perms;
+
+# dlkm_loader searches tracefs while looking for modules
+dontaudit dlkm_loader debugfs_bootreceiver_tracing:dir search;
+dontaudit dlkm_loader debugfs_mm_events_tracing:dir search;
+
+set_prop(dlkm_loader, vendor_device_prop)
diff --git a/shared/utils/dlkm_loader/sepolicy/property.te b/shared/utils/dlkm_loader/sepolicy/property.te
new file mode 100644
index 0000000..50f7b34
--- /dev/null
+++ b/shared/utils/dlkm_loader/sepolicy/property.te
@@ -0,0 +1 @@
+vendor_internal_prop(vendor_device_prop)
diff --git a/shared/utils/dlkm_loader/sepolicy/property_contexts b/shared/utils/dlkm_loader/sepolicy/property_contexts
new file mode 100644
index 0000000..2a347b3
--- /dev/null
+++ b/shared/utils/dlkm_loader/sepolicy/property_contexts
@@ -0,0 +1 @@
+vendor.dlkm.modules.ready      u:object_r:vendor_device_prop:s0 exact bool
diff --git a/shared/utils/dlkm_loader/vendor.modules.list.mk b/shared/utils/dlkm_loader/vendor.modules.list.mk
new file mode 100644
index 0000000..f28f618
--- /dev/null
+++ b/shared/utils/dlkm_loader/vendor.modules.list.mk
@@ -0,0 +1,231 @@
+VENDOR_DLKM_KERNEL_MODULES_LIST := \
+  ath10k_core.ko \
+  ath10k_pci.ko \
+  ath10k_snoc.ko \
+  ath11k_ahb.ko \
+  ath11k.ko \
+  ath11k_pci.ko \
+  ath.ko \
+  clk-spmi-pmic-div.ko \
+  cqhci.ko \
+  gpu-sched.ko \
+  lmh.ko \
+  lontium-lt9611.ko \
+  lontium-lt9611uxc.ko \
+  mcp251xfd.ko \
+  michael_mic.ko \
+  msm.ko \
+  nvmem_qfprom.ko \
+  qcom-pon.ko \
+  qcom_q6v5_mss.ko \
+  qcom_q6v5_pas.ko \
+  qcom_q6v5_wcss.ko \
+  qcom-spmi-adc5.ko \
+  qcom-spmi-adc-tm5.ko \
+  qcom-spmi-pmic.ko \
+  qcom_spmi-regulator.ko \
+  qcom-spmi-temp-alarm.ko \
+  qcom_tsens.ko \
+  reboot-mode.ko \
+  sdhci-msm.ko \
+  syscon-reboot-mode.ko \
+  system_heap.ko \
+  videocc-sdm845.ko \
+  videocc-sm8250.ko
+
+VENDOR_RAMDISK_KERNEL_MODULES_LIST := \
+  apr.ko \
+  arm_smmu.ko \
+  bam_dma.ko \
+  clk-qcom.ko \
+  clk-rpmh.ko \
+  cmd-db.ko \
+  dispcc-sdm845.ko \
+  dispcc-sm8250.ko \
+  display-connector.ko \
+  extcon-usb-gpio.ko \
+  fastrpc.ko \
+  gcc-sdm845.ko \
+  gcc-sm8250.ko \
+  gpio-regulator.ko \
+  gpio-wcd934x.ko \
+  gpucc-sdm845.ko \
+  gpucc-sm8250.ko \
+  i2c-designware-core.ko \
+  i2c-designware-platform.ko \
+  i2c-dev.ko \
+  i2c-mux.ko \
+  i2c-mux-pca954x.ko \
+  i2c-qcom-geni.ko \
+  i2c-qup.ko \
+  i2c-rk3x.ko \
+  icc-bcm-voter.ko \
+  icc-osm-l3.ko \
+  icc-rpmh.ko \
+  llcc-qcom.ko \
+  lpass-gfm-sm8250.ko \
+  mdt_loader.ko \
+  mhi.ko \
+  msm_serial.ko \
+  ohci-hcd.ko \
+  ohci-pci.ko \
+  ohci-platform.ko \
+  pdr_interface.ko \
+  phy-qcom-qusb2.ko \
+  phy-qcom-snps-femto-v2.ko \
+  phy-qcom-usb-hs.ko \
+  pinctrl-lpass-lpi.ko \
+  pinctrl-msm.ko \
+  pinctrl-sdm845.ko \
+  pinctrl-sm8250.ko \
+  pinctrl-spmi-gpio.ko \
+  pinctrl-spmi-mpp.ko \
+  pm8916_wdt.ko \
+  pm8941-pwrkey.ko \
+  q6adm.ko \
+  q6afe-clocks.ko \
+  q6afe-dai.ko \
+  q6afe.ko \
+  q6asm-dai.ko \
+  q6asm.ko \
+  q6core.ko \
+  q6routing.ko \
+  qcom_aoss.ko \
+  qcom-apcs-ipc-mailbox.ko \
+  qcom_common.ko \
+  qcom-cpufreq-hw.ko \
+  qcom_glink.ko \
+  qcom_glink_rpm.ko \
+  qcom_glink_smem.ko \
+  qcom_hwspinlock.ko \
+  qcom-ipcc.ko \
+  qcom-pdc.ko \
+  qcom_pil_info.ko \
+  qcom_q6v5_adsp.ko \
+  qcom_q6v5.ko \
+  qcom_rpmh.ko \
+  qcom-rpmh-regulator.ko \
+  qcom-scm.ko \
+  qcom_smd.ko \
+  qcom_sysmon.ko \
+  qcom_usb_vbus-regulator.ko \
+  qcom-vadc-common.ko \
+  qcom-wdt.ko \
+  qmi_helpers.ko \
+  qnoc-sdm845.ko \
+  qnoc-sm8250.ko \
+  qrtr.ko \
+  qrtr-mhi.ko \
+  qrtr-smd.ko \
+  qrtr-tun.ko \
+  regmap-sdw.ko \
+  regmap-slimbus.ko \
+  reset-qcom-aoss.ko \
+  reset-qcom-pdc.ko \
+  rmtfs_mem.ko \
+  rpmhpd.ko \
+  rpmsg_ns.ko \
+  rtc-pm8xxx.ko \
+  slim-qcom-ngd-ctrl.ko \
+  slimbus.ko \
+  smem.ko \
+  smp2p.ko \
+  smsm.ko \
+  snd-soc-dmic.ko \
+  snd-soc-hdmi-codec.ko \
+  snd-soc-lpass-va-macro.ko \
+  snd-soc-lpass-wsa-macro.ko \
+  snd-soc-max98927.ko \
+  snd-soc-qcom-common.ko \
+  snd-soc-rl6231.ko \
+  snd-soc-rt5663.ko \
+  snd-soc-sdm845.ko \
+  snd-soc-sm8250.ko \
+  snd-soc-wcd9335.ko \
+  snd-soc-wcd934x.ko \
+  snd-soc-wcd-mbhc.ko \
+  snd-soc-wsa881x.ko \
+  socinfo.ko \
+  soundwire-bus.ko \
+  soundwire-qcom.ko \
+  spmi-pmic-arb.ko \
+  spi-geni-qcom.ko \
+  spi-pl022.ko \
+  spi-qcom-qspi.ko \
+  spi-qup.ko \
+  ulpi.ko \
+  wcd934x.ko
+
+ifeq ($(TARGET_KERNEL_USE),5.15)
+VENDOR_DLKM_KERNEL_MODULES_LIST += \
+  qcom-pmic-typec.ko
+
+VENDOR_RAMDISK_KERNEL_MODULES_LIST += \
+  phy-qcom-qmp.ko \
+  q6dsp-common.ko \
+  ufs_qcom.ko
+endif
+
+ifeq ($(TARGET_KERNEL_USE),6.1)
+VENDOR_DLKM_KERNEL_MODULES_LIST += \
+  leds-qcom-lpg.ko \
+  qcom-pmic-typec.ko \
+  qnoc-sm8450.ko
+
+VENDOR_RAMDISK_KERNEL_MODULES_LIST += \
+  cpr.ko \
+  drm_display_helper.ko \
+  drm_dp_aux_bus.ko \
+  gcc-sm8450.ko \
+  gpi.ko \
+  phy-qcom-qmp-combo.ko \
+  phy-qcom-qmp-pcie.ko \
+  phy-qcom-qmp-pcie-msm8996.ko \
+  phy-qcom-qmp-ufs.ko \
+  phy-qcom-qmp-usb.ko \
+  pinctrl-sm8250-lpass-lpi.ko \
+  pinctrl-sm8450.ko \
+  q6apm-dai.ko \
+  q6apm-lpass-dais.ko \
+  q6prm-clocks.ko \
+  q6prm.ko \
+  snd-q6apm.ko \
+  snd-q6dsp-common.ko \
+  snd-soc-lpass-macro-common.ko \
+  snd-soc-qcom-sdw.ko \
+  spm.ko \
+  ufs_qcom.ko
+endif
+
+ifeq ($(TARGET_KERNEL_USE),6.6)
+VENDOR_DLKM_KERNEL_MODULES_LIST += \
+  leds-qcom-lpg.ko \
+  qcom_pmic_tcpm.ko \
+  qnoc-sm8450.ko
+
+VENDOR_RAMDISK_KERNEL_MODULES_LIST += \
+  cpr.ko \
+  drm_display_helper.ko \
+  drm_dp_aux_bus.ko \
+  gcc-sm8450.ko \
+  gpi.ko \
+  phy-qcom-qmp-combo.ko \
+  phy-qcom-qmp-pcie.ko \
+  phy-qcom-qmp-pcie-msm8996.ko \
+  phy-qcom-qmp-ufs.ko \
+  phy-qcom-qmp-usb.ko \
+  pinctrl-sm8250-lpass-lpi.ko \
+  pinctrl-sm8450.ko \
+  q6apm-dai.ko \
+  q6apm-lpass-dais.ko \
+  q6prm-clocks.ko \
+  q6prm.ko \
+  qcom_ice.ko \
+  snd-q6apm.ko \
+  snd-q6dsp-common.ko \
+  snd-soc-lpass-macro-common.ko \
+  snd-soc-qcom-sdw.ko \
+  snd-soc-wcd-classh.ko \
+  spm.ko \
+  ufs-qcom.ko
+endif
diff --git a/shared/utils/sdcard-boot/fstab.mmc b/shared/utils/sdcard-boot/fstab.mmc
index 387a0cd..1f689e8 100644
--- a/shared/utils/sdcard-boot/fstab.mmc
+++ b/shared/utils/sdcard-boot/fstab.mmc
@@ -1,5 +1,5 @@
 system		/system		erofs	ro				wait,logical,first_stage_mount,slotselect
-/dev/block/platform/soc@0/8804000.mmc/by-name/userdata	/data		ext4	discard,noatime,noauto_da_alloc,data=ordered,user_xattr,barrier=1,inlinecrypt	latemount,wait,formattable,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized,keydirectory=/metadata/vold/metadata_encryption,quota
+/dev/block/platform/soc@0/8804000.mmc/by-name/userdata	/data		f2fs	nodev,noatime,nosuid,inlinecrypt,reserve_root=32768	latemount,wait,formattable,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized,keydirectory=/metadata/vold/metadata_encryption,quota,check,fscompress,checkpoint=fs
 /dev/block/platform/soc@0/8804000.mmc/by-name/metadata	/metadata	ext4	noatime,nosuid,nodev,discard					wait,formattable,first_stage_mount,check
 /dev/block/platform/soc@0/8804000.mmc/by-name/misc /misc emmc defaults defaults
 /devices/platform/soc@0/a8f8800.usb/*/usb*		auto	auto	defaults	voldmanaged=usb1:auto
diff --git a/shared/utils/sdcard-boot/fstab.sdhci b/shared/utils/sdcard-boot/fstab.sdhci
index c385ba6..746f516 100644
--- a/shared/utils/sdcard-boot/fstab.sdhci
+++ b/shared/utils/sdcard-boot/fstab.sdhci
@@ -1,5 +1,5 @@
 system		/system		erofs	ro				wait,logical,first_stage_mount,slotselect
-/dev/block/platform/soc@0/8804000.sdhci/by-name/userdata	/data		ext4	discard,noatime,noauto_da_alloc,data=ordered,user_xattr,barrier=1,inlinecrypt	latemount,wait,formattable,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized,keydirectory=/metadata/vold/metadata_encryption,quota
+/dev/block/platform/soc@0/8804000.sdhci/by-name/userdata	/data		f2fs	nodev,noatime,nosuid,inlinecrypt,reserve_root=32768	latemount,wait,formattable,fileencryption=aes-256-xts:aes-256-cts:v2+inlinecrypt_optimized,keydirectory=/metadata/vold/metadata_encryption,quota,check,fscompress,checkpoint=fs
 /dev/block/platform/soc@0/8804000.sdhci/by-name/metadata	/metadata	ext4	noatime,nosuid,nodev,discard					wait,formattable,first_stage_mount,check
 /dev/block/platform/soc@0/8804000.sdhci/by-name/misc /misc emmc defaults defaults
 /devices/platform/soc@0/a8f8800.usb/*/usb*		auto	auto	defaults	voldmanaged=usb1:auto
diff --git a/sm8x50/BoardConfig.mk b/sm8x50/BoardConfig.mk
index 4995b75..43f437f 100644
--- a/sm8x50/BoardConfig.mk
+++ b/sm8x50/BoardConfig.mk
@@ -23,17 +23,34 @@
 BOARD_KERNEL_CMDLINE += qcom_geni_serial.con_enabled=1
 BOARD_KERNEL_CMDLINE += console=ttyMSM0,115200n8
 BOARD_KERNEL_CMDLINE += allow_mismatched_32bit_el0 clk_ignore_unused pd_ignore_unused
+
+ifeq ($(TARGET_SDCARD_BOOT), true)
+BOARD_KERNEL_CMDLINE += androidboot.boot_devices=soc@0/8804000.mmc
+else
 BOARD_KERNEL_CMDLINE += androidboot.boot_devices=soc@0/1d84000.ufs
+endif
+
 BOARD_KERNEL_CMDLINE += androidboot.hardware=sm8x50
 BOARD_KERNEL_CMDLINE += androidboot.verifiedbootstate=orange
 
 # Image Configuration
 BOARD_BOOTIMAGE_PARTITION_SIZE := 67108864 #64M
+
+ifeq ($(TARGET_SDCARD_BOOT), true)
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 8589934592 #8G
+BOARD_FLASH_BLOCK_SIZE := 4096
+# Super partition
+BOARD_SUPER_PARTITION_SIZE := 4294967296 #4G
+BOARD_DB_DYNAMIC_PARTITIONS_SIZE := 4290772992 # Reserve 4M for DAP metadata
+BOARD_SEPOLICY_DIRS += device/linaro/dragonboard/shared/utils/sdcard-boot/sepolicy/
+else
 BOARD_USERDATAIMAGE_PARTITION_SIZE := 223226966016 #200+G
 BOARD_FLASH_BLOCK_SIZE := 131072
 # Super partition
 BOARD_SUPER_PARTITION_SIZE := 6442450944 #6GB
 BOARD_DB_DYNAMIC_PARTITIONS_SIZE := 6438256640 # Reserve 4M for DAP metadata
+endif
+
 BOARD_SUPER_PARTITION_METADATA_DEVICE := super
 BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE := true
 BOARD_DB_DYNAMIC_PARTITIONS_PARTITION_LIST := system vendor system_ext product
diff --git a/sm8x50/device.mk b/sm8x50/device.mk
index 1613a5f..8928c74 100644
--- a/sm8x50/device.mk
+++ b/sm8x50/device.mk
@@ -51,9 +51,11 @@
     device/linaro/dragonboard/shared/utils/ethaddr/ethaddr.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/ethaddr.rc \
     device/linaro/dragonboard/shared/utils/ethaddr/set_ethaddr.sh:$(TARGET_COPY_OUT_VENDOR)/bin/set_ethaddr.sh
 
+ifneq ($(TARGET_SDCARD_BOOT), true)
 PRODUCT_COPY_FILES += \
     $(LOCAL_PATH)/fstab:$(TARGET_COPY_OUT_RAMDISK)/first_stage_ramdisk/fstab.sm8x50 \
     $(LOCAL_PATH)/fstab:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.sm8x50
+endif
 
 PRODUCT_VENDOR_PROPERTIES += \
     ro.soc.manufacturer=Snapdragon 8 Gen Devboard \
diff --git a/sm8x50/sm8x50.mk b/sm8x50/sm8x50.mk
index 55f8476..8272cdf 100644
--- a/sm8x50/sm8x50.mk
+++ b/sm8x50/sm8x50.mk
@@ -17,6 +17,9 @@
 
 $(call inherit-product, device/linaro/dragonboard/sm8x50/device.mk)
 
+#Boot from mmc-sdcard
+TARGET_SDCARD_BOOT ?= true
+
 # Product overrides
 PRODUCT_NAME := sm8x50
 PRODUCT_DEVICE := sm8x50