Skip to content

Kernels >= 3.10: w1_gpio destroys i2c bus 0 (raspicam doesn't work anymore) #435

Closed

Description

@crashmaster1

Since kernel versions >=3.10 "w1_gpio" became a showstopper for i2c bus 0 users, f.e. raspicam needs that!

It can be simply checked:

  • boot without loading the w1_gpio module
  • check i2c bus 0 ("i2cdetect -y 0"), you see lots of dashes, that's fine
  • now load w1_gpio (modprobe w1_gpio)
  • check i2c bus 0 again: all dashes have gone and you get a lot of numbers in ascending order :(
  • f.e. your raspicam will hang now (it uses i2c bus 0)

This happens with the latest official kernel for RPi (= 3.10.19-1) and newer versions.

Switching back to the previous version 3.6.11-18 works fine (without destroying i2c bus 0).

Activity

  1. JamesH65 commented on Nov 18, 2013

    @JamesH65
    Contributor

    I think this is a dupe of #434

  2. crashmaster1 commented on Nov 19, 2013

    @crashmaster1
    Author

    I didn't think so because it also affects the official kernel 3.10.x.

  3. popcornmix commented on Nov 20, 2013

    @popcornmix
    Collaborator

    I've had a quick look and can reproduce the problem.
    The problem is that the 1-wire module overwrite the gpio function selection for the I2C pins.
    Before 1-wire is loaded *0x20200000 = 0x48024 and I2C works (GPIO0 and GPIO in I2C alt function)
    After 1-wire is loaded *0x20200000 = 0x48921 and I2C fails (GPIO0 is set to an output)

    No idea yet why that happens yet, but that explains why I2C (and camera) stops working.

  4. crashmaster1 commented on Nov 21, 2013

    @crashmaster1
    Author

    Thanks popcornmix.

    A workaround is to load first the 1wire modules and afterwards the i2c modules.
    I2c initialization overwrites the 1wire quirks for bus 0, cam and w1 sensors work fine now.

  5. popcornmix commented on Nov 21, 2013

    @popcornmix
    Collaborator

    @crashmaster1
    Are you aware of where in the code register 0x20200000 gets written when 1-wire is loaded?
    I noticed that the 3.10 1-wire driver does some pin-muxing calls that 3.6 didn't do, but I assumed we have no pin muxing driver, so that would be a no-op.

  6. crashmaster1 commented on Nov 21, 2013

    @crashmaster1
    Author

    Sorry, i'm not aware of that.

  7. added a commit that references this issue on Nov 26, 2013
  8. chtitux commented on Dec 19, 2013

    @chtitux

    The workaround of @crashmaster1 DOES work (thank you !), at least on 3.10.24+ kernel.
    If if does not work, verify that :

    1. The i2c-bcm2708 is blacklisted in your /etc/modprobe.d/raspi-blacklist.conf

      # blacklist spi and i2c by default (many users don't need them)
      blacklist spi-bcm2708
      blacklist i2c-bcm2708
    2. The modules are in this order in your /etc/modules

      w1-gpio
      w1-therm
      i2c-bcm2078
      i2c-dev
      
  9. dkossman commented on Dec 20, 2013

    @dkossman

    sorry if this is a dumb question - trying to work around this issue - i'm using the rpi camera, 1-wire temp probes, and i2c (for running an lcd display, AD converter, etc.). I assume that if i blacklist spi and i2c that they'll stop working?

    my /etc/modules currently looks like this:

    w1-gpio pullup=1
    w1_therm
    snd-bcm2835
    spi-bcm2708
    i2c-bcm2708
    i2c-dev

    and raspi-blacklist.conf:

    #blacklist spi-bcm2708
    #blacklist i2c-bcm2708

    thanks

  10. crashmaster1 commented on Dec 20, 2013

    @crashmaster1
    Author

    You should not change your blacklist but in etc/modules try this order:

    w1-therm
    w1-gpio pullup=1
    i2c-dev
    i2c-bcm2708
    spi-bcm2708
    snd-bcm2835

  11. dkossman commented on Dec 20, 2013

    @dkossman

    thanks - made that change and restarted, but unhappily I'm still getting the same error. I've updated to the latest using apt-get update, apt-get upgrade, and rpi-update. Any suggestions?

    pi@raspberrypi ~ $ /usr/bin/raspistill -v -ex auto -mm backlit -w 1024 -h 768 -t 0 -o test.jpg

    raspistill Camera App v1.3.5

    Width 1024, Height 768, quality 85, filename test.jpg
    Time delay 0, Raw no
    Thumbnail enabled Yes, width 64, height 48, quality 35
    Link to latest frame enabled no
    Full resolution preview No
    Capture method : Run forever

    Preview Yes, Full screen Yes
    Preview window 0,0,1024,768
    Opacity 255
    Sharpness 0, Contrast 0, Brightness 50
    Saturation 0, ISO 0, Video Stabilisation No, Exposure compensation 0
    Exposure Mode 'auto', AWB Mode 'auto', Image Effect 'none'
    Metering Mode 'backlit', Colour Effect Enabled No with U = 128, V = 128
    Rotation 0, hflip No, vflip No
    ROI x 0.000000, y 0.000000, w 1.000000 h 1.000000
    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

  12. crashmaster1 commented on Dec 21, 2013

    @crashmaster1
    Author

    At first I've also got the ENOSPC failure. In my case I commented all "cma_" params i had made in "config.txt" and it helped. Probably you don't have them, but in my opinion you should look there to find out proper values for memory usage and you should have the latest firmware installed.

  13. dkossman commented on Dec 21, 2013

    @dkossman

    Thanks, I don't have any "cms_" params in config.txt - i am pretty sure that i've never edited that file. the only uncommented lines are:

    start_x=1
    gpu_mem=128

    when i run "i2cdetect -y 0" the output shows increasing numbers instead of dashes.

    By the way, if the camera uses i2c bus 0, i'm a bit confused about how we can use the suggested workaround above, when changing the order in /etc/modules doesn't work:

      "The i2c-bcm2708 *is* blacklisted in your /etc/modprobe.d/raspi-blacklist.conf"
    

    can anyone explain? or did i misunderstand?

    thanks
    Don

  14. dkossman commented on Dec 21, 2013

    @dkossman

    OK. i uncommented "blacklist i2c-bcm2708" in /etc/modprobe.d/raspi-blacklist.conf and now it appears that everything works (i2c, the 1-wire temperature probes, and the pi camera). I assume I misunderstood your suggestion above, and I'm going to leave well enough alone :-). Thanks for your help!

    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

  15. 15 remaining items

  16. hilmanshini commented on Jul 26, 2014

    @hilmanshini

    How is it now? is it solved yet?
    me either not works. 2 month struggling this,

    i have tried new rpi and new camera with following the instruction, but still rpi camera not working.

  17. joshhankins commented on Aug 11, 2014

    @joshhankins

    @crashmaster1 Please can you explain the steps required in order to fix my raspberry pi camera in a more simple way as i have just started programming and using the pi. Thanks for your help - much appreciated!

  18. crashmaster1 commented on Aug 11, 2014

    @crashmaster1
    Author

    @gecko: Sorry, i can't because i'm using Arch on my RPi's (not Raspbian). I think, it's better you ask for this in the Raspberry forum.

  19. JamesH65 commented on Aug 11, 2014

    @JamesH65
    Contributor

    Indeed, please use the forums to get advice and help for this sort of
    thing. The camera is known to work with the latest boards and
    firmware/kernel.
    On 11 Aug 2014 15:43, "crashmaster1" notifications@github.com wrote:

    @gecko https://github.com/gecko: Sorry, i can't because i'm using Arch
    on my RPi's (not Raspbian). I think, it's better you ask for this in the
    Raspberry forum.

    —
    Reply to this email directly or view it on GitHub
    #435 (comment).

  20. kimbongzo commented on Sep 17, 2014

    @kimbongzo

    Solution~

    Open /etc/modules -> sudo nano /etc/modules

    and below add two #

    snd-bcm2835
    i2c-dev
    #w1-gpio
    #w1-therm
    lirc_dev
    lirc_rpi gpio_out_pin=7

    and reboot. then GPIO Collision deleted.

  21. bootor commented on Sep 21, 2014

    @bootor

    ... and 1-wire will stop working...

  22. popcornmix commented on Sep 22, 2014

    @popcornmix
    Collaborator

    @bootor
    If you want to use 1-wire with a camera you need to set the GPIO pin to use. E.g. add to cmdline.txt

    bcm2708.w1_gpio_pin=16
    

    You can also code it in /etc/modules
    w1-gpio-gpiopin=16

    Problem is by default w1 modules uses GPIO4 which is needed by camera.

  23. GertjanvanhetHof commented on Mar 26, 2016

    @GertjanvanhetHof

    I had the same problem and I found probably the cause because I was able to reproduce it.
    For me it was a hardware problem. One of the wires on de flex cable (from raspberry to camera module) was broken.
    When I bow the cable the above problem was shown. This was because the connection was broken.
    When I put the cable straight, the camera was working correctly.
    I think it is the most left wire when camera is pointing to me.

  24. Ruffio commented on Aug 10, 2016

    @Ruffio

    @crashmaster1 has this issue been resolved? If yes, then please close this issue.

  25. kenxausten commented on Sep 15, 2017

    @kenxausten

    I am still encounter this issue. how should i do to solve this issue?
    pi@raspberrypi:~$ raspistill -o 1.jpg -v

    raspistill Camera App v1.3.11

    Width 3280, Height 2464, quality 85, filename 1.jpg
    Time delay 5000, Raw no
    Thumbnail enabled Yes, width 64, height 48, quality 35
    Link to latest frame enabled no
    Full resolution preview No
    Capture method : Single capture

    Preview Yes, Full screen Yes
    Preview window 0,0,1024,768
    Opacity 255
    Sharpness 0, Contrast 0, Brightness 50
    Saturation 0, ISO 0, Video Stabilisation No, Exposure compensation 0
    Exposure Mode 'auto', AWB Mode 'auto', Image Effect 'none'
    Metering Mode 'average', Colour Effect Enabled No with U = 128, V = 128
    Rotation 0, hflip No, vflip No
    ROI x 0.000000, y 0.000000, w 1.000000 h 1.000000
    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

    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
    pi@raspberrypi:~$ uname -a
    Linux raspberrypi 4.9.35-v7+ #1014 SMP Fri Jun 30 14:47:43 BST 2017 armv7l GNU/Linux
    pi@raspberrypi:~$ cat /etc/modules

    /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.

    w1-therm
    w1-gpio pullup=1
    w1-gpio-gpiopin=16
    bcm2708.w1_gpio_pin=16
    i2c-bcm2078
    i2c-dev
    snd-bcm2835
    bcm2708_wdog

  26. pelwell commented on Sep 15, 2017

    @pelwell
    Contributor

    You've got the latest firmware but your configuration was obsoleted 2 years ago with the switch to Device Tree. Try this:

    1. Remove everything from /etc/modules except this:
    i2c-dev
    
    1. Delete /etc/modprobe.d/raspi-blacklist.conf - you shouldn't need it.
    2. Enable the camera using raspi-config:
    sudo raspi-config
    # Open Interfacing Options
    # Select Camera
    # Choose Yes to enable the camera
    

    This will add start_x=1 and gpu_mem=64 to /boot/config.txt.

    1. If you are using a onewire device such as a DS18B20 (you don't say) then edit /boot/config.txt and add this line:
    dtoverlay=w1-gpio,gpiopin=16,pullup
    

    substituting your own pin number. Note that if your wiring to the onewire device includes a 3.3V line (which I recommend if you can), i.e. if it isn't using the phantom powering feature, then you just need:

    dtoverlay=w1-gpio,gpiopin=16
    
    1. Reboot.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions