arduinobeer
Posts: 6
Joined: Wed Jun 08, 2016 7:08 am

Re: B+, i2c-0, and Jessie

Wed Jun 08, 2016 7:52 pm

Ok, tried that:

Code: Select all

[email protected]:~ $ sudo raspi-gpio get
BANK0 (GPIO 0 to 27):
  GPIO 00: level=1 fsel=4 alt=0 func=SDA0
  GPIO 01: level=1 fsel=4 alt=0 func=SCL0
  GPIO 02: level=1 fsel=4 alt=0 func=SDA1
  GPIO 03: level=1 fsel=4 alt=0 func=SCL1
  GPIO 04: level=0 fsel=0 alt=  func=INPUT
  GPIO 05: level=1 fsel=0 alt=  func=INPUT
  GPIO 06: level=1 fsel=0 alt=  func=INPUT
  GPIO 07: level=1 fsel=0 alt=  func=INPUT
  GPIO 08: level=1 fsel=0 alt=  func=INPUT
  GPIO 09: level=0 fsel=0 alt=  func=INPUT
  GPIO 10: level=0 fsel=0 alt=  func=INPUT
  GPIO 11: level=0 fsel=0 alt=  func=INPUT
  GPIO 12: level=0 fsel=0 alt=  func=INPUT
  GPIO 13: level=0 fsel=0 alt=  func=INPUT
  GPIO 14: level=1 fsel=4 alt=0 func=TXD0
  GPIO 15: level=1 fsel=4 alt=0 func=RXD0
  GPIO 16: level=1 fsel=1 alt=  func=OUTPUT
  GPIO 17: level=0 fsel=0 alt=  func=INPUT
  GPIO 18: level=0 fsel=0 alt=  func=INPUT
  GPIO 19: level=0 fsel=0 alt=  func=INPUT
  GPIO 20: level=0 fsel=0 alt=  func=INPUT
  GPIO 21: level=0 fsel=0 alt=  func=INPUT
  GPIO 22: level=0 fsel=0 alt=  func=INPUT
  GPIO 23: level=0 fsel=0 alt=  func=INPUT
  GPIO 24: level=0 fsel=0 alt=  func=INPUT
  GPIO 25: level=0 fsel=0 alt=  func=INPUT
  GPIO 26: level=0 fsel=0 alt=  func=INPUT
  GPIO 27: level=0 fsel=0 alt=  func=INPUT
BANK1 (GPIO 28 to 45):
  GPIO 28: level=1 fsel=4 alt=0 func=SDA0
  GPIO 29: level=1 fsel=4 alt=0 func=SCL0
  GPIO 30: level=0 fsel=0 alt=  func=INPUT
  GPIO 31: level=1 fsel=1 alt=  func=OUTPUT
  GPIO 32: level=0 fsel=1 alt=  func=OUTPUT
  GPIO 33: level=0 fsel=0 alt=  func=INPUT
  GPIO 34: level=1 fsel=0 alt=  func=INPUT
  GPIO 35: level=1 fsel=0 alt=  func=INPUT
  GPIO 36: level=1 fsel=0 alt=  func=INPUT
  GPIO 37: level=0 fsel=0 alt=  func=INPUT
  GPIO 38: level=0 fsel=1 alt=  func=OUTPUT
  GPIO 39: level=0 fsel=0 alt=  func=INPUT
  GPIO 40: level=0 fsel=4 alt=0 func=PWM0
  GPIO 41: level=0 fsel=1 alt=  func=OUTPUT
  GPIO 42: level=0 fsel=0 alt=  func=INPUT
  GPIO 43: level=0 fsel=0 alt=  func=INPUT
  GPIO 44: level=1 fsel=4 alt=0 func=GPCLK1
  GPIO 45: level=1 fsel=4 alt=0 func=PWM1
BANK2 (GPIO 46 to 53):
  GPIO 46: level=1 fsel=0 alt=  func=INPUT
  GPIO 47: level=0 fsel=1 alt=  func=OUTPUT
  GPIO 48: level=0 fsel=4 alt=0 func=SD0_CLK
  GPIO 49: level=1 fsel=4 alt=0 func=SD0_CMD
  GPIO 50: level=1 fsel=4 alt=0 func=SD0_DAT0
  GPIO 51: level=1 fsel=4 alt=0 func=SD0_DAT1
  GPIO 52: level=1 fsel=4 alt=0 func=SD0_DAT2
  GPIO 53: level=1 fsel=4 alt=0 func=SD0_DAT3
[email protected]:~ $ 
I see SDA0 and SCL0 twice, I guess thats what you meant?

So I tried what you said, but put 29 in the second one, I guess that makes more sense:

Code: Select all

[email protected]:~ $ sudo raspi-gpio set 28 ip
[email protected]:~ $ sudo raspi-gpio set 29 ip
[email protected]:~ $ sudo raspi-gpio get
BANK0 (GPIO 0 to 27):
  GPIO 00: level=1 fsel=4 alt=0 func=SDA0
  GPIO 01: level=1 fsel=4 alt=0 func=SCL0
  GPIO 02: level=1 fsel=4 alt=0 func=SDA1
  GPIO 03: level=1 fsel=4 alt=0 func=SCL1
  GPIO 04: level=0 fsel=0 alt=  func=INPUT
  GPIO 05: level=1 fsel=0 alt=  func=INPUT
  GPIO 06: level=1 fsel=0 alt=  func=INPUT
  GPIO 07: level=1 fsel=0 alt=  func=INPUT
  GPIO 08: level=1 fsel=0 alt=  func=INPUT
  GPIO 09: level=0 fsel=0 alt=  func=INPUT
  GPIO 10: level=0 fsel=0 alt=  func=INPUT
  GPIO 11: level=0 fsel=0 alt=  func=INPUT
  GPIO 12: level=0 fsel=0 alt=  func=INPUT
  GPIO 13: level=0 fsel=0 alt=  func=INPUT
  GPIO 14: level=1 fsel=4 alt=0 func=TXD0
  GPIO 15: level=1 fsel=4 alt=0 func=RXD0
  GPIO 16: level=1 fsel=1 alt=  func=OUTPUT
  GPIO 17: level=0 fsel=0 alt=  func=INPUT
  GPIO 18: level=0 fsel=0 alt=  func=INPUT
  GPIO 19: level=0 fsel=0 alt=  func=INPUT
  GPIO 20: level=0 fsel=0 alt=  func=INPUT
  GPIO 21: level=0 fsel=0 alt=  func=INPUT
  GPIO 22: level=0 fsel=0 alt=  func=INPUT
  GPIO 23: level=0 fsel=0 alt=  func=INPUT
  GPIO 24: level=0 fsel=0 alt=  func=INPUT
  GPIO 25: level=0 fsel=0 alt=  func=INPUT
  GPIO 26: level=0 fsel=0 alt=  func=INPUT
  GPIO 27: level=0 fsel=0 alt=  func=INPUT
BANK1 (GPIO 28 to 45):
  GPIO 28: level=1 fsel=0 alt=  func=INPUT
  GPIO 29: level=1 fsel=0 alt=  func=INPUT
  GPIO 30: level=0 fsel=0 alt=  func=INPUT
  GPIO 31: level=1 fsel=1 alt=  func=OUTPUT
  GPIO 32: level=0 fsel=1 alt=  func=OUTPUT
  GPIO 33: level=0 fsel=0 alt=  func=INPUT
  GPIO 34: level=1 fsel=0 alt=  func=INPUT
  GPIO 35: level=1 fsel=0 alt=  func=INPUT
  GPIO 36: level=1 fsel=0 alt=  func=INPUT
  GPIO 37: level=0 fsel=0 alt=  func=INPUT
  GPIO 38: level=0 fsel=1 alt=  func=OUTPUT
  GPIO 39: level=0 fsel=0 alt=  func=INPUT
  GPIO 40: level=0 fsel=4 alt=0 func=PWM0
  GPIO 41: level=0 fsel=1 alt=  func=OUTPUT
  GPIO 42: level=0 fsel=0 alt=  func=INPUT
  GPIO 43: level=0 fsel=0 alt=  func=INPUT
  GPIO 44: level=1 fsel=4 alt=0 func=GPCLK1
  GPIO 45: level=0 fsel=4 alt=0 func=PWM1
BANK2 (GPIO 46 to 53):
  GPIO 46: level=1 fsel=0 alt=  func=INPUT
  GPIO 47: level=0 fsel=1 alt=  func=OUTPUT
  GPIO 48: level=0 fsel=4 alt=0 func=SD0_CLK
  GPIO 49: level=1 fsel=4 alt=0 func=SD0_CMD
  GPIO 50: level=1 fsel=4 alt=0 func=SD0_DAT0
  GPIO 51: level=1 fsel=4 alt=0 func=SD0_DAT1
  GPIO 52: level=1 fsel=4 alt=0 func=SD0_DAT2
  GPIO 53: level=1 fsel=4 alt=0 func=SD0_DAT3
And there it is:

Code: Select all

[email protected]:~ $ i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- 77 
Thanks a lot!

I mean, this is for some homebrewing, for beer, that's important! :D

Is this permanent? Why was it this way? Was that my fault?

User avatar
joan
Posts: 14097
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: B+, i2c-0, and Jessie

Wed Jun 08, 2016 8:14 pm

I'd count that as a firmware bug.

You will need to change the mode of GPIO 28/29 from ALT0 each time you boot until and if the firmware is "corrected".

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7026
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: B+, i2c-0, and Jessie

Wed Jun 08, 2016 8:46 pm

joan wrote:I'd count that as a firmware bug.

You will need to change the mode of GPIO 28/29 from ALT0 each time you boot until and if the firmware is "corrected".
dt-blob.dts bug to be precise.

https://github.com/raspberrypi/firmware ... t-blob.dts you'll find pins_bplus1, pins_bplus2, pins_aplus, pins_2b1, and pins_pi0 all have pins 28&29 (the camera I2C) mapped to i2c0. pins_2b2 does not.
The GPU code dynamically pin muxes the pins to i2c on demand, as that is how we get two identical camera modules working via one i2c bus on a Compute Module, so there should be no static muxing required on any of those platforms.

I picked up on it on viewtopic.php?f=107&t=150137 with the PiZero config looking wrong. I'll take it up with Phil again.

You could compile your own dt-blob.bin and stick it in /boot/ to get around it until the version built into the firmware is fixed.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

arduinobeer
Posts: 6
Joined: Wed Jun 08, 2016 7:08 am

Re: B+, i2c-0, and Jessie

Thu Jun 09, 2016 5:28 am

Thats what I did. Thank you guys, great forum.

So, to summarize for future people having this issue: If you're on a B+ V1.2, Raspian, Kernel 4.4 and want to enable the second i2c-bus, the i2c0 or i2c-0, because you want to use two bmp085 or bmp180 and won't try the XCLR trick, you've to do the following things: (I assume you did install and configure everything to have i2c1 running)
- add the following to /boot/config.txt

Code: Select all

dtparam=i2c_vc=on
- make sure "i2c-dev" is in /etc/modules
- open any editor and create a bash script, I named mine "StartupPinCorrect.sh" and add the following three lines:

Code: Select all

#! /bin/bash
sudo raspi-gpio set 28 ip
sudo raspi-gpio set 29 ip
-Save it and make it executable:

Code: Select all

sudo chmod a+x StartupPinCorrect.sh
- give it root permissions:

Code: Select all

sudo chmod 777 StartupPinCorrect.sh
- copy it to the right place:

Code: Select all

sudo cp ./StartupPinCorrect.sh /etc/init.d/
- let it run on boot:

Code: Select all

sudo update-rc.d StartupPinCorrect.sh defaults
- reboot

Code: Select all

sudo reboot
Once back up, scan your newly available i2c0:

Code: Select all

i2cdetect -y 0
Contrary to earlier posts you do not need any pullups, at least with bmp085.
Enjoy!

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7026
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: B+, i2c-0, and Jessie

Thu Jun 09, 2016 7:24 am

arduinobeer wrote:Thats what I did. Thank you guys, great forum.

So, to summarize for future people having this issue: If you're on a B+ V1.2, Raspian, Kernel 4.4 and want to enable the second i2c-bus....!
But don't do this on a Pi3! It will cause problems.
Email sent last night, so hopefully dtblob settings will be updated in the next day or so, although I don't know when the next Raspbian bump to the firmware will be.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
joan
Posts: 14097
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: B+, i2c-0, and Jessie

Thu Jun 09, 2016 7:52 am

arduinobeer wrote: ...
Contrary to earlier posts you do not need any pullups, at least with bmp085.
Enjoy!
You do need pull-ups, the I2C bus can not work without them.

There are two possibilities here, one benign, one not so benign.
  1. The internal pull-ups to 3V3 of about 50k (which are enabled at boot for GPIO 0/1) are sufficient to let the bus operate.
  2. The module you are using has its own pull-ups, if it does you need to check that they aren't to more than 3V3 (you should be safe if you are supplying the module from the 3V3 rail).

arduinobeer
Posts: 6
Joined: Wed Jun 08, 2016 7:08 am

Re: B+, i2c-0, and Jessie

Thu Jun 09, 2016 8:18 am

@6by9: I know, I clearly stated B+ V1.2
@joan: As I said, at least with bmp085, I've don't know for other modules. The bmp085 is at 3.3V, no risk here. I love the word benign... :D

User avatar
joan
Posts: 14097
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: B+, i2c-0, and Jessie

Thu Jun 09, 2016 8:22 am

arduinobeer wrote:@6by9: I know, I clearly stated B+ V1.2
@joan: As I said, at least with bmp085, I've don't know for other modules. The bmp085 is at 3.3V, no risk here. I love the word benign... :D
Benign is the mot juste. :D

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7026
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: B+, i2c-0, and Jessie

Thu Jun 16, 2016 1:47 pm

The dt-blob has been updated to correct the pin muxing. Manually having to reset GPIOs 28 & 29 to input should no longer be required with latest firmware from rpi-update (normal warnings apply about the cutting edge firmwares).

https://github.com/raspberrypi/firmware ... a4f97e98ca and https://github.com/Hexxeh/rpi-firmware/ ... 8f24db6137
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Interfacing (DSI, CSI, I2C, etc.)”