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
Thank you for the device link It seems that the device needs custom dtoverlay settings which you set 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 ?
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?
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, and it probably confirms my findings. Will continue with this investigation.
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?
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.
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
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.
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?
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
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 is what I have to install but have no idea how.
Thank you in advance!
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:
Cannot find device "can0"
SIOCGIFINDEX: No such device
I saw my can0 board uses mcp2517fd chip, balena doesn’t have the corresponding overlay.
I found this thread but I don’t understand how to continue and install the overlay.