• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

src/04-Jan-2025-7644

CMakeLists.txtD04-Jan-2025267 116

README.rstD04-Jan-20251.6 KiB5238

prj.confD04-Jan-2025226 98

sample.yamlD04-Jan-2025667 2625

README.rst

1.. zephyr:code-sample:: demand-paging
2   :name: Demand paging
3   :relevant-api: mem-demand-paging
4
5   Leverage demand paging to deal with code bigger than available RAM.
6
7Overview
8********
9
10This sample demonstrates how demand paging can be leveraged to deal with
11firmware bigger than the available RAM if XIP is not possible. Select code
12can be tagged to be loaded into memory on demand, and also be automatically
13evicted for more code to be executed when memory is exhausted.
14
15Requirements
16************
17
18This demo requires the presence of a supported hardware MMU and a backing
19store implementation with access to the compiled Zephyr binary.
20For demonstration purposes, the ondemand_semihost backing store is used on
21a QEMU ARM64 target with a hardcoded small RAM configuration.
22
23Building and Running
24********************
25
26This application can be built and executed on QEMU as follows:
27
28.. zephyr-app-commands::
29   :zephyr-app: samples/subsys/demand_paging
30   :host-os: unix
31   :board: qemu_cortex_a53
32   :goals: run
33   :compact:
34
35Sample Output
36=============
37
38.. code-block:: console
39
40    *** Booting Zephyr OS build v3.7.0-2108-g5975c3785356 ***
41    Calling huge body of code that doesn't fit in memory
42    free memory pages: from 37 to 0, 987 page faults
43    Calling it a second time
44    free memory pages: from 0 to 0, 987 page faults
45    Done.
46
47Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.
48
49To actually view the underlying demand paging subsystem at work, debug
50prints can be enabled using :kconfig:option:`CONFIG_LOG` and
51:kconfig:option:`CONFIG_KERNEL_LOG_LEVEL_DBG` in the config file.
52