[PATCH] usb: Make what it takes for "usbkbd" to work in "stdin" clear

Marek Vasut marex at denx.de
Mon Jan 27 23:23:09 CET 2025


On 1/27/25 11:20 PM, Dragan Simic wrote:
> Hello Marek,
> 
> On 2025-01-27 22:55, Marek Vasut wrote:
>> On 1/19/25 7:50 PM, Dragan Simic wrote:
>>> Selecting the CONFIG_SYS_CONSOLE_ENV_OVERWRITE option actually 
>>> prevents the
>>> CONFIG_USB_KEYBOARD option from working as expected, i.e. USB 
>>> keyboards end
>>> up not working as console inputs when "usbkbd" is properly specified 
>>> as part
>>> of the value of the "stdin" environment variable.  Describe this 
>>> clearly in
>>> the two relevant Kconfig files, to prevent any possible confusion.
>>>
>>> In more detail, the console_init_r() function ends up overwriting the 
>>> "stdin"
>>> environment variable so it contains only the devices available at 
>>> that point
>>> (which doesn't include "usbkbd"), while the "usb start" operation is 
>>> performed
>>> much later, at which point the probe_usb_keyboard() function cannot 
>>> assign any
>>> discovered USB keyboards to the console because "usbkbd" is no longer 
>>> present
>>> in the "stdin" environment variable.
>>
>> Wouldn't it be better to patch console_init_r() , check if "stdin"
>> variable contains 'usbkbd' and if so, start USB and register the
>> keyboard as stdin device at this point ? This is called after
>> relocation, so starting USB should be OK to do here. The behavior
>> should then be less confusing to users too.
> 
> Please correct me if I'm wrong, but isn't "usb start" deliberately
> left to be executed as desired by the supported boards, or as part
> of distroboot, i.e. in include/config_distro_bootcmd.h?

It is, but if the user needs USB keyboard as input device, shouldn't we 
probe for that (which yes, will make the start up slower) ?


More information about the U-Boot mailing list