Setting CAN clock to specific rate does not work

We have set up CAN communication as proposed here and activated CANs with:

sudo busybox devmem 0x0c303000 32 0x0000C400
sudo busybox devmem 0x0c303008 32 0x0000C458
sudo busybox devmem 0x0c303010 32 0x0000C400
sudo busybox devmem 0x0c303018 32 0x0000C458

sudo insmod /lib/modules/4.9.253-rt168-tegra/kernel/net/can/can.ko
sudo insmod /lib/modules/4.9.253-rt168-tegra/kernel/net/can/can-raw.ko
sudo insmod /lib/modules/4.9.253-rt168-tegra/kernel/net/can/can-bcm.ko
sudo insmod /lib/modules/4.9.253-rt168-tegra/kernel/net/can/can-gw.ko
sudo insmod /lib/modules/4.9.253-rt168-tegra/kernel/drivers/net/can/can-dev.ko
sudo insmod /lib/modules/4.9.253-rt168-tegra/kernel/drivers/net/can/mttcan/native/mttcan.ko

sudo ip link set can0 type can bitrate 500000
sudo ip link set can1 type can bitrate 500000

sudo ip link set up can0
sudo ip link set up can1

ip -s -d link show can0

Even though it was set as 500000 it shows 498701:

8: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP mode DEFAULT group default qlen 10
    link/can  promiscuity 0 
    can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0 
	  bitrate 498701 sample-point 0.870 
	  tq 26 prop-seg 33 phase-seg1 33 phase-seg2 10 sjw 1
	  mttcan: tseg1 2..255 tseg2 0..127 sjw 1..127 brp 1..511 brp-inc 1
	  mttcan: dtseg1 1..31 dtseg2 0..15 dsjw 1..15 dbrp 1..15 dbrp-inc 1
	  clock 38400000
	  re-started bus-errors arbit-lost error-warn error-pass bus-off
	  0          0          0          0          0          0         numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 
    RX: bytes  packets  errors  dropped overrun mcast   
    0          0        0       0       0       0       
    TX: bytes  packets  errors  dropped carrier collsns 
    0          0        0       0       0       0

Is there any way at all to set the clockrate at an exact value (say 500000) without flashing? I am working on an AGX Xavier.

Sorry for the late response, have you managed to get issue resolved or still need the support? Thanks

Sorry for the late response, have you managed to get issue resolved or still need the support? Thanks

We still need support.

Have you checked How to using CAN In nx devkit - Jetson & Embedded Systems / Jetson Xavier NX - NVIDIA Developer Forums?

Would that activate the pllaon clock for CAN? otherwise the bitrate won’t be exact, as we need it.

I have found that “Jetson-IO” would allow modifiying the dtb with an overlay, would this work? Can I set the PLLAON for CAN with Jetson-IO?

Is this still an issue to support? Any result can be shared? Thanks

It would be nice if you answer the questions, but otherwise the dtb setting was solved using diff and patch:

tegra194-a02-bpmp-p2888-a04.dts.patch:

26c26
< 			allowed-parents = <0x121 0x5b 0x13a>;
---
> 			allowed-parents = <0x121 0x5b 0x13a 0x5e>;
32c32
< 			allowed-parents = <0x121 0x5b 0x13a>;
---
> 			allowed-parents = <0x121 0x5b 0x13a 0x5e>;

tegra194-p2888-0001-p2822-0000.dts.patch:

5296,5298c5296,5298
< 		pll_source = "osc";
< 		clocks = <0x04 0x11c 0x04 0x0a 0x04 0x09 0x04 0x5b>;
< 		clock-names = "can_core\0can_host\0can\0osc";
---
> 		pll_source = "pllaon";
> 		clocks = <0x04 0x11c 0x04 0x0a 0x04 0x09 0x04 0x5e>;
> 		clock-names = "can_core\0can_host\0can\0pllaon";
5314,5316c5314,5316
< 		pll_source = "osc";
< 		clocks = <0x04 0x11d 0x04 0x0c 0x04 0x0b 0x04 0x5b>;
< 		clock-names = "can_core\0can_host\0can\0osc";
---
> 		pll_source = "pllaon";
> 		clocks = <0x04 0x11d 0x04 0x0c 0x04 0x0b 0x04 0x5e>;
> 		clock-names = "can_core\0can_host\0can\0pllaon";
13579c13579
< 			clocks = <0x14f 0x5e 0x04 0x09 0x04 0x0b>;
---
> 			clocks = <0x04 0x09 0x04 0x0b>;

This however isn’t changeable without flashing.

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