Skip to content

synxexample

Overview

The synx example illustrates the usage of the following synx APIs described here:

  • synx_initialize
  • synx_create
  • synx_import
  • synx_wait
  • synx_signal
  • synx_uninitialize

Project structure

  • inc/synxexample.idl

IDL interface that defines the synxexample API.

This IDL file is compiled by the QAIC IDL compiler into the following files:

synxexample.h: C/C++ header file

synxexample_stub.c: Stub source that needs to be built for the HLOS (Android, etc...)

synxexample_skel.c: Skel source that needs to be built for the Hexagon DSP

  • src/ : Source files for the HLOS executable and Hexagon-side implementation of the synxexample

    synxexample_apps.c : Demonstrates the synx APIs on HLOS side and invokes call to DSP functions that demonstrate the synx APIs on DSP.

    synxexample_imp.c : Demonstrates synx APIs on DSP.

Call flow of synxexample

The following diagram depicts the call flow of synx example

jpg

Definition of the terms in the diagram:

Term Description
synx_session1 Synx session created on CPU
setup This function creates the synx session on DSP
synx_session2 Synx session created on DSP
h_synx1, h_synx3 Synx objects created on CPU
workerthreadfunction Thread created at CPU where the h_synx1 object is signaled
dsp_callfn Thread created at CPU to call the dspalgorithm1 function
h_imp_synx1, h_imp_synx3 Synx objects imported on DSP that are mapped to h_synx1 and h_synx3 respectively
dspalgorithm1 The DSP implementation of this function calls the synx_wait on h_imp_synx1 object
dspalgorithm2 This function signals the h_imp_synx3 object that is waiting on CPU
Uninitialize This function deintializes the synx_session2 on DSP

Building

Using the walkthrough script

  • The example comes with a walkthrough script called synxexample_walkthrough.py which builds the code and runs on target.

  • The script must be run using the following command :

    python synxexample_walkthrough.py -T <Target Name>
    

Please review the generic setup and walkthrough_scripts instructions to learn more about setting up your device and using walkthrough scripts.

Note: This example is supported on Lanai target.

Using the cmake commands

  • To build your code without using the walkthrough script, you will need to build both the Android and Hexagon modules. To build the Android module along with the dependencies, run the following command:

    build_cmake android VERBOSE=1
    
  • To build the Hexagon module, run the following command:

    build_cmake hexagon DSP_ARCH=v73 VERBOSE=1
    

For more information on the build syntax, please refer to the building reference instructions.

Running on Target

If you want to run your code on target without using the walkthrough script, please use the following steps:

  • Use ADB as root and remount system read/write

    adb root
    adb wait-for-device
    adb remount
    
  • Push the HLOS side synxexample executable and the supporting stub library to the device

    adb shell mkdir -p /vendor/bin/
    adb push android_ReleaseG_aarch64/synxexample_device /vendor/bin/
    adb shell chmod 777 /vendor/bin/synxexample_device
    adb push android_ReleaseG_aarch64/ship/libsynxexample.so /vendor/lib64/
    
  • Push the Hexagon Shared Object to the device's file system

    adb shell mkdir -p /vendor/lib/rfsa/dsp/sdk
    adb push hexagon_ReleaseG_toolv87_v73/ship/libsynxexample_skel.so /vendor/lib/rfsa/dsp/sdk
    
  • Generate a device-specific test signature based on the device's serial number Follow the steps listed in the Use signer.py section of the signing documentation.

Note: This step only needs to be done once as the same test signature will enable loading any module.

  • Redirect DSP FARF messages to ADB logcat by creating a farf file

    adb shell "echo 0x1f > /vendor/lib/rfsa/dsp/sdk/synxexample.farf"
    

    Please refer to the page on messaging resources which discusses the tools available for logging debug messages from the DSP.

  • Launch a new CLI shell to view the DSP's diagnostic messages using logcat

    Open a new shell or command window and execute :

    adb logcat -s adsprpc
    
  • Execute the synxexample_device binary as follows :

    adb shell "export LD_LIBRARY_PATH=/vendor/lib64/ DSP_LIBRARY_PATH=/vendor/lib/rfsa/dsp/sdk; /vendor/bin//synxexample_device>"