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:
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> - Run the following commands using python 3.
For example:
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. Note The 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:
- 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:Flash APDP on device
To flash APDP on the device, run the following command:
/trustzone_images/ssg/securemsm/trustzone /qsee/mink/oem/config<chipset>/oem_config.xml
See KBA-191202045020-1 (ZIP). For more information, see MiniDump Software User Guide.
Note
The 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:- Generate an RSA key for encryption using:
- Show RSA key information and modulus using:
Note The modulus is used in the
pub_mod in oem_config.xmlfile. Thepub_expexponent is usually 65537. 0x10001 is known as thepublicExponent. - Set the RSA public key (exponent and modulus) in the
trustzone_images/ssg/securemsm/trustzone/qsee/mink/oem/config/<chipset>/ oem_config.xmlfile. Enable this feature by adding the following lines to theoem_config.xmlfile using:Note When the public key in theoem_config.xmlfile 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.xmlfile, using: - To build the TrustZone devcfg image, enter the OEM_ID field value and sign the
devcfg.mbnimage. - Flash the signed
devcfg.mbnimage using:
devcfg.mbn for QCS6490 and devcfg_iot.mbn for QCS9100.
- Collect the Qualcomm TEE/TrustZone log using:
Qualcomm TEE/TrustZone diag log decryption steps
- Download the Python decryption tool
decrypt_tzdiag_qsee_log_tools.pyfrom KBA-200917004544-1 (ZIP). - To install, run the following commands:
- To decrypt, run the following command:
- After successful decryption:
- Navigate the plain text of the Qualcomm TEE log to a readable string format.
- Convert the hexadecimal encoded error codes to string, using:
Next steps
- To learn how to develop and run trusted and client applications, see Develop trusted and client applications.
- To configure Qualcomm TEE for securing devices that handle sensitive data and run trusted applications, see Configure security services.
- To customize memory and SEPolicy, see Customize security services.

