The latest development version of this page may be more current than this released 4.0.0 version.

Linkable loadable extensions “module” sample

Browse source code on GitHub

Overview

This sample demonstrates the use of the Linkable Loadable Extensions (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 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:

Requirements

A board with a supported llext architecture and console. This can also be executed in QEMU emulation on the qemu_xtensa or qemu_cortex_r5 virtual boards.

Building and running

  • By default, the sample will compile the function along with the rest of Zephyr in the same binary. This can be verified via the following commands:

    west build -b qemu_xtensa/dc233c samples/subsys/llext/modules
    west build -t run
    
  • 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:

    west build -b qemu_xtensa/dc233c -T sample.llext.modules.module_build samples/subsys/llext/modules
    west build -t run
    

    Important

    Take a look at 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.

See also

Linkable loadable extensions