Starting March 27, 2025, we recommend using android-latest-release instead of aosp-main to build and contribute to AOSP. For more information, see Changes to AOSP.
Stay organized with collections
Save and categorize content based on your preferences.
Devices that launch with Android 12 using kernel
versions higher than v5.4 are required to ship with the GKI kernel. So that
partners can access DebugFS in userdebug builds while they develop on the GKI
kernel, the kernel config CONFIG_DEBUG_FS is enabled in the GKI defconfig.
Never mount DebugFS in user builds for devices
launching on Android 12.
Userdebug builds have better test coverage than user builds and get heavily
tested throughout the development cycle. The following plan minimizes the
difference between the two build types with respect to DebugFS access, and
provides these benefits:
Prevents userdebug builds from accidentally depending on DebugFS
for new functionality
Ensures that any existing functionality that's broken by the lack of DebugFS
is known early in the development cycle
Debugfs accesses in userdebug builds are categorized as
follows:
DebugFS file initializations during device boot, such as a
write access to a file in DebugFS to turn on debug data collection.
Bugreport generation: The dumpstate HAL reads DebugFS files when
DumpstateBoard() is invoked by dumpstate. This
information becomes part of the bug report.
Device-specific testing and validation.
The following table describes how each of these three categories is
supported in Android 12. Note that the
following only applies to userdebug builds since DebugFS can't be
mounted in user builds.
Use case
Android 12 userdebug build
One-time DebugFS files initialization, during startup.
This access happens only once during boot time.
Dumpstate HAL performs this during HAL initialization. To enable the same,
init mounts DebugFS in userdebug builds before the HAL initializes.
Init calls umount() on DebugFS when
the device has completed booting.
Bugreport generation: The dumpstate HAL reads
DebugFS files, which become part of the bug report.
Done by dumpstate HAL within DumpstateBoard() when invoked by dumpstate
(DumpstateDevice.cpp).
The dumpstate tool (part of the Android framework) ensures that DebugFS
mounts during the invocation.
Device-specific testing and validation
Adb root and shell. Mount DebugFS from the adb shell with
root access1.
1To mount DebugFS from adb shell with
root access, use this command:
adb shell mount -t debugfs debugfs /sys/kernel/debug.
Required partner actions
Partners must enact the following based on these changes in
Android 12 devices:
Don't allow DebugFS access during runtime. The following exceptions
apply:
Bugreport generation (comes from the dumpstate HAL)
Testing and validation (accessible by adb root and shell
- ensure that DebugFS is mounted first)
Developers can set the debug persistent property
persist.dbg.keep_debugfs_mounted to keep DebugFs mounted across
reboots on userdebug and eng builds.
GTS compliance tests ensure that the DebugFS filesystem isn't
mounted in user builds. Sepolicy neverallow statements ensure that in devices
launching on Android 12 or higher, unauthorized processes aren't provided
access to DebugFs.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-06-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-26 UTC."],[],[],null,["# Use DebugFS in Android 12\n\nDevices that launch with Android 12 using kernel\nversions higher than v5.4 are required to ship with the GKI kernel. So that\npartners can access `DebugFS` in userdebug builds while they develop on the GKI\nkernel, the kernel config `CONFIG_DEBUG_FS` is enabled in the GKI defconfig.\n**Never mount `DebugFS` in user builds** for devices\nlaunching on Android 12.\n\n\nUserdebug builds have better test coverage than user builds and get heavily\ntested throughout the development cycle. The following plan minimizes the\ndifference between the two build types with respect to `DebugFS` access, and\nprovides these benefits:\n\n- Prevents userdebug builds from accidentally depending on `DebugFS` for new functionality\n- Ensures that any existing functionality that's broken by the lack of DebugFS is known early in the development cycle\n\n\nDebugfs accesses **in userdebug builds** are categorized as\nfollows:\n\n1. `DebugFS` file initializations during device boot, such as a write access to a file in `DebugFS` to turn on debug data collection.\n2. Bugreport generation: The dumpstate HAL reads `DebugFS` files when `DumpstateBoard()` is invoked by `dumpstate`. This information becomes part of the bug report.\n3. Device-specific testing and validation.\n\nThe following table describes how each of these three categories is\nsupported in Android 12. Note that the\nfollowing only applies to userdebug builds since `DebugFS` can't be\nmounted in user builds.\n\n| Use case | Android 12 userdebug build |\n|-------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| **One-time `DebugFS` files initialization, during startup** . This access **happens only once** during boot time. | Dumpstate HAL performs this during HAL initialization. To enable the same, init mounts `DebugFS` in userdebug builds before the HAL initializes. `Init` calls `umount()` on `DebugFS` when the device has completed booting. |\n| **Bugreport generation** : The dumpstate HAL reads `DebugFS` files, which become part of the bug report. | Done by dumpstate HAL within `DumpstateBoard()` when invoked by dumpstate ([DumpstateDevice.cpp](https://cs.android.com/android/platform/superproject/+/android-latest-release:device/google/trout/hal/dumpstate/1.1/DumpstateDevice.cpp)). The dumpstate tool (part of the Android framework) ensures that `DebugFS` mounts during the invocation. |\n| **Device-specific testing and validation** | Adb root and shell. Mount `DebugFS` from the adb shell with root access^1^. |\n\n\n^1^To mount `DebugFS` from `adb shell` with\nroot access, use this command:\n\n`adb shell mount -t debugfs debugfs /sys/kernel/debug`.\n| **Note:**\n|\n| - **Android 12: There aren't any new APIs for accessing the\n| dumpstate HAL**.\n| - **Android 12: New clients don't have access** to the dumpstate HAL.\n| - Only the dumpstate HAL process and vendor-modprobe tool can access `DebugFS` for Android 12 launching devices, since the kernel modules it loads might create `DebugFS` files.\n\nRequired partner actions\n------------------------\n\n\nPartners must enact the following based on these changes in\nAndroid 12 devices:\n\n- Make all boot time initializations of `DebugFS` nodes happen during the dumpstate HAL initialization. For an example of how to do this, see [DNM:\n Example for boot time initialization of `DebugFS` files](https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1426054).\n- **Don't allow `DebugFS` access during runtime. The following exceptions\n apply:**\n - Bugreport generation (comes from the dumpstate HAL)\n - Testing and validation (accessible by `adb root` and `shell` - ensure that DebugFS is mounted first)\n\nDevelopers can set the debug persistent property\n`persist.dbg.keep_debugfs_mounted` to keep `DebugFs` mounted across\nreboots on userdebug and eng builds.\n\nGTS compliance tests ensure that the `DebugFS` filesystem isn't\nmounted in user builds. Sepolicy `neverallow` statements ensure that in devices\nlaunching on Android 12 or higher, unauthorized processes aren't provided\naccess to `DebugFs`."]]