Hello,
I am trying to get an i2c device to work on an image, and I’ve already tried the tips in here:
I’ve attached my dockerfile.template, dockerfile-compose.yaml and udev-rules.
What am I getting wrong here? The fatal error (in the title of this post) happens as soon as the installer for daqhats tries to read DAQ HAT EEPROMs over i2c:
[data_kit_srv] make: Leaving directory ‘/usr/src/app/daqhats/examples/c’
[data_kit_srv] Reading DAQ HAT EEPROMs
[data_kit_srv] modprobe: FATAL: Module i2c_dev not found in directory /lib/modules/6.1.35-yocto-standard
I’ve previously had a similar config work with i2c when interfacing with sparkfun-qwiic devices, so I really don’t understand what the root of the issue is here.
Docker compose file:
version: '2'
services:
data_kit_srv:
labels:
io.balena.features.kernel-modules: 1
build: .
privileged: true
# command: modprobe i2c-dev && python3 test
devices:
- /dev/i2c-1:/dev/i2c-1
- /dev/mem:/dev/mem
- /dev/gpiomem:/dev/gpiomem
environment:
- "UDEV=1"
ports:
- "5555:5555"
volumes:
- /lib/modules:/lib/modules
cap_add:
- “ALL”
Dockerfile.template:
FROM balenalib/%%BALENA_MACHINE_NAME%%-python:3.10
# Install any dependencies if required
# RUN apt-get update && apt-get install -y your-dependencies
RUN install_packages git gcc make python3-dev libc-dev
RUN apt-get update && apt-get install -y python3-smbus i2c-tools
WORKDIR usr/src/app
COPY requirements.txt requirements.txt
COPY udev-rules/90-i2c.rules /etc/udev/rules.d/90-i2c.rules
RUN cd ~
RUN git clone https://github.com/mccdaq/daqhats.git
RUN cd daqhats && chmod +x ./install.sh && ./install.sh
RUN pip3 install -r requirements.txt
# Copy all all files in root to the working directory
COPY . ./
#ensure plugged dynamic hardware devices show up in the container
ENV UDEV=1
CMD ["python","-u","src/data_kit_comms.py"]
and 90-i2c.rules:
SUBSYSTEM=="i2c-dev", GROUP="i2c", MODE="0666"