Skip to content

LPI example

This example illustrates how to generate a shared object that can be loaded in LPI mode and non-LPI mode.

This example should only be used as a reference to create LPI shared objects and run them in audio or sensor PD, but not in dynamic PD.

The objective of the LPI mode is to achieve power optimizations for audio/sensors/voice use-cases running on the aDSP and sDSP. In Low Power Island (LPI) mode, shared objects will be loaded into TCM (tightly coupled memory) instead of DDR because DDR access will be disabled.

Refer to the Feature Matrix for example support and to know the DSP architecture on the target.

Confirming usage of the LPI mode

Shared object that need to be loaded in LPI mode must be created with a separate note section containing text uimg.dl.ver.2.0.0. You can confirm whether a shared object is compiled for LPI mode or not by using the command below.

readelf --notes <shared_object>

If your output is similar to the excerpt below, then the specified shared object is compiled for LPI mode.

Notes at offset 0x00001000 with length 0x00000030:
  Owner                         Data size       Description
  uimg.dl.ver.2.0.0             0x0000000c      Unknown note type: (0x00000000)

The GNU/LLVM linker generally uses a linker script that is compiled into the linker executable to control the memory layout of the ELF. It is possible to supply a custom command file or linker script, which in our case will add a new note section in the shared object.

src/uimage_v2.lcs is used as the linker script in this example and src/uimage_dl_v2.c is compiled as part of the shared object to put the constant string uimg.dl.ver.2.0.0 in the new section created using uimage_v2.lcs.

FastRPC uses this note section uimg.dl.ver.2.0.0 to decide whether to load in TCM (in LPI mode) or in DDR (in non-LPI mode).

After running this example, you can see the loaded address of the shared object as below in logcat by running adb logcat -s adsprpc

adsprpc : so_source.c:31:0x9b:8: load address of shared object is 0x8bddf000

Below are the TCM ranges for SM8250 and Saipan

Target               tcm_range

Saipan (aDSP)       0x02C00000 - 0x02CD0000
SM8250 (aDSP)       0x02C00000 - 0x02D80000

From the load address in logcat and above TCM ranges you can confirm whether the shared object is loaded in TCM or not.

Note : LPI shared objects should only be loaded in audio and sensors PDs. Loading LPI shared objects into dynamic PD is currently not supported.