Page 1 of 1

ps2kbd.irx problem

Posted: Mon Oct 12, 2009 4:20 am
by belek666
I have problem with keyboard support in any homebrew program. I can't find any working ps2kbd.irx for my keyboard. In ps2link I get this log:

Code: Select all

PS2KBD: Found a keyboard device
PS2KBD: Connected device
PS2KBD - USB Keyboard Library
PS2KEYBOARD: Configuration set error res 290, bytes 0, arg a8700
290 = 0x122
from usbd.h

Code: Select all

#define USB_RC_ABORTED		0x122	// Operation Aborted
What that mean? How I can fix it?

Thanks for any help.

Posted: Mon Oct 12, 2009 8:38 am
by Mega Man
Maybe there are connection problems:
1. Try to plug it out and reconnect the keyboard.
2. You should only use a USB hub with power supply or connect the keyboard directly to the USB port of the PS2.

There was also a bug in the USB driver (usbd.irx) which could generate such errors, so use a newer USB driver (11.08.2009, SVN rev 1599 or higher)

Posted: Mon Oct 12, 2009 6:42 pm
by belek666
Thanks for reply. I tried reconnect keyboard but it doesn't help. I don't use any USB hubs and I used latest usbd.irx.

I have simply remove "return" function in ps2kbd src where I got error:

Code: Select all

if(resultCode != USB_RC_OK)
    {
      printf("PS2KEYBOARD: Configuration set error res %d, bytes %d, arg %p\n", resultCode, bytes, arg);
      return;
    }  
After that in ps2link I got this:

Code: Select all

PS2KBD: Found a keyboard device
PS2KBD: Connected device
PS2KEYBOARD: Configuration set error res 290, bytes 0, arg a8700
PS2KEYBOARD: Data Recv set res 4, bytes 0, arg a8700

Code: Select all

#define USB_RC_STALL		0x004	// Endpoint Stalled
and leds on keyboard have lighted but it's not working.

Posted: Tue Oct 13, 2009 7:27 am
by Mega Man
The failed call to UsbSetDeviceConfiguration() didn't set the configuration, so every try to use an USB endpoint will stall.
I add here an explanation, because you may to solve the problem by experimenting:
An USB endpoint is a one way pipe to communicate to the USB device. The only way for a device to refuse the communication is to stall. The configuration endpoint 0x00/0x80 is an exception. The endpoint 0x00/0x80 is used to configure the device and is always available. This endpoint allows communication in both directions. The other endpoints need to be activated by selecting a configuration.
The call UsbSetDeviceConfiguration() will activate a configuration. You can ask the device which configuration can be used. The function UsbGetDeviceStaticDescriptor() can read this configuration. I detected that this descriptor is sometimes bad. At least the listed endpoints were mixed up.
So what you can do:
1. Guess the correct configuration number: Replace "conf->bConfigurationValue" in the call to UsbSetDeviceConfiguration() by one number. Normally 1 is working, maybe you will need 2 or 3.
2. Read the configuration number from a working operating system: Connect the keyboard to an Linux and enter the command "lsusb -v" to get all possible configurations. Then look for possible values for bConfigurationValue. You need to select something which supports the boot protocol.

Posted: Tue Oct 13, 2009 9:12 pm
by belek666
I tried guess the correct configuration number (I checked from 1 to 10) and no luck. Then I launched ubuntu and from there I got bConfigurationValue = 1. Again no luck. There must be something wrong in ps2kbd.irx because my keyboard is working with modules from PS2 game (which aren't usable in homebrew).

Posted: Sat Oct 17, 2009 6:31 pm
by Mega Man
Ok, I think the problem is usbd.irx and not ps2kbd.irx, because usbd.irx is responsible for UsbSetDeviceConfiguration. You can try to use a usbd.irx from a PS2 game disc. Some old versions are compatible (at least with ps2kdb.irx). As far as I remember the version included in naplink was working with it. Other USB stuff was not working, but the keyboard.

Posted: Sat Oct 17, 2009 8:43 pm
by belek666
I've tested usbd.irx from naplink and the same error occurred. Also module taken from ps2 game (where my keyboard works) didn't help. I believe there must be bug in ps2kbd.irx.

I found something in ps2kbd. When I uncomment one line (which is printing configuration value) in src:

Code: Select all

  printf("Configuration value %d\n", conf->bConfigurationValue);
  UsbSetDeviceConfiguration(currDev->configEndp, conf->bConfigurationValue, ps2kbd_config_set, currDev);
in ps2link I only got this:

Code: Select all

PS2KBD - USB Keyboard Library

PS2KBD: Found a keyboard device
PS2KBD: Connected device
but keyboard is not working.

Sorry for bad English.

Posted: Sat Oct 17, 2009 10:03 pm
by Mega Man
Sorry, I've no further idea.

The ps2link connection sometimes looses lines if you print too much. You should also modify a printed line to verify that your code reaches the target.