Updating the clock frequency in Device tree on jetson nx

Hi Shubhi,

Now the can is up now. And i tried the loop-back coomunication in Jetson xavier NX. Its working but when we try to connect with host pc with CAN transceiver SN65HVD230, First time communication is happening but after sometimes CAN goes to CAN BUS_OFF state.

Thanks

what else have you connected over the bus?

Hi,
Nothing else i have connected, only the host pc.

One more thing, Is it possible to edit the kernel dtb and BPMP dtb directly on jetson xavier nx board(target hardware) without help of a local host machine running ubuntu os. If that possible we can download original sdcard image from jetson download center and able to edit the dtb on jetson system. Thank you.

Hi Shubhi,

Any Solution regarding previous message?

Regards.

Hi aravind,
You cannot edit bpmp dtb on local machine. But for kernel dtb , you can try it out in /boot/.
Are you still getting errors while sending?
Can you paste the logs and CAN stats details for more info?

Hi shubhi,
Actually i am facing multiple issues. The method we followed is downloading the jetson os and all using sdk manager. And then we edited the dtbs in the installed folder in the host pc. Then we run the flash command from tools folder. So i got a .img sd-card image. And then we put that in the sdcard by flashing using etcher. Now i am facing 2 problems:

  1. CAN is working and i can able to communicate. But some times CAN goes to the BUS off state. When we check the CAN status its showing CAN bus off state. Some time CAN goes to Error-passive state from Error-active. And the TX counter is increasing.

  2. After building the jetson using above mentioned method, Now when we run the application its asking for some dependency files ( .so ). But that dependencies and all are include in the sd-card image that we downloaded from Jetson download.

Can you suggest a method that we can able to edit the dtbs without kernel building. Because in kernel we dont want any edit. So how we will get a source which includes all this files including kernel, dtbs and dependency files. And what we need to do to build the image.

Thank you.

hi aravind,
For CAN issue, can you try changing the transceiver. Sometimes, transceiver causes these errors.
For other issues not related to can, can you raise a separate ticket and explain the issue there?

Hello,

We faced some issues with CAN when we installed the latest jetpack (4.5.1) onto a xavier. On an older installation CAN worked fine on 500 kbit/s.

I discovered that the CAN peripheral is now clocked with another parent clock. I followed the guide on updating the parent clock in the kernel-dtb file and the bpmp-dtb file.

This was the output in case CAN does not work properly:

$ ip -det link
...
10: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 72 qdisc pfifo_fast state UP mode DEFAULT group default qlen 100
        link/can  promiscuity 0
        can <BERR-REPORTING,FD> state ERROR-PASSIVE (berr-counter tx 0 rx 127) 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
            dbitrate 2021052 dsample-point 0.736
            dtq 26 dprop-seg 6 dphase-seg1 7 dphase-seg2 5 dsjw 1
            mttcan: dtseg1 1..31 dtseg2 0..15 dsjw 1..15 dbrp 1..15 dbrp-inc 1
            clock 38400000numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
...

I modified bootloader/t186ref/tegra194-a02-bpmp-p2888-a04.dtb:

		clock@can1 {
 			allow_fractional_divider = <0x1>;
-			allowed-parents = <0x121 0x5b 0x13a>;
+			allowed-parents = <0x121 0x5b 0x5e 0x13a>;
 			clk-id = <0x9>;
 		};
 
 		clock@can2 {
 			allow_fractional_divider = <0x1>;
-			allowed-parents = <0x121 0x5b 0x13a>;
+			allowed-parents = <0x121 0x5b 0x5e 0x13a>;
 			clk-id = <0xb>;
 		};

Used this command to flash this dtb file (note that we have a redundant setup, so we flash both slot A and slot B (suffix _b)):

$ sudo ./flash.sh  -r  -k bpmp-fw-dtb jetson-agx-xavier-devkit mmcblk0p1
$ sudo ./flash.sh  -r  -k bpmp-fw-dtb_b jetson-agx-xavier-devkit mmcblk0p1

After a reboot, verify that the proper dtb is loaded by checking /sys/kernel/debug/bpmp/debug/dt.

Next up, I modified kernel/dtb/tegra194-p2888-0001-p2822-0000.dtb:

--- kernel/dtb/tegra194-p2888-0001-p2822-0000.dts.bak	2021-04-19 13:33:34.342762489 +0200
+++ kernel/dtb/tegra194-p2888-0001-p2822-0000.dts	2021-04-19 13:34:32.248801134 +0200
@@ -5293,9 +5293,9 @@
 		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 = "osc";
-		clocks = <0x4 0x11c 0x4 0xa 0x4 0x9 0x4 0x5b>;
-		clock-names = "can_core", "can_host", "can", "osc";
+		pll_source = "pllaon";
+		clocks = <0x4 0x11c 0x4 0xa 0x4 0x9 0x4 0x5b 0x4 0x5e>;
+		clock-names = "can_core", "can_host", "can", "osc", "pllaon";
 		resets = <0x5 0x4>;
 		reset-names = "can";
 		mram-params = <0x0 0x10 0x10 0x20 0x0 0x0 0x10 0x10 0x10>;
@@ -5311,9 +5311,9 @@
 		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 = "osc";
-		clocks = <0x4 0x11d 0x4 0xc 0x4 0xb 0x4 0x5b>;
-		clock-names = "can_core", "can_host", "can", "osc";
+		pll_source = "pllaon";
+		clocks = <0x4 0x11d 0x4 0xc 0x4 0xb 0x4 0x5b 0x4 0x5e>;
+		clock-names = "can_core", "can_host", "can", "osc", "pllaon";
 		resets = <0x5 0x5>;
 		reset-names = "can";
 		mram-params = <0x0 0x10 0x10 0x20 0x0 0x0 0x10 0x10 0x10>;
@@ -13576,7 +13576,7 @@
 		status = "okay";
 
 		disable {
-			clocks = <0x14d 0x5e 0x4 0x9 0x4 0xb>;
+			clocks = < 0x4 0x9 0x4 0xb>;
 		};
 	};

And flash this device tree as well:

$ sudo ./flash.sh -r -k kernel-dtb jetson-agx-xavier-devkit mmcblk0p1
$ sudo ./flash.sh -r -k kernel-dtb_b jetson-agx-xavier-devkit mmcblk0p1

Verify the device tree is loaded by checking the proc file /proc/device-tree/mttcan@c310000/pll_source .

Note that for this to work, you do not need to modify and recompile the kernel.

2 Likes