CAN configuration

Hello,
We are currently debugging CAN-tsync and need to read the hardware timestamp. However, we find that the CAN clock cannot be located in bpmp-clk. Why is it not available on Thor, while it is confirmed to exist on AGX Orin?

Are there any suggestions for reading the hardware timestamp (SOF) of CAN-tsync?

Jetpack 7.1 is the version being used.
Looking forward to your reply!

Hi kepts,

Are you using the devkit or custom board for Thor?
What’s the Jetpack version in use?

Please note that Thor and Orin are different SoC series. The CAN of Thor is from FSI so that many registers are not allowed to be read.

Could you elaborate on your use case and requirement? I can check with internal team if there’s alternative approach for you.

I am using the devkit.
Jetpack 7.1 is the version being used.

Understood, but I now need to read the SOF timestamp. Is there any way to do this?

The main objective is to implement CAN time synchronization (CAN-tsync), which requires capturing the SOF and sending it back to the application layer.

I would appreciate your help, and I really need a feasible solution from you.

Hello,
do you have any suggestions?

Does the Jetson Thor support CAN hardware timestamps?

Linux_for_Tegra/source/nvidia-oot/drivers/net/can/mttcan/native/m_ttcan_linux.c

discuses can timestamping.

I know that I have already reviewed the code here, but when I tried to read it at the application layer, I did not obtain the relevant hardware timestamps.
Have you tried it? Were you able to read it successfully?

Does this show anything? change to can?

candump -t a can0 -n 5

candump -H can0 -n 5

I’m currently checking with internal team if CAN-tsync is supported on Thor.
I’ll keep you posted once I get any feedback.

Please also share the exact steps what you have done.


You can see that the timestamp cannot be read when the -H parameter is used.

My Thor is awaiting a fresh flash in the morning so I can not test tonight.

you’ve loaded modules can can_raw mttcan


See if turning fd off helps?
sudo ip link set can0 down
sudo ip link set can0 type can bitrate 500000 fd off
sudo ip link set can0 up

candump -H can0 -n 5

Thank you very much for looking into this matter at present. We hope to receive your feedback as soon as there is an update.

First, an attempt was made to read the HW timestamp using candump, but no output was generated.
Then, we checked via ethtool, yet there was no output indicating support for the relevant hardware timestamp feature.
After examining the kernel, we found the corresponding reading code was present, which led us to further suspect whether the CAN node in the device tree had hardware timestamping disabled. We then discovered that bpmp-clk could not be allocated to the CAN controller.
Finally, we wrote a program to configure the Socket timestamp function and extract timestamps from control messages, but the result was still only software timestamps being retrieved.

That’s fine. Please feel free to let me know about any operation you can think of, and I will carry it out.


The result is still the same.

https://github.com/linux-can/can-utils/blob/master/include/linux/net_tstamp.h

You could try this?

// enable_can_hwts.c
// Build: gcc -O2 -Wall enable_can_hwts.c -o enable_can_hwts
// Usage: sudo ./enable_can_hwts can0
//
// Enables RX hardware timestamping on an interface by issuing SIOCSHWTSTAMP
// with HWTSTAMP_TX_OFF + HWTSTAMP_FILTER_ALL.

#define _GNU_SOURCE
#include <errno.h>
#include <net/if.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <unistd.h>

/*
 * Use the kernel UAPI if present:
 *   /usr/include/linux/net_tstamp.h
 *   /usr/include/linux/sockios.h
 */
#include <linux/net_tstamp.h>
#include <linux/sockios.h>

static void die(const char *msg) {
    perror(msg);
    exit(1);
}

int main(int argc, char **argv) {
    if (argc != 2) {
        fprintf(stderr, "Usage: %s <ifname>\nExample: sudo %s can0\n", argv[0], argv[0]);
        return 2;
    }

    const char *ifname = argv[1];

    int fd = socket(AF_INET, SOCK_DGRAM, 0);
    if (fd < 0)
        die("socket(AF_INET,SOCK_DGRAM)");

    struct hwtstamp_config cfg;
    memset(&cfg, 0, sizeof(cfg));
    cfg.flags = 0;
    cfg.tx_type = HWTSTAMP_TX_OFF;
    cfg.rx_filter = HWTSTAMP_FILTER_ALL;

    struct ifreq ifr;
    memset(&ifr, 0, sizeof(ifr));
    strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
    ifr.ifr_data = (void *)&cfg;

    if (ioctl(fd, SIOCSHWTSTAMP, &ifr) < 0) {
        fprintf(stderr, "SIOCSHWTSTAMP failed on %s: %s (errno=%d)\n",
                ifname, strerror(errno), errno);
        close(fd);
        return 1;
    }

    // Driver may adjust cfg.rx_filter to the actual mode; print what we got back.
    printf("%s: HW timestamp configured. tx_type=%d rx_filter=%d flags=%d\n",
           ifname, cfg.tx_type, cfg.rx_filter, cfg.flags);

    close(fd);
    return 0;
}

image
The result is still the same.

Hello,
Is there any update on this issue? Please let me know. Thank you.

Hello,
Is there any update on this issue? Please let me know. Thank you.

It seems CAN-tsync is not supported on Jetson device.
You can try using PTP + HTE(Hardware Timestamp Engine) instead.
Please refer to Generic Timestamp Engine — NVIDIA Jetson Linux Developer Guide and Hardware Timestampping Engine (HTE) for details.

OK, I’d like to ask whether Thor doesn’t support it in terms of hardware or software, or neither?

We have HW timestamp support on Thor, but not for CAN-tsync.