System layers
Kernel, user-space, SDK, and application responsibilities; BCI and CSV data paths.
On this page
Real-time kernel
kernel/linux contains versioned Linux 7.3.1 mainline PREEMPT_RT source, pinned with its upstream archive and XTOS patch in kernel/source-pin.json, not a placeholder downloaded at build time. kernel/xtos_defconfig is merged after the architecture defconfig and enables CONFIG_PREEMPT_RT=y, CONFIG_HIGH_RES_TIMERS=y, CONFIG_HZ_1000=y, module support, and /proc/config.gz. The final configuration after olddefconfig is authoritative; a fragment alone does not establish that an option is enabled for the target kernel.
uname -r
/usr/bin/xtos-rt-status
zcat /proc/config.gz | grep '^CONFIG_PREEMPT_RT='
zcat /proc/config.gz | grep '^CONFIG_HZ='xtos-rt-status prints 1/exit 0, 0/exit 1, or unknown/exit 2. When /sys/kernel/realtime exists, only its exact value 1 is accepted. When absent, both CONFIG_PREEMPT_RT=y in the running kernel’s /proc/config.gz and a PREEMPT_RT marker in uname -v are required; otherwise the result is unknown. Build-tree configuration cannot replace running configuration. CONFIG_HZ_1000 sets the tick rate, not thread response, sampling accuracy, or hardware latency.
Scheduling helper
kernel/linux/kernel/sched/xtos_sched.c implements per-CPU locked priority queues and helper functions for enqueue, dequeue, and selection.
It explicitly is not a sched_class; Linux scheduling selection, task_struct layout, and the syscall ABI remain unchanged.
CONFIG_XTOS_SCHED=y in the default configuration builds it into the kernel, rather than replacing Linux SCHED_FIFO, SCHED_RR, or SCHED_OTHER with an XTOS policy.
The helper xtos_set_cpu_affinity stores advisory metadata and does not migrate Linux tasks. xtos_set_deadline stores deadline_ns without establishing deadline scheduling guarantees.
Application-side libxtos-rt uses standard sched_setscheduler, sched_setaffinity, and mlock/munlock; there is no direct SDK syscall channel to these kernel helpers.
BCI acquisition
drivers/xtos/bci contains the xtos_bci_core character-device core, xtos_bci_buffer ring-buffer module, and openbci_cyton serdev driver.
The driver targets an 8-channel, 24-bit ADC with a default 250 Hz sampling rate, sets serial baud to 115200 with flow control disabled, and matches device-tree compatible="openbci,cyton".
Loading the module registers a driver; an actual device and correct serdev/device-tree binding are still required for acquisition.
The receive callback assembles serial bytes into 33-byte packets, extracts signed 24-bit ADC values at the source’s channel offsets, sign-extends them, scales them with 64-bit integer arithmetic into s32 nanovolts, and writes them to the ring buffer.
The formula is raw × 4500000000 / (gain[channel] × 8388607), using each channel’s gain from configuration readback. Results are int32 nanovolts, not float microvolts; values outside int32 range are rejected.
Channel values start at packet offset 2 + channel × 3. The versioned frame path also records a device counter, quality flags, configuration generation, and host receive time. Host receive time is not device acquisition time.
The public Cyton serdev path supports only 250 Hz. 500/1000/2000 Hz return EOPNOTSUPP; other invalid rates return EINVAL. Configuration control during acquisition can return EBUSY.
Channel configuration supports gains 1, 2, 4, 6, 8, 12, 24. The core forwards enabled/gain to the driver; Cyton checks command acknowledgement and register readback before committing configuration. gain=0 preserves the read-back gain rather than requesting zero amplification.
calibrate and impedance checks both return EOPNOTSUPP and produce no calibration or measurement result. Source-level control and readback do not establish physical-board acceptance; validate packet layout, configuration effects, loss, and units on the target device.
UAPI and samples
kernel/linux/include/uapi/linux/xtos_bci.h defines the integer-only ioctl ABI, with corresponding SDK declarations in sdk/libxtos-bci/include/xtos/bci_uapi.h. Device information uses integer mV for input_range_mv, integer kΩ for impedance arrays, and 64-bit statistics counters. Raw sample bytes are a separate data interface. Integer control structures do not establish that the library converts raw sample values correctly.
The BCI SDK provides sessions, acquisition control, configuration queries, and versioned snapshot/frame interfaces. Legacy get_mmap_buffer always returns NULL and sets size to 0; a valid session gives EOPNOTSUPP. A snapshot is an integer-nanovolt view consumed by token/cursor and explicitly released, not converted float data.
Before routing hardware data into DSP, define raw type, endianness, channel order, unit conversion, and frame timestamps, then test values against known inputs.
START/STOP, SET_RATE, and SET_CHANNEL ioctls are acquisition controls, not robot, AR/VR, or general feedback-actuator APIs.
User-space boot
The x86_64 build uses system/busybox_defconfig to generate static BusyBox 1.37.0 and install applet links under /bin. system/rootfs/init runs as PID 1, mounts proc, sysfs, devtmpfs, devpts, and /dev/shm, then prints the kernel release and realtime flag.
It starts /bin/sh in a loop by default.
This section describes core /init from build_system.sh: without xtos.selftest=1, it neither self-tests automatically nor starts network services. The ISO/installed system instead uses system/baremetal/init and xtos-start, attempts DHCP, and starts Dropbear only when authorized_keys is nonempty.
The public v1.0.2 core x86_64 installer ISO and ARM64 boot bundle omit native update/pkg tools and their pinned repository key; Live repository commands do not directly apply. The separate Live recipe scripts/build_live.py installs those tools and trust material. Check the actual recipe, rootfs, and tool identity; similarly named host commands are not substitutes.
| Guest path | x86_64 contents |
|---|---|
| /usr/lib, /usr/include/xtos | Static .a archives and headers for all three SDKs; this does not imply an in-guest compiler. |
| /usr/libexec/xtos | The static test_rt, test_spsc, and test_signal executables. |
| /usr/bin | xtos-rt-status, xtos-selftest, xtos-eeg-pipeline, xtos-signal-benchmark, bci, and bci_test; selected tools from the core build path. |
| /lib/modules/<kernelrelease> | Kernel modules matching the image and depmod dependency indexes. |
| /usr/share/xtos/fixtures/valid.csv | The artificial EEG pipeline CSV fixture, not a real-device recording. |
ARM64/RISC-V64 scripts start from BusyBox defconfig, enable static linking, create /etc/inittab and /init→sbin/init, and offer a /bin/sh console; tests are installed under /bin. verify_guest_* separately copies the rootfs and replaces /init with xtos-guest-check.
This does not change the normal boot image.
Checks power off afterward, so an interactive prompt must not be assumed after DONE.
CSV and hardware
xtos-eeg-pipeline reads two-channel, 250 Hz nanovolt data from a CSV file, creates an SPSC queue of capacity 16, pushes and pops each frame, and checks sequence and data integrity.
It opens no BCI device, calls no ioctl, and does not traverse the kernel BCI ring buffer.
Optional bandpass processing uses double values in libxtos-signal in user space; CSV replay does not substitute for serdev acquisition.
xtos-eeg-pipeline --input /usr/share/xtos/fixtures/valid.csv
xtos-eeg-pipeline --input /usr/share/xtos/fixtures/valid.csv \
--bandpass 5 40 --dump-filtered /run/filtered.csvThe CSV header is # xtos-eeg-v1,channels=2,sample_rate_hz=250,unit=nanovolt; data rows are timestamp_ns,ch0_nv,ch1_nv with no additional column-name row.
The expected inter-frame interval is 4000000 ns with 1% tolerance, and timestamps must increase strictly.
JSON p50/p95/p99_latency_ns measures only the queue push/pop region, excluding CSV parsing, bandpass processing, hardware input, inference, and feedback.
Application responsibilities
- Input contract: choose CSV or device input and record units, channels, sample rate, frame timestamps, and loss policy. Do not connect interfaces with incompatible representations directly.
- Compute contract: preallocate working buffers, bound windows and queue capacity, and define behavior for scheduling-permission failures and timeouts. Library APIs existing do not establish bounded execution time for the whole application.
- Output contract: models, inference threads, result consumers, actuators, and feedback safety policies belong to the application. The public kernel guarantees neither recognition accuracy nor control safety.
Public references at commit c24e923717670c4724cdaf24c7c105caee8dc2fb: kernel/xtos_defconfig, kernel/linux/kernel/sched/xtos_sched.c, kernel/linux/drivers/xtos/bci/devices/openbci_cyton.c, kernel/linux/include/uapi/linux/xtos_bci.h, sdk/libxtos-rt/src/rt.c, sdk/libxtos-bci/src/session.c, tools/xtos-eeg-pipeline/pipeline.c, system/rootfs/init, and the three build_system scripts.