nuttx-apps/examples/nxflatxip/Kconfig
Marco Casaroli 2492317f15 examples/nxflatxip: Run an NXFLAT module in place out of xipfs.
The point of a writable execute-in-place file system is that a module can
arrive after the firmware was built and still run without being copied into
RAM.  This demonstrates exactly that, end to end: it writes an NXFLAT module
into xipfs the way a download would, declaring the size up front so the
extent is exact, checks the file system can hand out a real flash pointer
for it, and runs two instances concurrently.

Both instances report the address of their own text and of their stack.  The
text address is the same in both and is inside the flash window -- it is the
address the file occupies on the media -- while the stacks differ.  While
they run, the extent carries one pin per instance, which is what stops the
defragmenter relocating code that is executing.

Two subcommands cover the file system rather than the module.  bench times a
bulk read out of the mapped flash before and after a write, which on the
RP2350 is the cost of whichever path the driver used to restore XIP.  defrag
fills the volume, deletes every other file until an allocation genuinely
cannot be satisfied, compacts, retries the same allocation, then verifies
every relocated file byte for byte and again after a remount, printing a
block map at each step.

The module has neither static data nor string constants, and reports through
a callback into the firmware instead of formatting its own output.  That is
not stylistic: the ldnxflat in circulation resolves the GOT entries for .bss
objects into the import table, and drops the addend when it resolves the
PC-relative references to .rodata, so a module using either quietly computes
wrong addresses.  The comment in module/xipmod.c records both.  The callback
also exercises the other direction of the interface, firmware code entered
with the module's data base still live in r10.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-07-28 16:47:49 +08:00

38 lines
1.2 KiB
Text

#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config EXAMPLES_NXFLATXIP
tristate "NXFLAT execute-in-place from xipfs demo"
depends on FS_XIPFS && NXFLAT && LIBC_EXECFUNCS
default n
---help---
Write an NXFLAT module into xipfs at run time, the way a download
would, then run two instances of it concurrently. The module's
text is executed directly out of flash and shared between the
instances, while each instance gets its own data.
Subcommands:
bench XIP read throughput before and after a flash write
defrag fragment the volume, compact it, with a block map
Building the module needs the mknxflat and ldnxflat host tools
from the NuttX toolchain, and the board's Make.defs must name
them, exactly as apps/examples/nxflat requires.
if EXAMPLES_NXFLATXIP
config EXAMPLES_NXFLATXIP_MOUNTPT
string "xipfs mountpoint"
default "/mnt/xipfs"
config EXAMPLES_NXFLATXIP_MTD
string "MTD device backing the volume"
default "/dev/rpflash"
---help---
Used only by the defrag subcommand, which remounts the volume to
show that what it did survives.
endif # EXAMPLES_NXFLATXIP