Repository navigation
video: show a blinking text cursor on the video console - #74
Conversation
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]>
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
satchlj
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
|
Eyes-on row: J413 M2 Air, trial Stage 2 with this PR's U-Boot (tree of 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 ( |
|
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). |
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 movesANSI cursor moves (
ESC [r;cH,ESC [cG, the relative moves) went throughvidconsole_position_cursor(), which also sets the start of the text line (xstart_frac) to the new column. EFISetCursorPosition()sendsESC [r;cH, and GRUB calls it all the time. So after any move,\r/\nwent back to that column, a backspace at it wrapped to the previous line, and relative moves and theESC [6nreply were off, becauseget_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 wayget_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 onVIDEO_ANSI && CYCLIC)putc/putsof 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.schedule(), which the U-Boot CLI (fgetc) and EFIReadKeyStroke()/WaitForEvent()(viaefi_timer_check()) call while they wait for input. Nothing extra runs while the boot proceeds.ESC [?25l/ESC [?25h(EFIEnableCursor(), 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 GOPBlt()(an application such as GRUB gfxterm owns the screen), fromExitBootServices()and frombootm_final(), so the OS never takes over a frame buffer with a cursor on it.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 --failedempty, default GRUB entry andnext_entryunchanged. U-Boot version in/proc/device-tree/chosen/u-boot,versionconfirms the build.Reset-to-kernel time = arm64 counter (
cntvct_el0, starts at SoC reset) minusCLOCK_BOOTTIME, sampled 10-20 s after boot: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-Bootqemu_arm64_defconfig+VIDEO/VIDEO_BOCHS/VIDEO_CURSOR, ESP from a vvfat directory with the distro's GRUB EFI binary (ALARM: modules ofgrub 2:2.16-1aarch64, Fedora:grubaa64.efifromgrub2-efi-aa64-2.12-81.fc45as 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).echo abcXYgrub>promptecho helloBefore 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_contextpass;video_bmp*/video_copyfail on both (the test readstools/logos/*.bmprelative 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_removehook, which need the preprocessor.