xemu-project / xemu

Original Xbox Emulator for Windows, macOS, and Linux (Active Development)
https://xemu.app
Other
2.79k stars 279 forks source link

Input not working in Cromwell BIOS #1274

Open binarymaster opened 2 years ago

binarymaster commented 2 years ago

Bug Description

Cromwell BIOS does start, but input not working.

Steps to reproduce:

  1. Use latest XboxDev Cromwell BIOS from here: build-20220802-bf9dc2a
  2. Configure it in xemu settings
  3. Make sure keyboard (or a controller) is attached to the first USB slot
  4. Restart emulator
  5. BIOS has started but does not accept inputs

Expected Behavior

Input is expected to work without problems.

xemu Version

Version: 0.7.70 Branch: master Commit: 080022833db0896b8af4482e726200acd51507a0 Date: Sat Sep 10 19:55:39 UTC 2022

Last working in: 0.6.1-20-g21718399f2

System Information

CPU: Intel(R) Core(TM) i3-4010U CPU @ 1.70GHz OS Platform: Windows 8.1 Pro x64 OS Version: Windows 8.1 (Version 6.3.9600) Manufacturer: Intel GPU Model: Intel(R) HD Graphics 4400 Driver: 4.0.0 - Build 10.18.10.4425 Shader: 4.00 - Build 10.18.10.4425

Additional Context

No response

binarymaster commented 2 years ago

I have found older version where USB input works:

Version: 0.6.1-20-g21718399f2
Branch:  master
Commit:  21718399f2680b5d2e48e554f9dfd591f3efc0f2
Date:    Tue Oct 12 08:55:08 UTC 2021

However I'm not sure it's the last build where it worked.

In the Releases section v0.6.5 is the oldest available release, and it's affected by the problem.

Ryzee119 commented 2 years ago

I did some investigation on this and it appears cromwell while sending usb IN tokens does not accept any data (albiet the max packet size is 2 bytes)

So xemu hits this error which causes OHCI to return DATAOVERRUN https://github.com/mborgerson/xemu/blob/22db3304a454b2d289a9d5ea488fa3c3dec836f4/hw/usb/dev-hub.c#L539

In cromwell it hits this error block which causes a reset loop of the usb hub so they never work: https://github.com/XboxDev/cromwell/blob/bf9dc2a5738124113a1cb099835610f7b6ba9184/drivers/usb/core/hub.c#L1041

This prevented all usb hubs from working,

I was able to fix it by applying this patch to cromwell tree. Although probably not the root cause it may provide a hint. Its atleast the reason why usb hubs were not working but keyboards and other peripherals did work.

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 973a31f..c4f467a 100755
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -468,8 +468,6 @@ static int hub_configure(struct usb_hub *hub,

        usb_fill_int_urb(hub->urb, dev, pipe, *hub->buffer, maxp, hub_irq,
                hub, endpoint->bInterval);
-       hub->urb->transfer_dma = hub->buffer_dma;
-       hub->urb->transfer_flags |= URB_NO_DMA_MAP;
        ret = usb_submit_urb(hub->urb, GFP_KERNEL);