Debug provides a set of common logging and debugging techniques to troubleshoot issues in Qualcomm TEE, trusted and client applications, and secure devices.ImportantRun all the SSH commands in the SELinux Permissive mode. The Enforcing mode will be supported in the future. For instructions on how to connect to the device, see Qualcomm Linux Build Guide.
Debug Qualcomm TEE
Qualcomm TEE kernel logs, also known as the TrustZone diag log, can be used to debug errors that occur in Qualcomm TEE.The TrustZone diag log is available in the Linux kernel driver, which redirects the logs.
Connect to the device as the root using SSH.
Capture the TrustZone logs using the following command:
cat /proc/tzdbg/log > tzbsp_log.txt
The error codes in tzbsp_log.txt are encoded in hexadecimal. You can run the following tool to decode tzbsp_log.txt from hexadecimal to string.
Go to <TZ.XF.X.X path>/trustzone_images/ssg/bsp/tz/build/tz/A53_64/<BuildFlavor>
For device log collection, the TrustZone diag log buffer is part of the RAM dump, which can be parsed using qsee.elf from TZ.XF software in the crash dump parser tool. For offline or off-device log collection, the TrustZone diag log buffer is part of the RAM dump, which can be parsed using qsee.elf(trustzone\_images/ssg/bsp/qsee/build/\${tz\_bid:EACAANAA}) from the TZ.XF software in the crash dump parser tool.
Debug using secure crash dump
You can debug Qualcomm TEE using the RAM dump. The execution region dump of Qualcomm TEE is collected using secure crash dumps.Devices that trigger the fuse with stage 2 sec.elf are known as secure boot-enabled devices. To debug on these devices, see SecTools v2: Secure Debug User Guide.NoteThe SecTools guides are available to licensed developers with authorized access.
Debug trusted and client applications
The trusted application logs, also known as Qualcomm TEE logs, are used to debug the errors in trusted applications. To debug errors in the client application, the kernel and journalctl logs are used.For online or on-device log collection, Linux collects the Qualcomm TEE/kernel logs at runtime. You can connect to the device using SSH and use the following commands:
To collect the Qualcomm TEE logs from Linux:
cat /proc/tzdbg/qsee_log > qsee_log.txt
For client applications, to collect the kernel and logcat logs:
For offline or off-device log collection, the Qualcomm TEE log is available in RAM dumps along with the kernel and journalctl logs.
Debug on secure devices
As part of the secure boot procedure, blowing debug disable fuses disable debugging capabilities on the devices. This includes RAM dumps, INV, and NINV debug on the subsystems.The debug policy feature allows control over the debug capability for a device enabled with secure boot.The debug policy image allows debug capabilities such as JTAG re-enable (INV debug), RAM dump, and TrustZone logging (NINV debug) on commercial secure devices.For security reasons, the serial number of the device controls the debug policy for secure RAM dumps, Qualcomm TEE logs, and JTAG.Enabling JTAG on the Qualcomm TEE subsystem disables the device security with respect to hardware key generation. As a result, existing secure storage like user data, SFS, and RPMB becomes inaccessible. Sometimes, the device may prompt for a factory data reset. Use the following command to debug on secure devices:
Ensure that you configure the OEM_ID, PRODUCT_ID, serial number and keys, and certification paths appropriately.For more information, see SecTools v2: Secure Debug User Guide.NoteThe SecTools guides are available to licensed developers with authorized access.
Flash APDP on device
To flash APDP on the device, run the following command:
fastboot flash apdp_a <path to apdp.mbn>
Table : Debug policy flags for dump collection
Stage
Full dump
Mini dump
Stage
Applications (DCC and scan dump) aDSP/Video/RPM/ SLPI
Modem/Qualcomm TEE/Secure dump
TZDiag
Nonâsecure
No debug policy needed
No debug policy needed
No debug policy needed
Stages 1 secure
No APDP image needed
No APDP image needed
No debug policy needed
Stages 2 secure
--nonsecure-crash-dumps
âoffline-crash dumps with device serial number. See below for Available minidumps
QCS6490/QCS5430: ââlogsâ with device serial number QCS9075: ââtz-diag-logsâ with device serial number Or Encrypted TZDiag with --nonsecure-crash-dumps + TZDiag encryption public key/exp in devcfg can be configured in the following location:
See KBA-191202045020-1 (ZIP). For more information, see MiniDump Software User Guide.NoteThe SecTools and MiniDump guides are available to licensed user with authorized access.
Qualcomm TEE/TrustZone diag log collection on secure device
On the secure device, the Qualcomm TEE/TrustZone log thatâs collected from Linux is disabled by default. Qualcomm provides an encrypted log feature for logging. Follow these steps for enabling this feature:
Note
The modulus is used in the pub_mod in oem_config.xml file. The pub_exp exponent is usually 65537. 0x10001 is known as the publicExponent.
Set the RSA public key (exponent and modulus) in the trustzone_images/ssg/securemsm/trustzone/qsee/mink/oem/config/<chipset>/ oem_config.xml file.
Enable this feature by adding the following lines to the oem_config.xml file using:
Note
When the public key in the oem_config.xml file is updated, ensure that there are no new line characters, tabs, or spaces inserted between due to the Notepad or Wordpad editors.
Enable the encryption feature configuration flag from the trustzone_images/ssg/securemsm/trustzone/qsee/mink/oem/config/<chipset>/oem_config.xml file, using: