Setting up CAN Filters

We are working with a Jetson AGX Orin and using it to communicate over CAN . The CAN bus has 10-15 other devices. We are noticing the Orin is reading all the CAN packets being sent on the bus (even though they are not intended for the Orin). As a result, due to the heavy load (data coming at 500 Hz), the Orin misses some packets and is causing Rx errors.
We don’t want the Orin to read all the CAN packets on the bus and hence want to setup filters on the CAN bus. Which only looks for IDs that match it’s filter (id/mask) requirement.
We have tried modifying the std_filter and xtd filter files inside the platform/devices/net/can0 folder. But it doesn’t allow us to overwrite the file.
The filter on candump, doesn’t apply a hardware filter (but a software filter).
It didn’t even work by setting up filters on the socketCAN library (which is again a software filter) and not a hardware filter.
Any idea on how to setup hardware filters on CAN ?

We tried following the steps listed here Setting Hardware filters. But the std_filter, xtd_filter, gfc_filter files are not editable. You cannot even sudo into them and change them.

Hi misbahlabs,

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

Have you referred to the following instruction for CAN?
Controller Area Network (CAN) — Jetson Linux Developer Guide documentation (

Do you load can_raw for CAN-ID filtering?

Which CAN ID would you like to receive for AGX Orin?

Please try entering super user state and run the command

$ sudo su
# echo h > /sys/devices/platform/c310000.mttcan/net/can0/std_filter

hi @KevinFFF , thank you for getting back on this promptly.

It’s the devkit. Not custom.


Yes, I have gone through it. I have CAN working fine. It’s just that I want to setup filters (hardware level).

We do sudo modprobe can_raw . But I think the only filtering it allows is through software, such as using socketCAN. The hardware still reads through all the CAN IDs without any filtering on it.

We’d like it to listen to one or two IDs only. Such as 0x0AA or 0x021. We are flexible on this.

I tried this and getting the following error:

bash: echo: write error: Invalid argument

I think it’s because root doesn’t have permissions to write to the std_filter file.
I also tried sudo nano into that file and it says “permission denied” , locked file.

Please advise on how we can setup hardware filters on the Jetson Orin.

Please use the following command for your case.

# echo "sft=1 sfec=1 sfid1=0xAA sfid2=0x21 idx=0" > std_filter

For more details, you could refer to Section 2.4.5 of Bosch MTTCAN user manual.

1 Like

This solved our problem. Thanks a bunch @KevinFFF

Hi @KevinFFF ,
Your previous suggestion helped solve our problem (of setting up filters).
But now, I’m running into a strange situation, and hoping you may have some insight on this.

We have a CAN bus with 10-12 other devices who are communicating with each other. Data is sent every 1 millisecond.
We then add the Jetson on the bus, (and I have tested this with different filter settings as shown below). None of the devices are set to send to the filters setup on the Jetson and we don’t see anything on candump -x any.
But some how, every few seconds, the Jetson is reporting a Rx packet and an Rx Error (seen using watch -n 0.1 ifconfig). The word “few seconds” is important because, all other nodes are sending data with a 1 milli-second interval consistently. But Jetson only picks up Rx Packets and Errors, only every few seconds (not on a consistent basis). I’m trying for Jetson to NOT listen to any CAN data. Not sure if I got any of the filter settings wrong. I have tried the following filter settings (after referring to the Bosch manual):

 echo "sft=3 sfec=0 sfid1=0xAA sfid2=0x21 idx=0" > /sys/devices/platform/c310000.mttcan/net/can0/std_filter
echo "sft=1 sfec=1 sfid1=0xAA sfid2=0x21 idx=0" > /sys/devices/platform/c310000.mttcan/net/can0/std_filter

For the global filter

 echo "anfs=3 anfe=3 rrfs=1 rrfe=1" > /sys/devices/platform/c310000.mttcan/net/can0/gfc_filter
 echo "anfs=3 anfe=0 rrfs=0 rrfe=0" > /sys/devices/platform/c310000.mttcan/net/can0/gfc_filter

But nothing seems to work. Jetson somehow manages to pick up some Rx Packets/Errors, randomly. And nothing shows up on the candump -x any either.

What’ the command you used to setup can bus for AGX Orin?

Could you also help to verify with the latest R35.4.1?

Please share the result of the following command after you hit the issue.

$ sudo ip -d -s link show can0
$ sudo modprobe can
$ sudo modprobe can_raw
$ sudo modprobe mttcan
$ sudo ip link set can0 up type can bitrate 500000 dbitrate 1000000 berr-reporting on fd on
$ sudo ip link set can0 down
$ sudo su
echo "sft=1 sfec=1 sfid1=0xA1 sfid2=0x23 idx=0" > /sys/devices/platform/c310000.mttcan/net/can0/std_filter
echo "anfs=3 anfe=0 rrfs=0 rrfe=0" > /sys/devices/platform/c310000.mttcan/net/can0/gfc_filter
$ sudo ip link set can0 up

Will look into it. But I don’t know if it’ll make any significant difference.

It ran into 43 errors/packets in 3 mins. It’s strange how it’s only registering packets that are detected as errors and ignoring all other packets on that bus.
On another note. Not sure if you can make anything out of this. It shows 344 bytes received (and 43 packets/errors), suggesting maybe 8 bytes per packet. On our CAN bus, there are only two types of data packets. One being 4 bytes long and the other 12 bytes long. There aren’t any 8 bytes being transferred.
Is it possible to see what the error bytes are ?

Could you remove the " berr-reporting on" in this command?

$ sudo ip link set can0 up type can bitrate 500000 dbitrate 1000000 fd on

There should be minor fixes in the latest release.
If you are using the devkit, we would always suggest verify with the latest release so that your status could align with us.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.