Part 1
요약·해설
Caller source, QEMU 요구 사항, 두 Twister configuration command를 보존합니다.
CONFIG_HELLO_WORLD_MODE=y
CONFIG_HELLO_WORLD_MODE=m
Load ELF · resolve symbol · call
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
A8605C9E8A39DAFB9632B623814AA53874A55AD9399815CB040CA437752F0F93
.. zephyr:code-sample:: llext-modules
:name: Linkable loadable extensions "module" sample
:relevant-api: llext
Call a function in a loadable extension module,
either built-in or loaded at runtime.
Overview
********
This sample demonstrates the use of the :ref:`llext` subsystem in Zephyr. The
llext subsystem allows for the loading of relocatable ELF files at runtime;
their symbols can be accessed and functions called.
Specifically, this shows how to call a simple "hello world" function,
implemented in :zephyr_file:`samples/subsys/llext/modules/src/hello_world_ext.c`.
This is achieved in two different ways, depending on the value of the Kconfig
symbol ``CONFIG_HELLO_WORLD_MODE``:
- if it is ``y``, the function is directly compiled and called by the Zephyr
application. The caller code used in this case is in
:zephyr_file:`samples/subsys/llext/modules/src/main_builtin.c`.
- if it is ``m``, the function is compiled as an llext and it is included in
the application as a binary blob. At runtime, the llext subsystem is used to
load the extension and call the function. The caller code is in
:zephyr_file:`samples/subsys/llext/modules/src/main_module.c`.
Requirements
************
A board with a supported llext architecture and console. This can also be
executed in QEMU emulation on the :ref:`qemu_xtensa <qemu_xtensa>` or
:ref:`qemu_cortex_r5 <qemu_cortex_r5>` virtual boards.
Building and running
********************
- The following commands build and run the sample so that the files are linked
together in the same binary:
.. zephyr-app-commands::
:zephyr-app: samples/subsys/llext/modules
:board: qemu_xtensa
:goals: build run
:west-args: -T sample.llext.modules.builtin_build
:compact:
- The following commands build and run the sample so that the extension code is
compiled separately and included in the Zephyr image as a binary blob:
.. zephyr-app-commands::
:zephyr-app: samples/subsys/llext/modules
:board: qemu_xtensa
:goals: build run
:west-args: -T sample.llext.modules.module_build
:compact:
Take a look at :zephyr_file:`samples/subsys/llext/modules/sample.yaml` for the
additional architecture-specific configurations required in this case.
To build for a different board, replace ``qemu_xtensa`` in the commands above
with the desired board name.
Part 3
한국어 전문 번역
개요
Zephyr LLEXT subsystem은 relocatable ELF file을 runtime에 load하고 그 symbol에 접근하거나 function을 호출하게 합니다. 이 sample은 samples/subsys/llext/modules/src/hello_world_ext.c에 구현된 단순한 hello-world function을 호출합니다.
CONFIG_HELLO_WORLD_MODE=y이면 function을 Zephyr application에 직접 compile해 호출하며 caller는 samples/subsys/llext/modules/src/main_builtin.c입니다. 값이 m이면 function을 LLEXT로 별도 compile한 뒤 binary blob으로 application에 포함합니다. Runtime에는 LLEXT subsystem이 extension을 load해 function을 호출하며 caller는 samples/subsys/llext/modules/src/main_module.c입니다.
요구 사항
지원되는 LLEXT architecture와 console이 있는 board가 필요합니다. QEMU의 qemu_xtensa 또는 qemu_cortex_r5 virtual board에서도 실행할 수 있습니다.
빌드 및 실행
다음 configuration은 application과 extension source를 같은 binary에 함께 link해 build하고 실행합니다.
west build -b qemu_xtensa -T sample.llext.modules.builtin_build samples/subsys/llext/modules
west build -t run
다음 configuration은 extension code를 별도로 compile한 뒤 Zephyr image에 binary blob으로 포함해 build하고 실행합니다.
west build -b qemu_xtensa -T sample.llext.modules.module_build samples/subsys/llext/modules
west build -t run
Module 방식에 필요한 architecture별 추가 configuration은 samples/subsys/llext/modules/sample.yaml을 확인하십시오. 다른 board용으로 build하려면 command의 qemu_xtensa를 원하는 board 이름으로 바꿉니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.