16k: Add 16K variant kernel/ramdisk build targets

This adds two new build variables, BOARD_KERNEL_PATH_16K and
BOARD_KERNEL_MODULES_16K . BOARD_KERNEL_PATH_16K will be copied
to output directory as is.

BOARD_KERNEL_MODULES_16K is a list of modules which will be packed into a
ramdisk and added to output dir. This allows cuttlefish to switch to 16K
kernel at runtime without adding too much overhead, as ramdisk building
takes very little time.

Bug: 253827893
Test: m kernel_16k ramdisk_16k
Change-Id: I4e49c727e5ed07a915145897cb987f29b0fe68e2
This commit is contained in:
Kelvin Zhang
2023-05-16 18:27:27 -07:00
committed by Juan Yescas
parent 7833547153
commit 1f04dfaba2
2 changed files with 38 additions and 0 deletions

View File

@@ -1001,6 +1001,42 @@ $(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_RAMDISK)))
BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
ifneq ($(BOARD_KERNEL_MODULES_16K),)
TARGET_OUT_RAMDISK_16K := $(PRODUCT_OUT)/ramdisk_16k
BUILT_RAMDISK_16K_TARGET := $(PRODUCT_OUT)/ramdisk_16k.img
RAMDISK_16K_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_ramdisk_16k)
$(BUILT_RAMDISK_16K_TARGET): $(DEPMOD)
$(BUILT_RAMDISK_16K_TARGET): $(call copy-many-files,$(foreach file,$(BOARD_KERNEL_MODULES_16K),$(file):$(RAMDISK_16K_STAGING_DIR)/lib/modules/0.0/$(notdir $(file))))
$(DEPMOD) -b $(RAMDISK_16K_STAGING_DIR) 0.0
for MODULE in $(BOARD_KERNEL_MODULES_16K); do \
basename $$MODULE >> $(RAMDISK_16K_STAGING_DIR)/lib/modules/0.0/modules.load ; \
done;
mkdir -p $(TARGET_OUT_RAMDISK_16K)/lib
rm -rf $(TARGET_OUT_RAMDISK_16K)/lib/modules
cp -r $(RAMDISK_16K_STAGING_DIR)/lib/modules/0.0 $(TARGET_OUT_RAMDISK_16K)/lib/modules
$(MKBOOTFS) $(TARGET_OUT_RAMDISK_16K) > $@
# Builds a ramdisk using modules defined in BOARD_KERNEL_MODULES_16K
ramdisk_16k: $(BUILT_RAMDISK_16K_TARGET)
.PHONY: ramdisk_16k
endif
ifneq ($(BOARD_KERNEL_PATH_16K),)
BUILT_KERNEL_16K_TARGET := $(PRODUCT_OUT)/kernel_16k
$(eval $(call copy-one-file,$(BOARD_KERNEL_PATH_16K),$(BUILT_KERNEL_16K_TARGET)))
# Copies BOARD_KERNEL_PATH_16K to output directory as is
kernel_16k: $(BUILT_KERNEL_16K_TARGET)
.PHONY: kernel_16k
endif
ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
# -l enables the legacy format used by the Linux kernel
COMPRESSION_COMMAND_DEPS := $(LZ4)

View File

@@ -1810,6 +1810,8 @@ else ifeq ($(TARGET_BUILD_UNBUNDLED),$(TARGET_BUILD_UNBUNDLED_IMAGE))
$(INTERNAL_OTA_PACKAGE_TARGET) \
$(INTERNAL_OTA_METADATA) \
$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET) \
$(BUILT_RAMDISK_16K_TARGET) \
$(BUILT_KERNEL_16K_TARGET) \
$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET) \
$(SYMBOLS_ZIP) \
$(SYMBOLS_MAPPING) \