# CAN bus interface configuring fails

**URL:** <https://forums.balena.io/t/can-bus-interface-configuring-fails/4647>\
**Category:** Product support\
**Created:** [December 10, 2018, 12:28am UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647 "2018-12-10T00:28:44Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![janne\_kjellman](https://avatars.discourse-cdn.com/v4/letter/j/258eb7/32.png) [@janne\_kjellman](https://forums.balena.io/u/janne_kjellman)\
**Post date:** [December 10, 2018, 12:28am UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647/1 "2018-12-10T00:28:44Z")

</div>

[5.871990] mcp251x spi0.1 can0: MCP2515 successfully initialized.  
[5.883830] mcp251x spi0.0 can1: MCP2515 successfully initialized.  
[45.757812] can: controller area network core (rev 20170425 abi 9)  
[45.793194] can: raw protocol (rev 20170425)

Running balenaOS 2.27.0+rev1 on Raspberry Pi 3+ with PiCAN (dual) interface. The CAN interfaces get initialized correctly but configuring them via /sbin/ip produces error:

root@xxxxxx:~# /sbin/ip link set can0 up type can bitrate 250000 restart-ms 100  
ip: either “dev” is duplicate, or “type” is garbage

---

<div class="post-metadata">

**Author:** ![cyplo](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/cyplo/32/1224_2.png) [@cyplo](https://forums.balena.io/u/cyplo)\
**Post date:** [December 10, 2018, 8:01am UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647/4 "2018-12-10T08:01:52Z")

</div>

Hello ! Could you DM me a link to the device in the dashboard so that we can take a look ? Thanks ! 🙂

---

<div class="post-metadata">

**Author:** ![janne\_kjellman](https://avatars.discourse-cdn.com/v4/letter/j/258eb7/32.png) [@janne\_kjellman](https://forums.balena.io/u/janne_kjellman)\
**Post date:** [December 10, 2018, 8:30am UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647/6 "2018-12-10T08:30:34Z")

</div>

[https://dashboard.balena-cloud.com/devices/10eaf12ecd212d8d64a61ba2f7938607/summary](https://dashboard.balena-cloud.com/devices/10eaf12ecd212d8d64a61ba2f7938607/summary)

---

<div class="post-metadata">

**Author:** ![cyplo](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/cyplo/32/1224_2.png) [@cyplo](https://forums.balena.io/u/cyplo)\
**Post date:** [December 10, 2018, 9:18am UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647/14 "2018-12-10T09:18:39Z")

</div>

Thank you for the device link 🙂 It seems that the device needs custom `dtoverlay` settings which you [set](https://www.balena.io/docs/reference/OS/advanced/#setting-device-tree-overlays-dtoverlay-and-parameters-dtparam-) via the device settings page - this looks good 🙂 The `/resin-boot/config.txt` file does not contain the overlay settings though, would it be okay if I rebooted the device to see if it gets regenerated ?

---

<div class="post-metadata">

**Author:** ![janne\_kjellman](https://avatars.discourse-cdn.com/v4/letter/j/258eb7/32.png) [@janne\_kjellman](https://forums.balena.io/u/janne_kjellman)\
**Post date:** [December 10, 2018, 10:23am UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647/16 "2018-12-10T10:23:28Z")

</div>

Yes, please do, it’s only testing environment at this point.

I somehow have the feeling that the “ip link” program was working at some point but not anymore, strange…

T: Janne

---

<div class="post-metadata">

**Author:** ![janne\_kjellman](https://avatars.discourse-cdn.com/v4/letter/j/258eb7/32.png) [@janne\_kjellman](https://forums.balena.io/u/janne_kjellman)\
**Post date:** [December 11, 2018, 9:47am UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647/21 "2018-12-11T09:47:48Z")

</div>

root@xxxxxxx:/mnt/boot# cat config.txt  
avoid\_warnings=1  
disable\_splash=1  
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25  
dtoverlay=mcp2515-can1,oscillator=16000000,interrupt=24  
dtoverlay=spi-bcm2835-overlay  
dtparam=i2c\_arm=on  
dtparam=spi=on  
dtparam=audio=on  
gpu\_mem=16

The dtoverlay settings are found under /mnt/boot, and…

root@xxxxxx:/# ip link show can0  
3: can0: mtu 16 qdisc noop qlen 10  
link/[280]

So the device actually is there and is type CAN [280]. Could it be that the ip software is just outdated and unable to handle CAN type of devices? How can it be upgraded on host os?

// Janne

---

<div class="post-metadata">

**Author:** ![cyplo](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/cyplo/32/1224_2.png) [@cyplo](https://forums.balena.io/u/cyplo)\
**Post date:** [December 14, 2018, 3:41pm UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647/34 "2018-12-14T15:41:46Z")

</div>

Hello ! Thank you for this additional data, we are still looking into this and will let you know when we will have more information.

---

<div class="post-metadata">

**Author:** ![nazrhom](https://avatars.discourse-cdn.com/v4/letter/n/ee59a6/32.png) [@nazrhom](https://forums.balena.io/u/nazrhom)\
**Post date:** [December 17, 2018, 3:18pm UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647/41 "2018-12-17T15:18:37Z")

</div>

Hey, @janne_kjellman  
can you check if support access is enabled for the device, and enable it if its not.

---

<div class="post-metadata">

**Author:** ![janne\_kjellman](https://avatars.discourse-cdn.com/v4/letter/j/258eb7/32.png) [@janne\_kjellman](https://forums.balena.io/u/janne_kjellman)\
**Post date:** [December 17, 2018, 4:16pm UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647/42 "2018-12-17T16:16:15Z")

</div>

[https://dashboard.balena-cloud.com/devices/79940fe48f27f460f1fae264d2fdc7b9/summary](https://dashboard.balena-cloud.com/devices/79940fe48f27f460f1fae264d2fdc7b9/summary)

It should be enabled.

---

<div class="post-metadata">

**Author:** ![zrzka](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/zrzka/32/1612_2.png) [@zrzka](https://forums.balena.io/u/zrzka)\
**Post date:** [December 17, 2018, 7:08pm UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647/44 "2018-12-17T19:08:25Z")

</div>

Hi @janne_kjellman,

I checked your device and it seems okay. I mean the configuration looks good, kernel module is loaded, devices are visible, … It seems that `ip` can’t handle the `can` device. Unfortunately, I don’t have a can around to try it locally. I tried to find more info, like this one [https://community.nxp.com/thread/462448](https://community.nxp.com/thread/462448), and it probably confirms my findings. Will continue with this investigation.

---

<div class="post-metadata">

**Author:** ![janne\_kjellman](https://avatars.discourse-cdn.com/v4/letter/j/258eb7/32.png) [@janne\_kjellman](https://forums.balena.io/u/janne_kjellman)\
**Post date:** [December 18, 2018, 12:44pm UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647/46 "2018-12-18T12:44:48Z")

</div>

Hi,

Same hardware with Raspbian runs flawlessly…

I installed iproute2 to one of the Docker sub systems and run the command in Host OS:

root@79940fe:/mnt/data# ./ip link set can0 type can

root@79940fe:/mnt/data# ./ip link set can0 bitspeed 250000

Error: either “dev” is duplicate, or “bitspeed” is a garbage.

root@79940fe:/mnt/data# ./ip link set can0 up

RTNETLINK answers: Invalid argument

root@79940fe:/mnt/data#

So it feels that even with iproute2 the device is not working properly. Even this iproute2 does not support setting speed on device but even UP command does not return reasonable answer from the can0 device?

// Janne

---

<div class="post-metadata">

**Author:** ![majorz](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/majorz/32/639_2.png) [@majorz](https://forums.balena.io/u/majorz)\
**Post date:** [December 18, 2018, 2:10pm UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647/48 "2018-12-18T14:10:34Z")

</div>

Can you please try running the ip commands from a container, and not the host OS. The ip command in the host OS is provided by busybox, which is a smaller single binary implementation of many standard Linux tools.

Since you are in a multi-container environment please enable in your docker-compose.yml file `network_mode: "host"` and `privileged: true` for the container you are going to run the commands from.

---

<div class="post-metadata">

**Author:** ![janne\_kjellman](https://avatars.discourse-cdn.com/v4/letter/j/258eb7/32.png) [@janne\_kjellman](https://forums.balena.io/u/janne_kjellman)\
**Post date:** [December 18, 2018, 2:27pm UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647/49 "2018-12-18T14:27:37Z")

</div>

root@79940fe:/usr# ip -d link show can0  
2: can0: \<NOARP,ECHO\> mtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10  
link/can promiscuity 0  
can state STOPPED restart-ms 0  
mcp251x: tseg1 3…16 tseg2 2…8 sjw 1…4 brp 1…64 brp-inc 1  
clock 8000000  
root@79940fe:/usr# ip link set can0 bitspeed 250000  
Error: either “dev” is duplicate, or “bitspeed” is a garbage.  
root@79940fe:/usr# ip link set can0 up  
RTNETLINK answers: Invalid argument

---

<div class="post-metadata">

**Author:** ![majorz](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/majorz/32/639_2.png) [@majorz](https://forums.balena.io/u/majorz)\
**Post date:** [December 18, 2018, 2:50pm UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647/50 "2018-12-18T14:50:49Z")

</div>

Can you please run it in a Stretch container, since I think the default one is Jessie. This will bring us closer to Raspbian. `resin/raspberrypi3-debian:stretch`.

Also just in case can you run `ip link set can0 bitspeed 250000` as `ip link set can0 type can bitspeed 250000`. And also with a different speed, e.g. 1000000.

---

<div class="post-metadata">

**Author:** ![janne\_kjellman](https://avatars.discourse-cdn.com/v4/letter/j/258eb7/32.png) [@janne\_kjellman](https://forums.balena.io/u/janne_kjellman)\
**Post date:** [December 18, 2018, 5:42pm UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647/52 "2018-12-18T17:42:34Z")

</div>

Setting the container to run FROM resin/raspberrypi3-debian:stretch

root@79940fe:/# ip link set can0 type can bitrate 250000  
root@79940fe:/# ip link set can0 up  
root@79940fe:/# ip link show can0  
2: can0: \<NOARP,UP,LOWER\_UP,ECHO\> mtu 16 qdisc fq\_codel state UNKNOWN mode DEFAULT group default qlen 10  
link/can

-\> Seems to work.  
-\> Also candump shows packets.

Is there way to get this working in the raspberry3-node container as well?

---

<div class="post-metadata">

**Author:** ![shaunmulligan](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/shaunmulligan/32/34_2.png) [@shaunmulligan](https://forums.balena.io/u/shaunmulligan)\
**Post date:** [December 26, 2018, 12:38am UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647/53 "2018-12-26T00:38:00Z")

</div>

Hi @janne_kjellman, if you need node.js and stretch, you can try our new set of base images, I would try `balenalib/raspberrypi3-debian-node:8-stretch-build` which will give you node.js 8 with debian stretch for the raspberry pi 3.

This set of images is going to be released officially in the coming week and you can read a bit more about them on this [Docs pull request](https://github.com/balena-io/docs/blob/72fbb0d989c3ec05102e81dd4c7e2a7c10d62184/pages/reference/base-images/base-images.md)

---

<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, 8:34am UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647/56 "2020-11-05T08:34:32Z")

</div>

Hello! I have the same problem, my host can’t see can0 interface (same for my service).  
When I use a simple raspbian OS can works fine.  
What are the dt params I have to set and how?  
Also I guess I have to install the can bus driver to the kernel. I use seeed studio can bus v2 and I found that [this](https://github.com/Seeed-Studio/seeed-linux-dtoverlays/tree/master/modules/CAN-HAT) is what I have to install but have no idea how.  
Thank you in advance!

---

<div class="post-metadata">

**Author:** ![karaxuna](https://avatars.discourse-cdn.com/v4/letter/k/e480ec/32.png) [@karaxuna](https://forums.balena.io/u/karaxuna)\
**Post date:** [November 5, 2020, 10:12am UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647/58 "2020-11-05T10:12:49Z")

</div>

Hi @npetridis, here’s the [sample repo](https://github.com/balena-io-playground/balena-pican2-testbench) where you can find configuration you need. Please let us know if you have more questions.

---

<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, 10:50am UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647/60 "2020-11-05T10:50:27Z")

</div>

Thank you for your message, I setup the config.txt as suggested and after rebooting can0 is still not visible in the device’s interfaces.  
When I run `/sbin/ip link set can0 up type can bitrate 100000` in my start.sh file of my service I get:

```auto
Cannot find device "can0"
SIOCGIFINDEX: No such device

```

I have also added:

```auto
network_mode: host
labels:
      io.resin.features.kernel-modules: "true"
      io.resin.features.firmware: "true"

```

In my service docker-compose  
Any ideas?

---

<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, 12:04pm UTC](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647/61 "2020-11-05T12:04:22Z")

</div>

> [@majorz](#):
>
> network\_mode: “host”

I saw my can0 board uses mcp2517fd chip, balena doesn’t have the corresponding overlay.  
I found this [thread](https://forums.balena.io/t/add-custom-overlay-for-mcp2517fd-for-raspberry-pi-4-for-can-bus-fd/191260) but I don’t understand how to continue and install the overlay.

[Next page](https://forums.balena.io/t/can-bus-interface-configuring-fails/4647.md?page=2)
