I haven’t upgraded yet, but it’s on my list. Might be a month or two before I get around to it though.
@Atrer After some attempts
mcp2515 is probed successfully
ubuntu@tegra-ubuntu:~$ dmesg | grep mcp
[ 0.723055] mcp251x_init
[ 3.090789] mcp251x spi0.0: CANSTAT 0x80 CANCTRL 0x07
[ 3.091113] mcp251x spi0.0: probed
[ 3.091236] mcp251x spi0.0: CNF: 0x01 0xf5 0x01
ubuntu@tegra-ubuntu:~$ dmesg | grep spi
[ 0.000000] Lowering qspi maximum rate from 163200000 to 116600000
[ 0.359644] PMC: IO pad spi voltage is 1800000
[ 0.377758] PMC: IO pad spi-hv voltage is 1800000
[ 1.570153] tegra210-pmc-iopower pmc-iopower.29: Rail iopower-spi is having fixed voltage 1800000
[ 1.578993] tegra210-pmc-iopower pmc-iopower.29: Rail iopower-spi-hv is having fixed voltage 1800000
[ 2.961991] spi-tegra114 7000d400.spi: Static pin configuration used
[ 2.970028] spi_master spi0: cannot find modalias for /spi@7000d400/prod-settings
[ 2.980402] spi-tegra114 7000d400.spi: chipselect 0 already in use
[ 2.988012] spi_master spi0: spi_device register error /spi@7000d400/spidev0_0
[ 2.998252] spi-tegra114 7000d600.spi: /spi@7000d600/prod-settings has no reg property
[ 3.009355] spi-tegra114 7000d600.spi: Static pin configuration used
[ 3.017597] spi_master spi1: cannot find modalias for /spi@7000d600/prod-settings
[ 3.028427] spi-tegra114 7000da00.spi: /spi@7000da00/prod-settings has no reg property
[ 3.039797] spi-tegra114 7000da00.spi: Static pin configuration used
[ 3.048160] spi_master spi3: cannot find modalias for /spi@7000da00/prod-settings
[ 3.090789] mcp251x spi0.0: CANSTAT 0x80 CANCTRL 0x07
[ 3.091113] mcp251x spi0.0: probed
I tried configuring the can interface using the command
sudo ip link set can0 type can bitrate 125000
sudo ifconfig can0 up
I used “cansend” command to test the can0 interface and “candump” simultaneously to examine the interface.cansend can0 5A1#11.22.33.44.55.66.77.88
cansend can0 5A1#11.22.33.44.55.66.77.88
candump can0
I am able to see some traffic on can interface using oscilloscope but neither the bitrate nor the data matches the test data.Do I need to configure the mcp2515 exclusively through some application. Am i missing something. Looks I am close.
@Alter,@CalmCar were you able to configure mcp2515 on release 28.1,
i.e. How anybody got the answer to @Calmcar’s question → Since Release 28.1.There are no hard-code in arch/arm64/mach-tegra.Where do you place the platform code and board info code?
Hi Atrer,
Thanks for the detailed explanation. I am new to hardware interfacing of sensors and dev boards.
My main goal is to
integrate Lidar device which gives CAN-H and CAN-L lines as output, through MCP2515 to TX1 and also connect a camera through USB port of TX1, so that both these sensor readings are taken in real time.
I could see there are SPI pins on J21 header of TX1 (19,21,23). So can’t we directly use them to connect to MCP2515 and get lidar sensor data ?
Are you asking if you can control the MCP2515 directly from the SPI without compiling the kernel driver? The answer is yes, you could control it directly from spidev (after activating it in the device tree), but it would be a major pain to work through SPI instead of a real linux CAN interface.
I have the MCP2515 working on r28.1. Everything is in the device tree now.
I updated the main post, depending on interest I can add some more explanation of how to enable everything from scratch.
Hi Atrer
Thanks for updates.
I have updated the “tegra210-daxc03.dtsi” as per the gists you have shared, but unable to probe the mcp device in 28.1.
Can you add some more explanation or steps to enable it.
yeah I’ll try to get that done this week.
@bani_j Which SPI are you connecting to, and what GPIO are you planning on using for your interrupt?
@Atrer I am using SPI1 on J21 connector. I am using TEGRA_GPIO_PE4 i.e. gpio36.
bani_j
I modified atrer gist with your gpio pin on spi1/j21 give it a try
https://gist.github.com/annerajb/bc5a5791fb15c26dbfd7db80328a2135
Thanks @Atrer @annerjb for the gists.
@annerjb i have tried the gist you have shared. but it didn’t worked for me. I think i am missing some step except this. I have created a dtsi using this gist and included in my dts file. Enabled the can and MCP2515 in make menuconfig.
@Atrer Do I need to take any other changes. I cannot see in logs for mcp in dmesg.
@bani_j
Run menuconfig and under devices → spi → enable spi debug messages compile the kernel again copy it over and reboot.
Then run dmesg | grep mcp
You should see a few messages now (found those out yesterday)
Paste those messages this should mean that you configured the device tree correctly. They should show something like spi0.0 mcp251x
I added a logic analyzer to the spi pins on j21 a few hours ago and got no signal under l4t 3.1 and 28.1 wasn’t able to look further. If you can also put a logic analizer and record the spi during reboot. You should see traffic
@annerjb
I had enabled the spi debug messages in the kernel configuration.I never got anything like mcp in the dmesg output.
As you stated it seems that the device tree is not configured properly.
Can you please share the steps to carried out to probe the mcp.
If the device tree is not setup then we don’t have to go to that step since we have software things to solve first. Please verify that you have the following inside your .config that menuconfig creates in the tegra_kernel_out folder
CONFIG_CAN_MCP251X=y
CONFIG_CAN_DEV=y
CONFIG_SPI_SPIDEV=y
Also you should see the following printouts to indicate dtb configuration of spi
Paste the output of the following commands
dmesg | grep DTB
Verify that this date matches when you build the kernel
dmesg | grep -i spi
dmesg | grep -i can
And also upload the latest dts you are flashing to the Jetson tx1 running 28.1
Hi,
I had build my kernel and DTBs and copied the images in /boot folder.
Strange to see that the uname -a output doesn’t change even after replacing the new kernel image.
ubuntu@tegra-ubuntu:~$ dmesg | grep spi
[ 0.260332] tegra-pmc 7000e400.pmc: PMC: IO pad spi voltage is 1800000
[ 0.268365] tegra-pmc 7000e400.pmc: PMC: IO pad spi-hv voltage is 1800000
[ 2.961601] spi-tegra114 7000d400.spi: Static pin configuration used
[ 2.962109] spi-tegra114 7000d400.spi: registered master spi0
[ 2.962437] spi-tegra114 7000da00.spi: Static pin configuration used
[ 2.962891] spi-tegra114 7000da00.spi: registered master spi3
ubuntu@tegra-ubuntu:~$ dmesg | grep mcp
ubuntu@tegra-ubuntu:~$
ubuntu@tegra-ubuntu:~$
ubuntu@tegra-ubuntu:~$
ubuntu@tegra-ubuntu:~$ dmesg | grep can
[ 0.610079] tegra-pwm 7000a000.pwm: PWM clk can sleep in ops
[ 3.256221] can: controller area network core (rev 20120528 abi 9)
[ 3.256291] can: raw protocol (rev 20120528)
[ 3.256298] can: broadcast manager protocol (rev 20120528 t)
[ 3.256309] can: netlink gateway (rev 20130117) max_hops=1
[ 5.958836] xhci-tegra 70090000.xusb: can't get usb3-0 phy (-517)
[ 8.009284] xhci-tegra 70090000.xusb: cannot find firmware....retry after 1 second
ubuntu@tegra-ubuntu:~$ uname -a
Linux tegra-ubuntu 4.4.38 #0 SMP PREEMPT Mon Mar 12 19:54:40 2018 aarch64 aarch64 aarch64 GNU/Linux
ubuntu@tegra-ubuntu:~$ ls -l /boot/
total 42332
drwxr-xr-x 2 root root 4096 Sep 26 20:22 dtb
drwxr-xr-x 3 root root 4096 May 3 2016 efi
drwxr-xr-x 2 root root 4096 Feb 3 09:27 extlinux
-rwxr-xr-x 1 root root 20903608 Mar 21 13:35 Image
-rw-r--r-- 1 root root 20984368 Sep 26 20:22 Image_backup
-rw-r--r-- 1 root root 0 Sep 26 20:22 initrd
-rw-r--r-- 1 1004 1004 441763 Mar 19 19:32 tegra210-jetson-cv-base-p2597-2180-a00.dtb
-rw-r--r-- 1 1004 1004 277997 Mar 20 12:14 tegra210-jetson-e-base-p2595-0000-a00.dtb
-rwxr-xr-x 1 root root 278207 Mar 20 12:14 tegra210-jetson-e-p2595-0000-a00-00.dtb
-rw-r--r-- 1 1004 1004 442068 Mar 20 12:12 tegra210-jetson-tx1-p2597-2180-a01-devkit.dtb
ubuntu@tegra-ubuntu:~$
ubuntu@tegra-ubuntu:~$
ubuntu@tegra-ubuntu:~$
ubuntu@tegra-ubuntu:~$ dmesg | grep DTB
[ 0.032634] DTB Build time: Jul 20 2017 00:41:45
[ 0.209144] DTB Build time: Jul 20 2017 00:41:45
This is really simplified step. Am I missing/messsing something.
@bani_bj
I finally found what we both are missing (and atrer :P but he dosn’t need it)
https://devtalk.nvidia.com/default/topic/1022629/gpio-to-sfio-28-1/
The spi ports are disabled by default on the image 28.1 DTS files.
You can verify if they are enabled by running this command:
sudo cat /sys/kernel/debug/tegra_gpio | grep 0:2
It should say 1f when they are disabled
All 00 when it’s enabled.
If they are disabled you would need to add this section to the dtsi file:
gpio@6000d000 {
spi_enable {
gpio-hog;
function;
// gpios = <TEGRA_GPIO(C, 0) 0 TEGRA_GPIO(C, 1) 0 TEGRA_GPIO(C, 2) 0 TEGRA_GPIO(C, 3) TEGRA_GPIO(C, 4) 0>;
gpios = <0x10 0x0 0x11 0x0 0x12 0x0 0x13 00 0x14 0x0>;
};
};
here is the complete dtsi file i used to get it to work
https://gist.github.com/annerajb/bc5a5791fb15c26dbfd7db80328a2135
Nice job, I’ll update that gist
I updated the link for J21 SPI1 to point to annerjb’s gist.
@bani_j did it work?
BTW downloaded 28.2 and it seems at least my GPIO fix is not working
The sudo cat /sys/kerne/debug/tegra_gpio is showing the pins disabled.
Most likely it was changed once again the way to enable them. I do know my file is included in the build and device tree being used.
Will look into it later probably do a kernel diff.
