PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2489
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Tue Feb 24, 2015 2:18 pm

@Framb00s: Congratulations! You've stumbled into a bug which was present in the upstreamed pinctrl-bcm2835 driver from day one. It turns out that the BCM2835 GPIO block doesn't quite match the documentation. The difference doesn't affect the old bcm2708_gpio driver because of how it written, but in trying to be more efficient the new driver accidentally fell foul of this difference, which only affects GPIOs 28-31 and 46-53. Since you need a Model A or Rev 2 Model B with the optional P5 header in order to use GPIOs 28-31, and since the pins needed for GPIOs 46-53 are instead used for the SD card interface, the chances of hitting this bug are quite small.

I've pushed a source patch that fixes the problem, and it will get picked up in the next firmware release.

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Tue Feb 24, 2015 2:42 pm

Ahh - I'm hoping that fix will cure the problem I had getting interrupts from the extra GPIOs 31, 38 or 44 at TP1..3 on the A+ :D

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2489
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Tue Feb 24, 2015 2:48 pm

It would certainly have an effect on GPIO31, but it's hard to see how it could make any difference for the other two. As a test, try disabling Device Tree (add "device_tree=" to your config.txt and reboot), which will (amongst other things) cause the old GPIO driver to be used. If that doesn't fix it then don't hold your breath for this patch.

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Tue Feb 24, 2015 2:59 pm

With the " device_tree=" line added to config.txt I am getting interrupts at last from GPIO31, confirmed at TP1. Should've tried that before!

Nothing from TP2 or TP3, maybe my surmised GPIO numbers 38, 44 were incorrect?

No big deal, I only need one GPIO/interrupt for my purpose :D

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2489
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Tue Feb 24, 2015 3:02 pm

Good - that means that with the next release it should also work with DT enabled, which is the recommended configuration.

User avatar
PeterO
Posts: 5147
Joined: Sun Jul 22, 2012 4:14 pm

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Tue Feb 24, 2015 8:41 pm

Why does the first post in this thread say

Code: Select all

Add "dtparam=i2c_arm=on" to your config.txt and reboot.
yet the latest raspi-config adds

Code: Select all

dtparam=i2c_arm=on
Can someone keep the first post up to date please as it claims to have the solution !


So why doesn't I2C work after following the "enable I2C" option in raspi-config ?
I installed the i2ctools to see what is going on but......

Code: Select all

pi@raspberrypi /boot $ sudo i2cdetect -F 1
Error: Could not open file `/dev/i2c-1' or `/dev/i2c/1': No such file or directory
This is on a clean install of 2015-02-16 Raspbian on an plain B.
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
DougieLawson
Posts: 36571
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Tue Feb 24, 2015 8:45 pm

Have you modprobe'd i2c-dev or added that to /etc/modules?
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
PeterO
Posts: 5147
Joined: Sun Jul 22, 2012 4:14 pm

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Tue Feb 24, 2015 8:48 pm

DougieLawson wrote:Have you modprobe'd i2c-dev or added that to /etc/modules?
No. The instructions don't say anything about those, just to enable i2c in the device tree in config.txt. Is this a step missing from the "fix i2c" instructions ?
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
DougieLawson
Posts: 36571
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Tue Feb 24, 2015 8:50 pm

Looks like the docs need an update.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2489
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Tue Feb 24, 2015 9:40 pm

With respect to i2c_arm, I don't see what your point is.

With respect to i2c-dev, the behaviour hasn't changed. If you want to use /dev/i2c* then you still need to load the i2c-dev module - other drivers use I2C without the /dev entry.

If you expect the top posts to be a one stop shop for all things I2C, I2S and SPI then you are likely to continue to be disappointed.

User avatar
PeterO
Posts: 5147
Joined: Sun Jul 22, 2012 4:14 pm

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Tue Feb 24, 2015 9:53 pm

PhilE wrote:With respect to i2c_arm, I don't see what your point is.
mMy point is that the thing needed to be added to config.txt has changed, but there is no mention of this in the first post.
With respect to i2c-dev, the behaviour hasn't changed. If you want to use /dev/i2c* then you still need to load the i2c-dev module - other drivers use I2C without the /dev entry.
Ok, so I2C used to work on a particular PI. I upgraded to latest Raspbian and trying to do the right thing I enabled device tree and enabled I2C. It did not work. I came here, looked that the instructions in the first post and they were different to what raspi-config had done. This is a sticky thread. The thread title even says "Read this", and the first post gives instructions on how to fix it that are now out of date.
If you expect the top posts to be a one stop shop for all things I2C, I2S and SPI then you are likely to continue to be disappointed.
Yes in a thread like this I think it is reasonable to expect either the first post to be kept up to date with a working set of instructions or for it to at least acknowledge that its contents are out of date and to point to a later post with the latest instructions in it. It is unreasonable to expect some one coming here to wade through all the pages of the thread (and as it happens they still might not have a working system).

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

asandford
Posts: 1997
Joined: Mon Dec 31, 2012 12:54 pm
Location: Waterlooville

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Tue Feb 24, 2015 10:08 pm

PeterO wrote:
PhilE wrote:With respect to i2c_arm, I don't see what your point is.
mMy point is that the thing needed to be added to config.txt has changed, but there is no mention of this in the first post.
With respect to i2c-dev, the behaviour hasn't changed. If you want to use /dev/i2c* then you still need to load the i2c-dev module - other drivers use I2C without the /dev entry.
Ok, so I2C used to work on a particular PI. I upgraded to latest Raspbian and trying to do the right thing I enabled device tree and enabled I2C. It did not work. I came here, looked that the instructions in the first post and they were different to what raspi-config had done. This is a sticky thread. The thread title even says "Read this", and the first post gives instructions on how to fix it that are now out of date.
If you expect the top posts to be a one stop shop for all things I2C, I2S and SPI then you are likely to continue to be disappointed.
Yes in a thread like this I think it is reasonable to expect either the first post to be kept up to date with a working set of instructions or for it to at least acknowledge that its contents are out of date and to point to a later post with the latest instructions in it. It is unreasonable to expect some one coming here to wade through all the pages of the thread (and as it happens they still might not have a working system).

PeterO
+1 and it doesn't even show as a sticky to me (s/b in the announcements section)

DirkS
Posts: 10017
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Tue Feb 24, 2015 11:18 pm

PeterO wrote:
PhilE wrote:With respect to i2c_arm, I don't see what your point is.
mMy point is that the thing needed to be added to config.txt has changed, but there is no mention of this in the first post.
Read that bit several times, but I can't see the difference...

From your first post about this:
PeterO wrote:Why does the first post in this thread say

Code: Select all

Add "dtparam=i2c_arm=on" to your config.txt and reboot.
yet the latest raspi-config adds

Code: Select all

dtparam=i2c_arm=on
What's the difference between the two?

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2489
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Wed Feb 25, 2015 9:07 am

None of the advice previously given has become wrong - it continues to work. However, by using the newer firmware and following the latest instructions (which have been updated regularly) users no longer need to think about which model and revision of Pi they are using - the same command will enable the standard I2C interface on all Pi's.

If anything is out of date about the first post and README, it is the failure to mention the raspi-config option, but since both methods produce the same results (as your post shows) then I don't think that can be considered misleading. I'll add it anyway.

Referring to your upgrade, I can't understand how a pre-DT system with the /dev entries lost them after an upgrade and running raspi-config to enable the interfaces. I know for a fact that raspi-config doesn't touch /etc/modules, and as far as I know neither rpi-update nor apt-get upgrade will either. If they did, then previous rpi-updates would also have broken things. Do you have experience to contradict that, ideally with some kind of evidence? What was your upgrade procedure?

User avatar
PeterO
Posts: 5147
Joined: Sun Jul 22, 2012 4:14 pm

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Wed Feb 25, 2015 9:55 am

Ok, a bit of an "oopse" on my part....

I think I can see what happened...

My first port of call on this problem was the "Interfacing (DSI, CSI, I2C, etc.)" forum where there is also a sticky thread titled "Optional interfaces (I2C, I2S, SPI) and Device Tree "
That thread contains this in the first post ...

"If you want to use the respective header pins for I2C, SPI, I2S instead of GPIO then you now need to enable those interfaces by adding one (or more) of the following to your /boot/config.txt:"

Code: Select all

    dtparam=i2c=on
    dtparam=spi=on
    dtparam=i2s=on
This information is I believe out of date now, and didn't match up with what I saw in config.txt.

I must have then come back to the troubleshooting forum to report this situation and didn't notice that I had come back to a different forum with a similarly titled sticky at the top of the thread list. I cut and pasted the information from there and didn't notice it was infact correct :oops:

So I apologise unreservedly for what I said last night about the first post in this thread being out of date,

Sorry :oops:

PeterO

PS: Maybe the the sticky thread in "Interfacing (DSI, CSI, I2C, etc.)" could be updated ? :roll:
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
PeterO
Posts: 5147
Joined: Sun Jul 22, 2012 4:14 pm

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Wed Feb 25, 2015 9:59 am

So ... Moving on....

Would it be possible to write a DT overlay that would also load the i2c "dev" module at boot time ? It would seem a better way than having the core module loaded by DT and the dev module comming from configuration files in /etc

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2489
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Wed Feb 25, 2015 10:17 am

Since i2c and i2c_arm are absolutely equivalent, they are both valid. But I've started to use the "_arm" variant to make it clear that it doesn't enable both I2C interfaces. The other sticky has now been updated.

Device Tree is supposed to just describe the hardware, and is meant to be OS-neutral. It is thus against the spirit of DT to even try to load a pure software module. But I could see if it is possible. Easier, and less controversial, is to get raspi-config to do the necessary to /etc/modules.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2489
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Wed Feb 25, 2015 10:20 am

And I find "It was late and I was tired" a persuasive defence. No harm done.

User avatar
PeterO
Posts: 5147
Joined: Sun Jul 22, 2012 4:14 pm

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Wed Feb 25, 2015 11:25 am

PhilE wrote:Since i2c and i2c_arm are absolutely equivalent, they are both valid. But I've started to use the "_arm" variant to make it clear that it doesn't enable both I2C interfaces. The other sticky has now been updated.

Device Tree is supposed to just describe the hardware, and is meant to be OS-neutral. It is thus against the spirit of DT to even try to load a pure software module. But I could see if it is possible. Easier, and less controversial, is to get raspi-config to do the necessary to /etc/modules.
Ok, it just seemed like it would be the same as the situation I had with I2S where two modules needed to be loaded, one for the codec and one for the card, but I see that they both had some relation to the hardware.

Even with I2C enabled in DT any "I2C Howtos" will still have to mention loading dev modules which is something I didn't understand. My wrong assumption was the DT was going to do it all (which raspi-config sort of suggests it will do) and forgot about the other modules I had originally manually set up in /etc/modules.

PeterO

PS: Not too late but certainly tired !
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

Framb00s
Posts: 4
Joined: Mon Feb 16, 2015 3:57 pm

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Wed Feb 25, 2015 8:01 pm

@PhilE So I suppose lirc on GPIO31 will work in the comming weeks. Tnx

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2489
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Wed Feb 25, 2015 9:28 pm

Yes, although it sounds like I have to change the code again before we switch to 3.19.

muawijhe
Posts: 1
Joined: Wed Feb 25, 2015 10:53 pm

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Wed Feb 25, 2015 11:04 pm

Problems with SPI. I have been using SPI for months until recently I updated to the new kernel 3.18.7+ (rpi-update).
I read this topic and I tried to fix the config.txt:

pi@raspberrypi ~/Navio/C++/Examples/AccelGyroMag $ tail -n 4 /boot/config.txt
dtparam=spi=on
dtparam=i2s=on
dtparam=i2c1=on
device_tree=

it seems that the spi module is on as shown in dmesg:

pi@raspberrypi ~/Navio/C++/Examples/AccelGyroMag $ dmesg | grep spi
[ 5.738272] bcm2708_spi bcm2708_spi.0: master is unqueued, this is deprecated
[ 5.869269] bcm2708_spi bcm2708_spi.0: SPI Controller at 0x20204000 (irq 80)

and the device is created:

pi@raspberrypi ~/Navio/C++/Examples/AccelGyroMag $ ls /dev/spidev0.*
/dev/spidev0.0 /dev/spidev0.1

but the application I'm using is not working despite your suggestions...

Any help? :roll:

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2489
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Thu Feb 26, 2015 9:11 am

Your config.txt shows that you have all of the settings to enable SPI using Device Tree, but that DT is disabled ("device_tree="). This suggests that it is a problem caused by the change in kernel rather than the switch to DT.

One of the recent kernel changes was to the SPI API, a change which caused many SPI applications to stop working until their libraries were updated. You can tell that this is the problem because the device opens correctly but then one of the ioctl()s fails with -EINVAL. Here are some of the posts that discuss the problem:

http://www.raspberrypi.org/forums/viewt ... 65#p680665
http://www.raspberrypi.org/forums/viewt ... 0&p=702587

You could find out if that is what is happening using the strace command, but that may be too much detail. I suggest you work out which library you are using - py-spidev seems to be a common one - and update it.

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Fri Feb 27, 2015 11:14 am

It seems to me that the whole device tree idea has shifted the relative pain felt by kernel developers when dealing with different devices from themselves to the implementers and end users. Am I right or wrong?
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2489
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: I2C, SPI, I2S, LIRC, PPS, stopped working? Read this.

Fri Feb 27, 2015 11:31 am

I'm a kernel developer, and therefore inherently biased. Having said that, I wouldn't have thought that the overall level of pain for newcomers has increased - it is just different. Existing users will be feeling more pain because they have already configured things one way and either got used to doing it that way or forgotten all about it, but they too will eventually return to their previous level of contentedness. The largest obstacle is now the vast corpus of tutorials, both first and third party, that need updating.

The introduction of device tree has been a fairly significant change - a large stone has been dropped in the pond and the ripples are still spreading outwards - and I expect a long tail of questions and bug reports from people upgrading across the step change. I would argue that there are already some advantages to the DT way of doing things, but there will be more as developers adapt to the new way of doing things. Dynamic DT manipulation - adding and removing overlays from the command line without rebooting - has the potential to make this stuff even easier.

Discuss.

Return to “Troubleshooting”