Enable 16 KB toggle

16 KB toggle lets you to try a 16 KB kernel. This toggle switches between a 4 KB kernel and 16 KB kernel and can be found inside the "Developer option" menu in the settings app. The 16 KB toggle can be used to check application compatibility with the 16 KB kernel, but it might not reflect performance of actual 16 KB device due to the use of subpage blocks (when using EXT4 for /data and /metadata partitions) in 16 KB mode.

Steps for configuring toggle

  1. Make sure the device has set up the variables to be page-agnostic (to work with both 4 KB and 16 KB page size kernels). You may want to install the 16k kernel directly to make sure the device works in 16 KB mode directly before continuing to add the developer option. See the virtual device example target config.

        PRODUCT_NO_BIONIC_PAGE_SIZE_MACRO := true
        PRODUCT_MAX_PAGE_SIZE_SUPPORTED := 16384
    
  2. Setup product variable to display developer option in settings PRODUCT_16K_DEVELOPER_OPTION := true

  3. Set kernel path using BOARD_KERNEL_PATH_16K. This kernel should be built with CONFIG_ARM64_16K_PAGES=y.

      BOARD_KERNEL_PATH_16K := kernel/prebuilts/mainline/$(TARGET_KERNEL_ARCH)/16k/kernel-mainline.
    
  4. Set modules config path variable BOARD_KERNEL_MODULES_16K. This variable points to kernel modules which support 16KB. Setting these parameters creates two OTAs on the system partition : boot_ota_16k.zip(to switch to 16 KB kernel) and boot_ota_4k.zip(to switch to 4 KB kernel). Enable incremental OTAs by setting BOARD_16K_OTA_USE_INCREMENTAL := true for smaller size boot OTAs.

      BOARD_KERNEL_MODULES_16K += $(wildcard kernel/prebuilts/mainline/$(TARGET_KERNEL_ARCH)/16k/*.ko)
      BOARD_KERNEL_MODULES_16K += $(wildcard kernel/prebuilts/common-modules/virtual-device/mainline/$(TARGET_KERNEL_ARCH)/16k/*.ko)
    
  5. Set BOARD_16K_OTA_MOVE_VENDOR := true to move OTAs to the vendor partition. Only set this to move OTAs from system to vendor partition.

Verification

After successfully configuring the toggle, follow these steps:

  1. Check if Boot with 16 KB page size toggle is visible in settings app.
  2. Check if /system/boot_otas or /vendor/boot_otas contains two OTA zip files : boot_ota_16k.zip and boot_ota_4k.zip.

Use 16 KB toggle

  1. Go to Settings > System > Software updates and apply any updates which are available.
  2. Enable developer options. For instructions, see Configure on-device developer options.
  3. If the device is detected as OEM locked, a dialog displays asking you to OEM unlock the phone. For instructions, see Lock and unlock the bootloader.
  4. Click Boot with 16 KB page size. If /data and /metadataaren't ext4, a dialog displays asking you to wipe the device. Click Erase all data to wipe the device. The device is wiped and you must enable developer options again.
  5. Click Boot with 16 KB page size. A dialog displays asking you to switch to 16 KB, and on confirming, boot OTAs are applied. You can then toggle back and forth between 4 KB and 16 KB mode without clearing the data partition to test app behavior.

Check 16 KB Mode

Follow steps at getting page size to verify page size.