Merge "Prerequisite changes to switch to 6.1 kernel" into main
diff --git a/product_files/fstab.trout b/product_files/fstab.trout
index 82726c8..d7c98c0 100644
--- a/product_files/fstab.trout
+++ b/product_files/fstab.trout
@@ -10,6 +10,8 @@
 product /product ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb
 system_ext /system_ext ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb=vbmeta_system
 vendor /vendor ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb=vbmeta
+vendor_dlkm /vendor_dlkm ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb=vbmeta_dlkm
+system_dlkm /system_dlkm ext4 noatime,ro,errors=panic wait,logical,first_stage_mount,slotselect,avb=vbmeta_system_dlkm
 /dev/block/zram0 none swap defaults zramsize=75%
 /tmp /sdcard none defaults,bind recoveryonly
 /devices/*/block/vdb auto auto defaults voldmanaged=sdcard1:auto,encryptable=userdata
diff --git a/trout_arm64/BoardConfig.mk b/trout_arm64/BoardConfig.mk
index 3d20522..f99db1a 100644
--- a/trout_arm64/BoardConfig.mk
+++ b/trout_arm64/BoardConfig.mk
@@ -51,32 +51,55 @@
 # Kernel - prefer version 5.10 by default for trout
 TARGET_KERNEL_USE ?= 5.10
 
+# Select the prebuilt trout kernel if 5.10 or 5.4 is in use
 TROUT_KERNEL_DIR ?= $(wildcard device/google/trout-kernel/$(TARGET_KERNEL_USE)-arm64)
 
-# The trout kernel is provided as source to AOSP,
-# and thus we cannot rely on it existing outside of Google-internal builds. Make sure not to try
-# and include a missing kernel image.
-ifndef TARGET_KERNEL_PATH
-# wildcard is for existence checking,
-# so TROUT_KERNEL_IMAGE is suppose to be a list that contains at most one path.
-# The foreach below is only for extracting the path from the list.
-TROUT_KERNEL_IMAGE := $(wildcard $(TROUT_KERNEL_DIR)/Image)
-$(foreach kernel_img, $(TROUT_KERNEL_IMAGE), $(eval TARGET_KERNEL_PATH := $(kernel_img)))
-endif
-
 TARGET_BOARD_PLATFORM := vsoc_arm64
 TARGET_ARCH := arm64
 TARGET_ARCH_VARIANT := armv8-a
 TARGET_CPU_ABI := arm64-v8a
 TARGET_CPU_VARIANT := cortex-a53
 
--include device/google/trout/shared/BoardConfig.mk
+ifneq ($(TROUT_KERNEL_DIR),)
+KERNEL_MODULES_PATH ?= $(TROUT_KERNEL_DIR)
+TARGET_KERNEL_PATH ?= $(TROUT_KERNEL_DIR)/Image
 
-TROUT_KO_DIR ?= $(TROUT_KERNEL_DIR)
-ifneq ($(TROUT_KO_DIR),)
-BOARD_VENDOR_RAMDISK_KERNEL_MODULES := $(wildcard $(TROUT_KO_DIR)/*.ko)
+# For local builds of the android12-5.10 kernel, this directory doesn't exist.
+# The system_dlkm partition won't have any kernel modules in it, which matches
+# how this kernel was originally used.
+#
+# For prebuilts of the android12-5.10 kernel, the result is the same.
+#
+# For local builds of the android14-6.1 kernel and later, this directory should
+# be created by extracting the system_dlkm_staging_archive.tar.gz file in the
+# build directory of the kernel before building the android image.
+#
+# For prebuilts of the android14-6.1 kernel and later, TROUT_KERNEL_DIR should
+# not be specified, in which case it will follow whatever the upstream
+# cuttlefish device specifies.
+SYSTEM_DLKM_SRC ?= $(TROUT_KERNEL_DIR)/flatten/lib/modules
 endif
 
+# The list of modules strictly/only required either to reach second stage
+# init, OR for recovery. Do not use this list to workaround second stage
+# issues.
+RAMDISK_KERNEL_MODULES ?= \
+    failover.ko \
+    nd_virtio.ko \
+    net_failover.ko \
+    virtio_blk.ko \
+    virtio_console.ko \
+    virtio_dma_buf.ko \
+    virtio-gpu.ko \
+    virtio_input.ko \
+    virtio_net.ko \
+    virtio_mmio.ko \
+    virtio_pci.ko \
+    virtio-rng.ko \
+    vmw_vsock_virtio_transport.ko \
+
+-include device/google/trout/shared/BoardConfig.mk
+
 AUDIOSERVER_MULTILIB := first
 
 HOST_CROSS_OS := linux_bionic
@@ -110,3 +133,6 @@
 
 # Add default fstab settings
 BOARD_KERNEL_CMDLINE += androidboot.fstab_name=fstab androidboot.fstab_suffix=trout
+
+# Prevent mac80211_hwsim from simulating any radios
+BOARD_KERNEL_CMDLINE += mac80211_hwsim.radios=0