-
Notifications
You must be signed in to change notification settings - Fork 282
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
Socketcan candump hardware timestamp usage #100
Comments
The Linux driver doesn't support timestamps, yet, but this can be added. But I don't know about the status of the firmware. |
it appears our firmware has had hw timestamps since 56192e7 |
@marckleinebudde ah yes I see that gs_usb doesn't have the timestamp_us in the frame: https://github.com/torvalds/linux/blob/master/drivers/net/can/usb/gs_usb.c#L216 but the firmware does https://github.com/candle-usb/candleLight_fw/blob/master/include/gs_usb.h#L256 So since the kernel seems to support this it would be relatively easy to add to the gs_usb module? |
hopefully :) Create a new struct: struct classic_can_ts {
u8 data[8];
u32 timestamp_us;
} __packed; Add it to the Adjust the Add Add timestamping infrastructure like in Use the |
Thanks for the pointers. I'll have a look and see where I get. |
@marckleinebudde I had time to look at this today and have a working fork: torvalds/linux@master...tuna-f1sh:linux:gs_usb_hwts It's pretty much as you said. The worker grabs the reference count from the BREQ_TIMESTAMP every 3600 seconds (30 mins) - since the TIM2 is clocked at 1 MHz (rather than 48 MHz like the MCP) it would roll over after 4294 seconds (71 mins). Maybe this is overly conservative? Then each frame sets the hardware timestamp. I've tested the function and it appears to work as intended. Couple of questions:
|
Let's move the discussion to the linux-can mailing list. http://vger.kernel.org/vger-lists.html#linux-can -> https://lore.kernel.org/20220826104629.2837024-1-mkl@pengutronix.de |
As far as this firmare is concerned, this can probably be closed ? |
Yes closing as the firmware has everything need to support this. Will update for reference when the driver support is merged. |
As promised and for reference if anyone comes across this: the gs_usb module supporting this is included in the kernel 6.1 release. Thanks to Marc for the support getting this done. One can confirm with 6.1 that a gs_usb interface supports hardware timestamps with
I've used it to pin point a CAN node deviating from it's cycle threshold and then confirm that the bug was fixed. It was important to use hardware timestamping to eliminate the host OS introducing any timing delay - I found it was enough to effect my results. For interest to demonstrate this, I just created a STM32F4 sending a CAN messages every 2 ms in the SysTick ISR. Using candleLight_fw with |
Cool, thanks for confirming and for that nice test data. How did you produce the graphs ? |
The graphs are really nice! The "hardware" RX timestamps look quite good, even if they are created by software in the µC. For reference, current limitations:
|
The graphs are produced with a Python script and plotly. Here is a folder with scatter, histogram and interactive versions if you're interested (they are big and quite slow as lots of data-points): https://www.dropbox.com/sh/sdhaht8p2cqfu7m/AAC-Y7qqVa4_G855dhWHRhssa?dl=0 Yes the hardware ones are still not perfect but good enough for most use and much better than the host timestamps for timing specific tests. |
Hi @tuna-f1sh! Thanks for the awesome work here.
|
@lglenat I have the not very helpful reply of 'works on my machine'! I can only think that perhaps the BeagleBone kernel is not compiled with hardware timestamp support. I'm not that familiar with BeagleBone and their builds and couldn't find anything on the One test would be what |
At least in this boot log,
... and the C_CAN doesn't support time stamping. |
Sorry for the waste of time, turns out I mistakenly passed the wrong CAN interface to
I used the wrong one because plugging USB after the beaglebone boot enumerates the device on Thanks all for the help. |
Yep I was able to use |
Does the firmware support the
candump -H
hardware timestamp flag? Quickly looking at the firmware, a timestamp is provided in the gsusb frame using the TIM2 but I get zeros fromcandump can0 -H -t a
:The same flag works with a PCAN USB device so not sure whether this is supported by candleLight or I am doing something wrong?
The text was updated successfully, but these errors were encountered: