Enable 16 KB toggle

16 KB toggle lets you to try a 16 KB kernel. This switches between a 4 KB kernel and 16 KB kernel. This toggle is inside the "Developer option" menu in the settings app. It needs to be enabled for device individually.

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 BOARD_KERNEL_MODULES_16K. This points to kernel modules which support 16KB. Setting these parameters will create 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. Optional, and most devices should not set this.

Verification

After successfully setting this up

  1. 16 KB toggle is visible in settings app with "Boot with 16 KB page size".
  2. /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. Enable developer options as directed at dev options documentation.
  2. If the device is detected as OEM locked, a dialog displays to request the user to OEM unlock the phone. Follow steps to OEM unlock.
  3. When the user hits "Boot with 16 KB page size", /data and /metadata partitions need to be ext4. If they aren't, a dialog displays to request the user to wipe the device. Answering "Yes" wipes the device and you'll have to activate developer options again.
  4. 16 KB toggle now shows a confirmation dialog 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.