User Tools

Site Tools


1wireandraspicam

Solving mmal error with RaspberryPi Cam and 1wire modules

If you have updated your Raspberry Pi to the newest kernel and you are using the Raspberry Pi cam AND you also loaded the 1wire modules (e.g. w1-gpio, w1-therm), then you might get into trouble with your cam, because you get the error, that the mmal interface is somehow blocked or in use and the camera could not be enabled. The error might look like this one:

pi@raspberrypi ~ $ raspistill -o test.jpg
mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
mmal: camera component couldn't be enabled
mmal: main: Failed to create camera component
mmal: Failed to run camera app. Please check for firmware updates

This is a known issue as it can be read here. It's related to an issue with the 1wire kernel module w1-gpio, This module overwrites the setup of the I²C pins and prevents the access of the RaspberryPi camera, which is also using the I²C bus. To solve this problem, it's just important to ensure the correct order, when which module is loaded.

Prerequisites

You want to use the RaspberryPi Cam by using the mmal interface and you want to use the 1wire modules. If you e.g. want to take the temperature with an DS18S20 1wire temp sensor, then you get an error, you probably get the temp, but no cam pic anymore.

Preparation

Fist update everything by calling

sudo apt-get update
sudo apt-get upgrade

Install the i2c-tool, just to ensure, we can verify, that our I²C bus is working correctly:

sudo apt-get install i2c-tools

If you haven't had loaded your 1wire modules you can do that now by calling:

sudo modprobe w1-gpio
sudo modprobe w1-therm

If you now want to test your I²C bus, you get the following errors, which prove, that the I²C bus is somehow disturbed:

pi@raspberrypi ~ $ sudo i2cdetect -y 0
Error: Could not open file `/dev/i2c-0' or `/dev/i2c/0': No such file or directory
pi@raspberrypi ~ $ sudo i2cdetect -y 1
Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory


Solving the issue

As said before, to get the error solved, it's just important to ensure the order how the modules will be loaded and this what has to be done.

Therefore edit the /etc/modules with an editor of your coice and make it a least look like this one:

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.

wire
w1-gpio
w1-therm
i2c-bcm2708
i2c-dev
snd-bcm2835

Then ensure, that the modules spi-bcm2708 and i2c-bcm2708 are on the blacklist, so that they are not immediately loaded.

pi@raspberrypi ~ $ cat /etc/modprobe.d/raspi-blacklist.conf 
# blacklist spi and i2c by default (many users don't need them)
 
blacklist spi-bcm2708
blacklist i2c-bcm2708

Finally make a reboot, so that all modules are loaded again:

sudo reboot

After that, you can verify your I²C bus again and you will get these promising results:

pi@raspberrypi ~ $ sudo i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- 36 -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
pi@raspberrypi ~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         


Solving the issue, if it's bigger

Important additional information: Since the newest firmware (kernel 3.12.26+), the i2c-1 address 0x3b is now been taken over by the OS, this might result in an I²C bus result, with having the UU here:

pi@raspberrypi ~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

UU means that probing was skipped, because this address is currently in use by a driver. This strongly suggests that there is a chip at this address, but in this case, it's an error.

To fix this, you have to add two more modules to the blacklist (/etc/modprobe.d/raspi-blacklist.conf), this finally has to look like this:

blacklist spi-bcm2708
blacklist i2c-bcm2708
blacklist snd-soc-bcm2708-i2s
blacklist snd_soc_wm8804

Then reboot the Raspberry Pi and recheck the bus status, not it should be fixed and you get the same result as above with e.g. the 36 (but no UU anymore).

1wireandraspicam.txt · Last modified: 15.08.2014 13:37 by andreas