Skip to content

Kernel mode support - #13

Draft
raiden00pl wants to merge 14 commits into
apache:mainfrom
raiden00pl:kernel-mode-support
Draft

Kernel mode support#13
raiden00pl wants to merge 14 commits into
apache:mainfrom
raiden00pl:kernel-mode-support

Conversation

@raiden00pl

Copy link
Copy Markdown
Member

changes required for testing nuttx in kernel build

@raiden00pl raiden00pl linked an issue Aug 10, 2026 that may be closed by this pull request
@raiden00pl
raiden00pl force-pushed the kernel-mode-support branch 3 times, most recently from beb9b3e to 38d33ba Compare August 11, 2026 13:43
@raiden00pl

Copy link
Copy Markdown
Member Author

this patchset is too big, I'll break it into smaller PRs

@raiden00pl
raiden00pl force-pushed the kernel-mode-support branch 2 times, most recently from 2a28bfb to 32aec96 Compare August 24, 2026 11:54
Kernel-mode CMake builds install applications to <build>/bin. On qemu
arm/riscv the target mounts them over a semihosting hostfs relative to
the spawned process working directory. When the generated .config
selects CONFIG_BUILD_KERNEL=y, register app_bindir=<build>/bin and
exec_cwd=<build>, keeping values set in YAML.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
Requirements only supported exact [key, value] matching, which cannot
express init configuration that differs between build modes: flat
builds use CONFIG_INIT_ENTRYPOINT, kernel builds CONFIG_INIT_FILEPATH.
Add, backward compatibly:

- [key, "*"]: any truthy value satisfies
- [[key, value], ...]: alternatives, any one satisfies

Also name the product, core and unmet requirement in the abort message.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
With app_bindir configured, cmd_check resolves commands against the
application binary directory first and falls back to symbol lookups
over bin_debug for names that are not applications (NSH builtins like
cmd_df, cmocka entries). Flat-mode behavior is unchanged.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
Runtime checks searched the core ELF or the NSH help output, neither of
which lists kernel-mode applications. Route check_cmd through
CoreConfig.cmd_check when the core is a kernel build with a known
application directory, so runtime checks agree with collection-time
filtering.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
With exec_cwd set, QEMU resolved a relative '-kernel' path against the
spawn directory instead of the NTFC working directory it is expressed
in, so boot timed out. Absolutize the image path in the qemu and sim
start paths when a custom spawn directory is configured.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
In kernel builds a faulting user task is killed while the kernel keeps
running and the prompt returns, so the console message is the only
crash evidence; such faults were reported as command timeouts. Register
the fault messages as SEGFAULT signatures:

- 'Segmentation fault in' (risc-v)
- 'PANIC: Unhandled user exception' (arm64)

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
Real hardware has no hostfs, so kernel-mode applications must be
shipped as a filesystem image. Add the per-core apps_image option,
which generates a ROMFS image from app_bindir with genromfs after the
build, and the $APPS_BINDIR and $APPS_IMG flash command placeholders.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
Prebuilt kernel-mode images have no host application directory, so
check_cmd could not resolve commands. List CONFIG_PATH_INITIAL (default
/system/bin) once on the running target, cache it, and match cmd_check
patterns against it with the matcher shared with AppBinDir. A failed
listing is not cached and is retried.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
CMake registers application targets at configure time from .config, but
kv overrides are applied after configuring, so an override enabling a
new application changed .config without ever creating its build target:
code-level options took effect through the .config -> config.h rule
while the application never appeared in the image. Overrides can also
unlock suboptions (e.g. *_PROGNAME) whose missing defaults make cmake
drop the application silently. Run olddefconfig and configure again
after applying overrides.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
First kernel-mode reference target. The S-mode knsh64 build boots
through the QEMU bundled OpenSBI firmware, so '-bios none' is not
passed. The stock defconfig mounts hostfs 'fs=../apps', which does not
match the CMake layout; override it with 'fs=.' so /system maps to the
build directory holding bin/.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
Board-agnostic template for kernel-mode targets on a serial console,
documenting the apps_image/$APPS_IMG flashing pattern, prebuilt image
discovery and the boot_timeout requirement. Board specifics are filled
in once the hardware target is selected.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
Second kernel-mode reference target, exercising the ROMFS deployment
path (no hostfs on x86_64): applications are packed into a ROMFS image
linked into the kernel. kv overrides supply what the stock defconfig
lacks, each annotated in the file.

Requires the CMake kernel-build fixes for x86_64 from the vendored
NuttX branch fix-x86_64-cmake-kernel-build.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
Kernel-mode reference targets for arm64 and arm, mirroring the riscv
knsh64 hostfs pattern: semihosting hostfs with 'fs=.' mapped to the
build directory.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
@raiden00pl
raiden00pl force-pushed the kernel-mode-support branch from 32aec96 to b14ce38 Compare August 25, 2026 11:19
The gcore tests wrote the "Saved corefile" and GCORE_MARKER reply
lines into the pipe before calling generate_coredump().  If the
reader thread consumed those lines before generate_coredump()
reset _gcore_done and _last_corefile, the reset discarded them and
the wait timed out, returning None (seen as a flaky CI failure on
the Python 3.14 job).

Feed the reply via a proc.stdin.write side effect triggered by the
GCORE_MARKER echo command instead, so it arrives only after the
controller has issued the gcore command -- mirroring real gdb and
making the ordering deterministic.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
@raiden00pl
raiden00pl force-pushed the kernel-mode-support branch from 81b32f0 to cb413d8 Compare August 25, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kernel build support

1 participant