Skip to content

Commit 2f6eb05

Browse files
committed
lmdk: How to convert and build loadable modules
How to tutorial descibing process of building and creating headers pack for needs of lmdk. Signed-off-by: Dobrowolski, PawelX <[email protected]>
1 parent 3c8c515 commit 2f6eb05

File tree

1 file changed

+84
-3
lines changed

1 file changed

+84
-3
lines changed

getting_started/loadable_modules/lmdk_user_guide.rst

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,86 @@ What is LMDK
88

99
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.
1010

11+
.. code-block:: bash
12+
13+
$ python scripts/lmdk/libraries_build.py -l dummy -k "/path/to/signing/key.pem"
14+
15+
Latest headers pack is being deployed with FW and its versioning is keept in sof\src\include\module\module\api_ver.h . Every change in headers must be marked in that header(todo: automation).
16+
Creating deployment header pack is done by calling:
17+
18+
.. code-block:: bash
19+
20+
$ python scripts/lmdk/header_pack.py
21+
22+
These headers should be extracted in include directory of lmdk with the same include path as it is in the sof project.
23+
24+
.. code-block:: cmake
25+
26+
target_compile_definitions(dummy PRIVATE CONFIG_XTENSA=1
27+
CONFIG_IPC_MAJOR_4=1
28+
CONFIG_LIBRARY=1
29+
XCHAL_HAVE_HIFI3=1
30+
SOF_MODULE_API_PRIVATE=1)
31+
32+
set(LMDK_DIR_INCLUDE ../../../lmdk/include)
33+
34+
target_include_directories(up_down_mixer PRIVATE "${LMDK_DIR_INCLUDE}"
35+
"${LMDK_DIR_INCLUDE}/src/include"
36+
"${LMDK_DIR_INCLUDE}/src/include/sof/audio/module_adapter/iadk"
37+
"${LMDK_DIR_INCLUDE}/posix/include"
38+
"${LMDK_DIR_INCLUDE}/posix/include/sof"
39+
40+
Good example how to prepare module for using lmdk exported headers is included dummy module.
41+
42+
How to prepare MODULE to be loadable
43+
************************************
44+
45+
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
46+
declared in a body of the module.
47+
48+
.. code-block:: c
49+
50+
static struct native_system_service_api* system_service;
51+
uint32_t heap_mem[2048] __attribute__((section(".heap_mem"))) __attribute__((aligned(4096)));
52+
53+
Each module also has to declare as a loadable and has prepared manifest which is specific for each.
54+
55+
.. code-block:: c
56+
57+
DECLARE_LOADABLE_MODULE_API_VERSION(dummy);
58+
59+
static void* entry_point(void* mod_cfg, void* parent_ppl, void** mod_ptr)
60+
{
61+
system_service = *(const struct native_system_agent**)mod_ptr;
62+
63+
return &up_down_mixer_interface;
64+
}
65+
66+
__attribute__((section(".module")))
67+
const struct sof_man_module_manifest dummy_module_manifest = {
68+
.module = {
69+
.name = "DUMMY",
70+
.uuid = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
71+
.entry_point = (uint32_t)dummyPackageEntryPoint,
72+
.type = {
73+
.load_type = SOF_MAN_MOD_TYPE_MODULE,
74+
.domain_ll = 1
75+
},
76+
.affinity_mask = 3,
77+
}
78+
};
79+
80+
81+
1182
How to build
1283
************
84+
Designers of lmdk prepared two options of building loadable modules. Using them is depend from needs.
1385

86+
Using CMake scripts
87+
===================
1488
To build example loadable library execute:
15-
.. code-block:: bash
89+
90+
.. code-block:: bash
1691
1792
$ cd libraries/example
1893
$ mkdir build
@@ -21,5 +96,11 @@ To build example loadable library execute:
2196
$ cmake -DRIMAGE_COMMAND="/path/to/rimage" -DSIGNING_KEY="/path/to/signing/key.pem" ..
2297
$ cmake --build .
2398
24-
Here RIMAGE_COMMAND is path to rimage executable binary, SIGNING_KEY is path to
25-
signing key for rimage. `LMDK <https://github.com/thesofproject/sof/pull/7354>`
99+
Using Python scripts
100+
====================
101+
Building module using python
102+
103+
.. code-block:: bash
104+
105+
$ python scripts/lmdk/libraries_build.py -l dummy -k "/path/to/signing/key.pem"
106+

0 commit comments

Comments
 (0)