-
Notifications
You must be signed in to change notification settings - Fork 5
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
Upstream this driver #2
Comments
Those "improvements" are workarounds, the right place to fix that bug is in https://github.com/linklayer/cantact-pro-fw instead, not on |
Well, NXPs solution for this errata is to send NAK. If the driver is still sending messages in the format of the length 4 + N*16 and there is no change in the firmware the problem would still exist. There are other things to even worry more about in the firmware. Take a closer look at the can.c RAM assignment. One RX FIFO element uses 64 bytes data + 8 bytes of additional RAM per element = 72 bytes |
Ah, I see, thanks for explaining @moechr, much appreciated! I've been quite disappointed by the overall CANtact "Pro" quality lately. I guess what upsets me the most is @ericevenchick not showing up for support after the @crowdsupply campaign (/cc @storborg @lifton?)... despite multiple bugs piling up for userspace tooling, documentation and firmware sides for the affected cantact repositories. At this point I wouldn't recommend this dongle for any production use until the firmware, tooling and docs don't see thorough testing, bug squashing and benchmarking so that folks know the actual limits of this thing... it's definitely not worth 140eur at this point in time, IMO. |
@brainstorm I totally agree with you. Simple "loop-tests" as a verification of the performance of a CAN coupler are way to less. There is a lot to to on the Cantact Pro project. As @ericevenchick mentioned - his CAN products are for hacking - maybe the hacking starts on the product itself ;) |
@pfink-christ as discussed, I've moved our discussion here (responding to your comment in #3 )
Yep, this makes sense, I agree. As for the hack, I assume you're talking about
Yeah spot on, I believe https://github.com/candle-usb/candleLight_fw is the main repository. I'll try to contact them over the next week or so in an attempt to get them involved in this. I think that as long as they're aware of it, we'll be fine. As far as discussion goes, can we open up a discussion board on git (https://docs.github.com/en/discussions/quickstart) even if that's in your repo? Or would you prefer to keep discussion here?
I've got the same problem with time at the moment but will try to take a look at this over the weekend. I'll fork your repo, add my VID/PID, tidy a couple of things up and will submit a PR. Then we can discuss further on how to proceed. Cheers |
The easiest would be to create a PR where you add the various bits for |
No, I'm talking about the length of the transmitted gs_host_frame. Because the data part has to have
In my previous implementation the struct had the maximum size and only the necessary length was transmitted via usb. The struct was cut off so to speak. That was the hacky part where I wanted to find a better solution.
IMHO not easily possible. The suggested workaround by NXP would require to add some usb rx/tx control and detection when to send a NAKed TX transfer. I don't think that's useful. Sending one byte more in this case isn't too hard on the performance, whereas NAKing a transfer and causing complete dummy transfers would sum up in a bigger total performance dip. At least that is how I see it in theory. As a benefit it would keep the complexity on the firmware and kernel driver side as it is. I reworked the code and found a - in my eyes - quite good solution without changing too much. @marckleinebudde Could you help me out on this macro here? Do I really need to supply
That was also my line of thinking. Should we also list/define the feature bits in the kernel driver even if not used? 6 and 7 are not used at the moment but are defined in the candlelight firmware. Currently I had them removed, but I guess it wouldn't hurt adding them back. |
@BennyEvans are there any other errata relevant for us (NXP LPC... users) to additionally keep in mind or were they only relevant on your custom hardware? Because I don't think we are aware of any others. |
I have already some patches that add these bits to the driver. Are you subscribed to the linux-can mailing list? I'll send these patches around. |
Have a look at |
Yes, I am subscribed.
Thanks. That works for the instances where I have a pointer to gs_host_frame available, but not in gs_can_open, where gs_host_frame is not used, but only its size is relevant e.g. for allocation of usb rx buffer with usb_alloc_coherent. I could add a pointer to gs_host_frame, but it would only be used to calculate the size with struct_size. old: |
Make it so.
Sounds good. |
I've just gone over my notes. Errata "3.22 USB.15: USB high-speed device in endpoint TX data corruption" is the only relevant issue that I'm aware of. |
@pfink-christ may you please provide a link to the repository you're working out of? I submitted a PR to the branch and repository I thought you were working out of but you then deleted the branch about 10 minutes after which closed the PR. Just want to all be on the same page here. |
Hi all, I've created a fork of this repo and implemented compatibility in the driver for both existing classic CAN devices and newer FD devices. I'd appreciate if you could have a look over it and test the functionality. Unfortunately, I don't currently have access to an FD device so I have only confirmed that's it's working with a Canable device running the candlelight firmware. Link to the repo: https://github.com/BennyEvans/gs_usb_fd I took @pfink-christ version when it was available and have updated the @marckleinebudde as you've had some experience modifying this driver, I'd appreciate any feedback. @pfink-christ Apologies if you were working out of another repository. If you were and can share it, perhaps we can analyse each other's versions and move forward towards something we can submit to mainline. I've kept both our devices VID/PID in my version. Edit: Feel free to submit any PRs. Cheers |
Hey @BennyEvans,
Make sure to have a clean patch stack. Only change one thing at a time. Feel free to use https://github.com/marckleinebudde/linux/commits/gs_usb_fd as a base. It already adds the missing bit definitions to the driver. Speaking of clean patches, I myself have to add proper patch descriptions to all patches. |
Thanks @marckleinebudde I've not pushed code into mainline before so it's all a bit of a learning curve. I've forked the repository you've linked and will commit changes to that in smaller chunks tomorrow. Is this what's expected? However, this being said, I'll still require someone to test my version of the driver with a CAN FD device as I currently don't have access to one. Cheers |
ACK
I have a board here. |
@BennyEvans my current working repository is not online because I want to test my code properly before I publish something. That's also the reason I deleted my old working branch, so that nobody uses or works on this not anymore up to date codebase. Uff... @marckleinebudde I rebased my changes on your repository, but I realized that your commit marckleinebudde/linux@86f7bf6, which adds the timestamp after the data field in the struct, kinda killed my whole idea of the flex array. What do you think about the idea of including the timestamp in the data array or is something like the following better? The size calculation would have to be adapted as well (decrease the flex array length by the size of the
|
Although time stamps are not supported in the Linux driver yet, we should keep this in mind.
I'd like to have the timestamp as a separate
I think you can use an anonymous struct.
Let's call it
|
@pfink-christ no problem, don't want to step on any toes, just trying to help. I'll wait until you've made your code public before proceeding any further. Thanks for your work on all this. Please keep me updated. |
Hi everybody, I hope this doesn't come across as offtopic, but after relatively long intensive runs of
Possible driver memory leak? $ free
total used free shared buff/cache available
Mem: 440412 103808 29892 22432 306712 260840
Swap: 102396 256 102140
$ cat /proc/cpuinfo
processor : 0
model name : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS : 697.95
Features : half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xb76
CPU revision : 7
Hardware : BCM2835
Revision : 000e
Serial : 000000007c696cc1
Model : Raspberry Pi Model B Rev 2
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 15G 6.7G 7.1G 49% /
devtmpfs 183M 0 183M 0% /dev
tmpfs 216M 0 216M 0% /dev/shm
tmpfs 216M 22M 194M 11% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 216M 0 216M 0% /sys/fs/cgroup
/dev/mmcblk0p1 253M 49M 204M 20% /boot
tmpfs 44M 0 44M 0% /run/user/1000
$ uname -a
Linux raspberrypi 5.10.17+ #1421 Thu May 27 13:58:02 BST 2021 armv6l GNU/Linux How could I debug this further? Restarting the interface is ineffective, it needs a full reboot to be back into working shape. |
Hey @brainstorm, you can try to increase the CMA size: https://elixir.bootlin.com/linux/v5.15/source/Documentation/admin-guide/kernel-parameters.txt#L638 |
Thanks! What'd you put as a reasonable value given the hardware outlined? |
Look at your kernel log and search for CMA, double that size:
|
Thanks! That explains things, before rebooting:
After reboot:
So I bumped it to
I'll report back if it fails again (not entirely sure why |
I think the memory gets fragmented over time.... |
My compiler is currently fine with it, but the setup from my colleague had some issues with DECLARE_FLEX_ARRAY on Friday. I think some additional tests would be good once the last issue below is cleared.
The idea was to be able to do something like this:
Because now struct_size reports size = 88 when hf_data_len = 64. If my math is correct it's exactly sizeof(struct classic can) = 12 too long. Using a macro again would be a practical solution or reducing hf_data_len by 12, which I don't like for obvious reasons. |
Use |
You are welcome. =) ...quite some more changes 😄 Awesome! We tried to reproduce your setup, where you are losing frames, but not even CANtact Pro lost frames with these commands in our setup (I was told that still the original CANtact Pro firmware is on our device):
What bitrate did you use? When omitting I missed that yesterday evening at first and it seems you pulled it faster than I was able to force push my reword (or you changed it back? - I looked it up, because I wasn't sure myself) -> marckleinebudde/linux@f2c7dab "an union" -> "a union"
I have no objections. You can add me or I can do it myself in a follow up commit.
Works for me.
Makes sense. I think this survived from a former implementation before the union and I was too focused on changing as little as possible.
ACK
Wasn't completely aware of classic_can being used if the device supports CAN-FD, but you are of course right.
I thought about it and because we didn't see any corruption there I later forgot about that possibility. Or maybe we were just focused too much on testing FD, that we did't notice it. Thanks for adding it.
Again remains from the previous implementation cycle where this was necessary. Sorry for not cleaning up properly.
ACK
ACK
ACK Tested and Signed-off-by me :) Seems like @ericevenchick has the last word then. |
Yes I "fixed" that, but just found out, that "a union" is correct. Will fix.
Let's give him some time. He has modified the original GPL driver, so the
500 kbit/s on a imx6 single core
The no buffer space available error is expected to happen....I'll test on other SoCs with other USB host controllers. |
Thanks for all of your work on this @pfink-christ and @marckleinebudde |
We actually tested on a dual core i.MX6DL where we didn't see any lost packages, but maybe we missed something else in our setup. 🤷 |
Hi all. Thanks for all the work on this. I've been away from this project for some personal reasons but it's great to see the work done here! Patch is signed-off-by me too. |
The CANtact FD and other devices implement a gs-usb compatible USB protocol. The protocol has been extended to support CAN-FD and the changes on the Linux gs_usb driver will be mainlined soon. This patch adds the new GS_CAN_MODE_*, GS_CAN_FEATURE_* and GS_CAN_FLAG_* bits as well as struct gs_host_frame_canfd to the candlelight driver. This is mainly for documentation purpose, as the STM32F042 and STM32F072 don't support CAN-FD. But there are some ports to CAN-FD capable STM32 µC that can make use of these definitions. [1] linklayer/gs_usb_fd#2
Hello @BennyEvans,
I've send a PR that adds the CAN-FD related bits to the candlelight fw: candle-usb/candleLight_fw#79 |
Hi , just dropping in to introduce myself - I'm indeed the de-facto maintainer of candleligh_fw (Hubert "gave me the keys" and has not been involved recently). This seems like a low-impact change for our firmware (the stm32f042 / f072 we target do not even support CAN-FD) and have no objection to cooperating. The less quirks and special cases in the mainline kernel driver, the better. We've had some users doing some isolated work on FD (e.g. candle-usb/candleLight_fw#21 ) but not sure what came of it. |
Hey, I just found an overlap in the USB request ids:
As the As the CANtact Pro is out there I'll add a workaround for the Do we need workarounds for other devices and/or regards, |
The CANtact FD and other devices implement a gs-usb compatible USB protocol. The protocol has been extended to support CAN-FD and the changes on the Linux gs_usb driver will be mainlined soon. This patch adds the new GS_CAN_MODE_*, GS_CAN_FEATURE_*, GS_USB_BREQ_DATA_BITTIMING, and GS_CAN_FLAG_* bits as well as struct gs_host_frame_canfd to the candlelight driver. This is mainly for documentation purpose, as the STM32F042 and STM32F072 don't support CAN-FD. But there are some ports to CAN-FD capable STM32 µC that can make use of these definitions. [1] linklayer/gs_usb_fd#2
Apologies @marckleinebudde, I had completely forgotten about doing this. Thanks for taking the lead on it.
I believe the CANtact Pro is currently the only production device using this driver for CAN FD and thus, no other production device should be using the Cheers, |
Makes sense. |
First of all - happy new year to all 🎉🧨💥 sorry for being a bit late....didn't check my business mails any earlier.
Thanks @marckleinebudde for your scrutiny! No objections from my side, as we can still move the bits around in our firmware to match the driver. We currently only have a low number of test devices around, where updating the firmware will be no problem at all and become necessary anyway when mainline support is there. |
The CANtact FD and other devices implement a gs-usb compatible USB protocol. The protocol has been extended to support CAN-FD and the changes on the Linux gs_usb driver will be mainlined soon. This patch adds the new GS_CAN_MODE_*, GS_CAN_FEATURE_*, GS_USB_BREQ_DATA_BITTIMING, and GS_CAN_FLAG_* bits as well as struct gs_host_frame_canfd to the candlelight driver. This is mainly for documentation purpose, as the STM32F042 and STM32F072 don't support CAN-FD. But there are some ports to CAN-FD capable STM32 µC that can make use of these definitions. [1] linklayer/gs_usb_fd#2
@marckleinebudde your latest version is currently not online somewhere, is it? I guess you are going to send the patches upstream when you are ready and when you have time for it? Or are there still open issues that I could help with? Or maybe some more testing,...? |
Hey @pfink-christ, I just pushed my latest work-in-progress to: EDIT: the driver is now on it's way to upstream. I had to split the So testing would be good. |
CANtact Pro from Linklayer is the first gs_usb compatible device supporting CAN-FD with a different HW and re-written candlelight FW. Support for CAN-FD is indicated by the device setting the GS_CAN_FEATURE_FD flag. CAN-FD support is requested by the driver with the GS_CAN_MODE_FD flag. The CAN-FD specific data bit timing parameters are set with the GS_USB_BREQ_DATA_BITTIMING control message. This patch is based on the Eric Evenchick's gs_usb_fd driver (which itself is a fork of gs_usb). The gs_usb_fd code base was reintegrated into the gs_usb driver, and reworked to not break the existing classical-CAN only hardware. Link: linklayer/gs_usb_fd#2 Co-developed-by: Eric Evenchick <[email protected]> Signed-off-by: Eric Evenchick <[email protected]> Signed-off-by: Peter Fink <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
CANtact Pro from Linklayer is the first gs_usb compatible device supporting CAN-FD with a different HW and re-written candlelight FW. Support for CAN-FD is indicated by the device setting the GS_CAN_FEATURE_FD flag. CAN-FD support is requested by the driver with the GS_CAN_MODE_FD flag. The CAN-FD specific data bit timing parameters are set with the GS_USB_BREQ_DATA_BITTIMING control message. This patch is based on the Eric Evenchick's gs_usb_fd driver (which itself is a fork of gs_usb). The gs_usb_fd code base was reintegrated into the gs_usb driver, and reworked to not break the existing classical-CAN only hardware. Link: linklayer/gs_usb_fd#2 Co-developed-by: Eric Evenchick <[email protected]> Signed-off-by: Eric Evenchick <[email protected]> Signed-off-by: Peter Fink <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
CANtact Pro from Linklayer is the first gs_usb compatible device supporting CAN-FD with a different HW and re-written candlelight FW. Support for CAN-FD is indicated by the device setting the GS_CAN_FEATURE_FD flag. CAN-FD support is requested by the driver with the GS_CAN_MODE_FD flag. The CAN-FD specific data bit timing parameters are set with the GS_USB_BREQ_DATA_BITTIMING control message. This patch is based on the Eric Evenchick's gs_usb_fd driver (which itself is a fork of gs_usb). The gs_usb_fd code base was reintegrated into the gs_usb driver, and reworked to not break the existing classical-CAN only hardware. Link: linklayer/gs_usb_fd#2 Co-developed-by: Eric Evenchick <[email protected]> Signed-off-by: Eric Evenchick <[email protected]> Signed-off-by: Peter Fink <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
CANtact Pro from Linklayer is the first gs_usb compatible device supporting CAN-FD with a different HW and re-written candlelight FW. Support for CAN-FD is indicated by the device setting the GS_CAN_FEATURE_FD flag. CAN-FD support is requested by the driver with the GS_CAN_MODE_FD flag. The CAN-FD specific data bit timing parameters are set with the GS_USB_BREQ_DATA_BITTIMING control message. This patch is based on the Eric Evenchick's gs_usb_fd driver (which itself is a fork of gs_usb). The gs_usb_fd code base was reintegrated into the gs_usb driver, and reworked to not break the existing classical-CAN only hardware. Link: linklayer/gs_usb_fd#2 Co-developed-by: Eric Evenchick <[email protected]> Signed-off-by: Eric Evenchick <[email protected]> Signed-off-by: Peter Fink <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
Thanks again for all your work on this @marckleinebudde @pfink-christ. I've been away for the past few weeks but will will jump in over the next few days and perform some further testing. |
FYI: I've send a pull request to net-next/master with CAN-FD support https://lore.kernel.org/all/[email protected]/ |
CANtact Pro from Linklayer is the first gs_usb compatible device supporting CAN-FD with a different HW and re-written candlelight FW. Support for CAN-FD is indicated by the device setting the GS_CAN_FEATURE_FD flag. CAN-FD support is requested by the driver with the GS_CAN_MODE_FD flag. The CAN-FD specific data bit timing parameters are set with the GS_USB_BREQ_DATA_BITTIMING control message. This patch is based on the Eric Evenchick's gs_usb_fd driver (which itself is a fork of gs_usb). The gs_usb_fd code base was reintegrated into the gs_usb driver, and reworked to not break the existing classical-CAN only hardware. Link: https://lore.kernel.org/all/[email protected] Link: linklayer/gs_usb_fd#2 Co-developed-by: Eric Evenchick <[email protected]> Signed-off-by: Eric Evenchick <[email protected]> Signed-off-by: Peter Fink <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
Awesome! Thanks for all of your work on this @marckleinebudde @pfink-christ. Appreciate it. |
So... What's the current status of upstreaming this driver? |
It's mainline since v5.18. |
@marckleinebudde thanks a lot! |
We would like to get this driver into mainline linux kernel. Has anybody already done work in that direction? @ericevenchick or somebody else?
I think that it won't be accepted as a new driver as it is right now, because it's largely a copy of what's already there in gs_usb.c.
In my opinion the best way would be to adapt the upstream gs_usb.c in a way that makes it work with the original gs_usb devices and autodetect the newer fd devices. Opinions, thoughts?
I also saw @marckleinebudde and @hartkopp around here having likely the most experience with mainline patch submitting....what do you think? Would you keep it a separate driver?
We also have some improvements ready like @moechr shared the errata bug at linklayer/cantact#19
This would solve #1, too.
The text was updated successfully, but these errors were encountered: