Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4436

Interfacing (DSI, CSI, I2C, etc.) • Correct config and overlay for CAN on spi1.0?

$
0
0
I'm doing bringup on a new CM4 carrier board that includes an MCP2515 CAN controller. The test CM4 is loaded with the lite version of Pi OS 11.7.

The mcp2515 is wired to CAN1 as follows:

[MCP2515] [CM4]
SCLK_CAN -- CM4 Pin 25 (BCM GPIO 21) - SPI 1 Clock
MISO_CAN -- CM4 Pin 26 (BCM GPIO 19) - SPI 1 MISO
MOSI_CAN -- CM4 Pin 27 (BCM GPIO 20) - SPI 1 MOSI
CAN_INT -- CM4 Pin 41 (BCM GPIO 25) - SPI CAN_INT
SPI_CE0 -- CM4 Pin 49 (BCM GPIO 18) - SPI1 CE0

SPI 0 is not in use - the MIOS and MOIS pins are being used for UART4. (Not sure if that matters, but there you have it.)

The config.txt file has the following:

Code:

# enable SPI and load the drivers for CAN busdtparam=spi=ondtoverlay=spi1-1cs,cs0_spidevdtoverlay=mcp2515.dtbo,spi1-0,oscillator=4000000,interrupt=25
After booting, I get the following in the dmesg log:

Code:

[    6.889365] CAN device driver interface[    6.971290] mcp251x spi1.0 can0: MCP2515 successfully initialized.[    7.102587] mcp251x spi1.0 CAN1: renamed from can0
If I go into the associated /sys directory, it looks like I would expect:

Code:

root@astra1(ro):/sys/bus/spi/devices/spi1.0/net/CAN1# lsaddr_assign_type  broadcast   carrier_down_count  dev_id duplex    ifalias  link_mode       napi_defer_hard_irqs  phys_port_id    power speed     testing   typeaddress  carrier   carrier_up_count    dev_port  flags    ifindex  mtu       netdev_group     phys_port_name  proto_down  statistics  threaded   ueventaddr_len  carrier_changes  device       dormant gro_flush_timeout  iflink   name_assign_type  operstate     phys_switch_id  queues subsystem   tx_queue_len
However, when I go to start the interface manually, the network stack locks up hard. I can't break out of the command. I can't shell in from another terminal session on either Wifi or Ethernet (both of which are active). I have to reboot to be able to get back in.

Code:

 ip link set CAN1 up type can bitrate 125000
Is my configuration in /boot.config.txt incorrect for this setup (SPI bus 1, interrupt 25, chip select on GPIO 18 / SPI1_CE0_N)?

Can anyone tell me why the kernel decides to rename the device from can0 to CAN1?

Should I be using a different overlay? The ones I see in /boot/overlays are:

Code:

-rwxr-xr-x 1 root root 1793 Jul 15  2023 mcp2515-can0.dtbo-rwxr-xr-x 1 root root 1612 Jul 15  2023 mcp2515-can1-0.dtbo-rwxr-xr-x 1 root root 1793 Jul 15  2023 mcp2515-can1.dtbo-rwxr-xr-x 1 root root 3843 Jul 15  2023 mcp2515.dtbo-rwxr-xr-x 1 root root 6428 Jul 15  2023 mcp251xfd.dtbo
Any suggestions would be greatly appreciated.

Statistics: Posted by falkenavionics — Wed Oct 23, 2024 11:40 pm — Replies 0 — Views 45



Viewing all articles
Browse latest Browse all 4436

Trending Articles