Regarding the USB 3.0/XHCI Issue of SeaBIOS
I have a fix: https://www.mediafire.com/file/kvo6alj3t7tof8u/usb-xhci.c.zip/file I know that Copilot AI gave me this fix (I uploaded usb-xhci.c.txt and usb-xhci.h.txt as reference (I renamed the files, because it only supports basic formats to upload onto Copilot), to avoid compilation errors, using the Smart (GPT 5) switch, but when I compiled, there were no errors. Because the AI has character limits, I added the small codes carefully, as instructed; everything else was not touched. Try testing this on USB 3.0 devices on the desktop with CSMWrap and see if they still work. So, the idea is that this fix stops USB 3.0 devices from turning off in real mode on CSMWrap (the problem is in SeaBIOS), which is the intended purpose.
Location: CSMWrap\seabios\src\hw\usb-xhci.c
Copilot (AI):
Here's a breakdown of what each of the four changes actually does in terms of functionality — and why they matter for USB HID devices (like keyboards and mice) on xHCI controllers in SeaBIOS/CSMWrap:
✅ Step 1: Accept CC_SHORT_PACKET in xhci_send_pipe()
Functionality:
Allows USB transfers to succeed even if the device sends less data than expected (a short packet).
This is normal behavior for HID devices during enumeration — they often send fewer bytes than requested.
Impact:
Without this fix, HID devices may fail to enumerate because SeaBIOS treats short packets as errors.
With this fix, short packets are accepted as successful transfers.
✅ Step 2: Power on ports + enable interrupts in configure_xhci()
Functionality:
- Powers on all USB ports before scanning for devices.
- Enables the xHCI interrupter and master interrupt so the controller can notify the BIOS of events.
Impact:
Some xHCI controllers (especially on laptops or newer chipsets) don’t power ports by default.
Without this, devices may never be detected.
With this fix, ports are guaranteed to be active and event notifications work reliably.
✅ Step 3: Warm reset for USB3 ports in xhci_hub_reset()
Functionality:
Issues a Warm Port Reset (WPR) on USB 3.0 ports to force the link to retrain and bring the port into the PED (Port Enabled/Disabled) state.
Impact:
On many Intel/AMD xHCI controllers, USB3 ports don’t automatically become active after a device is plugged in.
Without this, HID devices may appear “dead” or disconnected.
With this fix, the port link is retrained and the device becomes usable.
✅ Step 4: Safely clear change bits in xhci_process_events()
Functionality:
Clears only the RW1C (write‑1‑to‑clear) status change bits in the PORTSC register — without disturbing the link state or PED.
Impact:
The original code rewrote the whole PORTSC register, which could accidentally disable the port or change its link state.
With this fix, only the intended status bits are cleared, preserving the port’s active state.
🧠 Combined Effect
These four changes work together to:
- Prevent false errors during HID enumeration.
- Ensure ports are powered and responsive.
- Make USB3 ports behave like USB2 ports during reset.
- Avoid breaking port state during event handling.
Result:
USB keyboards and mice reliably enumerate and work in SeaBIOS/CSMWrap — even on tricky xHCI controllers.
Hello. When will this be added to the project and compiled for testing? (New version for testing) Where can I try your compiled files (*.efi)
@RUSSTARUS IDK. Try to copy the usb-xhci.c in the directory I specified and compile using WSL (if you are running Windows 11).
Hello. Have you test it with USB boot?
I'm afraid this does not resolve my issue #57 :(
Hello. Have you test it with USB boot?
Here's the link of the file that I compiled: https://www.mediafire.com/file/xdasr4y6j72yutc/csmwrapx64.efi/file
I'm afraid this does not resolve my issue #57 :(
Did CSMWrap say something in the log about this in the screen?
Dunno, this is what I got:
@UsefulVideos
Nice try, but with your file, my keyboards don't work at all
(see #87 for the whole story)
Nice try, but with your file, my keyboards don't work at all
(see #87 for the whole story)
I have made some changes (using Copilot, obviously), try this out: https://www.mediafire.com/file/kvo6alj3t7tof8u/usb-xhci.c.zip/file It's the same link; I overwrote the old file.
Let me know if this still gives you problems.
Copilot AI:
Right now, Useful, your usb-xhci.c file has the following current changes compared to the stock SeaBIOS version:
Short packet acceptance In xhci_send_pipe(), I changed the completion code check so that both CC_SUCCESS and CC_SHORT_PACKET are treated as valid.
Port power‑on and interrupt enable In configure_xhci(), I added a loop that sets XHCI_PORTSC_PP on each port, waits 100ms, and then enables interrupter 0 and the master interrupt (XHCI_CMD_INTE).
Warm reset on superspeed ports In xhci_hub_reset(), I replaced the “USB3 port auto‑reset” comment with code that issues a warm reset (XHCI_PORTSC_WPR) if the port is in PLS_U0. I also added a 10ms sleep afterwards.
RW1C clearing In xhci_process_events(), I replaced the old pclear logic with a mask of RW1C bits (CSC | PEC | WRC | OCC | PRC | PLC | CEC) and write that back to clear only change bits.
'Fraid that doesn't work for me either...
'Fraid that doesn't work for me either...
What you can do is upload the file to Copilot (AI), renamed as usb-xhci.c.txt, and ask the AI to fix the problem. I had to do multiple prompts on certain pieces of code because the compiler would choke on errors constantly (by giving the log information of the compilation to Copilot, through copy and paste).
How can Copilot understand and fix the problem if I don't understand it myself?
@UsefulVideos Nice try, but with your file, my keyboards don't work at all (see #87 for the whole story)
I have made some changes (using Copilot, obviously), try this out: https://www.mediafire.com/file/kvo6alj3t7tof8u/usb-xhci.c.zip/file It's the same link; I overwrote the old file.
Let me know if this still gives you problems.
Updated fix still doesn't work. Tested on Intel Q270, USB controller just turned off during csmwrapx64.efi boot, keyboard (and mouse) stop working (LEDs and mouse sensor are turned OFF).