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

**URL:** <https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260>\
**Category:** balenaOS\
**Created:** [September 20, 2020, 4:23am UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260 "2020-09-20T04:23:41Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![dreyplatt](https://avatars.discourse-cdn.com/v4/letter/d/dc4da7/32.png) [@dreyplatt](https://forums.balena.io/u/dreyplatt)\
**Post date:** [September 20, 2020, 4:23am UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260/1 "2020-09-20T04:23:41Z")

</div>

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

[Link to Overlay](https://github.com/Seeed-Studio/seeed-linux-dtoverlays/tree/master/modules/CAN-HAT)

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

```auto
/resin-boot/overlays

```

I see the

```auto
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.

---

<div class="post-metadata">

**Author:** ![phil-d-wilson](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/phil-d-wilson/32/3730_2.png) [@phil-d-wilson](https://forums.balena.io/u/phil-d-wilson)\
**Post date:** [September 21, 2020, 8:28am UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260/4 "2020-09-21T08:28:48Z")

</div>

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:

> **[Advanced boot settings - Balena Documentation](https://www.balena.io/docs/reference/OS/advanced/#setting-device-tree-overlays-dtoverlay-and-parameters-dtparam)**

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

> <https://github.com/raspberrypi/linux/blob/rpi-4.19.y/arch/arm/boot/dts/overlays/README>

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

Phil

---

<div class="post-metadata">

**Author:** ![npetridis](https://avatars.discourse-cdn.com/v4/letter/n/e9c0ed/32.png) [@npetridis](https://forums.balena.io/u/npetridis)\
**Post date:** [November 5, 2020, 1:03pm UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260/6 "2020-11-05T13:03:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![npetridis](https://avatars.discourse-cdn.com/v4/letter/n/e9c0ed/32.png) [@npetridis](https://forums.balena.io/u/npetridis)\
**Post date:** [November 5, 2020, 1:18pm UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260/7 "2020-11-05T13:18:00Z")

</div>

Hi there! Did you manage to load the overlay?

---

<div class="post-metadata">

**Author:** ![acostach](https://avatars.discourse-cdn.com/v4/letter/a/bcef8e/32.png) [@acostach](https://forums.balena.io/u/acostach)\
**Post date:** [November 5, 2020, 8:31pm UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260/8 "2020-11-05T20:31:50Z")

</div>

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](https://github.com/balena-os/balena-raspberrypi/pull/484)

---

<div class="post-metadata">

**Author:** ![npetridis](https://avatars.discourse-cdn.com/v4/letter/n/e9c0ed/32.png) [@npetridis](https://forums.balena.io/u/npetridis)\
**Post date:** [November 7, 2020, 11:21am UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260/10 "2020-11-07T11:21:08Z")

</div>

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](https://github.com/raspberrypi/linux/tree/rpi-5.4.y/arch/arm/boot/dts) 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](https://github.com/Seeed-Studio/seeed-linux-dtoverlays/tree/master/modules/CAN-HAT), 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!

---

<div class="post-metadata">

**Author:** ![robertgzr](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/robertgzr/32/1387_2.png) [@robertgzr](https://forums.balena.io/u/robertgzr)\
**Post date:** [November 9, 2020, 6:38am UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260/11 "2020-11-09T06:38:41Z")

</div>

heyo @npetridis,

the patched makefile is here [https://github.com/raspberrypi/linux/blob/rpi-5.4.y/arch/arm/boot/dts/overlays/Makefile](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…

---

<div class="post-metadata">

**Author:** ![Gregory](https://avatars.discourse-cdn.com/v4/letter/g/e56c9b/32.png) [@Gregory](https://forums.balena.io/u/Gregory)\
**Post date:** [February 17, 2021, 3:47pm UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260/13 "2021-02-17T15:47:42Z")

</div>

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](https://github.com/raspberrypi/linux/blob/rpi-5.4.y/arch/arm/boot/dts/overlays/mcp251xfd-overlay.dts) and new [seeed-can-fd-hat-v2-overlay.dts](https://github.com/raspberrypi/linux/blob/rpi-5.4.y/arch/arm/boot/dts/overlays/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.

---

<div class="post-metadata">

**Author:** ![Gregory](https://avatars.discourse-cdn.com/v4/letter/g/e56c9b/32.png) [@Gregory](https://forums.balena.io/u/Gregory)\
**Post date:** [February 18, 2021, 7:16am UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260/14 "2021-02-18T07:16:34Z")

</div>

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](https://www.raspberrypi.org/documentation/linux/kernel/building.md).  
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.

---

<div class="post-metadata">

**Author:** ![anujdeshpande](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/anujdeshpande/32/3155_2.png) [@anujdeshpande](https://forums.balena.io/u/anujdeshpande)\
**Post date:** [February 18, 2021, 11:29am UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260/17 "2021-02-18T11:29:22Z")

</div>

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](https://www.balena.io/blog/sensors-and-data-logging-with-embedded-linux-the-ultimate-guide-part-1/) - which talks about how you could go about doing that.

---

<div class="post-metadata">

**Author:** ![Ereski](https://avatars.discourse-cdn.com/v4/letter/e/958977/32.png) [@Ereski](https://forums.balena.io/u/Ereski)\
**Post date:** [February 24, 2021, 5:55pm UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260/19 "2021-02-24T17:55:19Z")

</div>

Hi. Were you able to load those overlays dynamically?

---

<div class="post-metadata">

**Author:** ![WestCoastDaz](https://avatars.discourse-cdn.com/v4/letter/w/858c86/32.png) [@WestCoastDaz](https://forums.balena.io/u/WestCoastDaz)\
**Post date:** [April 15, 2021, 10:05pm UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260/23 "2021-04-15T22:05:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anujdeshpande](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/anujdeshpande/32/3155_2.png) [@anujdeshpande](https://forums.balena.io/u/anujdeshpande)\
**Post date:** [April 16, 2021, 5:58am UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260/24 "2021-04-16T05:58:40Z")

</div>

Hey @westcoastdaz

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

---

<div class="post-metadata">

**Author:** ![WestCoastDaz](https://avatars.discourse-cdn.com/v4/letter/w/858c86/32.png) [@WestCoastDaz](https://forums.balena.io/u/WestCoastDaz)\
**Post date:** [April 23, 2021, 3:30pm UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260/26 "2021-04-23T15:30:39Z")

</div>

@anujdeshpande

Thanks for the reply. I haven’t had a chance to try yet as I’m waiting on hardware to be shipped. When you say blog post you mean [Sensors and Data Logging with Embedded Linux](https://www.balena.io/blog/sensors-and-data-logging-with-embedded-linux-the-ultimate-guide-part-1/)

---

<div class="post-metadata">

**Author:** ![rosswesleyporter](https://avatars.discourse-cdn.com/v4/letter/r/bc79bd/32.png) [@rosswesleyporter](https://forums.balena.io/u/rosswesleyporter)\
**Post date:** [April 26, 2021, 8:51pm UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260/27 "2021-04-26T20:51:11Z")

</div>

Hi @westcoastdaz,

You are correct - that is the blog post.

Is there a specific MCP2518FD device that you have in mind / on order? For instance, gregory above refers to the dts for a [Seeed HAT](https://www.seeedstudio.com/CAN-BUS-FD-HAT-for-Raspberry-Pi-p-4742.html).

---

<div class="post-metadata">

**Author:** ![rosswesleyporter](https://avatars.discourse-cdn.com/v4/letter/r/bc79bd/32.png) [@rosswesleyporter](https://forums.balena.io/u/rosswesleyporter)\
**Post date:** [May 18, 2021, 6:02pm UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260/30 "2021-05-18T18:02:08Z")

</div>

Hi @westcoastdaz,

MCP2518FP support has been added for the Pi3 (32-bit) and balenaFin devices types in balenaOS 2.77.0+rev1, now available in production. The same will be true of the Pi4 device type in 2-4 weeks. If you need to experiment with a Pi4 now, note that the Pi4 now has the necessary kernel module mcp251xfd.ko, so in theory you can manually copy the mcp251xfd-overlay dtb and set RESIN\_HOST\_CONFIG\_dtoverlay, but we have not tested this. Thank you for asking about MCP2518FP support - future CAN bus users will thank you.

---

<div class="post-metadata">

**Author:** ![WestCoastDaz](https://avatars.discourse-cdn.com/v4/letter/w/858c86/32.png) [@WestCoastDaz](https://forums.balena.io/u/WestCoastDaz)\
**Post date:** [May 18, 2021, 7:01pm UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260/32 "2021-05-18T19:01:33Z")

</div>

@rosswesleyporter

Thank you for the update and for helping get the Balena team to work on this! I will keep you posted with the testing.

---

<div class="post-metadata">

**Author:** ![rosswesleyporter](https://avatars.discourse-cdn.com/v4/letter/r/bc79bd/32.png) [@rosswesleyporter](https://forums.balena.io/u/rosswesleyporter)\
**Post date:** [June 14, 2021, 9:03pm UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260/34 "2021-06-14T21:03:00Z")

</div>

Hi @westcoastdaz,

FYI, MCP2518FP support is now live for PI4. More specifically, balenaOS 2.80.3+rev1 for the “Raspberry Pi 4 (using 64bit OS)” device type now includes the mcp251xfd.dtbo overlay as well as the mcp251xfd.ko kernel module.

---

<div class="post-metadata">

**Author:** ![WestCoastDaz](https://avatars.discourse-cdn.com/v4/letter/w/858c86/32.png) [@WestCoastDaz](https://forums.balena.io/u/WestCoastDaz)\
**Post date:** [June 17, 2021, 4:12pm UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260/36 "2021-06-17T16:12:25Z")

</div>

@rosswesleyporter Thank you very much. Given the fact that the MCP2515 is NRND, do you think the MCP2518 support will make it into other RPI Balena OS builds, such as RPI Zero W?

Thanks,

---

<div class="post-metadata">

**Author:** ![rosswesleyporter](https://avatars.discourse-cdn.com/v4/letter/r/bc79bd/32.png) [@rosswesleyporter](https://forums.balena.io/u/rosswesleyporter)\
**Post date:** [June 18, 2021, 7:09pm UTC](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260/37 "2021-06-18T19:09:23Z")

</div>

Good question. I’ll check on those plans including the Zero W.

[Next page](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260.md?page=2)
