I am trying to use SpiDev to use the SPI on the Raspberry Pi 3 B+ to communicate with an add-on board.
I am starting by just attempting to read the chip ID of the device to make sure that the SPI is working,
I initialize the SPI with the following, and it doesn’t give an error
SPI_FREQUENCY = 976563 SPI_MODE = 1 # Initialize the wiringpi SPI setup. self.spi_handle = spidev.SpiDev() # Open SPI device "/dev/spidev0.0". self.spi_handle.open(0,0) self.spi_handle.max_speed_hz = conf.SPI_FREQUENCY self.spi_handle.mode = conf.SPI_MODE if (self.spi_handle == -1): raise IOError("ERROR: Could not access SPI device file")
To read the Chip ID byte I use
chipId = self.spi_handle.readbytes(1)
I keep reading the Chip ID in a loop with a 100ms delay between calls, and when I probe the SCK pin with my oscilloscope I never see the clock, only noise.
If I run
After looking through the balena forums I tried “RUN modprobe bcm2835-412” and “RUN mdprobe v412_common” to no success.
Following is my Dockerfile.template:
FROM balenalib/%%BALENA_MACHINE_NAME%%-python:3-stretch-run # enable container init system. ENV INITSYSTEM on # use `install_packages` if you need to install dependencies, # for instance if you need git, just uncomment the line below. # RUN install_packages git RUN install_packages build-essential RUN pip install --upgrade pip RUN apt-get update && apt-get install -yq --no-install-recommends build-essential rpi.gpio RUN pip install smbus2 RUN pip install spidev #RUN modprobe bcm2835-v4l2 #RUN modprobe v4l2_common # Set our working directory WORKDIR /usr/src/automated_testing_button_panel # Copy requirements.txt first for better cache on later pushes COPY requirements.txt requirements.txt # pip install python deps from requirements.txt on the resin.io build server RUN pip install -r requirements.txt # This will copy all files in our root to the working directory in the container COPY . ./ # Enable udevd so that plugged dynamic hardware devices show up in our container. ENV UDEV=1 # main.py will run when container starts up on the device CMD ["python","-u","src/automated_testing_button_panel_main.py"]
And my DT parameters and overlays.