Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,14 @@ itself is at `kernel/kernel-6.6/COPYING` (GPL-2.0) and `kernel/kernel-6.6/LICENS
top-level directories have their own license files. GitHub's license detector only looks at the
repo root, so it'll correctly show "no license detected" here — check the specific subdirectory
you're actually using.

## Which parts are NebulaOS?

Most of this repository is a vendor SDK. The
[wiki](https://github.com/NebulaOS-KE/NebulaOS-kernel/wiki) is the developer documentation:
[What NebulaOS changes](https://github.com/NebulaOS-KE/NebulaOS-kernel/wiki/What-NebulaOS-Changes)
separates the four layers on `openke` - the inherited OpenKE work, five real hardware-bug fixes
in the vendor board description, NebulaOS's own eight changes and the eleven-commit
freeze-diagnosis layer (pstore black box, lockup detectors, watchdog pre-timeout dump) - and
[Build and integration](https://github.com/NebulaOS-KE/NebulaOS-kernel/wiki/Build-And-Integration)
explains why the firmware build no longer applies kernel patches.
16 changes: 16 additions & 0 deletions docs/nebulaos/WHAT_NEBULAOS_CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# What NebulaOS changes in this kernel - moved to the wiki

This page is now this repository's **[wiki](https://github.com/NebulaOS-KE/NebulaOS-kernel/wiki)**,
kept as Markdown pages in the top-level [`wiki/`](../../wiki) directory and published from
there. One copy, one place to read it.

| Looking for | Page |
|---|---|
| Which parts of this repository are NebulaOS | [What NebulaOS changes](https://github.com/NebulaOS-KE/NebulaOS-kernel/wiki/What-NebulaOS-Changes) |
| The black box, the lockup detectors, the watchdog pre-timeout dump | [Freeze diagnosis](https://github.com/NebulaOS-KE/NebulaOS-kernel/wiki/Freeze-Diagnosis) |
| `CONFIG_PREEMPT` rather than `CONFIG_PREEMPT_RT` | [Scheduling model](https://github.com/NebulaOS-KE/NebulaOS-kernel/wiki/Scheduling-Model) |
| `openke` against `main`, and that name | [Branch model](https://github.com/NebulaOS-KE/NebulaOS-kernel/wiki/Branch-Model) |
| How the firmware build consumes this repository | [Build and integration](https://github.com/NebulaOS-KE/NebulaOS-kernel/wiki/Build-And-Integration) |
| SoC, display, touch | [The hardware](https://github.com/NebulaOS-KE/NebulaOS-kernel/wiki/Hardware) |

The vendor SDK's own documentation is unchanged, under `docs/doc/`.
35 changes: 35 additions & 0 deletions wiki/Branch-Model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Branch model

Which branch to read, and why one of them is called `openke`. Written against the `openke`
branch at `95d0321e`, which is what NebulaOS 1.0.2 ships (`KERNEL_PIN` in the firmware manifest
at `3bdf3ff`, with `KERNEL_BRANCH=openke`) and is also the branch tip.


| Branch | What it is |
|---|---|
| `main` | `a98c2e1f2`, "initial release" - the **pristine vendor baseline**, forked from `Llixuma/ingenic-linux-kernel6.6-x2000-v1.0-20250221` |
| `openke` | The branch NebulaOS builds from: 133 commits on top of that baseline |

`openke` is the default branch, and the one to read. `main` exists so the vendor baseline stays
available for comparison - `git diff origin/main origin/openke` is the complete set of changes.

**A caution about that diff:** it reports around 13,000 files changed, which is not a measure of
NebulaOS's footprint. Most of it is the vendor tree reorganisation that came with the OpenKE
import. The NebulaOS-specific surface is small and listed below.


## The name

The branch is called `openke` because this repository's history runs through the
[OpenKE](https://github.com/coreflake1/guppyscreen) import, and the name was never changed when
the repository was renamed. **OpenKE is a separate project** that shares an author and some
history with NebulaOS; it is not the same thing, and its documentation does not describe
NebulaOS. Read nothing into the branch name beyond its history - see
[What NebulaOS changes](What-NebulaOS-Changes), whose first layer is exactly the work inherited
from it.

## Which one ships

The firmware repository pins an exact commit here and checks it out directly. `KERNEL_PIN` is
what ships; this branch's tip is not, when the two differ. At 1.0.2 they are the same commit,
`95d0321e`. See [Build and integration](Build-And-Integration).
70 changes: 70 additions & 0 deletions wiki/Build-And-Integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Build and integration

How this repository is consumed, what the firmware build does with it, and what it no longer
does. Written against `95d0321e` (the 1.0.2 pin) and firmware `3bdf3ff`.

**Do not build this repository standalone expecting a printer image.** It does not produce one.
The firmware repository pins an exact commit here, checks it out, and builds the kernel as one
stage of its own pipeline:
[Building from source](https://github.com/NebulaOS-KE/NebulaOS-firmware/wiki/Building-From-Source).

## What the firmware build does *not* do any more

This matters for anyone comparing documents, because it changed.

The kernel changes used to be applied at build time from
`patches/x2000_kernel_6.6-openke.patch`. They are now **real commits on `openke`**, and
`00-fetch-vendor-sources.sh` checks that branch out directly.

So the firmware's `scripts/build/01-apply-kernel-patches.sh` **applies nothing**. It is a
verification step: it checks that the expected changes are present in the checked-out tree. The
script keeps its `01-` number on purpose so existing documentation and habits still work.

The answer to *which changes are maintained here versus applied by the build* is therefore:
**all of them are maintained here, and none are applied by the build.**

## Building

The firmware build owns this. `03-build-kernel-and-rootfs.sh` builds the kernel inside the
pinned build container with `nebulaos_halley5_v30_defconfig`, producing the `xImage` that goes
into a system image.

The pinned commit is in `NebulaOS-firmware/manifests/dependencies.conf` as `KERNEL_PIN`, with
`KERNEL_BRANCH=openke` and `KERNEL_CONFIG_PROFILE=production`. **That pin is what ships** - this
branch's tip is not, when the two differ.

`.github/workflows/build.yml` compile-checks the kernel on every push and pull request -
`xImage` for `nebulaos_halley5_v30`, with Ubuntu's MIPS cross compiler (GCC 13, as in the
image's Buildroot toolchain) and without the built-in Wi-Fi firmware blobs, which come from the
firmware build. It is a compile check, not a qualification: it produces no printer image and
nothing in it runs on hardware.

## What stage 01 actually checks

Worth knowing, because it is the gate a kernel change meets first. At 1.0.2
(`scripts/build/01-apply-kernel-patches.sh`) it refuses to continue unless:

- the checkout's `HEAD` is exactly `KERNEL_PIN`, read from the manifest rather than from a
second hardcoded copy - and it checks this independently of
`00-fetch-vendor-sources.sh`, so a hand-run `git pull` between the two scripts is still caught;
- the checkout has **no working-tree changes at all** - the build must never modify the kernel
tree, because every NebulaOS kernel change is a commit here;
- five specific pieces of the fork's content are present: `ns2009.c`, the
`panel-openke-general-480x272.c` display driver, `openke,bcm4343x-bt` in `hci_h5.c`,
`ns2009@48` in `halley5_v30.dts`, and the literal line `gzip -nv9f $(obj)/vmlinux.bin` in
`arch/mips/boot/zcompressed/Makefile`.

That last one is the build-reproducibility fix, and it shows how this repository and the
firmware divide the work: the `-n` flag that stops gzip storing a name and an mtime in the
compressed kernel is **a commit here** - `b31be02d9`, one line, `gzip -v9f` to `gzip -nv9f` in
`arch/mips/boot/zcompressed/Makefile`, an ancestor of the 1.0.2 pin - and the firmware's job is
only to verify it did not get lost. Without it the compressed kernel carried a name and an
mtime, which is what kept `xImage` from reproducing; with it, firmware `3bdf3ff` built twice
gave the same `xImage` byte for byte (the firmware's `docs/REPRODUCIBILITY.md`, corrected
2026-11-12 in `d464b46` - it previously credited this fix to a build-time variant script that
does not exist).

It does **not** check which branch the checkout is on. That check existed and was removed: a
checkout at an exact commit is a detached HEAD, so `git rev-parse --abbrev-ref HEAD` reports the
literal string `HEAD` and the check failed a checkout that was exactly correct. The pin check is
the real invariant.
76 changes: 76 additions & 0 deletions wiki/Freeze-Diagnosis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Freeze diagnosis and the black box

Eleven commits on `openke`, written after two real failures on the development printer. They do
not change how the printer prints; they change what is left behind when it stops. Written
against `95d0321e`, the 1.0.2 pin.

The userspace half - `nebulaos-blackbox`, the reset verdict and the two overlay files that go
with it - is in the firmware wiki:
[The black box](https://github.com/NebulaOS-KE/NebulaOS-firmware/wiki/Black-Box).

The two failures: a partial hang on 2026-11-06, where SSH and shell commands blocked for
minutes while the screen and Klipper kept running, and a mid-print freeze on 2026-11-08, where
both CPUs stopped and the hardware watchdog reset the board 60 s later **with nothing in the
kernel log**.

| Commit | Change | Where |
|---|---|---|
| `ef2a2c264` | pstore/ramoops in 1 MB of RAM, reset-status readback, soft-lockup panic; quiet EEPROM-busy I2C aborts | `dts/x2000/halley5_v30.dts`, defconfig, `watchdog/ingenic_wdt.c`, `i2c/busses/i2c-ingenic.c` |
| `842860ab2` | Clear the CPM reboot signature at probe; unbuffered ramoops (`mem-type = <1>`) | `ingenic_wdt.c`, `halley5_v30.dts` |
| `785b600f7` | Keep the unhandled WDT interrupt masked - it was holding the shared TCU line asserted | `ingenic_wdt.c` |
| `b9245f14e` | Hung-task detector, report only (120 s, never panics) | defconfig |
| `e5f4d8fe7` | RSR bit 0 named power-on; ramoops' empty-zone header message to debug | `ingenic_wdt.c`, `fs/pstore/ram_core.c` |
| `11f0f0c87` | `CONFIG_PREEMPT` instead of `CONFIG_PREEMPT_RT`; `localversion-rt` removed; "restart" vs "watchdog" wording; the wireless-extensions warning to `pr_debug_once` | defconfig, `localversion-rt`, `ingenic_wdt.c`, `net/wireless/wext-core.c` |
| `ece4732b0` | **Watchdog pre-timeout dump**: an interrupt 40 s without a feed prints the clockevent state, blocked tasks and every CPU backtrace, then panics; `nebulaos_core_ost_dump()`; hard-lockup (buddy) detector with panic | `ingenic_wdt.c`, `clocksource/ingenic_core_ost.c`, defconfig |
| `3b6086868` | `sched_clock` takes `clocksource_lock` with trylock, so a freeze dump cannot hang on its own first timestamp | `ingenic_core_ost.c` |
| `e8596387b` | `nebulaos_sdio_idle` module parameter for the Wi-Fi SDIO bus; a boot line saying whether KSO save/restore is in use | `brcm80211/brcmfmac/sdio.c` |
| `95d0321ef` | I2C: `INTM = 0` before a controller reset and before the clock is gated | `i2c-ingenic.c` |

Three of these are worth understanding in detail, because a developer will meet them in a log.

**The black box is pstore/ramoops.** `halley5_v30.dts` reserves 1 MB at `0x0e000000`:
512 KB console (the kernel log), 64 KB per oops/panic record, 256 KB `pmsg` for the userspace
heartbeat, with ECC and `mem-type = <1>` so the last writes before a hard reset are not sitting
in a write buffer. The address lies inside the vendor's own 256M ISP pool, which is `disabled`
in the DTS and which the bootloader leaves alone - re-enabling that pool on a 256 MB board would
overlap ramoops, and the DTS comment says so. The area survives a watchdog or panic reset and is
read back from `/sys/fs/pstore` on the next boot; a real power cut loses it, as RAM does.
The defconfig side is `CONFIG_PSTORE`, `PSTORE_RAM`, `PSTORE_CONSOLE`, `PSTORE_PMSG`, with
`PSTORE_COMPRESS` off so the result is readable without tooling.

**Three detectors, deliberately different.** `CONFIG_SOFTLOCKUP_DETECTOR` with
`BOOTPARAM_SOFTLOCKUP_PANIC` panics a CPU stuck in the kernel, so the dump is kept and
`PANIC_TIMEOUT=10` restarts the board instead of waiting out the 60 s hardware watchdog with
nothing recorded. `HARDLOCKUP_DETECTOR` (the buddy detector, since this SoC has no NMI
perf counter) with `BOOTPARAM_HARDLOCKUP_PANIC` covers a CPU that has stopped taking
interrupts. `DETECT_HUNG_TASK` with `DEFAULT_HUNG_TASK_TIMEOUT=120` only *reports* -
`BOOTPARAM_HUNG_TASK_PANIC` is deliberately off, because a slow eMMC must not restart a printer
that is printing. That asymmetry is a decision, not an oversight.

**The watchdog pre-timeout dump is the last resort.** `nebulaos_wdt_pretimeout()` in
`ingenic_wdt.c` is hooked to the watchdog's `H` compare, which the hardware reaches at two
thirds of the armed timeout - 40 s of the 60 s the userspace feeder arms. It is a device
interrupt on the RTC-clocked TCU line, so it still arrives when every kernel timer is dead, as
long as the CPU it is routed to still takes interrupts. It masks itself (one shot, no storm),
restarts the hardware count so the dump has a full timeout to finish, prints
`nebulaos_core_ost_dump()`, `show_state_filter(TASK_UNINTERRUPTIBLE)` and
`trigger_all_cpu_backtrace()`, and then panics on purpose, because the panic path is what writes
the whole kernel log into pstore past a console lock a frozen CPU may be holding. A software
restart is not a freeze and is skipped (`system_state != SYSTEM_RUNNING`). **If this never fires
and the board resets anyway, that is itself a result:** the CPU owning the line had interrupts
disabled for the whole 40 s.

**The Wi-Fi idle parameter is an experiment, not a fix.** `brcmfmac`'s SDIO bus sleeps after
`idletime` watchdog ticks (10 ms each) without traffic; on the CYW43430 with save/restore that
is a KSO sleep/wake of the chip thousands of times an hour on a quiet link.
`/sys/module/brcmfmac/parameters/nebulaos_sdio_idle` is writable at runtime: `-1` (the default)
keeps the driver's own `idletime`, `0` never sleeps the bus, `N` waits N ticks. **The default
changes nothing**, which is what makes it an A/B test rather than a behaviour change.


## Not a fix

Nothing on this page claims the freeze is fixed. These commits are instrumentation and two
mitigations, written from the evidence of two failures; none of them was verified on a printer
by this page's author. If a board resets and the pre-timeout dump never fired, that is itself a
result - see the paragraph on it above.
16 changes: 16 additions & 0 deletions wiki/Hardware.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# The hardware

What this kernel runs on. Written against `95d0321e`, the 1.0.2 pin.

| | |
|---|---|
| SoC | Ingenic X2000 (`xburst2`, `soc-x2000`) |
| Architecture | MIPS (`mipsel`) |
| Kernel | 6.6 (`kernel/kernel-6.6/`) |
| Display | 480x272 panel, framebuffer - no X11 or Wayland |
| Touch | NS2009 resistive controller |

The 6.6 kernel version is also how NebulaOS tells its own slot apart from Creality's at boot:
the firmware's `ota_slot_holds_nebulaos()` reads the slot's kernel uImage name, and a 6.x kernel
means NebulaOS while the other system's is 4.4.

56 changes: 56 additions & 0 deletions wiki/Home.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# NebulaOS-kernel

The Linux 6.6 kernel NebulaOS runs on the Creality Ender-3 V3 KE (Ingenic X2000). Development
happens on **`openke`**; complete, flashable images are built by
[NebulaOS-firmware](https://github.com/NebulaOS-KE/NebulaOS-firmware), not here. Building this
repository on its own does not produce a working printer image.

Most of this repository is a vendor SDK. The page that answers the question developers arrive
with - which parts are NebulaOS? - is
[What NebulaOS changes](What-NebulaOS-Changes).

This wiki is the developer documentation for the kernel. The end-user manual is the
[NebulaOS wiki](https://github.com/NebulaOS-KE/NebulaOS/wiki).

## Which code this describes

| | |
|---|---|
| Branch | `openke` (the default branch) |
| Commit | **`95d0321e`**, the branch tip |
| Ships as | NebulaOS **1.0.2**: `KERNEL_PIN=95d0321ef4270adb3e080fe2125ab81fcb232b91` in firmware `3bdf3ff` (tag `v1.0.2`), `KERNEL_BRANCH=openke`, `KERNEL_CONFIG_PROFILE=production` |

At 1.0.2 the pin and the branch tip are the same commit, so for once the documented code is
exactly the shipped code. That is not guaranteed to stay true: the firmware manifest is the
shipping authority, and `REPOSITORY_HEAD` is not `SHIPPING_PIN`.

## The pages

- **[What NebulaOS changes](What-NebulaOS-Changes)** - the four layers on `openke`: the
inherited OpenKE work, five real hardware bugs in the vendor board description, NebulaOS's own
eight changes, and how they connect to the software above
- **[Freeze diagnosis](Freeze-Diagnosis)** - the eleven-commit black box: pstore/ramoops, three
deliberately different lockup detectors, the watchdog pre-timeout dump, and one experiment
that changes nothing by default
- **[Scheduling model](Scheduling-Model)** - `CONFIG_PREEMPT`, not `CONFIG_PREEMPT_RT`, since
1.0.2, and what went away with it
- **[Branch model](Branch-Model)** - `openke` against `main`, and why the branch has that name
- **[Build and integration](Build-And-Integration)** - how the firmware consumes this
repository, what stage 01 verifies, and why nothing is patched at build time any more
- **[The hardware](Hardware)** - SoC, display, touch

## What this wiki does not cover

- **The vendor SDK itself** - most of this tree, including `frameworks/`, `development/` and
`external/`. Its own documentation is under `docs/doc/`, partly in Chinese.
- **U-Boot**, in `u-boot/`, with its own vendor history.
- **Real-time latency figures.** No latency was measured for these pages.
- **Hardware behaviour.** Nothing in this wiki was observed on a printer by its author; every
claim is read from the source at `95d0321e`.

## Related

- [NebulaOS-firmware wiki](https://github.com/NebulaOS-KE/NebulaOS-firmware/wiki) - where the
image is built, and the userspace half of the black box
- [Repository map](https://github.com/NebulaOS-KE/NebulaOS-firmware/wiki/Repository-Map) - every
repository in the project, and what is upstream rather than ours
16 changes: 16 additions & 0 deletions wiki/Scheduling-Model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# The scheduling model

Written against `95d0321e`, the 1.0.2 pin. This is the change most likely to surprise someone
who read an older document: NebulaOS is **not** a PREEMPT_RT system any more.

The kernel is built with **`CONFIG_PREEMPT`** (`nebulaos_halley5_v30_defconfig` line 7), not
`CONFIG_PREEMPT_RT`. The tree is still based on `linux-stable-rt`, so the RT patch set is
present in the source and the model is one defconfig line to switch; `localversion-rt` was
removed in `11f0f0c87` so a kernel that is not RT does not report `-rt79` in `uname`.

Two consequences a developer should know:

- `NEBULAOS_KTIMERS_PRIO` is gone with it - `ktimers/N` threads only exist on RT.
- The IRQ thread priority table stays and still applies: MIPS selects `IRQ_FORCED_THREADING`,
and the explicitly threaded handlers (`uart1`, DWC2, mmc) are threaded on `PREEMPT` too.

Loading