You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/dlmodule/README.md
+20-20Lines changed: 20 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
-
# Dynamic Module: dlmodule #
1
+
@page component_dlmodule Dynamic Module: dlmodule
2
2
3
3
In traditional desktop operating systems, user space and kernel space are separate. The application runs in user space, and the kernel and kernel modules run in kernel space. The kernel module can be dynamically loaded and deleted to extend the kernel functionality. `dlmodule` is a software component of the dynamic module loading mechanism provided in kernel space of RT-Thread. In versions of RT-Thread v3.1.0, this was also called the `Application Module`. After RT-Thread v3.1.0 and later, it returned to the tradition and was named after the `dynamic module`.
4
4
5
5
`dlmodule` is more of an ELF format loader. The code segment and data segment of a separately compiled elf file are loaded into memory, and the symbols are parsed and bound to the API address exported by the kernel. The elf files are primarily placed on file systems under RT-Thread.
6
6
7
-
##Introduction ##
7
+
# Introduction
8
8
9
9
The dynamic module provides a mechanism for dynamically loading program modules for RT-Thread. Because it is also compiled independently of the kernel, it is more flexible to use. In terms of implementation, this is a mechanism to separate the kernel from the dynamic modules. Through this mechanism, the kernel and dynamic modules can be compiled separately, and at runtime, the compiled dynamic modules are loaded into the kernel through the module loader in the kernel.
10
10
@@ -15,11 +15,11 @@ In the dynamic module of RT-Thread, two formats are currently supported:
15
15
16
16
The current RT-Thread architecture supporting dynamic modules mainly includes ARM architecture and x86 architecture, and will be extended to MIPS and RISC-V architecture in the future. The RT-Thread kernel firmware section can use a variety of compiler toolchains, such as GCC, ARMCC, IAR and other toolchains; however, dynamic module partial compilation currently only supports GNU GCC toolchain compilation. Therefore, compiling the RT-Thread module requires downloading GCC tools, such as CodeSourcery's arm-none-eabi toolchain. In general, it's best to use kernel and dynamic modules to compile with the same toolchain (so that it doesn't produce inconsistent behavior in *libc*). In addition, dynamic modules can only be loaded into RAM and used for symbol resolution binding to the API address exported by the kernel. Instead of running directly in XIP mode based on Flash (because Flash can't modify the code segment again).
17
17
18
-
##Using Dynamic Module ##
18
+
# Using Dynamic Module
19
19
20
20
When you want to use the dynamic modules in your system, you need to compile a firmware that supports dynamic modules, as well as dynamic modules that need to be run. The following two parts are compiling firmware and compiling dynamic modules.
21
21
22
-
###Compile Firmware ###
22
+
## Compile Firmware
23
23
24
24
When you want to use the dynamic module, you need to open the corresponding option in the firmware configuration, use menuconfig to open the following configuration:
25
25
@@ -82,7 +82,7 @@ Then execute the `scons` under the BSP project directory and generate the firmwa
82
82
83
83
to generate the kernel header file search path and global macro definitions that need to be included when compiling the dynamic module.
84
84
85
-
###Compile Dynamic Module ###
85
+
## Compile Dynamic Module
86
86
87
87
There is a separate repository on github: [rtthread-apps](https://github.com/RT-Thread/rtthread-apps) , which contains some examples of dynamic modules and dynamic libraries.
88
88
@@ -151,11 +151,11 @@ int main(int argc, char *argv[])
151
151
}
152
152
```
153
153
154
-
## APIs of Dynamic Module
154
+
# APIs of Dynamic Module
155
155
156
156
In addition to dynamically loading and executing dynamic modules via msh, dynamic modules can be loaded or unloaded using the dynamic module API provided by RT-Thread in the main program.
This function loads the dynamic module from the file system into memory, and if it is loaded correctly, returns a pointer to the module. This function does not create a thread to execute this dynamic module, just load the module into memory and parse the symbolic address.
172
172
173
-
###Execute Dynamic Module
173
+
## Execute Dynamic Module
174
174
175
175
```c
176
176
struct rt_dlmodule *dlmodule_exec(const char* pgname, const char* cmd, int cmd_size);
This function loads the dynamic module according to the `pgname` path and starts a thread to execute `main` of the dynamic module. At the same time, `cmd` is passed as the command line Parameter to `main` entry of the dynamic module.
This function returns the symbol address based on the symbol name.
244
244
245
-
## Libdl API of POSIX Standard ##
245
+
# Libdl API of POSIX Standard
246
246
247
247
The POSIX standard libdl API is also supported in RT-Thread dlmodule. It is similar to loading a dynamic library into memory (and parsing some of the symbol information). This dynamic library provides the corresponding set of function operations. The libdl API needs to include the header files: `#include <dlfcn.h>`
This function is similar to the `dlmodule_load` , which loads the dynamic library from the file system and returns the handle pointer of the dynamic library.
This function looks in the dynamic library `handle` for the presence of the symbol of `symbol` , if there is an address that returns it.
280
280
281
-
### Close Dynamic Library
281
+
## Close Dynamic Library
282
282
283
283
```
284
284
int dlclose (void *handle);
@@ -293,15 +293,15 @@ int dlclose (void *handle);
293
293
294
294
This function closes the dynamic library pointed to by `handle` and unloads it from memory. It should be noted that when the dynamic library is closed, the symbolic address originally returned by `dlsym` will no longer be available. If you still try to access it, it may cause a fault error.
295
295
296
-
## FAQs
296
+
# FAQs
297
297
298
-
Please refer to [*User Manual of Env*](../env/env.md) for issues related to the Env tool.
298
+
Please refer to @ref env for issues related to the Env tool.
299
299
300
-
### Q: Dynamic modules cannot be run successfully according to the documentation.
300
+
## Q: Dynamic modules cannot be run successfully according to the documentation.
301
301
302
302
**A:** Please update the RT-Thread source code to version 3.1.0 and above.
303
303
304
-
### Q: Compile the project with the scons command, prompting "undefined reference to __rtmsymtab_start".
304
+
## Q: Compile the project with the scons command, prompting "undefined reference to __rtmsymtab_start".
305
305
306
306
**A:** Please refer to the qemu-vexpress-a9 BSP GCC link script file *link.lds* to add the following to the TEXT section of the project's GCC link script.
0 commit comments