Skip to content

video: show a blinking text cursor on the video console - #74

Merged
DjDeveloperr merged 2 commits into
aurora-wipfrom
feat/video-blinking-cursor
Nov 25, 2026
Merged

DjDeveloperr merged 2 commits into
aurora-wipfrom
feat/video-blinking-cursor

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

What: The video console now draws a blinking cursor, so the U-Boot prompt and the GRUB menu entry editor ('e') and command line ('c') show where typed text goes. Before this there was no cursor at all, so editing boot entries was guesswork. A second commit fixes an older bug that put GRUB's editor and shell text at the wrong column after every cursor move. All our distros run GRUB on the EFI text console (terminal_output console), which U-Boot draws, so this one change covers Fedora, ALARM, Debian and NixOS on every Mac.
Tested: J413 M2 Air and J316s M1 Pro at d6298e3 (U-Boot build of the identical tree 713a3321): guarded Stage 2 trial with only U-Boot swapped, boots Linux, PASS (Enforcing, 0 failed units) on both; reset-to-kernel time unchanged within boot-to-boot spread (J413 9.0-9.9 s, M1 Pro 28.06 s vs 28.10-28.28 s production). QEMU (virt + bochs-display) at the same tree with the distros' own GRUB binaries (ALARM grub 2.16-1, Fedora grub2-efi-aa64 2.12-81.fc45): cursor blinks every 500 ms at the U-Boot prompt, in the GRUB editor and in the GRUB shell, follows typing and arrow keys, stays off in the menu. Sandbox ut dm video*: same results as aurora-wip.
Risk: two-way door · all Macs (shared video console code; Apple defconfigs enable it)
Not yet: eyes-on of the cursor on a Mac display (the GRUB editor needs a key press at boot); J473 and J616s trial rows.

Thanks to Lancer for the report (ALARM GRUB editor with no visible cursor).

Details

Commit 1: video: vidconsole: keep the line start on ANSI cursor moves

ANSI cursor moves (ESC [r;cH, ESC [cG, the relative moves) went through vidconsole_position_cursor(), which also sets the start of the text line (xstart_frac) to the new column. EFI SetCursorPosition() sends ESC [r;cH, and GRUB calls it all the time. So after any move, \r/\n went back to that column, a backspace at it wrapped to the previous line, and relative moves and the ESC [6n reply were off, because get_cursor_position() counts from the line start. In GRUB's shell the prompt and the echoed text landed 20+ columns apart (see Evidence). ANSI moves now change only the cursor and count columns from the line start, the same way get_cursor_position() does. vidconsole_set_cursor_pos() / vidconsole_position_cursor() (pixel placement for the logo and expo) are unchanged.

Commit 2: video: show a blinking text cursor on the video console (CONFIG_VIDEO_CURSOR, depends on VIDEO_ANSI && CYCLIC)

  • The cursor is an underline across the bottom of the character cell at the text position, in the text colour, 1/8 of the cell high (at least 2 px).
  • The stdio putc/puts of the video console erase it before output and draw it at the new position after. It therefore follows typing, cursor moves, wraps and scrolling, and stays solid while text is being typed.
  • The pixels under it are saved and put back on erase. A pixel that no longer holds the cursor colour (screen cleared, or drawn over through GOP) is left alone, so a stale restore can't damage the screen.
  • Blink: one cyclic function (50 ms poll) toggles it every 500 ms. Cyclic functions run from schedule(), which the U-Boot CLI (fgetc) and EFI ReadKeyStroke()/WaitForEvent() (via efi_timer_check()) call while they wait for input. Nothing extra runs while the boot proceeds.
  • ESC [?25l / ESC [?25h (EFI EnableCursor(), U-Boot's bootmenu) hide and show it. A quiet console (CONFIG_VIDEO_QUIET_BOOT, the logo-preserving boot) never draws it but still tracks these requests, so the state is right once text appears.
  • vidconsole_park_cursors() erases it and keeps it off until the next text output. It is called from GOP Blt() (an application such as GRUB gfxterm owns the screen), from ExitBootServices() and from bootm_final(), so the OS never takes over a frame buffer with a cursor on it.
  • Rotated consoles get no cursor (they use another coordinate system); nothing changes for them.
  • No board, SoC or firmware checks; the Apple defconfigs (apple_m1_defconfig, apple_j873_defconfig) enable it.
Evidence

Mac rows: candidate = the Mac's live Stage 2 image with only the gzip'd U-Boot replaced (aura, device trees and config trailer byte-identical), booted once through the aura-try trial path with the trial guard and dead-man armed, then back to production. Health row = Enforcing, systemctl --failed empty, default GRUB entry and next_entry unchanged. U-Boot version in /proc/device-tree/chosen/u-boot,version confirms the build.

Reset-to-kernel time = arm64 counter (cntvct_el0, starts at SoC reset) minus CLOCK_BOOTTIME, sampled 10-20 s after boot:

Mac boot U-Boot reset -> kernel
J413 production 5445237 9.477 s, 9.418 s
J413 trial, unchanged image (control) 5445237 9.035 s
J413 trial, aurora-wip base 91409c2 9.333 s
J413 trial, this PR 713a3321 9.870 s
J316s production 5445237 28.103 s, 28.278 s
J316s trial, this PR 713a3321 28.058 s

Nothing in the boot path draws a cursor: the quiet boot keeps the video console silent, and the blink timer only checks one flag every 50 ms.

QEMU: qemu-system-aarch64 -M virt -device bochs-display, U-Boot qemu_arm64_defconfig + VIDEO/VIDEO_BOCHS/VIDEO_CURSOR, ESP from a vvfat directory with the distro's GRUB EFI binary (ALARM: modules of grub 2:2.16-1 aarch64, Fedora: grubaa64.efi from grub2-efi-aa64-2.12-81.fc45 as shipped). A script drives the U-Boot prompt, the GRUB menu, the editor and the shell over serial and takes a QMP screendump every 125 ms. Toggles = frames that differ from the previous frame in ~2.6 s; box = the pixels that changed (8x16 font, 1280x1024).

step ALARM GRUB 2.16 Fedora GRUB 2.12 CONFIG_VIDEO_CURSOR off
U-Boot prompt idle 5 toggles, cell (3,15) same 0
typed echo abc 5, cell (11,15) same 0
3 x backspace 5, cell (8,15) same 0
GRUB menu 0 (GRUB hides the cursor) 0 0
editor, Down x2 + End 5, cell (34,6) same 0
editor, typed XY 5, cell (36,6) same 0
editor, Left x3 5, cell (33,6) same 0
shell grub> prompt 5, cell (6,9) same 0
shell, typed echo hello 5, cell (16,9) same 0
shell, after Enter 5, cell (6,11) same 0
gfxterm menu (GOP) 0 (U-Boot cursor parked) 0 0

Before commit 1, the shell prompt after the help text was drawn at column 27 while GRUB echoed the typed text from column 6.

Sandbox: ./u-boot -T -c 'ut dm video*' gives the same result on aurora-wip 91409c2 and on this branch: video_ansi, video_text, video_text_12x22, video_truetype*, video_chars, video_context pass; video_bmp*/video_copy fail on both (the test reads tools/logos/*.bmp relative to the build directory).

checkpatch: 0 errors; 2 warnings for the #if IS_ENABLED(CONFIG_VIDEO_CURSOR) around the struct member and the uclass .pre_remove hook, which need the preprocessor.

An ANSI cursor position sequence (ESC [row;colH, ESC [colG and the
relative moves) went through vidconsole_position_cursor(), which also
sets the start of the text line (xstart_frac) to the new column. After
any cursor move a carriage return or newline went back to that column
rather than to column 0, and a backspace at it wrapped to the end of the
previous line. get_cursor_position() counts columns from the line start,
so relative moves and the ESC [6n reply were off by the same amount.

EFI applications position the cursor all the time: the EFI
SetCursorPosition() service sends ESC [row;colH. In the GRUB menu entry
editor and command line every line after a cursor move was drawn at the
wrong column, typed text and the prompt landed apart, and backspace
jumped lines.

Make ANSI moves change only the cursor position, counting columns from
the line start the way get_cursor_position() does.
vidconsole_set_cursor_pos() and vidconsole_position_cursor() keep setting
the line start for callers that place text at a pixel position.

Signed-off-by: Ryan Murray <[email protected]>
The video console draws no cursor. At the U-Boot prompt, and in EFI
applications that use the EFI text console, such as the GRUB menu entry
editor and command line, there is no way to see where typed text goes.
The EFI EnableCursor() service sends ESC [?25h / ESC [?25l, which the
video console ignored.

Add CONFIG_VIDEO_CURSOR. The cursor is an underline across the bottom of
the character cell at the text position, in the text colour, 1/8 of the
cell high (at least 2 pixels). It is taken off the screen when text
output starts and drawn at the new position when it ends, so it follows
typing, cursor moves, line wraps and scrolling. The pixels under it are
saved and put back on erase; a pixel that no longer holds the cursor
colour (the screen was cleared or drawn over) is left alone.

A cyclic function blinks it every 500 ms. Cyclic functions run from
schedule(), which the U-Boot command line and the EFI ReadKeyStroke()
and WaitForEvent() services call while they poll for input, so the
cursor blinks while something waits for a key and costs nothing while
the boot runs. ESC [?25l hides it and ESC [?25h shows it again; a quiet
console (CONFIG_VIDEO_QUIET_BOOT) draws no cursor but still follows
these requests.

Something else may own the screen: an EFI application drawing through
GOP Blt(), or the operating system after ExitBootServices() or bootm.
vidconsole_park_cursors() erases the cursor there and keeps it off until
the next text output, so no cursor is left in the frame buffer the OS
takes over.

Enable it for the Apple machines.

Signed-off-by: Ryan Murray <[email protected]>
@github-actions github-actions Bot added blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 25, 2026
@github-actions

Copy link
Copy Markdown

Merge readiness at d6298e38: not ready yet

Check Detail
CI at head running running: build
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at d6298e38
Conflicts ok none
PR text ok Risk: two-way · all Macs (shared video console code; Apple defconfigs enable it)

Areas: none matched in CODEOWNERS

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@satchlj satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE at d6298e38f197

Blockers: none

Checked:

  • Full diff for blinking text cursor support on the video console
  • CI build and readiness checks at d6298e38f197
Evidence
  • Video console blinking cursor implementation cleanly tracks cursor state, restores cell contents before scrolling/redraws, and keeps non-blinking configurations unaffected.
  • CI at d6298e38f197: 3/3 checks green (build, readiness / readiness, pr-text / pr-text).

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed full diff at d6298e38f197: ANSI cursor positioning preserves xstart_frac, CONFIG_VIDEO_CURSOR bounds-checks and restores only untouched cursor-colour pixels, parks cleanly on GOP blits and OS handover, and cleans up on removal. Exact-head 2-gen Stage 2 trial rows (J413 + J316s), QEMU GRUB, and sandbox ut dm video* all pass with 3/3 CI green.

@DjDeveloperr
DjDeveloperr merged commit c2a5cbc into aurora-wip Nov 25, 2026
3 checks passed
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Eyes-on row: J413 M2 Air, trial Stage 2 with this PR's U-Boot (tree of d6298e38), GRUB menu held: in the menu entry editor (e) and the GRUB shell (c) the cursor blinks and follows the arrow keys and typing. Confirmed by eye.

Note on those two held-menu trials (J413, J316s): both Macs reset about 3 minutes after reaching GRUB and came back on the production image. That is aura's trial watchdog: every aura-try boot runs under a 178 s watchdog until Linux takes it over (WDT_TRIAL_SECONDS in aura src/wdt.h). The resets land 178 s after Stage 2 on both Macs. Ordinary boots don't arm it. The same image booted Linux in every trial that left GRUB in time: 4 unattended J413 trials, 1 J316s trial, and a J316s trial with the GRUB menu visible for 5 s. In QEMU, the same editor/shell key sequence followed by Enter boots the kernel normally.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Row: c2a5cbc (merged) | J616s (M4 Pro, T6040), U-Boot-only Stage 2 trial on fleet89 | PASS: booted U-Boot 2026.07-gc2a5cbc629a6, Enforcing, 0 failed units at 242 s; production restored. Hardware now covered at the merged SHA: J413, J473, J616s (plus J316s at the identical tree 713a3321).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants