Add custom overlay for MCP2517FD for Raspberry pi 4 for CAN bus FD

So, I am trying to interface with the can bus hat from seeed studio using the raspberry pi 4.

Link to Overlay

This new board uses the newer mcp2517fd chip instead of the notorious mcp2515 chip which is built into raspbian. I need to now add this overlay to

/resin-boot/overlays

I see the

mcp2515-can0.dtbo

overlay. Of course resin-boot is read only so I have to do something before it starts up, but have no idea what that would be.

1 Like

Hi Drey!

I’m glad to see you’re still fighting! We’re working in the background to try and work out your Beaglebone Green issue with CANbus, but moving over to a more capable device might be a good step anyway.

So to this issue, you can use our special configurable variables to set DT Overlays:

This page gives some guidance for the overlay you’re trying to use:

Hope this helps. Keep going, we’ll get you sorted!

Phil

Hello! I also need overlay support for MCP2517FD for raspberry pi 3B+.
Can you provide instructions on how to add the custom overlay?
Thank you in advance

Hi there! Did you manage to load the overlay?

Hi @npetridis,

To include your custom overlay in a BalenaOS image you can open a PR in the balena-raspberrypi repository. Here’s an example PR on how to add your overlay https://github.com/balena-os/balena-raspberrypi/pull/484

1 Like

Thank you very much Alexandru! A little more help here.
So the PR has three file changes:

  • layers/meta-balena-raspberrypi/conf/layer.conf
    Seems ok I’m just not sure if I should name my dtbo file 2xmcp2517fd or mcp2517fd. Should this be defined by how it is named in the raspberry kernel system?
  • layers/meta-balena-raspberrypi/recipes-kernel/linux/linux-raspberrypi_%.bbappend
    Is straight forward
  • layers/meta-balena-raspberrypi/recipes-kernel/linux/linux-raspberrypi/0009-seeed studio-can-bus-v2-Add-dtbo-for-this-can-bus.patch
    About my patch file, should it have prefix 0001, 0009 or something else?

Concerning the content of the patch file, the diff is extracted from where? A quick search lead me here but I can’t find arch/arm/boot/dts/overlays/Makefile path
I use raspberry pi 3 model B maybe not the correct branch?
Also I have located 2xMCP2517FD.dtbo and 2xMCP2517FD-overlay.dts files here, should I add these files somehow of are they already located in raspberry os (not balena os).
Sorry for the noob questions first time trying to figure these out! Hopefully I will soon be able to contribute more independently!

heyo @npetridis,

the patched makefile is here https://github.com/raspberrypi/linux/blob/rpi-5.4.y/arch/arm/boot/dts/overlays/Makefile - github always struggles with lots of files in a directory but going via url works…

1 Like

Hi all,

It seems this discussion is the closest to my similar problem.
First did you get something running with mcp2517fd ?

In my case, I want to use a Seed 2x CAN FD channel HAT based on mcp2518fd.

I have found that mcp251xfd-overlay.dts and new seeed-can-fd-hat-v2-overlay.dts exist in v5.4.y raspberrypi/linux repo.

My basics questions is how to get these file and compiled dtbo in the balenaOS ?

  • Do I need to recompile myself the balenaOS ?
  • Can I compile dts to dtbo with device-tree-compiler on my machine (is dtbo the same on all arch arm or arm64 ?)
  • Can I just try to add dtbo in /boot/overlays folder of balenaOS sdcard + adding “dtoverlay” setting in balenaCloud ?
  • How to get these dtbo in futur balenaOS release ?

Thanks.

To continue on my topic.

I clone and recompile the raspberrypi 5.4.y kernel for arm64 arch, just following this guide : Kernel building - Raspberry Pi Documentation.
Then I just copy the mcp25xfd.dtbo to resin-boot/boot/overlays partition, and add the correct dtoverlay parameters on balenaCloud device configuration :
"spi1-1cs","mcp251xfd,spi0-0,interrupt=25","mcp251xfd,spi1-0,interrupt=24"
Then my Seed HAT (a dual mcp2518fd without rtc) is correctly recognize.

So what’s next step ?
How to get this dts overlay included in next balenaOS release ?
I’m sure mcp2517 and mcp2518 including CAN FD will be used by many people.

Hi

Is it acceptable to you to load overlays dynamically, instead of making them part of the OS?
Check out this blog - Sensors and Data Logging with Embedded Linux - The Ultimate Guide Part 1 - which talks about how you could go about doing that.

Hi. Were you able to load those overlays dynamically?

Any updates on this thread? Has any one been able to use the MCP2518FD successfully?

Hey @westcoastdaz

Did you try the stuff in the blog post that was linked? Did you run into issues while following that?