Page 1 of 1
Pi5 CANbus with Balena
Posted: 25 Apr 2025, 04:20
by agregg
Hi, I am trying to get the Pi5 CANbus to work with Balena OS. I have successfully loaded Balena and I am using dt overlays that work with a different MCP2515-based CAN hat. I doubt these are correct for RevPi. I'm unable to see the can devices in ifconfig. Could you tell me the correct overlays that I should be applying? Thank you!
Under Balena configuration, I'm using:
Define DT Overlays:
Code: Select all
"mcp2515-can1,oscillator=16000000,interrupt=25", "mcp2515-can0,oscillator=16000000,interrupt=23", "spi-bcm2835-overlay"
Define DT Parameters for the Default Overlay:
Re: Pi5 CANbus with Balena
Posted: 02 May 2025, 21:17
by nicolaiB
Hi
there are several things:
- Connect 5 is using the mcp251863 controll, thus you need to use the mcp251xfd overlay
- Connect 5 uses a 20 MHz oscillator
- You must use the correct pins and SPI interface. The controller is connected to SPI1 with pin 11 as chip select (cs1)
- Controller for spi1 must be enabled with the spi1
Everything together results in the following two overlay definitions
Code: Select all
spi1-2cs,cs1_pin=11
mcp251xfd,spi1-1,interrupt=6,oscillator=20000000
If you're interested on the rest of the hardware or the overlay in general, you can find it here:
https://gitlab.com/revolutionpi/linux/- ... verlay.dts
https://gitlab.com/revolutionpi/linux/- ... verlay.dts
Nicolai
Re: Pi5 CANbus with Balena
Posted: 05 May 2025, 17:42
by agregg
Thanks! I started looking through the overlay files and was almost there. I tried the overlays you recommended:
Code: Select all
"spi1-2cs,cs1_pin=11","mcp251xfd,spi1-1,interrupt=6,oscillator=20000000"
After removing the default param
that was causing a gpio conflict, I was able to get can0 working!
Working on can1 now...
Re: Pi5 CANbus with Balena
Posted: 06 May 2025, 12:29
by nicolaiB
CAN1 is attached to spi5 with irq=25, miso=13, mosi=14, clk=15 and cs=12
https://gitlab.com/revolutionpi/linux/- ... y.dts#L137
This would result in
Code: Select all
"spi5-1cs","mcp251xfd,spi5-1,interrupt=25,oscillator=20000000"
Nicolai
Re: Pi5 CANbus with Balena
Posted: 07 May 2025, 17:57
by agregg
I'm having trouble with that one. I tried adding it with the previous can0 overlay and also just by itself.
I get the following conflict:
root@balena:~# dmesg | grep spi
[ 3.009703] spi spi0.0: chipselect 0 already in use
[ 3.009712] spi_master spi0: spi_device register error /axi/pcie@1000120000/rp1/spi@50000/spidev@0
[ 3.009725] spi_master spi0: Failed to create SPI device for /axi/pcie@1000120000/rp1/spi@50000/spidev@0
[ 3.315641] spi_master spi0: will run message pump with realtime priority
[ 3.354154] mcp251xfd spi0.0 (unnamed net_device) (uninitialized): Failed to read Oscillator Configuration Register (osc=0xffffffff).
[ 3.354162] mcp251xfd spi0.0: error -ENODEV: Failed to detect MCP251xFD.
Re: Pi5 CANbus with Balena
Posted: 08 May 2025, 15:00
by nicolaiB
Please double check the overlay names. In your log file the error is about spi 0 and not 5.
Nicolai
Re: Pi5 CANbus with Balena
Posted: 09 May 2025, 15:47
by agregg
Hi Nicolai, that's what is strange. I'm setting spi5 exactly how you wrote in your post, but the error is coming back as spi0.
Re: Pi5 CANbus with Balena
Posted: 13 Jun 2025, 17:52
by agregg
Bump on this ^ Are you able to replicate with Balena?