From aa0a0d4f68f8d3a109d5ad774f200ac80251d667 Mon Sep 17 00:00:00 2001 From: Tim Date: Sun, 1 Nov 2026 21:34:01 +0100 Subject: [PATCH 1/4] docs: which parts of this kernel are NebulaOS Most of this repository is a vendor SDK, and nothing separated NebulaOS's own work from Ingenic's or OpenKE's. docs/nebulaos/WHAT_NEBULAOS_CHANGES.md does that, which is the question a developer actually arrives with. The branch layout is the key: main is a98c2e1f2 "initial release", the pristine vendor baseline forked from Llixuma/ingenic-linux-kernel6.6-x2000-v1.0-20250221, and openke carries 122 commits on top. So git diff origin/main origin/openke is the complete change set. The page warns about that diff rather than quoting it as a figure of merit: it reports around 13,000 files changed, almost all of it vendor tree reorganisation from the OpenKE import. Presenting that as NebulaOS's footprint would be misleading by a factor of a thousand. The real surface is three layers. The inherited OpenKE commit. Five commits fixing genuine errors in the vendor board description - a missing third cell in wlan_pwrseq reset-gpios, a missing post-power-on-delay-ms causing an SDIO probe race, drvvbus-gpio on the wrong pin, uart1 never wired up at all, and as_dmic holding the pins uart1 needed. And eight NebulaOS commits, each with a G-number, listed with the subsystem each touches. Those five fixes are presented as a group on purpose: the last two are one story, in which the link to the mainboard MCU did not exist in the vendor board file and a second device was holding its pins. Three NebulaOS changes are explained by what needs them above the kernel, which reading the kernel alone does not reveal: the buzzer exists as a PWM channel so Klipper's nebulaos_beeper can drive it from userspace, the watchdog arms with a programmed timeout so S02nebulaos-watchdog can feed it, and the power-on picture survives the display takeover so the boot logo does not flash to black before NebulaScreen appears. And the answer to the mission's question about which changes are maintained here versus applied by the firmware build: all of them are here, none are applied. 01-apply-kernel-patches.sh applies nothing now - it verifies that the expected changes are present, and keeps its 01- number so existing documentation still works. Anyone comparing older documents needs that. Co-Authored-By: Claude Opus 5.5 (1M context) --- README.md | 8 ++ docs/nebulaos/WHAT_NEBULAOS_CHANGES.md | 131 +++++++++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 docs/nebulaos/WHAT_NEBULAOS_CHANGES.md diff --git a/README.md b/README.md index 50737bb61c..8f7c26d8ed 100644 --- a/README.md +++ b/README.md @@ -54,3 +54,11 @@ 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. +[What NebulaOS changes in this kernel](docs/nebulaos/WHAT_NEBULAOS_CHANGES.md) separates the +three layers on `openke` - the inherited OpenKE work, five real hardware-bug fixes in the vendor +board description, and NebulaOS's own eight changes - and explains why the firmware build no +longer applies kernel patches. diff --git a/docs/nebulaos/WHAT_NEBULAOS_CHANGES.md b/docs/nebulaos/WHAT_NEBULAOS_CHANGES.md new file mode 100644 index 0000000000..d44160240d --- /dev/null +++ b/docs/nebulaos/WHAT_NEBULAOS_CHANGES.md @@ -0,0 +1,131 @@ +# What NebulaOS changes in this kernel + +This repository is mostly a vendor SDK. This page answers the question a developer actually +arrives with: **which parts are NebulaOS, and which are Ingenic's or OpenKE's?** + +Written against the `openke` branch at `d86790d`. + +## Branch layout + +| 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: 122 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 three layers on `openke` + +Reading the history from the baseline forward, the commits fall into three groups. + +### 1. The OpenKE layer + +`8e97319a1` - *"openke: NS2009 touch, OpenKE display panel, BT H5 vendor ext, watchdog fix, DTS +wiring"*. The work that made this SoC usable on this printer at all, inherited rather than +written here. Attribute it to OpenKE. + +### 2. Real hardware bugs, found and fixed + +Five commits, each fixing something genuinely wrong in the vendor board description rather than +adapting it to taste: + +| Commit | What was wrong | +|---|---| +| `e67eefc40` | `wlan_pwrseq` `reset-gpios` missing its third cell - a real Wi-Fi SDIO init bug | +| `5dca5971f` | `wlan_pwrseq` missing `post-power-on-delay-ms` - a real 0-delay SDIO probe race | +| `c902097d1` | `drvvbus-gpio` wired to the wrong pin, confirmed against stock's own DTB | +| `4905cb23e` | `uart1` - the real mainboard MCU link - never wired up in the board file | +| `c60cf4d67` | `as_dmic` left enabled, a real pin conflict blocking that same `uart1` | + +Worth reading as a group. The last two are the same story: the link to the mainboard MCU did not +exist in the vendor board file, and a second device was holding the pins it needed. A vendor SDK +being wrong about its own hardware is normal; this is the list of places it was. + +### 3. NebulaOS's own changes + +Eight commits, each with a `G`-number tying it to a NebulaOS workstream: + +| Commit | Change | Subsystem | +|---|---|---| +| `862cc4c24` | NebulaOS boot card as the kernel's display-init logo | `video/logo-ingenic` | +| `27fe61c54` | Keep the power-on picture through the display takeover | `video/fbdev/ingenic` | +| `62d724789` | Boot picture diagnostics always in the boot log | `video/fbdev/ingenic/fb_stage` | +| `65f93367c` | NS2009 touch mode and `touch_down_count` exposed in sysfs | `drivers/misc` | +| `5ba3d3afc` | KE buzzer (GPC3) as a standard kernel PWM channel | `drivers/pwm` | +| `f28a670d5` | `ingenic_wdt` arms with a programmed timeout | `drivers/watchdog` | +| `38c467bf5` | `ingenic_wdt` read-only marker `nebulaos_arm_fix` | `drivers/watchdog` | +| `cf4dd8126` | Vendor boot messages at info level rather than warning/error | various | + +Plus the configs - `nebulaos_halley5_v30_defconfig` and +`nebulaos_halley5_v30_diagnostic.config` - which are the most-touched files in the repository +(17 changes across the history), since every capability added has to be enabled somewhere. + +### How those changes connect outward + +Three of them exist because something above the kernel needs them, which is easy to miss when +reading the kernel alone: + +- **The buzzer as a PWM channel** (`5ba3d3afc`) is what lets Klipper's `nebulaos_beeper` extra + drive it from userspace through sysfs. The kernel does not play sounds; it exposes a channel. +- **The watchdog arming with a programmed timeout** (`f28a670d5`) is what + `S02nebulaos-watchdog` feeds, so a frozen printer resets itself instead of hanging until + someone cuts the power. +- **Keeping the power-on picture through the display takeover** (`27fe61c54`) is why the boot + logo does not flash to black before NebulaScreen appears. + +## 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 (`xImage`, +`nebulaos_halley5_v30`) on push. + +## The hardware + +| | | +|---|---| +| 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. + +## Not covered here + +- **The vendor SDK itself.** Most of this repository is Ingenic's, including + `frameworks/`, `development/` and `external/`. Its own documentation is under `docs/doc/`, + partly in Chinese. +- **PREEMPT_RT and real-time behaviour.** Referenced in firmware analysis documents; not + established here. +- **Hardware behaviour.** Nothing on this page was observed on a printer by its author. +- **U-Boot**, which lives in `u-boot/` and has its own vendor history. From 9cd31b083bd143bf425d0f1d55f363fc5cfbbe5b Mon Sep 17 00:00:00 2001 From: NebulaOS <33003628+coreflake1@users.noreply.github.com> Date: Tue, 10 Nov 2026 09:27:47 +0100 Subject: [PATCH 2/4] docs: the freeze-diagnosis layer, and PREEMPT instead of PREEMPT_RT Re-verified against openke 95d0321e, which is also the kernel NebulaOS 1.0.2 ships (KERNEL_PIN in the firmware manifest at v1.0.2). - New section: the eleven-commit diagnosis layer written after the 2026-11-06 partial hang and the 2026-11-08 mid-print freeze - pstore/ramoops in the DTS, soft/hard-lockup panic and report-only hung-task detection, the watchdog pre-timeout dump at 40 s of the armed 60 s, the lock-free sched_clock read, the nebulaos_sdio_idle A/B parameter and the I2C INTM masking. - New section: the scheduling model is CONFIG_PREEMPT, not PREEMPT_RT; the tree stays on linux-stable-rt and localversion-rt was removed. - The "not covered" bullet claiming PREEMPT_RT was unestablished is replaced by what the defconfig actually sets; commit counts refreshed (133 commits over the vendor baseline, 25 config changes). Co-Authored-By: Claude Opus 5.5 (1M context) --- README.md | 7 +- docs/nebulaos/WHAT_NEBULAOS_CHANGES.md | 95 ++++++++++++++++++++++++-- 2 files changed, 92 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 60f36db4f8..c644fe318d 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,7 @@ you're actually using. Most of this repository is a vendor SDK. [What NebulaOS changes in this kernel](docs/nebulaos/WHAT_NEBULAOS_CHANGES.md) separates the -three layers on `openke` - the inherited OpenKE work, five real hardware-bug fixes in the vendor -board description, and NebulaOS's own eight changes - and explains why the firmware build no -longer applies kernel patches. +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 explains why the firmware +build no longer applies kernel patches. diff --git a/docs/nebulaos/WHAT_NEBULAOS_CHANGES.md b/docs/nebulaos/WHAT_NEBULAOS_CHANGES.md index d44160240d..78dd91749e 100644 --- a/docs/nebulaos/WHAT_NEBULAOS_CHANGES.md +++ b/docs/nebulaos/WHAT_NEBULAOS_CHANGES.md @@ -3,14 +3,16 @@ This repository is mostly a vendor SDK. This page answers the question a developer actually arrives with: **which parts are NebulaOS, and which are Ingenic's or OpenKE's?** -Written against the `openke` branch at `d86790d`. +Written against the `openke` branch at `95d0321e`, which is also what ships: the firmware +manifest at tag `v1.0.2` pins `KERNEL_PIN=95d0321ef4270adb3e080fe2125ab81fcb232b91` with +`KERNEL_BRANCH=openke`, and that is the branch tip. ## Branch layout | 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: 122 commits on top of that baseline | +| `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. @@ -19,9 +21,9 @@ available for comparison - `git diff origin/main origin/openke` is the complete 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 three layers on `openke` +## The four layers on `openke` -Reading the history from the baseline forward, the commits fall into three groups. +Reading the history from the baseline forward, the commits fall into four groups. ### 1. The OpenKE layer @@ -63,7 +65,7 @@ Eight commits, each with a `G`-number tying it to a NebulaOS workstream: Plus the configs - `nebulaos_halley5_v30_defconfig` and `nebulaos_halley5_v30_diagnostic.config` - which are the most-touched files in the repository -(17 changes across the history), since every capability added has to be enabled somewhere. +(25 changes across the history), since every capability added has to be enabled somewhere. ### How those changes connect outward @@ -78,6 +80,72 @@ reading the kernel alone: - **Keeping the power-on picture through the display takeover** (`27fe61c54`) is why the boot logo does not flash to black before NebulaScreen appears. +A fourth connection came with the diagnosis layer below: the reserved ramoops area and the +reset-status registers are what the firmware's `nebulaos-blackbox` reads after a reboot, so +"why did the printer restart?" has an answer on the printer itself. + +### 4. Freeze diagnosis and the black box + +Eleven commits, written after two real failures on the development printer: a partial hang on +2026-11-06 (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**. They are a diagnosis layer: they +do not change how the printer prints, they change what is left behind when it stops. + +| 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. + ## What the firmware build does *not* do any more This matters for anyone comparing documents, because it changed. @@ -106,6 +174,19 @@ branch's tip is not, when the two differ. `.github/workflows/build.yml` compile-checks the kernel (`xImage`, `nebulaos_halley5_v30`) on push. +## The scheduling model + +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. + ## The hardware | | | @@ -125,7 +206,7 @@ means NebulaOS while the other system's is 4.4. - **The vendor SDK itself.** Most of this repository is Ingenic's, including `frameworks/`, `development/` and `external/`. Its own documentation is under `docs/doc/`, partly in Chinese. -- **PREEMPT_RT and real-time behaviour.** Referenced in firmware analysis documents; not - established here. +- **Real-time latency figures.** The scheduling model is stated below; no latency was measured + here. - **Hardware behaviour.** Nothing on this page was observed on a printer by its author. - **U-Boot**, which lives in `u-boot/` and has its own vendor history. From 04349e89cf393af4d6d0ab51e56be1c35d0b4f98 Mon Sep 17 00:00:00 2001 From: NebulaOS <33003628+coreflake1@users.noreply.github.com> Date: Thu, 12 Nov 2026 01:20:13 +0100 Subject: [PATCH 3/4] docs(wiki): the kernel's developer documentation becomes this repository's wiki docs/nebulaos/WHAT_NEBULAOS_CHANGES.md becomes six wiki pages in a top-level wiki/ directory - Home, _Sidebar, What-NebulaOS-Changes, Freeze-Diagnosis, Scheduling-Model, Branch-Model, Build-And-Integration, Hardware - with wiki-style links, the same shape as the central manual and the NebulaScreen wiki. The in-repo document stays as a pointer table; the vendor SDK's own docs/doc/ is untouched. The seven pages published on the wiki today are from 2026-08-15 and describe a project that has moved: they name the coreflake1 organisation, the retired NebulaOS-klipper fork, PREEMPT_RT, and eight build-time "qualified variants" applied by a script that no longer exists. Replacing all of them. New material, read from source at 95d0321e and firmware 3bdf3ff rather than carried over: - Build-And-Integration documents what stage 01 verifies, now that it applies nothing: the pin (independently of stage 00, so a hand-run git pull between them is caught), a completely unmodified checkout, and five specific pieces of the fork's content - including the literal `gzip -nv9f` line in arch/mips/boot/zcompressed/Makefile. That line is the build-reproducibility fix, and it is a commit here, not a build-time variant: the firmware's REPRODUCIBILITY.md still calls it kernel-gzip-determinism-variant.sh, and no such script exists at 1.0.2. The page says so. - It also records why the branch-name check was removed rather than special-cased (a pinned checkout is a detached HEAD, so --abbrev-ref HEAD reports "HEAD"). - The CI line is now what the workflow says: a compile check of xImage for nebulaos_halley5_v30 with Ubuntu's GCC 13 and without the Wi-Fi blobs, which is not a qualification. Freeze-Diagnosis ends with what it is not: instrumentation and two mitigations, none of it verified on a printer by its author, and no claim that the freeze is fixed. Co-Authored-By: Claude Opus 5.5 (1M context) --- README.md | 14 +- docs/nebulaos/WHAT_NEBULAOS_CHANGES.md | 222 ++----------------------- wiki/Branch-Model.md | 35 ++++ wiki/Build-And-Integration.md | 66 ++++++++ wiki/Freeze-Diagnosis.md | 76 +++++++++ wiki/Hardware.md | 16 ++ wiki/Home.md | 56 +++++++ wiki/Scheduling-Model.md | 16 ++ wiki/What-NebulaOS-Changes.md | 85 ++++++++++ wiki/_Sidebar.md | 14 ++ 10 files changed, 385 insertions(+), 215 deletions(-) create mode 100644 wiki/Branch-Model.md create mode 100644 wiki/Build-And-Integration.md create mode 100644 wiki/Freeze-Diagnosis.md create mode 100644 wiki/Hardware.md create mode 100644 wiki/Home.md create mode 100644 wiki/Scheduling-Model.md create mode 100644 wiki/What-NebulaOS-Changes.md create mode 100644 wiki/_Sidebar.md diff --git a/README.md b/README.md index c644fe318d..eedf50ee8e 100644 --- a/README.md +++ b/README.md @@ -47,9 +47,11 @@ you're actually using. ## Which parts are NebulaOS? -Most of this repository is a vendor SDK. -[What NebulaOS changes in this kernel](docs/nebulaos/WHAT_NEBULAOS_CHANGES.md) 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 explains why the firmware -build no longer applies kernel patches. +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. diff --git a/docs/nebulaos/WHAT_NEBULAOS_CHANGES.md b/docs/nebulaos/WHAT_NEBULAOS_CHANGES.md index 78dd91749e..58d01966ab 100644 --- a/docs/nebulaos/WHAT_NEBULAOS_CHANGES.md +++ b/docs/nebulaos/WHAT_NEBULAOS_CHANGES.md @@ -1,212 +1,16 @@ -# What NebulaOS changes in this kernel +# What NebulaOS changes in this kernel - moved to the wiki -This repository is mostly a vendor SDK. This page answers the question a developer actually -arrives with: **which parts are NebulaOS, and which are Ingenic's or OpenKE's?** +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. -Written against the `openke` branch at `95d0321e`, which is also what ships: the firmware -manifest at tag `v1.0.2` pins `KERNEL_PIN=95d0321ef4270adb3e080fe2125ab81fcb232b91` with -`KERNEL_BRANCH=openke`, and that is the branch tip. - -## Branch layout - -| 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 four layers on `openke` - -Reading the history from the baseline forward, the commits fall into four groups. - -### 1. The OpenKE layer - -`8e97319a1` - *"openke: NS2009 touch, OpenKE display panel, BT H5 vendor ext, watchdog fix, DTS -wiring"*. The work that made this SoC usable on this printer at all, inherited rather than -written here. Attribute it to OpenKE. - -### 2. Real hardware bugs, found and fixed - -Five commits, each fixing something genuinely wrong in the vendor board description rather than -adapting it to taste: - -| Commit | What was wrong | -|---|---| -| `e67eefc40` | `wlan_pwrseq` `reset-gpios` missing its third cell - a real Wi-Fi SDIO init bug | -| `5dca5971f` | `wlan_pwrseq` missing `post-power-on-delay-ms` - a real 0-delay SDIO probe race | -| `c902097d1` | `drvvbus-gpio` wired to the wrong pin, confirmed against stock's own DTB | -| `4905cb23e` | `uart1` - the real mainboard MCU link - never wired up in the board file | -| `c60cf4d67` | `as_dmic` left enabled, a real pin conflict blocking that same `uart1` | - -Worth reading as a group. The last two are the same story: the link to the mainboard MCU did not -exist in the vendor board file, and a second device was holding the pins it needed. A vendor SDK -being wrong about its own hardware is normal; this is the list of places it was. - -### 3. NebulaOS's own changes - -Eight commits, each with a `G`-number tying it to a NebulaOS workstream: - -| Commit | Change | Subsystem | -|---|---|---| -| `862cc4c24` | NebulaOS boot card as the kernel's display-init logo | `video/logo-ingenic` | -| `27fe61c54` | Keep the power-on picture through the display takeover | `video/fbdev/ingenic` | -| `62d724789` | Boot picture diagnostics always in the boot log | `video/fbdev/ingenic/fb_stage` | -| `65f93367c` | NS2009 touch mode and `touch_down_count` exposed in sysfs | `drivers/misc` | -| `5ba3d3afc` | KE buzzer (GPC3) as a standard kernel PWM channel | `drivers/pwm` | -| `f28a670d5` | `ingenic_wdt` arms with a programmed timeout | `drivers/watchdog` | -| `38c467bf5` | `ingenic_wdt` read-only marker `nebulaos_arm_fix` | `drivers/watchdog` | -| `cf4dd8126` | Vendor boot messages at info level rather than warning/error | various | - -Plus the configs - `nebulaos_halley5_v30_defconfig` and -`nebulaos_halley5_v30_diagnostic.config` - which are the most-touched files in the repository -(25 changes across the history), since every capability added has to be enabled somewhere. - -### How those changes connect outward - -Three of them exist because something above the kernel needs them, which is easy to miss when -reading the kernel alone: - -- **The buzzer as a PWM channel** (`5ba3d3afc`) is what lets Klipper's `nebulaos_beeper` extra - drive it from userspace through sysfs. The kernel does not play sounds; it exposes a channel. -- **The watchdog arming with a programmed timeout** (`f28a670d5`) is what - `S02nebulaos-watchdog` feeds, so a frozen printer resets itself instead of hanging until - someone cuts the power. -- **Keeping the power-on picture through the display takeover** (`27fe61c54`) is why the boot - logo does not flash to black before NebulaScreen appears. - -A fourth connection came with the diagnosis layer below: the reserved ramoops area and the -reset-status registers are what the firmware's `nebulaos-blackbox` reads after a reboot, so -"why did the printer restart?" has an answer on the printer itself. - -### 4. Freeze diagnosis and the black box - -Eleven commits, written after two real failures on the development printer: a partial hang on -2026-11-06 (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**. They are a diagnosis layer: they -do not change how the printer prints, they change what is left behind when it stops. - -| 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. - -## 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 (`xImage`, -`nebulaos_halley5_v30`) on push. - -## The scheduling model - -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. - -## The hardware - -| | | +| Looking for | Page | |---|---| -| 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. - -## Not covered here - -- **The vendor SDK itself.** Most of this repository is Ingenic's, including - `frameworks/`, `development/` and `external/`. Its own documentation is under `docs/doc/`, - partly in Chinese. -- **Real-time latency figures.** The scheduling model is stated below; no latency was measured - here. -- **Hardware behaviour.** Nothing on this page was observed on a printer by its author. -- **U-Boot**, which lives in `u-boot/` and has its own vendor history. +| 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/`. diff --git a/wiki/Branch-Model.md b/wiki/Branch-Model.md new file mode 100644 index 0000000000..cd20f9b1d5 --- /dev/null +++ b/wiki/Branch-Model.md @@ -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). diff --git a/wiki/Build-And-Integration.md b/wiki/Build-And-Integration.md new file mode 100644 index 0000000000..0fa5d9b934 --- /dev/null +++ b/wiki/Build-And-Integration.md @@ -0,0 +1,66 @@ +# 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**, and the firmware's job is only to verify it did not get +lost. The firmware's reproducibility record still describes it as a build-time variant script; +no such script exists at 1.0.2. + +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. diff --git a/wiki/Freeze-Diagnosis.md b/wiki/Freeze-Diagnosis.md new file mode 100644 index 0000000000..6d133e07af --- /dev/null +++ b/wiki/Freeze-Diagnosis.md @@ -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. diff --git a/wiki/Hardware.md b/wiki/Hardware.md new file mode 100644 index 0000000000..5f641f89f3 --- /dev/null +++ b/wiki/Hardware.md @@ -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. + diff --git a/wiki/Home.md b/wiki/Home.md new file mode 100644 index 0000000000..01488e6be6 --- /dev/null +++ b/wiki/Home.md @@ -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 diff --git a/wiki/Scheduling-Model.md b/wiki/Scheduling-Model.md new file mode 100644 index 0000000000..a3fde71b86 --- /dev/null +++ b/wiki/Scheduling-Model.md @@ -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. + diff --git a/wiki/What-NebulaOS-Changes.md b/wiki/What-NebulaOS-Changes.md new file mode 100644 index 0000000000..6c5aa58807 --- /dev/null +++ b/wiki/What-NebulaOS-Changes.md @@ -0,0 +1,85 @@ +# What NebulaOS changes in this kernel + +This repository is mostly a vendor SDK. This page answers the question a developer actually +arrives with: **which parts are NebulaOS, and which are Ingenic's or OpenKE's?** + +Written against the `openke` branch at `95d0321e`, which is also what ships: the firmware +manifest at tag `v1.0.2` pins `KERNEL_PIN=95d0321ef4270adb3e080fe2125ab81fcb232b91` with +`KERNEL_BRANCH=openke`, and that is the branch tip. The branch layout and the name are on +[Branch model](Branch-Model). + +## The four layers on `openke` + +Reading the history from the baseline forward, the commits fall into four groups. + +### 1. The OpenKE layer + +`8e97319a1` - *"openke: NS2009 touch, OpenKE display panel, BT H5 vendor ext, watchdog fix, DTS +wiring"*. The work that made this SoC usable on this printer at all, inherited rather than +written here. Attribute it to OpenKE. + +### 2. Real hardware bugs, found and fixed + +Five commits, each fixing something genuinely wrong in the vendor board description rather than +adapting it to taste: + +| Commit | What was wrong | +|---|---| +| `e67eefc40` | `wlan_pwrseq` `reset-gpios` missing its third cell - a real Wi-Fi SDIO init bug | +| `5dca5971f` | `wlan_pwrseq` missing `post-power-on-delay-ms` - a real 0-delay SDIO probe race | +| `c902097d1` | `drvvbus-gpio` wired to the wrong pin, confirmed against stock's own DTB | +| `4905cb23e` | `uart1` - the real mainboard MCU link - never wired up in the board file | +| `c60cf4d67` | `as_dmic` left enabled, a real pin conflict blocking that same `uart1` | + +Worth reading as a group. The last two are the same story: the link to the mainboard MCU did not +exist in the vendor board file, and a second device was holding the pins it needed. A vendor SDK +being wrong about its own hardware is normal; this is the list of places it was. + +### 3. NebulaOS's own changes + +Eight commits, each with a `G`-number tying it to a NebulaOS workstream: + +| Commit | Change | Subsystem | +|---|---|---| +| `862cc4c24` | NebulaOS boot card as the kernel's display-init logo | `video/logo-ingenic` | +| `27fe61c54` | Keep the power-on picture through the display takeover | `video/fbdev/ingenic` | +| `62d724789` | Boot picture diagnostics always in the boot log | `video/fbdev/ingenic/fb_stage` | +| `65f93367c` | NS2009 touch mode and `touch_down_count` exposed in sysfs | `drivers/misc` | +| `5ba3d3afc` | KE buzzer (GPC3) as a standard kernel PWM channel | `drivers/pwm` | +| `f28a670d5` | `ingenic_wdt` arms with a programmed timeout | `drivers/watchdog` | +| `38c467bf5` | `ingenic_wdt` read-only marker `nebulaos_arm_fix` | `drivers/watchdog` | +| `cf4dd8126` | Vendor boot messages at info level rather than warning/error | various | + +Plus the configs - `nebulaos_halley5_v30_defconfig` and +`nebulaos_halley5_v30_diagnostic.config` - which are the most-touched files in the repository +(25 changes across the history), since every capability added has to be enabled somewhere. + +### How those changes connect outward + +Three of them exist because something above the kernel needs them, which is easy to miss when +reading the kernel alone: + +- **The buzzer as a PWM channel** (`5ba3d3afc`) is what lets Klipper's `nebulaos_beeper` extra + drive it from userspace through sysfs. The kernel does not play sounds; it exposes a channel. +- **The watchdog arming with a programmed timeout** (`f28a670d5`) is what + `S02nebulaos-watchdog` feeds, so a frozen printer resets itself instead of hanging until + someone cuts the power. +- **Keeping the power-on picture through the display takeover** (`27fe61c54`) is why the boot + logo does not flash to black before NebulaScreen appears. + +A fourth connection came with the diagnosis layer below: the reserved ramoops area and the +reset-status registers are what the firmware's `nebulaos-blackbox` reads after a reboot, so +"why did the printer restart?" has an answer on the printer itself. + + +The fourth layer - freeze diagnosis and the black box, eleven commits - is large enough to have +its own page: [Freeze diagnosis](Freeze-Diagnosis). + +## Not covered here + +- **The vendor SDK itself.** Most of this repository is Ingenic's, including `frameworks/`, + `development/` and `external/`. Its own documentation is under `docs/doc/`, partly in Chinese. +- **Hardware behaviour.** Nothing on this page was observed on a printer by its author. +- **U-Boot**, which lives in `u-boot/` and has its own vendor history. +- **Real-time latency figures.** The [scheduling model](Scheduling-Model) is stated; no latency + was measured here. diff --git a/wiki/_Sidebar.md b/wiki/_Sidebar.md new file mode 100644 index 0000000000..7f0a0abae8 --- /dev/null +++ b/wiki/_Sidebar.md @@ -0,0 +1,14 @@ +### 🐧 NebulaOS-kernel + +**[Home](Home)** + +- [What NebulaOS changes](What-NebulaOS-Changes) +- [Freeze diagnosis](Freeze-Diagnosis) +- [Scheduling model](Scheduling-Model) +- [Branch model](Branch-Model) +- [Build and integration](Build-And-Integration) +- [The hardware](Hardware) + +--- +- [Firmware](https://github.com/NebulaOS-KE/NebulaOS-firmware/wiki) +- [End-user manual](https://github.com/NebulaOS-KE/NebulaOS/wiki) From b4a1059446d58e73a17ec834b021a21de7bbd986 Mon Sep 17 00:00:00 2001 From: NebulaOS <33003628+coreflake1@users.noreply.github.com> Date: Thu, 12 Nov 2026 19:38:28 +0100 Subject: [PATCH 4/4] docs(wiki): name the gzip -n commit, now that the firmware record does too Build-And-Integration said stage 01 verifies the literal `gzip -nv9f` line and that the firmware's reproducibility record wrongly credited it to a build-time variant script. The firmware corrected that (d464b46), so the page names the commit instead: b31be02d9 here, one line in arch/mips/boot/zcompressed/Makefile, an ancestor of the 1.0.2 pin - verified in this repository, not taken from the other one's say-so - and what it bought: firmware 3bdf3ff built twice gives the same xImage byte for byte. Co-Authored-By: Claude Opus 5.5 (1M context) --- wiki/Build-And-Integration.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/wiki/Build-And-Integration.md b/wiki/Build-And-Integration.md index 0fa5d9b934..9b29a91b73 100644 --- a/wiki/Build-And-Integration.md +++ b/wiki/Build-And-Integration.md @@ -56,9 +56,13 @@ Worth knowing, because it is the gate a kernel change meets first. At 1.0.2 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**, and the firmware's job is only to verify it did not get -lost. The firmware's reproducibility record still describes it as a build-time variant script; -no such script exists at 1.0.2. +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