AGX Xavier Canbus not working

Hi,

I am tring to use the latest T194 SoC variant AGX Xavier.:
L4T 32.5.1 [ JetPack 4.5.1 ]
Ubuntu 18.04.5 LTS
Kernel Version: 4.9.201-tegra
CUDA 10.2.89
CUDA Architecture: 7.2
OpenCV version: 4.1.1
OpenCV Cuda: NO
CUDNN: 8.0.0.180
TensorRT: 7.1.3.0
Vision Works: 1.6.0.501
VPI: ii libnvvpi1 1.0.15 arm64 NVIDIA Vision Programming Interface library
Vulcan: 1.2.70

I am setting up the canbus according to the article Enabling CAN on Nvidia Jetson Xavier Developer Kit | by Ramin Nabati | Medium

This is confrimed to work well with the previous gen SoC but on the current variant with the latest L4T version can-bus does not work.

The bus is always in state ERROR-ACTIVE

dmesg shows the following:

[ 127.475635] mttcan c310000.mttcan can0: Stuff Error Detected
[ 127.475907] mttcan c310000.mttcan can0: IR 0x8010000 PSR 0x711
[ 127.476092] mttcan c310000.mttcan can0: Stuff Error Detected
[ 127.476220] mttcan c310000.mttcan can0: IR 0x8000000 PSR 0x711
[ 127.476352] mttcan c310000.mttcan can0: Stuff Error Detected
[ 127.476475] mttcan c310000.mttcan can0: IR 0x8000000 PSR 0x711
[ 127.476639] mttcan c310000.mttcan can0: Stuff Error Detected
[ 127.476762] mttcan c310000.mttcan can0: IR 0x8000000 PSR 0x719
[ 127.476926] mttcan c310000.mttcan can0: Bit1 Error Detected
[ 127.477056] mttcan c310000.mttcan can0: IR 0x8000000 PSR 0x71c
[ 127.478045] mttcan c310000.mttcan can0: Bit1 Error Detected
[ 127.478180] mttcan c310000.mttcan can0: IR 0x8000000 PSR 0x71c
[ 127.478339] mttcan c310000.mttcan can0: Bit1 Error Detected
[ 127.478470] mttcan c310000.mttcan can0: IR 0x8000000 PSR 0x71c
[ 127.478690] mttcan c310000.mttcan can0: Bit1 Error Detected
[ 127.478817] mttcan c310000.mttcan can0: IR 0x8000000 PSR 0x71c
[ 127.479038] mttcan c310000.mttcan can0: Bit1 Error Detected
[ 127.483009] mttcan c310000.mttcan can0: IR 0x8000000 PSR 0x71c
[ 127.489169] mttcan c310000.mttcan can0: entered error warning state
[ 127.495050] mttcan c310000.mttcan can0: entered error passive state
[ 127.501444] mttcan c310000.mttcan can0: entered bus off state
[ 127.507027] mttcan c310000.mttcan can0: Bit1 Error Detected
[ 127.512660] mttcan c310000.mttcan can0: IR 0xb800000 PSR 0x7e4
[ 318.152291] mttcan c310000.mttcan can0: bitrate error 1.0%
[ 318.152424] mttcan c310000.mttcan can0: Bitrate set
[ 318.152435] mttcan c310000.mttcan can0: bitrate error 1.0%
[ 318.152606] mttcan c310000.mttcan can0: wait for bus off seq
[ 318.164636] mttcan c310000.mttcan can0: Bit0 Error Detected

canbus is essential to what we are doing

Hi,
May I know more details:
What is connected apart from Xavier on CAN bus.
share ip details:
ip -d -s link show can0

I can’t disclose that unfortunately but there are 0 hardware changes since jetpack 4.2 which is what used with the previous Xavier and everything worked really well. I suspect the issue is with the pllaon to osc change and I have tried changing the dtbs to make the change however I think I am doing it incorrectly.

The instructions in the Nvidia docs are not very clear. I have a few questions
To flash the bpmb dtb what command should I use?

I know to flash the kernel dtb I should use
. /flash.sh -k kernel-dtb jetson-Xavier mmclk0p1

This alone doesn’t work. The decive tree does change but when I check clock source for can1 I get pll_c.

Also under dmesg I get errors from can driver that say: unable to set clock parent

I suspect I need to use another command to flash the other dtb, I am only flashing kernel dtb with the command above, is that correct? This would explain why can driver cannot set parent as pllaon because pllaon is still disabled

I am now getting this error during boot

/clocks-init/disable: could not get #clock-cells for /host1x

Previously I was not running the command sudo ./flash.sh -k bpmp-fw-dtb jetson-xavier mmcblk0p1
and hence the pbmp files were not being updated

The relavent code in the kernel dts looks like this:

clocks-init {
	compatible = "nvidia,clocks-config";
	status = "okay";

	disable {
		clocks = <0x14d 0x4 0x9 0x4 0xb>;
	};
};

Not sure what I am doing wrong. I only removed 0x5e from the list of disabled clocks. The other line I changed are:

mttcan@c310000 {
	compatible = "nvidia,tegra194-mttcan";
	reg = <0x0 0xc310000 0x0 0x400 0x0 0xc311000 0x0 0x32 0x0 0xc312000 0x0 0x1000>;
	reg-names = "can-regs", "glue-regs", "msg-ram";
	interrupts = <0x0 0x28 0x4>;
	pll_source = "pllaon";
	clocks = <0x4 0x11c 0x4 0xa 0x4 0x9 0x4 0x5e>;
	clock-names = "can_core", "can_host", "can", "pllaon";
	resets = <0x5 0x4>;
	reset-names = "can";
	mram-params = <0x0 0x10 0x10 0x20 0x0 0x0 0x10 0x10 0x10>;
	tx-config = <0x0 0x10 0x0 0x40>;
	rx-config = <0x40 0x40 0x40>;
	status = "okay";
	linux,phandle = <0x185>;
	phandle = <0x185>;
};

Per the instruction in the docs. I am not sure what is goin on

So I was able to solve the problem. For others who are dealing with same issue of can bus not wokring with jetpack 4.5 when it was working with an older version, most likely the issue is with the PLLAON no longer being the source. You need to follow the instructions in the docs that tell you how to make the change.

The thing I was doing wrong was that in

clocks-init {
compatible = “nvidia,clocks-config”;
status = “okay”;

disable {
	// clocks = <0x14d 0x4 0x9 0x4 0xb>; // <---- This line needs to be commented out completely, can't just remove 0x5e from it. 
};

};