Skip to content

Commit

Permalink
lmdk: How to convert and build loadable modules
Browse files Browse the repository at this point in the history
How to tutorial

Signed-off-by: Dobrowolski, PawelX <pawelx.dobrowolski@intel.com>
  • Loading branch information
pjdobrowolski committed Mar 22, 2024
1 parent 3c8c515 commit f2ac296
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion getting_started/loadable_modules/lmdk_user_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,71 @@ What is LMDK
************

LMDK(Loadable Module Development Kit) is a standalone package required to build loadable module. It is independent from SOF FW but contains necessary data structures to interact with it.
Package consists building CMake scripts and headers pack which is generated by python building script by executing it with -p:

.. code-block:: bash
$ python scripts/lmdk/build_modules.py -l dummy -k "/path/to/signing/key.pem" -p
These headers should be extracted in include directory of lmdk:

.. code-block:: cmake
set(LMDK_DIR_INCLUDE ../../../lmdk/include)
target_include_directories(up_down_mixer PRIVATE "${LMDK_DIR_INCLUDE}"
"${LMDK_DIR_INCLUDE}/sof"
"${LMDK_DIR_INCLUDE}/sof/audio"
"${LMDK_DIR_INCLUDE}/module/audio")
How to prepare MODULE to be loadable
************************************

Loadable modules are using functions provided by native_system_services which are narrowed to only neccesary and safe functions. For example all dynamic allocations are done on strict size local heap_mem
declared in a body of the module.

.. code-block:: c
static struct native_system_service_api* system_service;
uint32_t heap_mem[2048] __attribute__((section(".heap_mem"))) __attribute__((aligned(4096)));
Each module also has to declare as a loadable and has prepared manifest which is specific for each.

.. code-block:: c
DECLARE_LOADABLE_MODULE_API_VERSION(dummy);
static void* entry_point(void* mod_cfg, void* parent_ppl, void** mod_ptr)
{
system_service = *(const struct native_system_agent**)mod_ptr;
return &up_down_mixer_interface;
}
__attribute__((section(".module")))
const struct sof_man_module_manifest dummy_module_manifest = {
.module = {
.name = "DUMMY",
.uuid = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
.entry_point = (uint32_t)dummyPackageEntryPoint,
.type = {
.load_type = SOF_MAN_MOD_TYPE_MODULE,
.domain_ll = 1
},
.affinity_mask = 3,
}
};
How to build
************

Using CMake scripts
===================
To build example loadable library execute:
.. code-block:: bash

.. code-block:: bash
$ cd libraries/example
$ mkdir build
Expand All @@ -23,3 +82,6 @@ To build example loadable library execute:
Here RIMAGE_COMMAND is path to rimage executable binary, SIGNING_KEY is path to
signing key for rimage. `LMDK <https://github.com/thesofproject/sof/pull/7354>`

Using Python scripts
====================

0 comments on commit f2ac296

Please sign in to comment.