# Debug For performance profiling of the applications, you can use the Snapdragon Profiler and kernel commands. The procedures to collect information for profiling and debugging using the kernel commands, and to collect logs, are described here. Note Use the commands described here with caution because these commands may impact the power consumption of the device. ## Capture Weston/Wayland logs To capture the Weston/Wayland debug logs, run the following command before launching the Weston or any other application: export WAYLAND_DEBUG=server/client Copy to clipboard ## Kernel/KGSL Before debugging the kernel or KGSL, remount the file system using the following command: mount -o remount,rw / Copy to clipboard ### Set CPU to Performance mode 1. To set all CPU cores, replace `cpux` with `cpu0`, `cpu1`, and `cpun`. echo 1 > /sys/devices/system/cpu/[cpux]/online Copy to clipboard cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors Copy to clipboard Sample output: ondemand userspace performance schedutil 2. If any CPU clock is running at a low frequency, set the CPU to Performance mode and verify the issue by running the following command: echo performance > /sys/devices/system/cpu/[cpux]/cpufreq/scaling_governor Copy to clipboard 3. To validate the trial settings, run the following commands: cat /sys/devices/system/cpu/[cpux]/online (cpux : cpu0,cpu1 …) Copy to clipboard cat /sys/devices/system/cpu/[cpux]/cpufreq/scaling_governor(cpux : cpu0, cpu1 …) Copy to clipboard ### Set GPU frequency 1. For the power level, check the `available_frequencies` sys node. cat /sys/class/kgsl/kgsl-3d0/devfreq/available_frequencies Copy to clipboard Sample output: 812000000 700000000 608000000 550000000 450000000 315000000 From the sample output, GPU power levels are interpreted as: | **Frequency** | 812000000 | 700000000 | 608000000 | 550000000 | 450000000 | 315000000 | | --- | --- | --- | --- | --- | --- | --- | | **Power level** | 0 | 1 | 2 | 3 | 4 | 5 | 2. Increment the GPU power level by one and perform the GPU power-level test by substituting `` with 0, 1, 2, 3, 4, and so on, in the following commands: echo > /sys/class/kgsl/kgsl-3d0/min_pwrlevel Copy to clipboard echo > /sys/class/kgsl/kgsl-3d0/max_pwrlevel Copy to clipboard Note For QCS5430: - The Adreno GPU frequency is fixed at 315 MHz. - The power levels specified here are not supported and the output of the `available_frequencies` command displays 315000000. ### Set GPU to Performance mode - To set the GPU to Performance mode, run the following commands: echo 0 > /sys/class/kgsl/kgsl-3d0/min_pwrlevel Copy to clipboard echo 0 > /sys/class/kgsl/kgsl-3d0/max_pwrlevel Copy to clipboard Note These commands force the GPU to always run at the maximum frequency. - To ensure that the GPU does not enter the low-power state even if the device is idle for 10000000 ms, run the following command: echo 10000000 > /sys/class/kgsl/kgsl-3d0/idle_timer Copy to clipboard - To set the GPU to Performance mode while ensuring that the GPU does not enter the low-power state, run the following commands: echo 0 > /sys/class/kgsl/kgsl-3d0/min_pwrlevel Copy to clipboard echo 0 > /sys/class/kgsl/kgsl-3d0/max_pwrlevel Copy to clipboard echo 10000000 > /sys/class/kgsl/kgsl-3d0/idle_timer Copy to clipboard Note The Performance mode is not supported on QCS5430 because the frequency of the Adreno GPU is fixed at 315 MHz. ### Check other KGSL settings - To enable the KGSL clock, run the following command: echo 1 > /sys/class/kgsl/kgsl-3d0/force_clk_on Copy to clipboard - To enable the KGSL rail, run the following command: echo 1 > /sys/class/kgsl/kgsl-3d0/force_rail_on Copy to clipboard - To enable the KGSL bus, run the following command: echo 1 > /sys/class/kgsl/kgsl-3d0/force_bus_on Copy to clipboard ## OpenGL ES-based applications The Snapdragon Profiler tool is used to capture snapshots and real-time traces of OpenGL ES applications. For more information, see [Snapdragon Profiler](https://docs.qualcomm.com/doc/80-70017-19/topic/graphics_developer_tools.html#section-mwq-r4x-31c). ## OpenCL-based applications The Snapdragon Profiler tool is used to capture snapshots and real-time traces of OpenCL applications. - For more information, see [Snapdragon Profiler](https://docs.qualcomm.com/doc/80-70017-19/topic/graphics_developer_tools.html#section-mwq-r4x-31c). - For performance profiling, see **Performance profiling** in [Qualcomm® Snapdragon™ Mobile Platform OpenCL General Programming and Optimization Guide](https://docs.qualcomm.com/bundle/publicresource/80-NB295-11_REV_C_Qualcomm_Snapdragon_Mobile_Platform_Opencl_General_Programming_and_Optimization.pdf). Note Some of the sections in the [Qualcomm® Snapdragon™ Mobile Platform OpenCL General Programming and Optimization Guide](https://docs.qualcomm.com/bundle/publicresource/80-NB295-11_REV_C_Qualcomm_Snapdragon_Mobile_Platform_Opencl_General_Programming_and_Optimization.pdf) are applicable to Android platforms and not to Qualcomm Linux devices. However, some profiling options are purely based on the OpenCL API and are therefore supported on Qualcomm Linux devices. For example, the `clGetEventProfilingInfo` API. ## Vulkan-based applications The Snapdragon Profiler tool is used to capture snapshots and real-time traces of Vulkan applications. For more information, see [Snapdragon Profiler](https://docs.qualcomm.com/doc/80-70017-19/topic/graphics_developer_tools.html#section-mwq-r4x-31c). In addition to the Snapdragon Profiler, you can also use validation layers to debug Vulkan applications. To debug a Vulkan application using validation layers, do the following on the Linux host: 1. To set the source environment, run the following command: source /environment-setup-armv8-2a-qcom-linux Copy to clipboard 2. To download the validation layers, run the following command: git clone https://github.com/KhronosGroup/Vulkan-ValidationLayers Copy to clipboard 3. To build the validation layers, run the following commands: cmake -S . -B build -D UPDATE_DEPS=ON -D BUILD_WSI_XLIB_SUPPORT=OFF -D BUILD_TESTS=OFF -D CMAKE_BUILD_TYPE=Release -D BUILD_WSI_XCB_SUPPORT=OFF -D BUILD_WSI_WAYLAND_SUPPORT=ON Copy to clipboard cmake --build build --config Debug Copy to clipboard scp -r build/layers/libVkLayer_khronos_validation.so root@[IP-address-of-device]:/tmp/local/debug/vulkan/ Copy to clipboard scp -r build/layers/VkLayer_khronos_validation.json root@[IP-address-of-device]:/tmp/local/debug/vulkan/ Copy to clipboard export VK_LAYER_PATH=/tmp/local/debug/vulkan:$VK_LAYER_PATH Copy to clipboard Note If the `/tmp/local/debug/vulkan` directory is not available, create a similar directory. 4. To enable the validation layers on Vulkan applications, set the `VK_INSTANCE_LAYERS` environment variable as follows: export VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation Copy to clipboard 5. To edit or append the settings in the `layers/vk_layer_settings.txt` file, run the following commands: khronos_validation.debug_action = VK_DBG_LAYER_ACTION_LOG_MSG Copy to clipboard khronos_validation.report_flags = error,warn,perf Copy to clipboard khronos_validation.file = true Copy to clipboard khronos_validation.log_filename = vk_validatedump.txt Copy to clipboard 6. To push the `layers/vk_layer_settings.txt` file to the device, run the following command: scp -r vk_layer_settings.txt root@[IP-address-of-device]:/tmp/local/debug/vulkan/ Copy to clipboard 7. To dump the log, add path of the validation layers by running the following command: export VK_LAYER_SETTINGS_PATH=/tmp/local/debug/vulkan/vk_layer_settings.txt Copy to clipboard Dumps are generated in the same directory where the Vulkan application binary was pushed. Note To avoid data flush in the `tmp` directory, save the Vulkan application binary to another location. If you change the location of the binary, ensure to update the environment variables accordingly and verify the changes after rebooting. Last Published: Dec 27, 2024 [Previous Topic Tools](https://docs.qualcomm.com/bundle/publicresource/80-70017-19/topics/graphics_developer_tools.md) [Next Topic Supported extensions](https://docs.qualcomm.com/bundle/publicresource/80-70017-19/topics/supported_extensions.md)