-
Notifications
You must be signed in to change notification settings - Fork 303
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
Replace ST USB stack? #28
Comments
If replacing the USB stack means fixing the weird inexplicable issues, I'm very open to the idea. |
I made an attempt here:
The API is /way/ cleaner - though not really documented... It's working now. buffer was the wrong size... The tinyusb implementation is pretty clean. |
that's a bit off-putting...
Can you elaborate ? tinyusb seems to be MIT-licensed, and if their low-level ST-specific code is restricted to ST (which is probably only the case if they're directly using files from ST's libraries), that shouldn't prevent us from supporting other mcus ? |
It should be. I found that part not fun; but that said, reading the code was MUCH easier than reading ST's code.
Assuming the OP is correct, simply not compiling the ST code into other microcontrollers would be enough. Taht said, I don't think the OP is correct about this. Looks like a BSD-3 lic to me. |
Hi, I am implementing the usb2can protocol for candlelight based on ESP32. esp32's usb stack is tinyusb. currently the open source software tsmaster has successfully enumerated canable devices. I would appreciate it if someone could give me some pointers.
|
I think you have to implement the |
@zigele, did you reference my branch linked above? Marckleinebudde is correct. See my branch's copy of usb_descriptors.c, main.c, and in particular gs_usb.c |
Yes, I have implemented it. However, what I am very confused about is what data I should return to the host. I am stuck with my work. This is my test code. The problem is this code case GS_USB_BREQ_MODE
|
You're not implementing the CONTROL_STAGE_DATA. See my branch's copy of gs_usb.c, line 265 |
Thank you very much for the pointers. It worked. |
Please share the code, once it's working. |
Of course I will. It may take some time to sort out the code and implement the can driver for ESP32. |
Very unfortunate and worrisome results. I implemented the candlelight source code on the ESP32S3 chip, using the tinyusb stack and the cherryusb stack, and got unsatisfactory results. When the CAN bus is running at 1Mbps baud rate and the load exceeds 50%, the usb device endpoint receives a clear feature from the host computer, which causes the bulk in transmission to stop on the device side. I suspect that there is a problem with the driver of the Tsmaster software on the PC side, but I have not found the root cause, which is beyond my capabilities. I am considering dropping the ESP32 and choosing the advance chip instead. |
Oh, that's not good. FWIW I would test with the Linux kernel driver, not with a user space driver. Don't know the quality. Can you still upload the code somewhere? |
I put the relevant source code in this repository. In order to find some bugs, the code was messed up by me.
|
TSmaster use the windows usb driver is https://github.com/HubertD/candle_dll/tree/master/src,I guess。 |
The problem is the "stall". The USB device says something is broken. |
Are you sure ? that driver is nearly unusable as-is. I spent many frustrating hours trying to make it work well at higher bus loads but it seems nearly impossible with just a userland driver that uses winUSB. If they somehow fixed it to work "better", they should have the source code somewhere since it is LGPL; I'd be interested to see that... |
not sure。By decompiling the cando .dll file in its installation directory, it seems that it has partially identical interfaces. But I'm not sure, maybe I can raise an issue with Tsmaster. |
Maybe you can create a capture with wireshark, so we can analyze it, too. A stall is created by the USB device (here the ESP) if something does unexpectedly wrong. Although the windows driver might not be that good, it smells more like a problem with the USB stack on the ESP. During porting of the candlelight firmware to the STM32G0B1 we run into a similar problem. Under high load the device was sending a stall, too. It turned out to be a bug in the USB driver. It wanted to do a read-modify-write of one of the registers in the USB controller, but instead it did a read-clear-modify-write. If a USB USB is send from the PC to the STM32G0B1 between the "clear" and the "write", the USB endpoint is not configured and the controller sends a stall. |
@zigele , did you find out any more on this issue?
@fenugrec, I found that Tsmaster can easily scale in busload so I can have a PCAN FD checking Busload at 87% and the STMF072 candlelight fw board keeps up. It use a cando.dll . I haven't seen any published source which might be avoided by labeling the dll file as cando rather than candle. Meanwhile, in cangaroo v2.3 using the candle.dll I can't get accurate timing at 50ms or less in the single digit bus load range. |
Renaming a file doesn't mean they can bypass LGPL requirements...
As-is, the publicly available source for candle.dll is unusable, as you have described. I spent some time a while back trying to improve it, tried many things. Never published because it was still unreliable garbage. But this is getting off-topic; this issue is about replacing the ST USB stack. |
Hello @HubertD! I saw you mention this in a pull request and it's something I'm likely going to have to address. I haven't dug into it too deeply but tinyusb is a stack that claims to support many STM32 µCs -- I would have to add STM32G support myself, but it has STM32F support.
Anyway, if any of us start any serious work on this, we can use this issue to track it. Thanks!
EDIT: I forgot to mention, the only real problem with it is that the license pollution by adding the restriction that it cannot be used on non-ST products (which seems a tad bit silly to me anyway). As we don't support any non-ST chips (yet), it's only an issue of the license being non-free.
The text was updated successfully, but these errors were encountered: