Skip to content

Commit f2ac296

Browse files
committed
lmdk: How to convert and build loadable modules
How to tutorial Signed-off-by: Dobrowolski, PawelX <[email protected]>
1 parent 3c8c515 commit f2ac296

File tree

1 file changed

+63
-1
lines changed

1 file changed

+63
-1
lines changed

getting_started/loadable_modules/lmdk_user_guide.rst

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,71 @@ What is LMDK
77
************
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.
10+
Package consists building CMake scripts and headers pack which is generated by python building script by executing it with -p:
11+
12+
.. code-block:: bash
13+
14+
$ python scripts/lmdk/build_modules.py -l dummy -k "/path/to/signing/key.pem" -p
15+
16+
These headers should be extracted in include directory of lmdk:
17+
18+
.. code-block:: cmake
19+
20+
set(LMDK_DIR_INCLUDE ../../../lmdk/include)
21+
target_include_directories(up_down_mixer PRIVATE "${LMDK_DIR_INCLUDE}"
22+
"${LMDK_DIR_INCLUDE}/sof"
23+
"${LMDK_DIR_INCLUDE}/sof/audio"
24+
"${LMDK_DIR_INCLUDE}/module/audio")
25+
26+
27+
How to prepare MODULE to be loadable
28+
************************************
29+
30+
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
31+
declared in a body of the module.
32+
33+
.. code-block:: c
34+
35+
static struct native_system_service_api* system_service;
36+
uint32_t heap_mem[2048] __attribute__((section(".heap_mem"))) __attribute__((aligned(4096)));
37+
38+
Each module also has to declare as a loadable and has prepared manifest which is specific for each.
39+
40+
.. code-block:: c
41+
42+
DECLARE_LOADABLE_MODULE_API_VERSION(dummy);
43+
44+
static void* entry_point(void* mod_cfg, void* parent_ppl, void** mod_ptr)
45+
{
46+
system_service = *(const struct native_system_agent**)mod_ptr;
47+
48+
return &up_down_mixer_interface;
49+
}
50+
51+
__attribute__((section(".module")))
52+
const struct sof_man_module_manifest dummy_module_manifest = {
53+
.module = {
54+
.name = "DUMMY",
55+
.uuid = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
56+
.entry_point = (uint32_t)dummyPackageEntryPoint,
57+
.type = {
58+
.load_type = SOF_MAN_MOD_TYPE_MODULE,
59+
.domain_ll = 1
60+
},
61+
.affinity_mask = 3,
62+
}
63+
};
64+
65+
1066
1167
How to build
1268
************
1369

70+
Using CMake scripts
71+
===================
1472
To build example loadable library execute:
15-
.. code-block:: bash
73+
74+
.. code-block:: bash
1675
1776
$ cd libraries/example
1877
$ mkdir build
@@ -23,3 +82,6 @@ To build example loadable library execute:
2382
2483
Here RIMAGE_COMMAND is path to rimage executable binary, SIGNING_KEY is path to
2584
signing key for rimage. `LMDK <https://github.com/thesofproject/sof/pull/7354>`
85+
86+
Using Python scripts
87+
====================

0 commit comments

Comments
 (0)