Overview
The Hexagon SDK provides ability to collect diagnostic messages from the DSP.
-
Read FARF for information on the recommended framework for sending log messages from the DSP.
-
Read printf for information on how sending log messages from the DSP via standard printf prototype.
-
Read Runtime FARF for information on how to enable DSP messages at runtime.
-
READ logcat for information on how to view DSP messages in logcat.
FARF
Diagnostic messages are sent via the FARF API defined in /inc/HAP_farf.h.
FARF(level, msg, ...)
Logging is controlled via conditional compilation. A FARF level should be defined to 1 for FARF macros to be compiled in. For example:
|
If FARF_LOW is defined to 0, as it is by default, the above FARF string will not be compiled in, if it is defined to 1 it will be compiled in. Users can also define their own custom levels. For example:
|
The LEVEL define tells FARF what runtime logging level to use. These are mapped to their diag level counterparts, in the above example the message will be logged to diag's LOW level.
When building the Debug variant or builds defining _DEBUG the following FARF levels will be enabled:
-
ALWAYS
-
HIGH
-
ERROR
-
FATAL
Note: To push the FARF messages to logcat, check logcat column
printf
printf is enabled on newer targets and it can be used to send diagnostic messages similar to FARF. printf is supported in its standard prototype.
Any messages sent to STDOUT are considered as FARF_HIGH message. Messages sent to STDERR is considered as FARF_ERROR messages and displayed in QXDM.
printf("Helloworld!!!\n");
Runtime FARF
Introduction
Note: Support introduced on Snapdragon 810 targets.
Runtime FARF can be used to log messages that are disabled by default, and can be enabled at runtime as and when desired. Runtime FARF messages have no (or significantly low) overhead unless enabled.
Runtime FARF messages are always compiled in. A message can be logged via runtime FARF as below
#include "HAP_farf.h"
FARF(RUNTIME_LOW,"Runtime Low FARF message");
FARF(RUNTIME_MEDIUM,"Runtime Medium FARF message");
FARF(RUNTIME_HIGH,"Runtime High FARF message");
FARF(RUNTIME_ERROR,"Runtime Error FARF message");
FARF(RUNTIME_FATAL,"Runtime Fatal FARF message");
Just as in regular FARF, The LEVEL tells FARF what runtime logging level to use.
Runtime FARF messages can be enabled either by
-
Adding a config file to the HLOS
-
Programmatically calling an API in HLOS code
Enabling runtime FARF via config file
The FastRPC Android user library (libadsprpc.so) watches the folder defined by ADSP_LIBRARY_PATH (/vendor|system/lib/rfsa/adsp) for config files that can be used to enable / disable runtime FARF message.
Config file name
In order to reference a particular FastRPC process, the config file can be named in any one of the following formats:
-
<rpc_hlos_process_name>.farf
-
<rpc_hlos_pid>.farf
-
<rpc_adsp_asid>.farf
The FastRPC process PID and ASID can be discovered using the adsp_ps tool included with the SDK.
For example in order to reference a FastRPC process (say farf_runtime_test), the corresponding config file can be named:
-
farf_runtime_test.farf
-
2.farf (Assuming that the ASID of this process is 2)
-
3492.farf (Assuming that the PID of this process is 3492)
Contents of the config file
The contents of the config file are formatted as below:
<hex_mask> <comma separated filenames (optional)>
The mask has one bit for each level
-
0x01 – LOW
-
0x02 – MEDIUM
-
0x04 – HIGH
-
0x08 – ERROR
-
0x10 - FATAL
For example
-
To enable all levels of runtime messages for all files in the process
-
0x1f
-
-
To enable all levels of runtime messages for the file farf_runtime_test_adsp.c
-
0x1f farf_runtime_test_adsp.c
-
-
To enable all levels of runtime messages for the files farf_runtime_test_adsp.c and foo.c
-
0x1f farf_runtime_test_adsp.c,foo.c
-
Enabling at process start-up
If you would like to enable runtime FARF messages for a particular FastRPC process at process startup, place a config file with the name <rpc_hlos_process_name>.farf in the appropriate folder defined
by ADSP_LIBRARY_PATH. The FastRPC user library scans for this file before it starts the RPC process. It will not look for the other filenames at startup (since the PID / ASID are non-deterministic)
Enabling runtime FARF programmatically
You can enable runtime FARF programmatically by calling the method
int HAP_setFARFRuntimeLoggingParams(unsigned int mask, const char* files[], short numberOfFiles);
You can then use your own mechanism to enable or disable runtime logging. See
For Windows: . <sdk root>\examples\common\farf_runtime_test
For Linux: . <sdk root>/examples/common/farf_runtime_test
for an example on how to enable and use runtime FARF messages programmatically.
Obtaining PID and ASID of FastRPC processes
It is possible to enable logging in a particular process, by referencing that process using either its ASID or HLOS PID. This allows you to target a specific process if there are multiple processes with the
same name running. In order to obtain the ASID and PID of the running FastRPC processes, you can use the adsp_ps executable. See adsp_ps for more information
root@msm8994:/data # ./adsp_ps
./adsp_ps
FastRPC process list
-----------------------
*****************************************************************************
ASID HLOS PID HLOS Process Name DSP Process Name
*****************************************************************************
2 3389 adsp_ps /frpc/f09f75d0 adsp_
*****************************************************************************
logcat
Regular FARF messages on DSP can be directed to logcat. When enabled, FARF messages on the DSP will show up in the logcat stream with the tag adsprpc.
How to enable
The same mechanism used for Runtime FARF is used to direct regular FARF messages to logcat.
For example, to see the calculator example's messages printed in logcat place an file (an empty is also sufficient) in ADSP_LIBRARY_PATH (/system|vendor/lib/rfsa/adsp) named
calculator.farf
Follow the Runtime FARF instructions for more on enabling logcat messages
How to filter logcat for DSP messages
To view DSP messages (from ADSP/CDSP/SLPI/MDSP) use logcat's built in logcat filtering mechanism.
adb logcat -s adsprpc
Example output should look like this:
05-25 19:25:57.275 4442 4443 W adsprpc : calculator_imp.c:17:0x40a6:=============== DSP: sum result 499500 ===============