Skip to content

fix USB keyboard initialization#2102

Merged
tlaurion merged 1 commit intolinuxboot:masterfrom
notgivenby:fix-usb-keyboard-initialization
May 7, 2026
Merged

fix USB keyboard initialization#2102
tlaurion merged 1 commit intolinuxboot:masterfrom
notgivenby:fix-usb-keyboard-initialization

Conversation

@notgivenby
Copy link
Copy Markdown
Contributor

Summary

This commit solves the issue with the usb keyboard initialization for some boards that needed it. Initially discovered during my wip m900 port. Please see #2101

Initial Problem

Systems with CONFIG_USB_KEYBOARD_REQUIRED=y or CONFIG_USER_USB_KEYBOARD=y need USB keyboard support during initrd/early boot.

Previously, the initrd/init boot script only called:

enable_usb

This enabled USB support, but it did not load the usbhid.ko module required for USB keyboard input.

As a result, systems that depend on a USB keyboard during early boot could be left without keyboard input. This could prevent users from interacting with the system during initrd, including cases where keyboard input is needed to unlock or recover the system.

Solution Description

The solution changes the USB keyboard initialization path so that initrd/init calls:

enable_usb_keyboard

instead of calling enable_usb directly.

The enable_usb_keyboard function in initrd/etc/functions.sh now performs the complete USB keyboard setup sequence:

enable_usb
wait_for_usb_devices
insmod.sh /lib/modules/usbhid.ko || DIE "usbhid: module load failed"

This ensures that when USB keyboard support is required or enabled, the system will:

  1. Enable USB support.
  2. Wait for USB devices to become available.
  3. Load the usbhid.ko USB HID keyboard module.

Changes

  • Updated initrd/init to call enable_usb_keyboard for USB keyboard setup.
  • Updated enable_usb_keyboard in initrd/etc/functions.sh to:
    • Call enable_usb
    • Call wait_for_usb_devices
    • Load /lib/modules/usbhid.ko

Expected Result

USB keyboards are now properly initialized during early boot when CONFIG_USB_KEYBOARD_REQUIRED=y or CONFIG_USER_USB_KEYBOARD=y.

Testing

  • Verified that USB keyboard initialization now follows the full setup path.
  • Confirmed that usbhid.ko is loaded through enable_usb_keyboard when USB keyboard support is enabled.

@tlaurion tlaurion force-pushed the fix-usb-keyboard-initialization branch from c5a7057 to 7d476d4 Compare May 7, 2026 19:03
Signed-off-by: notgivenby <notgivenby@gmail.com>
Signed-off-by: Thierry Laurion <insurgo@riseup.net>
@tlaurion tlaurion force-pushed the fix-usb-keyboard-initialization branch from 7d476d4 to ab308e6 Compare May 7, 2026 19:04
@tlaurion
Copy link
Copy Markdown
Collaborator

tlaurion commented May 7, 2026

@notgivenby i've rebased on master and fixed indentation under ab308e6 but that makes me co-author.

If you're ok with that commit, LGTM and ready to merge, let me know

@tlaurion tlaurion added bug initrd UX port new board addition from existing coreboot port labels May 7, 2026
@tlaurion tlaurion linked an issue May 7, 2026 that may be closed by this pull request
50 tasks
@tlaurion tlaurion self-requested a review May 7, 2026 19:08
Copy link
Copy Markdown
Collaborator

@tlaurion tlaurion left a comment

Choose a reason for hiding this comment

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

fixed indentation in ab308e6

LGTM!

@tlaurion tlaurion force-pushed the fix-usb-keyboard-initialization branch 2 times, most recently from 87a7317 to ab308e6 Compare May 7, 2026 19:14
@notgivenby
Copy link
Copy Markdown
Contributor Author

@notgivenby i've rebased on master and fixed indentation under ab308e6 but that makes me co-author.

If you're ok with that commit, LGTM and ready to merge, let me know

I am very happy about it!

@tlaurion tlaurion merged commit 830b304 into linuxboot:master May 7, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug initrd port new board addition from existing coreboot port UX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

usb keyboard initialization is brocken

2 participants