How to setup a raspberry pi 3 with CAN Interface?
Hardware:
Raspberry pi 3 b+
PiCAN 2 Duo – CAN-Bus Board
Software:
balenaOS 2.31.5+rev5
My fist step to setup this projct:
Add the overlays by: to config.txt
4 lines to the end of config.txt file:
dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=mcp2515-can1,oscillator=16000000,interrupt=24
dtoverlay=spi-bcm2835-overlay
But no can driver is visable. What ist going wrong?
Could you share the Dockerfile that you’re using to set up your container? I would check to make sure you’re using a stretch-based image (if you’re using Debian).
Additionally could you enable support access for your device and share the URL here, we can then take a look to see if we can figure out what’s happening. There are some ideas around debugging CAN interfaces in this thread.
FROM resin/%%RESIN_MACHINE_NAME%%-python
ENV INITSYSTEM on
COPY ./requirements.txt /requirements.txt
RUN pip install -r /requirements.txt
COPY . /usr/src/app
WORKDIR /usr/src/app
CMD [“python”, “gpio_example.py”]
requirements.txt:
RPi.Gpio
python-can
And i get the following error:
[Info] Starting build for helloworld, user xxx
[Info] Dashboard link: https://dashboard.balena-cloud.com/apps/1454763/devices
[Info] Building on arm03
[Info] Pulling previous images for caching purposes…
[Success] Successfully pulled cache images
[main] Step 1/7 : FROM resin/raspberrypi3-64-python
[main] repository resin/raspberrypi3-64-python not found: does not exist or no pull access
[Error] Some services failed to build:
[Error] Service: main
[Error] Error: repository resin/raspberrypi3-64-python not found: does not exist or no pull access
[Error] Not deploying release.
The repository: resin/raspberry3-65-python is not found!
the basis setup you used is out of date since we dropped support for old resin base images a while ago, the resin/raspberrypi3-64-python image is not found because that device was added after the support ended.
Please switch to the new balenalib base images by changing to FROM balenalib/%%BALENA_MACHINE_NAME%%-python. You can drop this line ENV INITSYSTEM on and add ENV UDEV on since udev is off by default.
@tomtom68, we have some breaking changes in the balenalib base images (you can find more details in the blog post here https://www.balena.io/blog/new-year-new-balena-base-images/). So the default image now only contains essential packages for a project to run, not all the tools or common libraries.
Looks like you should install build-essential package here, please add RUN install_packages build-essential to your Dockerfile before RUN pip install... command.
Could you share your Dockerfile on a gist so I can try building it on my end?
Did you make the configuration change on the dashboard or on the config.txt itself?
If so, you should make the changes on the dashboard. Go to the device page and on Device Configuration, add the custom variables there.
So RESIN_HOST_CONFIG_dtparam = on (it should be already ON)
And for the other configs, you need to add the RESIN_HOST_CONFIG_ or BALENA_HOST_CONFIG_ prefix.