Skip to content

Commit 3efc120

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 3efc120

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

getting_started/loadable_modules/lmdk_user_guide.rst

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

67+
Using CMake scripts
68+
===================
1469
To build example loadable library execute:
1570
.. code-block:: bash
1671
@@ -23,3 +78,6 @@ To build example loadable library execute:
2378
2479
Here RIMAGE_COMMAND is path to rimage executable binary, SIGNING_KEY is path to
2580
signing key for rimage. `LMDK <https://github.com/thesofproject/sof/pull/7354>`
81+
82+
Using Python scripts
83+
===================

0 commit comments

Comments
 (0)