Update the device-tree for CAN-BUS, PLLAON Clock

Ok, after a new attempt it works on JetPack 4.6. The clock is set to pllaon when I activate the mttcan with modprobe.

The last thing I did was indeed the good strategy but I must have mess-up one of my dts file, hence causing the freeze of the kernel. (maybe I took one from an other version of JetPack accidentally due to a bad copy paste)

For those who have issue using the can on the Jetson Xavier AGX, JetPack 4.6 here is my solution.

Download with the sdkmanager the JetPack 4.6 but flash the device yet.
Then as I said in my previous post, copy into a workspace folder the files “bootloader/t186ref/tegra194-a02-bpmp-p2888-a04.dtb” and “kernel/dtb/tegra194-p2888-0001-p2822-0000.dtb”

Then use the “dtc” (device-tree compiler) command to de-compile the files: (or download the edited .dtb further down in my post)

dtc -I dtb -O dts tegra194-p2888-0001-p2822-0000.dtb -o tegra194-p2888-0001-p2822-0000.dts
dtc -I dtb -O dts tegra194-a02-bpmp-p2888-a04.dtb -o tegra194-a02-bpmp-p2888-a04.dts

edit the file “tegra194-a02-bpmp-p2888-a04.dts” to allow the “pllaon” (0x5e) clock to be a parent of the two CAN

...
clock@can1 {
	allow_fractional_divider = <0x1>;
	allowed-parents = <0x121 0x5b 0x13a 0x5e>; // changed
	clk-id = <0x9>;
};

clock@can2 {
	allow_fractional_divider = <0x1>;
	allowed-parents = <0x121 0x5b 0x13a 0x5e>; // changed
	clk-id = <0xb>;
};
...

And the “tegra194-p2888-0001-p2822-0000.dts” file to change the “pll_source”, and the “pllaon” to the field “clocks” and “clock-names” of the two “mttcan”. Also remove the “pllaon” clock from the disabled clocks.

...
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"; // changed
	clocks = <0x4 0x11c 0x4 0xa 0x4 0x9 0x4 0x5e>; // changed
	clock-names = "can_core", "can_host", "can", "pllaon"; // changed
	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 = <0x187>;
	phandle = <0x187>;
};

mttcan@c320000 {
	compatible = "nvidia,tegra194-mttcan";
	reg = <0x0 0xc320000 0x0 0x400 0x0 0xc321000 0x0 0x32 0x0 0xc322000 0x0 0x1000>;
	reg-names = "can-regs", "glue-regs", "msg-ram";
	interrupts = <0x0 0x2a 0x4>;
	pll_source = "pllaon"; // changed
	clocks = <0x4 0x11d 0x4 0xc 0x4 0xb 0x4 0x5e>; // changed
	clock-names = "can_core", "can_host", "can", "pllaon"; // changed
	resets = <0x5 0x5>;
	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 = <0x188>;
	phandle = <0x188>;
};
...
clocks-init {
	compatible = "nvidia,clocks-config";
	status = "okay";
	disable {
		clocks = <0x4 0x9 0x4 0xb>; // changed
	};
};
...

Remove the “.dtb” files and recompile them from the sources with:

dtc -I dts -O dtb tegra194-p2888-0001-p2822-0000.dts -o tegra194-p2888-0001-p2822-0000.dtb
dtc -I dts -O dtb tegra194-a02-bpmp-p2888-a04.dts -o tegra194-a02-bpmp-p2888-a04.dtb

I have uploaded my dtb files here: working_dtb_mttcan_pllaon_4.6.zip (225.3 KB)

Then replace the existing file “tegra194-p2888-0001-p2822-0000.dtb” in the “kernel/dtb” folder and “tegra194-a02-bpmp-p2888-a04.dtb” in the “bootloader/t186ref”

Then flash the jetson with the command:
sudo ./flash.sh jetson-agx-xavier-devkit mmcblk0p1

Once it is done, setup the ubuntu (language, keyboard etc…)

Then to use the CAN, type as root using sudo:

busybox devmem 0x0c303000 32 0x0000c400
busybox devmem 0x0c303008 32 0x0000c458
busybox devmem 0x0c303010 32 0x0000c400
busybox devmem 0x0c303018 32 0x0000c458

modprobe can
modprobe can_raw
modprobe mttcan

ip link set can0 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on 
ip link set can1 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on 
ip link set up can0
ip link set up can1

And then once you connected the CAN transceiver to the correct pins, it works.

I hope it can help someone.

3 Likes