USB Keyboard support in U-Boot

Published on May 30, 2013

Archived Notice

This article has been archived and may contain broken links, photos and out-of-date information. If you have any questions, please Contact Us.

640px-Serial_port Serial ports have been around for over 40 years and many of us embedded folks don't leave home without them.

In recent years, they've been harder to come by though. They're no longer standard on PCs, and laptops generally need a USB to serial adapter.

We're also shipping devices in enclosures without serial port connectors, so changing a U-Boot setting through the serial port requires disassembly.

To address this, we recently enabled USB Keyboard support to our U-Boot configuration files and added some commands to our default boot script that enable it if boot fails

The links above show the details:

  • The CONFIG_USB_KEYBOARD and CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP macros must be set in the board.h file.
  • The usb start command starts the USB subsystem, and
  • You can tell U-Boot to read keys by adding usbkbd to the stdin environment variable.

There is a small down-side to this. Because polling the keyboard is relatively slow, you might see serial port buffer overruns if pasting lots of data into U-Boot from the serial port. To disable the USB keyboard, you can just set things back:

U-Boot > setenv stdin serial

Availability

This code is enabled in our staging branch of our Github tree, and will be enabled in production very soon.