-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
USB: Replace OHCI USB host library #438
Conversation
Amazing! 🎉 |
Misses adjustment of the README.md |
Ive made a sdl_joystick driver using this new stack. It does not use hal/input.c at all and instead directly calls the usb HID APIs, so hal/input.c can be completely removed. I've tested this on SDLPopX, OpenTyrian, Commander keen, Xenium-Tools, sdl_gamecontroller sample and NevolutionX It also supports native Xbox360, Xbone controllers too! To test replace your lib/sdl/SDL2 with this fork.
|
fdaf570
to
6720601
Compare
f7d93e5
to
72fd41d
Compare
6edbfaa
to
54d25d8
Compare
ecd3610
to
ab3254b
Compare
@@ -97,4 +121,4 @@ int main(void) | |||
} | |||
|
|||
return 0; | |||
} | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misses Newline 😏
samples/usb/main.c
Outdated
*/ | ||
void device_connection_callback(UDEV_T *udev, int status) | ||
{ | ||
debugPrint("Device connected on port %u (PID: %04x VID: %04x)\n", udev->port_num, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do these ports look like? If they are USB ports and not gamepad ports, then that's relevant for the message, in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are the number of the USB hub port. I have updated the wording here.
samples/usb/main.c
Outdated
|
||
usbh_core_init(); | ||
usbh_install_conn_callback(&device_connection_callback, &device_disconnect_callback); | ||
debugPrint("Plug and unplug USB devices to test\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a bit more explicit.
People might assume that this will test their gamepad like that XDK sample that everybody loves (with the 3D gamepad).
This, however, merely seems to show plug and unplug events?
debugPrint("Plug and unplug USB devices to print USB device VID and PID\n");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated the debug print here to make it clearer what it is doing
samples/usb/main.c
Outdated
|
||
void device_disconnect_callback(UDEV_T *udev, int status) | ||
{ | ||
debugPrint("Device disconnected on port %u (PID: %04x VID: %04x)\n", udev->port_num, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think I might prefer order 1. VID, 2. PID; but I'm not sure what other common USB tools use. (Idea is to visually group them by manufacturer first.. so that should come first)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me. Updated this
@@ -0,0 +1,5 @@ | |||
XBE_TITLE = nxdk\ sample\ -\ usb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think just calling this sample "usb" is not ideal; but I have trouble coming up with my own name.
Just to clarify, I mean both: XBE title, but more importantly, pathname
(I'd assume there'll be different USB samples eventually, at least some of which will likely deserve a "usb-" prefix)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps call it hotplugging
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree that it needs a better name. This sample really just shows the absolute basic core init so it atleast builds during ci tests. People might get drawn into it for gamecontroller stuff when they should be using SDL_gamecontroller.
I am working on an 'all-in-one` usb sample. https://github.com/Ryzee119/nxdk_ohci_test/blob/xbox/main.c, advantage being it includes all source files in ci runs to catch issues better.
lib/usb/Makefile
Outdated
|
||
.PHONY: clean-usb | ||
clean-usb: | ||
$(VE)rm -f $(USBH_OBJS) $(NXDK_DIR)/lib/libnxdk_usb.lib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this Makefile should be part of the USB submodule, unless that submodule remains platform unspecific (which, to be honest, sounds like a good idea to me; but only if we can attract other stakeholders / convince upstream to submodule it)
Other maintainers might have different thoughts on this matter though.
.gitmodules
Outdated
@@ -31,3 +31,6 @@ | |||
[submodule "lib/sdl/SDL2_image"] | |||
path = lib/sdl/SDL2_image | |||
url = https://github.com/libsdl-org/SDL_image.git | |||
[submodule "lib/usb/ohci_usbhostlib"] | |||
path = lib/usb/ohci_usbhostlib | |||
url = https://github.com/Ryzee119/ohci_usbhostlib.git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Where to discuss Ryzee119/libusbohci@master...xbox?
- What's Ryzee119/libusbohci@xbox...timing?
- What are your plans for https://github.com/Ryzee119/nxdk_ohci_test/tree/master?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I created a self PR, happy to discuss stack specifics there. Xbox port: Ryzee119/libusbohci#2
- Timing branch was a initial attempt to minimise/remove some of the blocking delays in the stack. Have not spent any time on this yet. afair the whole stack is non-block except during device connection/removal/suspend stuff
- Master branch is/was intended to be a clean copy of upsteam to track diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a self PR, happy to discuss stack specifics there. Ryzee119/libusbohci#1
Please add this information to the PR description - I assume it could be more important than the discussion on this repository.
What are your plans for https://github.com/Ryzee119/nxdk_ohci_test/tree/master?
Master branch is/was intended to be a clean copy of upsteam to track diff.
I should probably have made a separate comment, but I was asking about "nxdk_ohci_test" and not "ohci_usbhostlib"; trying to get an idea of the existing ecosystem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are your plans for https://github.com/Ryzee119/nxdk_ohci_test/tree/master?
I think it could make a good nxdk sample if/when i clean it up to it suitable quality. Probably something I will do in the near future. See the 'xbox' branch for something a bit better quality.
e5da652
to
87a4962
Compare
This is fantastic!
I've invited you to the xboxdev org if you want to move it |
eaabadd
to
f835fe6
Compare
This PR was merged in a bad state - XboxDev/nxdk-sdl@60ff410 is not part of the XboxDev git repo. GitHub only finds it because it's part of the same fork tree. |
This PR replaces the legacy 'hacked' together linux usb stack currently in nxdk with a new library.
Note: CI will fail on the sdl samples because I havent update theIt should work now, but I have submoduled in own SDL2 fork. XboxDev/nxdk-sdl#38 will need to be merged and SDL2 submodule update prior to merge.hal/input.c
code yetThis library was developed by OpenNuvoton (https://github.com/OpenNuvoton) who are a large manufacturer of ARM based embedded microcontrollers. This library was intended for use on their range of chips with OHCI hardware. I specifically imported it from https://github.com/OpenNuvoton/N9H30_emWin_NonOS/tree/master/Library/UsbHostLib with some modifications to make it xbox friendly. The largest change is the separation between virtual and physical memory which is not really a concept on microcontrollers.
The library has some advantages over the current implementation:
**I have thoroughly tested this on my own repo projects. Some outstanding aspects: **
Untested on 1.0 xboxes with daughterboard. I would expect this to have no issues though.Has been tested ok!PR does not include changes tosdl_joystick driver rewritten. All old features plus more. (Rumble, hotplugging etc)hal/input.c
, consequently sdl2 joystick/gamecontroller will break. I am happy to do this work but would like some feedback on the preferred APIs going forward.Currently the ohci library is included as a submodule to my personal repo. This should either be migrated here or commited directly into nxdk (or it can stay linked to my repo, I dont mind)Its here https://github.com/XboxDev/libusbohci.The mass storage class driver has been tested, but disabled in this PR due to the fact it is hardcoded to use FATFS. I think this requirement should be removed to allow other filesystem types (FATX etc). I can do this in a follow up PR.FATFS code removed. This class driver just supports standard SCSI needed for MSC. User filesystem drivers need to be linked in.