Mcp2515 config

Hello, I configured mcp2515 as can1 in R32.7.1. The device tree configuration is as follows
image

But when I check the output information of the development board, it is can0,
image

The test found that it is indeed contrary to the device tree configuration

When I transplanted the same code to R35.1, there was no such problem. In R35.1, the actual output is consistent with the device tree configuration

How to configure mcp2515 to can1

Xavier NX has got an integrated CAN controller, which is much better than the MCP2515. Why don’t you use this?

Xavier nx has only one can, and ifconfig displays can0,; I need two channels of can, so I need to configure mcp2515 as can1, but now after the configuration is completed, mcp2515 is displayed as can0, and nx’s own display is displayed as can1

I solved it because of the address. Thank you

There is a problem. After changing the address in the device tree, I can set mcp2515 to can1, but it will return to its original state when I refresh next time. So, there are still problems. Do you have a solution

There is only one mcp2515 on the development board. How to initialize to can1 instead of can0

You may want to look into udev rules.

But there is no description of can in udev rules

doesn’t matter. try udevadm info on the can interfaces.

Well, I don’t understand. Could you elaborate,thank you

I create a new file “77-nx-can-config.rules” in the “/etc/udev/rules. d” directory of the development board, and add the following information to the newly created file

SUBSYSTEM=="net", ACTION=="change", ATTR{devpath}=="/sys/devices/3230000.spi/spi_master/spi2/spi2.0/net/can0", KERNEL=="can*", NAME="can1"

Then restart udev rules

 sudo udevadm control --reload

After restarting the development board, the can interface has not changed. Can you help me see what is wrong with the configuration. The following is my can information

nvidia@nvidia-desktop:/etc/udev/rules.d$ udevadm info -a -p /sys/class/net/can0

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/3230000.spi/spi_master/spi2/spi2.0/net/can0':
    KERNEL=="can0"
    SUBSYSTEM=="net"
    DRIVER==""
    ATTR{addr_assign_type}=="0"
    ATTR{addr_len}=="0"
    ATTR{address}==""
    ATTR{broadcast}==""
    ATTR{carrier}=="1"
    ATTR{carrier_changes}=="1"
    ATTR{dev_id}=="0x0"
    ATTR{dev_port}=="0"
    ATTR{dormant}=="0"
    ATTR{flags}=="0x40081"
    ATTR{gro_flush_timeout}=="0"
    ATTR{ifalias}==""
    ATTR{ifindex}=="4"
    ATTR{iflink}=="4"
    ATTR{link_mode}=="0"
    ATTR{mtu}=="16"
    ATTR{netdev_group}=="0"
    ATTR{operstate}=="up"
    ATTR{proto_down}=="0"
    ATTR{tx_queue_len}=="10"
    ATTR{type}=="280"

  looking at parent device '/devices/3230000.spi/spi_master/spi2/spi2.0':
    KERNELS=="spi2.0"
    SUBSYSTEMS=="spi"
    DRIVERS=="mcp251x"

  looking at parent device '/devices/3230000.spi/spi_master/spi2':
    KERNELS=="spi2"
    SUBSYSTEMS=="spi_master"
    DRIVERS==""

  looking at parent device '/devices/3230000.spi':
    KERNELS=="3230000.spi"
    SUBSYSTEMS=="platform"
    DRIVERS=="spi-tegra114"
    ATTRS{driver_override}=="(null)"

nvidia@nvidia-desktop:/etc/udev/rules.d$ udevadm info -a -p /sys/class/net/can1

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/c310000.mttcan/net/can1':
    KERNEL=="can1"
    SUBSYSTEM=="net"
    DRIVER==""
    ATTR{addr_assign_type}=="0"
    ATTR{addr_len}=="0"
    ATTR{address}==""
    ATTR{broadcast}==""
    ATTR{carrier}=="1"
    ATTR{carrier_changes}=="1"
    ATTR{cccr_init_txbar}=="CCCR.INIT reset"
    ATTR{dev_id}=="0x0"
    ATTR{dev_port}=="0"
    ATTR{dormant}=="0"
    ATTR{flags}=="0x40081"
    ATTR{gro_flush_timeout}=="0"
    ATTR{ifalias}==""
    ATTR{ifindex}=="8"
    ATTR{iflink}=="8"
    ATTR{link_mode}=="0"
    ATTR{mtu}=="16"
    ATTR{netdev_group}=="0"
    ATTR{operstate}=="up"
    ATTR{proto_down}=="0"
    ATTR{std_filter}=="Standard Filters"
    ATTR{tdc_offset}=="tdc_offset=0x0, DBTP.tdc=0"
    ATTR{trigger_mem}=="Trigger Memory Elements"
    ATTR{tx_queue_len}=="10"
    ATTR{txbar}=="Not implemented"
    ATTR{type}=="280"
    ATTR{xtd_filter}=="Extended Filters"

  looking at parent device '/devices/c310000.mttcan':
    KERNELS=="c310000.mttcan"
    SUBSYSTEMS=="platform"
    DRIVERS=="mttcan"
    ATTRS{driver_override}=="(null)"