"could not insert 'i2c_dev'" error with resinOS and Raspberry Pi 2


I’ve been playing around with resinOS (not resin.io), trying to deploy a simple project that uses node.js and Johnny-Five to light up some LEDs on a Raspberry Pi 2 Model B.

This usually works really well on Raspbian Jessie on the Raspberry Pi but on ResinOS I get a modprobe error when the container starts:

?modprobe: ERROR: could not insert 'i2c_dev': Exec format error

I’ve created a minimal test case on github that should:

  • install wiring pi
  • install Johhny-Five and the Raspi-IO adapter code
  • light up an LED connected to wiring pi pin 1

Pushing the container using rdt push --source . seems to build fine. But, once built the container continually restarts.

$ rdt logs
(node:42141) DeprecationWarning: Using Buffer without `new` will soon stop working. Use `new Buffer()`, or preferably `Buffer.from()`, `Buffer.allocUnsafe()` or `Buffer.alloc()` instead.
Reporting discovered devices
? select a device resin.local (
? Select a container /resin-johnny-five-example (3134aee1361) - Restarting (1) About a minute ago
?modprobe: ERROR: could not insert 'i2c_dev': Exec format error

I read here that modprobe i2c-dev was necessary and I’ve added that to the RUN command in my Dockerfile.

Can anyone give me some pointers on what I’m doing wrong?

Many thanks

Hey @andrewn,

This is a known issue with the current resinOS beta release, which will be fixed in the upcoming betas that will be soon available for download. In the meantime, the easiest workaround would be to use an alpine base image, which in your case should be resin/raspberrypi2-alpine-node.

Best, Kostas

Thanks for the advice Kostas. Any idea when the next beta will be released?

I’ve just tried using resin/raspberrypi2-alpine-node but I can’t seem to get wiringpi or Raspi-io to build. :frowning:

First a thought, you should not add modprobe i2c-dev to your Dockerfile, but into your start script, as it’s a run-time command, not a build-time one.

Then there is a wiringpi Alpine package that you might try (might need to use one of the edge tags for the alpine image, e.g. 5-edge), for example installing in the Dockerfile with

RUN apk add --no-cache wiringpi

What are the issues when you are trying to install raspi-io?
Will try these out tomorrow, see if we hit any issues that can be resolved.

Working on the new builds for resinOS, but don’t have an ETA yet. It’s very near the top of our list, though, just sorting out some internal build processes to make it happen well.

:mag_right: I’ve seen how you’ve added the modprobe command to the CMD command in the Dockerfile (not to RUN as you mentioned), so that would actually be good place to do that (regarding my previous commit).

Been testing it a bit today, but run out of time, will continue tomorrow :clock:

@andrewn I have hit this problem as well. My current work around is to just modprobe from the hostOS via an SSH connection. It’s not idea, but it gets the job done and even if you have something like CMD modprobe i2c-dev && python main.py it won’t fail after you have the module already loaded, so you can keep your code the same for both resinOS and resin.io. I am hoping we can get the updated resinOS beta soon.

1 Like

Hi @imrehg,

Thanks so much for your reply.

I’ve tried a bit more with alpine, wiring-pi and Raspi-io. My code’s on the [alpine branch]((https://github.com/andrewn/resin-johnny-five-example/blob/alpine/Dockerfile) of my example github project.

Installing wiringpi via apk works fine. Afterwards, I have the gpio binary installed and can turn on/off an LED connected to GPIO using gpio write 1 1.

However, I think Raspi-io uses node-gyp to link against the wiringpi headers?

First, the log output was complaining about not finding the wiringpi headers:
../src-native/init.cc:25:22: fatal error: wiringPi.h: No such file or directory

So I added the line to the Dockerfile to git clone wiring-pi and copy the headers into /usr/local/includes. It’s still not build though, here’s the full log:

I think Raspi-io has a lot of dependencies that expect certain native libraries to be around on the system.

@shaunmulligan Yeah, using rdt ssh --host and runnning modprobe i2c-dev, then restarting the container seems to bring things up. I guess I could get the host to run modprobe i2c-dev on startup?