Skip to content

gk7205v200: capture a crash log across reboot with pstore/ramoops - #2392

Merged
widgetii merged 6 commits into
masterfrom
gk7205v200-pstore-ramoops
Sep 11, 2026
Merged

gk7205v200: capture a crash log across reboot with pstore/ramoops#2392
widgetii merged 6 commits into
masterfrom
gk7205v200-pstore-ramoops

Conversation

@widgetii

@widgetii widgetii commented Sep 10, 2026

Copy link
Copy Markdown
Member

Why

A camera that boots but whose kernel panics/oopses (a driver/sensor init loop, a crashing streamer) leaves nothing to diagnose: the console is muted, syslog is a 64 KB RAM ring, and the panic=20 reboot wipes both. Enable pstore/ramoops so the last kernel log survives the warm reboot and is readable at /sys/fs/pstore next boot — captured via kmsg_dump, which is independent of the muted console. (A cold power cut still loses it; that case is the bootloader recovery, not this.)

The "collect logs to root-cause a field brick" half of the initiative.

What

Three files. The ramoops region is reserved in the device tree (OpenIPC/linux), not carved from bootargs:

  • gk7205v200.generic.config — enable CONFIG_PSTORE + PSTORE_RAM (+ PMSG; ZLIB compressor, the only one whose workspace is preallocated at register time, so it is safe to compress from inside a panic on this 4.9 kernel).
  • general/overlay/etc/init.d/S29pstore — mount /sys/fs/pstore so the records are exposed (review finding 2).
  • general/overlay/init — anchor the flash-vs-ramdisk match to the root= value: a bare ram was matching the substring in ramoops, so init skipped the overlay pivot and fell through to the read-only squashfs. A correctness fix for every board.

The physical reservation is a /reserved-memory ramoops node in OpenIPC/linux (merged into goke-gk7205v200): it costs exactly its own size, leaves mem= and the mmz/cma media zone untouched, and works for both goke allocators without the CMA-alignment loss of a bootargs carve. This supersedes the earlier bootargs-carve approach, which bricked the gk allocator — see the thread below for the full root-cause (the carve is gone; set_allocator is back to its original form).

Hardware verification (lab gk7205v200, both allocators)

  • gk (the board's real allocator): set_allocator gk → claimed, pstore mounted, MMZ conflict 0, RTSP up. echo c > /proc/sysrq-trigger → after the reboot /sys/fs/pstore/dmesg-ramoops-0 (13 KB) holds the crash (sysrq_handle_crash + backtrace); streaming intact.
  • cma: reserved region clear of the 4M-aligned CMA zone; panic captured across reboot; streaming intact.
  • Also proven on gk7205v300 (128 MB) — same design, second Goke SoC.

A camera that boots but whose kernel panics or oopses (a driver/sensor init
loop, a crashing streamer) leaves nothing behind: the console is muted, syslog
is a RAM ring, and the panic=20 reboot wipes it. Enable pstore/ramoops so the
last kernel log survives the warm reboot and is readable at /sys/fs/pstore on
the next boot -- via kmsg_dump, which is independent of the muted console, so it
works on these boards. (A cold power cut still loses it; that case is the
bootloader firmware_scan recovery, not this.)

128 KiB is enough for one 64 KiB panic dump plus headroom (record_size 64K,
mem_size 128K, console/pmsg zones off). The region is carved so it collides
with neither Linux RAM nor the media (mmz) pool, in both goke allocators:

  gk  (mem=osmem, mmz above): shrink the OS window by 128K and place ramoops in
      the freed gap [base+osmem-128K, base+osmem), just below mmz_start, which
      is unchanged -- the mmz pool is untouched.
  cma (mem=totalmem, mmz a CMA region inside it): reserve the top 1 MiB (mmz is
      M-granular there; a >=128 MiB cma board loses 1 MiB, negligible), drop
      mem= by the same 1 MiB, and place ramoops at the top, above both the
      kernel window and the media zone.

set_allocator writes the ramoops.* params (and the reduced mem=) into bootargs;
load_goke's check_allocator backfills them on a camera whose bootargs predate
pstore (set_allocator otherwise only runs when mmz_allocator is absent), so the
region reaches already-provisioned cameras on their next boot too. Effective on
the boot after the rewrite, like every other set_allocator change.

Scoped to gk7205v200 (its own osdrv package). Shell-parse and strip-comment
gates pass; address math verified for both allocators. On-camera panic ->
pstore verification under each allocator follows.
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Sep 10, 2026

Copy link
Copy Markdown

PR Summary by Qodo

Persist gk7205v200 kernel crash logs with pstore/ramoops

✨ Enhancement 🐞 Bug fix ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Enables compressed pstore/ramoops crash capture across warm reboots on gk7205v200.
• Reserves collision-free memory for both gk and CMA allocator layouts.
• Mounts pstore automatically and protects flash-root detection from ramoops boot arguments.
Diagram

graph TD
  G["set_allocator"] --> H{"Allocator mode"} -->|gk 128K| C["Ramoops region"]
  H -->|cma 4M gap| C
  A["Kernel panic"] --> B["Kernel pstore"] --> C --> D["Warm reboot"] --> E["S29pstore"] --> F["Sysfs records"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Device-tree reserved-memory ramoops
  • ➕ Expresses the physical reservation through a standard kernel hardware description
  • ➕ Reduces allocator-script bootarg arithmetic
  • ➕ Makes the reservation visible alongside other platform memory regions
  • ➖ Static device-tree addresses fit allocator-dependent layouts poorly
  • ➖ Requires board-specific kernel and device-tree integration
  • ➖ Does not easily migrate already-provisioned U-Boot environments

Recommendation: Retain the bootarg-based approach because ramoops placement depends on allocator mode and firmware memory values. However, add or verify migration handling for existing devices: the supplied diff changes set_allocator, while the current load_goke check only invokes it when mmz_allocator is absent and therefore does not backfill ramoops arguments into previously provisioned bootargs.

Files changed (4) +88 / -8

Enhancement (2) +72 / -5
S29pstoreMount pstore during system startup +21/-0

Mount pstore during system startup

• Adds an init service that detects kernel pstore support and mounts it at /sys/fs/pstore. The script remains inert on kernels without pstore support and avoids remounting an existing mount.

general/overlay/etc/init.d/S29pstore

set_allocatorReserve allocator-specific ramoops memory +51/-5

Reserve allocator-specific ramoops memory

• Adds common ramoops boot arguments and reserves a 128 KiB record region for both allocator modes. The gk layout trims 128 KiB from the OS window, while CMA leaves a 4 MiB aligned gap to avoid CMA rounding and U-Boot relocation overwrites.

general/package/goke-osdrv-gk7205v200/files/script/set_allocator

Bug fix (1) +6 / -2
initRestrict root-type detection to the root argument +6/-2

Restrict root-type detection to the root argument

• Anchors NFS, MMC, and RAM root detection to the root= command-line value. This prevents ramoops parameters or other unrelated tokens from disabling the writable flash overlay.

general/overlay/init

Other (1) +10 / -1
gk7205v200.generic.configEnable compressed pstore and ramoops support +10/-1

Enable compressed pstore and ramoops support

• Enables the pstore core, RAM backend, console, and PMSG support for the gk7205v200 kernel. Selects ZLIB compression because this Linux 4.9 configuration requires a compressor and ZLIB preallocates its panic-safe workspace.

br-ext-chip-goke/board/gk7205v200/gk7205v200.generic.config

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Sep 10, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (1) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Existing cameras never capture crashes ⊘ Outdated 🐞 Bug ≡ Correctness
Description
ramoops_args adds the required parameters only when set_allocator runs, while check_allocator
skips that command whenever the persisted command line already contains mmz_allocator. Cameras
provisioned before this change therefore boot the pstore-enabled kernel without a ramoops region, so
mounting /sys/fs/pstore cannot expose a crash record after reboot.
Code

general/package/goke-osdrv-gk7205v200/files/script/set_allocator[R7-8]

+ramoops_args() {   # $1 = physical base address
+  echo "ramoops.mem_address=$1 ramoops.mem_size=${RAMOOPS_SIZE} ramoops.record_size=0x10000 ramoops.console_size=0 ramoops.pmsg_size=0 ramoops.dump_oops=1"
Evidence
The only repository code producing ramoops boot arguments is ramoops_args, and those arguments
reach persistent bootargs only through the two set_allocator branches. check_allocator calls
that script solely when /proc/cmdline has no mmz_allocator, so an already-provisioned camera
with the legacy allocator marker cannot receive the new reservation automatically.

general/package/goke-osdrv-gk7205v200/files/script/set_allocator[3-8]
general/package/goke-osdrv-gk7205v200/files/script/set_allocator[63-90]
general/package/goke-osdrv-gk7205v200/files/script/load_goke[101-109]
general/overlay/etc/init.d/S29pstore[2-12]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Existing cameras whose boot arguments already contain `mmz_allocator` never run `set_allocator`, leaving them without the new ramoops parameters and reserved memory layout.
## Fix Focus Areas
- general/package/goke-osdrv-gk7205v200/files/script/load_goke[101-109]
- general/package/goke-osdrv-gk7205v200/files/script/set_allocator[7-8]
- general/package/goke-osdrv-gk7205v200/files/script/set_allocator[63-90]
## Recommended Fix
Detect the absence of `ramoops.mem_address` independently of `mmz_allocator` and migrate the existing allocator layout. Preserve every unrelated boot argument while replacing only the allocator-specific `mem`, `mmz`, and ramoops fields, then persist the updated command line for the next boot.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Cameras receive an untested memory map 📘 Rule violation ☼ Reliability
Description
set_allocator reduces Linux-visible RAM and media-zone sizing, persists ramoops parameters in
bootargs for both allocator layouts, and check_allocator backfills those arguments on
already-provisioned cameras while CONFIG_PSTORE_RAM changes the running kernel. After the next
reboot, these changes reach boot, media allocation, panic capture, and streaming, but the supplied
verification marks both real-camera allocator tests as still in progress and provides no
before-and-after output from gk7205v200 hardware.
Code

general/package/goke-osdrv-gk7205v200/files/script/set_allocator[62]

+  newbootargs="mem=${mem} console=${console} panic=${panic} rootfstype=${rootfstype} root=${root} init=${init} mtdparts=${mtdparts} mmz_allocator=gk ${ramoops} ${extras}"
Evidence
Compliance rule 1 requires real-camera evidence for changes that can alter firmware behavior, and
the cited changes directly modify the kernel feature set, Linux-visible RAM, media-zone sizing, and
persistent boot command line for both allocator modes, including the backfill path used by
already-provisioned cameras. The PR verification explicitly marks the corresponding on-camera
panic/reboot and streaming tests as still in progress rather than completed, so runtime
compatibility and RAM retention on deployed hardware have not been demonstrated.

Rule 1: Hardware evidence is present and honest
general/package/goke-osdrv-gk7205v200/files/script/set_allocator[57-72]
general/package/goke-osdrv-gk7205v200/files/script/load_goke[109-119]
br-ext-chip-goke/board/gk7205v200/gk7205v200.generic.config[2394-2400]
general/package/goke-osdrv-gk7205v200/files/script/set_allocator[33-42]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The kernel configuration, persistent memory layout, and ramoops boot arguments can alter camera boot, panic recovery, and streaming behavior, but real-hardware verification has not been completed for either supported allocator layout and the PR provides no before-and-after output.
## Fix Focus Areas
- br-ext-chip-goke/board/gk7205v200/gk7205v200.generic.config[2394-2400]
- general/package/goke-osdrv-gk7205v200/files/script/set_allocator[57-72]
- general/package/goke-osdrv-gk7205v200/files/script/load_goke[109-119]
## Recommended Fix
Test the resulting image on a gk7205v200 camera in both `gk` and `cma` allocator modes. For each mode, attach before-and-after boot logs, the effective command line and memory map, trigger a controlled kernel panic and allow the configured warm reboot, show the recovered `/sys/fs/pstore` record, and confirm that normal streaming still operates before merging.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Crash logs stay hidden after reboot ✓ Resolved 🐞 Bug ≡ Correctness
Description
CONFIG_PSTORE_RAM and the new ramoops arguments register persistent records, but no init path
mounts the pstore filesystem. The shipped init mounts proc and filesystems declared through `mount
-a, while the repository has no pstore mount, so records are not exposed at /sys/fs/pstore` after
reboot.
Code

br-ext-chip-goke/board/gk7205v200/gk7205v200.generic.config[2400]

+CONFIG_PSTORE_RAM=y
Evidence
The configuration enables the pstore and ramoops filesystems, and the allocator supplies their
backing-memory parameters. The complete startup sequence mounts proc, invokes mount -a, and
separately mounts only debugfs; no repository startup or filesystem table mounts pstore.

br-ext-chip-goke/board/gk7205v200/gk7205v200.generic.config[2320-2326]
br-ext-chip-goke/board/gk7205v200/gk7205v200.generic.config[2394-2400]
general/package/goke-osdrv-gk7205v200/files/script/set_allocator[3-8]
general/overlay/etc/inittab[17-29]
general/overlay/etc/init.d/S29debugfs[5-8]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The ramoops backend can retain records, but userspace does not mount the pstore filesystem that exposes them at `/sys/fs/pstore`.
## Fix Focus Areas
- br-ext-chip-goke/board/gk7205v200/gk7205v200.generic.config[2394-2400]
- general/overlay/etc/inittab[17-29]
## Recommended Fix
Add a gk7205v200-specific startup script that creates `/sys/fs/pstore` if needed and mounts it with `mount -t pstore pstore /sys/fs/pstore`. Install the script from the gk7205v200 package rather than changing the shared init behavior for every board.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View high (1)
4. Upgrades erase custom boot options ✓ Resolved 🐞 Bug ≡ Correctness
Description
check_allocator now sends every legacy allocator through set_allocator, which reconstructs
bootargs from only seven parsed fields and the separate extras environment value. Any other
option stored directly in bootargs is removed on the first upgraded boot, so deployed cameras that
depend on custom kernel parameters reboot without them.
Code

general/package/goke-osdrv-gk7205v200/files/script/load_goke[R117-118]

+			*mmz_allocator=cma*) set_allocator cma ;;
+			*mmz_allocator=gk*)  set_allocator gk ;;
Evidence
The new backfill calls set_allocator for existing allocator-bearing command lines. That script
reads only mem, console, panic, rootfstype, root, init, and mtdparts, then builds a
replacement value from those fields; the existing legacy migration demonstrates preservation of the
original command-line tail instead.

general/package/goke-osdrv-gk7205v200/files/script/load_goke[101-120]
general/package/goke-osdrv-gk7205v200/files/script/set_allocator[12-24]
general/package/goke-osdrv-gk7205v200/files/script/set_allocator[57-64]
general/package/goke-osdrv-gk7205v200/files/script/set_allocator[69-73]
general/package/legacy/datalink/files/tweaksys[118-123]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The automatic ramoops backfill reconstructs the complete persistent boot command line from a narrow whitelist, deleting unrecognized options already present on deployed cameras.
## Fix Focus Areas
- general/package/goke-osdrv-gk7205v200/files/script/load_goke[109-119]
- general/package/goke-osdrv-gk7205v200/files/script/set_allocator[12-23]
- general/package/goke-osdrv-gk7205v200/files/script/set_allocator[57-73]
## Recommended Fix
Transform the existing `bootargs` value in place: replace the allocator-controlled `mem`, `mmz`, and ramoops parameters while preserving every unrelated token. Write the resulting complete value back as one quoted bootargs value and make repeated execution idempotent.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can switch off images and animations for a plain-text comment

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread general/package/goke-osdrv-gk7205v200/files/script/set_allocator Outdated
Comment thread br-ext-chip-goke/board/gk7205v200/gk7205v200.generic.config
Comment thread general/package/goke-osdrv-gk7205v200/files/script/load_goke Outdated
…targs (review)

Two fixes from review of the pstore change:

- Nothing mounted the pstore filesystem, so a crash log ramoops captured across
  the reboot was held in the reserved RAM but never exposed at /sys/fs/pstore.
  Add S29pstore, which mounts it when the kernel has pstore (inert otherwise),
  the same shape as S29debugfs. (finding: crash logs stay hidden after reboot)

- check_allocator backfilled the ramoops bootargs on already-provisioned
  cameras by re-running set_allocator, but set_allocator rebuilds bootargs from
  a fixed set of parsed fields plus ${extras}, so any other custom kernel
  parameter stored directly in bootargs would be dropped on the next boot.
  Revert the backfill: ramoops is now added only through set_allocator's
  existing trigger (when mmz_allocator is absent -- a fresh env / firstboot), so
  a provisioned camera's bootargs are never rewritten. Fleet reach for existing
  cameras is deferred rather than bought at the cost of clobbering their kernel
  command line. (finding: upgrades erase custom boot options)
The disable line targeted CONFIG_PSTORE_DEFLATE_COMPRESS, a symbol this 4.9
kernel does not have (it was renamed from ZLIB in a later kernel), so it was a
no-op. The compressor here is a mandatory Kconfig choice with no "none" arm; it
defaults to ZLIB, whose workspace is preallocated at pstore_register so it is
safe to compress from inside a panic. Name that symbol explicitly instead of a
dead one. Resolved kernel config is unchanged (ZLIB was already selected).
@widgetii
widgetii marked this pull request as draft September 10, 2026 13:48
@widgetii

Copy link
Copy Markdown
Member Author

Hardware verification (lab gk7205v200) — the bootargs carve bricks the camera; converting to draft

Ran the memory-map test the review asked for, on the lab gk7205v200 (UART + PoE recovery). Result: fail on the gk allocator — the change bricks the camera into an unclaimed, video-less state that needs UART/U-Boot recovery. Details:

What happens. After set_allocator gk writes the ramoops bootargs (mem=40832K … ramoops.mem_address=0x427e0000 …), the next normal boot fails to complete the overlay pivot_root (general/overlay/init:60, unchecked). The camera then runs on the read-only squashfs → /etc read-only → root's shadow reverts to the blank hash (camera reads as unclaimed)fw_printenv fails (environment not initialized) → load_goke defaults osmem to 32 → mmz_start=0x42000000ERROR: Conflict MMZ … MMZ conflict to kernel memory (0x40000000, 0x427DFFFF) → every SDK module fails → no video.

Isolation (what is and isn't the cause):

  • mem=40832K without ramoops boots healthy (mmz_start 0x42800000, osal … init success, claimed) — the K-suffixed/non-MB mem is not the cause.
  • With the ramoops params it bricks, 2/2.
  • Booting init=/bin/sh + ramoops and running the /init sequence by hand all succeeds: jffs2 mount rc=0, overlay content intact, overlayfs mount rc=0, no dmesg errors. So ramoops doesn't break the mounts — it breaks /init's automated early-boot pivot (a subtle timing/pivot interaction).
  • The kernel itself is fine: ramoops: attached 0x20000@0x427e0000, pstore: using zlib compression.

Conclusion. The set_allocator bootargs carve is too fragile for this non-DT vendor kernel — it must not ship. The right approach is to reserve the ramoops region via a kernel reserved-memory mechanism in OpenIPC/linux, which decouples it from bootargs/mem/mmz and the /init+load_goke coordination.

What is verified-good and can be kept (all confirmed on hardware): the CONFIG_PSTORE* board-config toggles, S29pstore auto-mount (review finding 2), and the load_goke backfill revert (review finding 3). Only the memory carve in set_allocator is the problem.

Marking this draft while the carve is redesigned. The lab camera was recovered to a healthy mem=40M baseline.

The flash-root test grepped the whole kernel command line for a bare
"ram"/"mmcblk"/"nfs", so any unrelated token spelled with those letters made
init believe the root was a ramdisk / SD / NFS mount. It then skipped the flash
overlay mount and pivot_root entirely and fell through to /sbin/init on the
read-only squashfs: the camera came up with a read-only /etc, its saved
password gone (unclaimed), and -- because /etc/fw_env could not be written --
load_goke fell back to the default osmem and the mmz zone collided with kernel
RAM, so nothing streamed.

The trigger was the pstore "ramoops.*" crash-log parameters, but the bug is the
unanchored match; anchor all three to the root= value. A flash board's cmdline
carries none of these letters in root=, so its result is unchanged; only a
command line that mentioned them outside root= (as ramoops does) is fixed.

Found on a gk7205v200 (UART recovery) while bringing up pstore.
…rounding and U-Boot

set_allocator cma hung the board right after "Starting kernel" -- an early
panic() before the console. Two constraints, both found on hardware, decide
where ramoops can go on the cma path:

- The media zone is a cma region, reserved with dma_declare_contiguous(), which
  rounds the region up to the CMA alignment (PAGE_SIZE << max(MAX_ORDER-1,
  pageblock_order) = 4M on this kernel) and rejects a fixed region whose rounded
  end runs past the end of RAM (mm/cma.c: "fixed && base + size >
  highmem_start"). drivers/goke/cma/cma.c turns that -EINVAL into a panic() from
  an early initcall. The first attempt shrank the zone by 1M, which rounded back
  up to the full size and overran mem= by 1M -> panic. The zone has to end on a
  4M boundary at or below mem=, so drop a whole 4M (totalmem-osmem-4, still
  4M-aligned since osmem/totalmem are 4M multiples).

- ramoops then cannot go in the freed top 128K either: U-Boot relocates to the
  top of DRAM on every boot (bdinfo here: relocaddr 0x43F20000, page tables
  0x43FF0000 -- the top ~1.25M), so a crash log left there is overwritten by the
  reboot before the kernel reads it back (seen as an empty /sys/fs/pstore after a
  panic). Land ramoops at the media zone's end instead and stop mem= there, well
  clear of both the kernel's RAM and U-Boot's window.

On a cma board (>=128M) the 4M is negligible; gk7205v200 is 64M and always runs
the gk allocator, so this branch is only reached by a manual override. Verified
on a gk7205v200: cma now boots, streams, and captures a panic to /sys/fs/pstore
across the reboot.
@widgetii

Copy link
Copy Markdown
Member Author

Resolved — root-caused and fixed in-repo; both allocators verified on hardware

My earlier "the carve bricks the camera" comment was premature. On the lab gk7205v200 (UART + PoE) I found the two real root causes and fixed them; pstore now works end-to-end on both allocators, no brick.

Root cause 1 — the gk brick was a shared-init bug, not the carve

general/overlay/init decided flash-vs-ramdisk with grep 'root=.*nfs\|mmcblk\|ram' — a bare ram that matched the substring in ramoops. So the ramoops bootargs made init think the root was a ramdisk, skip the flash-overlay mount + pivot_root, and fall through to /sbin/init on the read-only squashfs: read-only /etc, blank shadow (camera reads as unclaimed), fw_printenv fails, load_goke falls back to the default osmem, mmz collides with kernel RAM, nothing streams. Fixed by anchoring the match to the root= value (init: match root= exactly…). Strictly a correctness fix for every board.

Root cause 2 — cma hung at "Starting kernel" from CMA alignment, not ramoops

The cma media zone is a CMA region reserved via dma_declare_contiguous(), which rounds the region up to the CMA alignment (PAGE_SIZE << max(MAX_ORDER-1, pageblock_order) = 4M here) and rejects a fixed region crossing end-of-RAM (mm/cma.c), which drivers/goke/cma/cma.c turns into a panic() in an early initcall — before the console. Reserving 1M rounded back up and overran mem= by 1M. Fixed by dropping a full 4M step so the zone ends on a 4M boundary at/below mem=. ramoops also can't go in the freed top 128K: bdinfo shows U-Boot relocates to the top ~1.25M (relocaddr 0x43F20000, page tables 0x43FF0000) on every boot and overwrites it (empty /sys/fs/pstore after a panic), so it lands just above the media zone. On a cma board (≥128M) the 4M is negligible; gk7205v200 is 64M and always runs gk, so cma here is only a manual override.

Hardware evidence (lab gk7205v200)

gk (the board's real allocator): set_allocator gkmem=40832K, ramoops.mem_address=0x427e0000, mmz 0x42800000+24M, claimed=YES, pstore mounted, MMZ conflict: 0, RTSP up. echo c > /proc/sysrq-trigger → after reboot /sys/fs/pstore/dmesg-ramoops-0 (13 KB) holds the crash (sysrq_handle_crash, backtrace); streaming intact.

cma (manual override): mem=60M, mmz 0x42800000+20M, ramoops.mem_address=0x43c00000, claimed=YES, pstore mounted, MMZ conflict: 0, ramoops: attached 0x20000@0x43c00000, RTSP up. Panic → after reboot /sys/fs/pstore/dmesg-ramoops-0 holds the crash; streaming intact.

Also confirmed on hardware: S29pstore auto-mounts /sys/fs/pstore (review finding 2), and the load_goke backfill revert ships (review finding 3). Marking ready for review.

@widgetii
widgetii marked this pull request as ready for review September 10, 2026 15:00
Comment thread general/package/goke-osdrv-gk7205v200/files/script/set_allocator Outdated
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 956ddb3

…evice tree

The ramoops region is now reserved by a /reserved-memory node in the board DTS
(OpenIPC/linux), which costs exactly 128K and leaves mem= and the media (mmz/cma)
zone untouched, so it works for both allocators. Carving it out of bootargs
here could not: on the cma path the media zone is a CMA region that
dma_declare_contiguous() rounds up to the 4M CMA alignment, so making room for a
128K log cost a full 4M and, done wrong, paniced the board before the console.

Revert set_allocator to exactly its pre-pstore form (no ramoops parameters, no
mem/media reduction). CONFIG_PSTORE_RAM and the S29pstore mount stay; the driver
binds to the DT region. Needs the OpenIPC/linux DTS node to actually capture a
crash, but is harmless without it (pstore just mounts empty). No conflict in
either landing order, since bootargs no longer carry ramoops.* to clash with the
DT node.
@widgetii

Copy link
Copy Markdown
Member Author

Pivot: ramoops region now comes from the device tree, not a bootargs carve

Per review discussion, the ramoops reservation is moving to a /reserved-memory node in the board DTS — OpenIPC/linux#56 (proven on hardware, not yet merged). That costs exactly 128K and leaves mem= and the media (mmz/cma) zone untouched, so it works cleanly for both allocators. The bootargs carve could not: on the cma path the media zone is a CMA region that dma_declare_contiguous() rounds up to the 4M CMA alignment, so a 128K log cost a full 4M (and, done wrong, paniced before the console).

This PR is now reduced to its safe, in-repo pieces (set_allocator and load_goke are back to their exact pre-pstore form — 0 diff vs master):

  • gk7205v200.generic.config: enable CONFIG_PSTORE/_RAM/_CONSOLE/_PMSG (+ name the real ZLIB compressor symbol for 4.9).
  • S29pstore: mount /sys/fs/pstore when the kernel has pstore (inert otherwise).
  • init: anchor the flash-root test to the root= value — an independent correctness fix (a bare ram/mmcblk/nfs matched anywhere in the cmdline; harmless now that no ramoops.* is in bootargs, but still a latent bug).

Verified on hardware (gk7205v200) with the DTS node + plain bootargs — full mem, full media zone, both allocators:

allocator mem media (mmz) ramoops: attached mmz conflict panic → /sys/fs/pstore
gk 40M (full) 0x20000@0x41f00000 0 ✅ across reboot
cma 64M (full) 24M (full) 0x20000@0x41f00000 0 ✅ across reboot

Coordination: this and OpenIPC/linux#56 can land in either order — the firmware no longer emits ramoops.*, so there's nothing to clash with the DT node. Full crash capture needs both; this PR alone is harmless (pstore mounts empty until the kernel DTS lands, since the kernel is pulled from the goke-gk7205v200 branch).

@widgetii
widgetii merged commit 0f477fd into master Sep 11, 2026
116 checks passed
@widgetii
widgetii deleted the gk7205v200-pstore-ramoops branch September 11, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant