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

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

Fri Feb 27, 2015 11:40 am

Richard-TX wrote: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?
I think you're wrong.

DT has enabled Notro's FBTFT to be included in the stock kernel
DT has enabled Gert's VGA add-on board
DT will enable my ENC28J60 (when Phil finishes that piece)
DT has added the I2S support for IQAudio and HifiBerry

And I'll get all of those things without having to build my own kernel or run with an out of band kernel.

DT is a Good Thing™ and should enable new hardware to be supported quicker.

The implementation had a few hiccups but considering we'd never seen DT in the wild before 3rd December it's not been too painful and Phil has worked really hard to "make it so".
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: 2480
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:44 am

Thanks, Dougie. I haven't forgotten you project, and the current wave of support is starting to subside. If you could upload or email me (I'm sure you can guess my address) the whole of your .dts it would help me to write the overlay - right now I just have a piece that refers to some unseen portions.

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

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

Fri Feb 27, 2015 12:28 pm

PhilE wrote:(I'm sure you can guess my address)
I'll guess it's something dead simple like <your forum name> [at] raspberrypi [dot] org.

I'll have to wire the ENC28J60 to my Aplus again.
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.

notro
Posts: 695
Joined: Tue Oct 16, 2012 6:21 pm
Location: Drammen, Norway

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

Fri Feb 27, 2015 7:36 pm

I also want to join in Dougie's praise of Phil.
He has done an outstanding job in smoothing out the introduction of Device Tree.
It's a rare thing to see an engineer write so much documentation without being wipped. But it can also be because he's smart, who's going to answer all those DT questions :-)

And why do need this Device Tree thing?
It's because the entire ARM world is moving towards it, and because it becomes difficult to add support for the increasing number of Pi add-on boards without it.
Many of these boards use I2C, SPI and/or gpio's. These busses doesn't have enumeration capabilities, so the kernel has to be told about a device's presence.
Device Tree is perfect for this.
And if we add the DT overlay parameters into this, we have a very powerful and simple way to tweak the device.
Previously such parameters would have to be added to the platform specific kernel code, which meant that only parameters needed by many people would be implemented.
And if the official DT overlay doesn't quite cut it, it's relatively easy to make one that fits. Previously such changes would require a kernel build.
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.
This is in part correct.

Kernel developers
In the x86 world BIOS is very helpful in setting up devices and help with enumeration. In the ARM world there is no BIOS. All the non enumerable device information is kept in the platform or board file. This makes it almost impossible to make a kernel that will boot on several different platforms/boards.
Imagine having to install a specific kernel for the Toshiba laptop and another one for the Dell laptop? This is what's happening in the ARM world.
With Device Tree it's possible to build multi architecture kernels, and let the bootloader provide a Device Tree that matches the board.

Device/HAT makers
A device maker in the pre-DT world still had to make a patch to implement their device in the platform code. Now they make a Device Tree overlay instead. I can't imagine anyone who has the responsibility to maintain device support for the Pi ever wanting to go back.

End users
End users have to learn about DT overlays. And yes, I hate when things that worked before, suddenly stops working. But I would say that Phil's documentation is quite good, and finally getting some sticky posts in the forums have probably relieved the pain for many.
And the result is quite powerful on a development board like the Pi with it's myriad of add-on boards.
All kinds of drivers can now be enabled in the official kernel build, and it's easy to make use of them. No need to build a kernel just to get that driver almost no one uses with it's device adding code!
When HAT manufacturers start adding eeprom's with DT overlays on them, we really reap the benefit from this.
Just plug in the board with the default kernel and Everything just works!

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

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

Fri Feb 27, 2015 8:24 pm

Thanks, notro. I've learnt the hard way that if you don't document your work you are condemned to answer the same questions over and over again. With the documentation written you still get the questions, but there is only one answer.

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

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

Mon Mar 02, 2015 10:53 pm

I'm just trying out a i2c rtc on a PI2.
The names of the rtc overlays seem to have changed a bit over time :-)

I have updated to latest firmware and now my working config is

Code: Select all

dtparam=i2c_arm=on
dtoverlay=i2c-rtc,ds3231
Before updating I didn't manage to get a working setup :-( I'll reflash the SD tomorrow and try again with the stock firmware now I think I know what I'm doing :roll:

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
PeterO
Posts: 5133
Joined: Sun Jul 22, 2012 4:14 pm

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

Tue Mar 03, 2015 9:11 am

I didn't know what I was doing because after every reboot the time came up as 1st Jan 1970 and hwclock reported that the RTC had some sort of invalid settings or information. And the hwclock.sh in /etc/init.d seems to have wrong start and stop levels specified.

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: 2480
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

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

Tue Mar 03, 2015 9:21 am

marcus15 did a lot of detective work on this problem, and found that it was necessary to modify /lib/udev/hwclock-set, changing "--systz" to "--hctosys" in two places. With that change made, and with the fake hwclock disabled or removed, it should work.

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

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

Tue Mar 03, 2015 9:56 am

PhilE wrote:marcus15 did a lot of detective work on this problem, and found that it was necessary to modify /lib/udev/hwclock-set, changing "--systz" to "--hctosys" in two places. With that change made, and with the fake hwclock disabled or removed, it should work.
Thanks Phil. I'de already nuked the fake hardware clock (learned that from previous rtc installation). I see some posts from "marcus15" in appropriate looking threads so I'll check them out this evening.

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: 2480
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

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

Tue Mar 03, 2015 9:59 am

By all means read up, but just changing all occurences of --systs to --hctosys in /lib/udev/hwclock-set should be all you need to stop it being corrupted at boot.

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

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

Tue Mar 03, 2015 10:36 am

PhilE wrote:By all means read up, but just changing all occurences of --systs to --hctosys in /lib/udev/hwclock-set should be all you need to stop it being corrupted at boot.
OK, but I'm interested in seeing how he found out that was the solution because I would have never though of looking there !
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

predecker
Posts: 7
Joined: Fri Jan 23, 2015 4:29 pm

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

Wed Mar 04, 2015 9:27 pm

Hi,

after a round of apt-get update/apt-get upgrade (from 3.6.11 to 3.18.8+) I'm stuck in this problem. My i2c isn't working as before anymore.

I'm playing with a RFID-chip (RC522) connected via i2c. It worked before the update. Without device-tree (device-tree= in /boot/config.txt) I see

Code: Select all

pre@raspi-test ~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
but the UU are not at the addresses of the RFID. With

Code: Select all

dtparam=i2c_arm=on
dtparam=spi=on
dtoverlay=w1-gpio,gpiopin=4
my device isn't recognized any more:

Code: Select all

pre@raspi-test ~ $ 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: -- -- -- -- -- -- -- --                         
But if I connect my adafruit display with a MCP23017 (as only device on i2c) it is running as before the updates.
The device tree seems to work for the display. Why isn't it working for the RFID-chip? Is there any chance to debug i2c without a logic analyzer?
I changed the i2c-baudrate to 4000, but that did not solve the problem. The display was slower but worked. RFID wasn't seen.
I tried a second RFID-chip, it didn't work either.

Any ideas what to try next?

Peter

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

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

Wed Mar 04, 2015 9:55 pm

A few more details might help:
* Which Pi do you have?
* What extra hardware is fitted? Those I2C devices (0x1b, 0x3b) don't look like standard equipment.
* What header pins and GPIOs are you connecting to?
* Can you show the i2c-detect output with the display connected?

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

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

Wed Mar 04, 2015 10:02 pm

It's OK, I've realised that the UUs aren't real devices - they are the result of not blacklisting the tas5713 and wm8804 drivers for the HifiBerry Digi and HifiBerry Amp boards.

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

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

Wed Mar 04, 2015 10:19 pm

From what I can find, although the RC522 supports I2c, on the Pi it is often wired up as an SPI device, so looking for it with i2c-detect might be a waste of time.

predecker
Posts: 7
Joined: Fri Jan 23, 2015 4:29 pm

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

Thu Mar 05, 2015 7:16 am

Hi Phil,
PhilE wrote:* Which Pi do you have?
* What extra hardware is fitted? Those I2C devices (0x1b, 0x3b) don't look like standard equipment.
* What header pins and GPIOs are you connecting to?
* Can you show the i2c-detect output with the display connected?
My Pi is a B with 512MB
There are no other devices connected
The RFID-board is connected to Pin 1,3,5,6 and 22 (for reset), all other pins are free.
The Pi is at home, so the i2c-detect output from the display has to wait until evening. But it looked normal with the one device shown with the correct address.
From what I can find, although the RC522 supports I2c, on the Pi it is often wired up as an SPI device, so looking for it with i2c-detect might be a waste of time.
Yes, but mine is one which has switches to select the interface. I want to connect two of them to one Pi, so I took these. It's that rare that I can't find it on ebay anymore. :-( And it worked with i2c before the update, not as fast as SPI, but it worked.
I didn't change the wiring after the update, so I think the hardware is still ok.

Peter

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

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

Thu Mar 05, 2015 9:04 am

Is it possible that the device is being held in reset? Is anything actively driving pin 22 (i.e. GPIO 25)? You could use the gpio readall command from Wiring Pi to examine the state and even change it, or use the /sys/class/gpio mechanism.

predecker
Posts: 7
Joined: Fri Jan 23, 2015 4:29 pm

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

Thu Mar 05, 2015 9:35 am

Hi Phil,

good idea, i'll check it this evening.

Thanks,
Peter

predecker
Posts: 7
Joined: Fri Jan 23, 2015 4:29 pm

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

Thu Mar 05, 2015 5:49 pm

Hi Phil,
PhilE wrote:Is it possible that the device is being held in reset?
exact, that's my problem. I disconnected the reset line and the device shows up at i2cdetect. So I have to find out, what has changed with the reset line. Sounds easy ...

Thanks for your help,
Peter

Forret
Posts: 4
Joined: Sat Mar 07, 2015 3:16 pm

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

Sat Mar 07, 2015 4:00 pm

There was i thinking. "great little machine", when somebody changed the firmware and wrecked my system. Spent a full day diagnosing my hardware and discovering that the SPI bus didn't work any more. Got as far as finding out ioctl was returning an error. I tried all the fixes listed above - nothing worked. The only solution was to go back to older firmware - got my system back. A day of my life I won't get back. By the way, i'm not at all sure that device trees are a good idea and to suddenly introduce it in such a drastic change without trumpets is a bit naff.

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

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

Sat Mar 07, 2015 4:49 pm

If you wind back the thread a little way to here: http://www.raspberrypi.org/forums/viewt ... 531#p70553
you'll see that this is caused by a change in the kernel SPI framework, and that you need to update the SPI library you are using.

Forret
Posts: 4
Joined: Sat Mar 07, 2015 3:16 pm

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

Sat Mar 07, 2015 9:28 pm

I'm sorry i'm not trying to be objectionable but firmware 3.18 is very badly conceived. Thousands of people like me will find their software unusable when they do an upgrade and will have to do the trawl to find out about device trees and how to fix their code. This won't do the Pi reputation any good. I know device trees are high fashion for more complex IO structures like the beaglebone, but they can add more complexity and be a bit of a mind blower for less experienced programmers. Going down the road of erasing backward compatibility is very dangerous.

John

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

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

Sat Mar 07, 2015 9:42 pm

Device tree is the best thing since the RPi. It's going to make every future hardware addition a thousand times easier.

You can disable it (in the current kernel/firmware), but you'll be better off by embracing the new technology and working through why you think it doesn't work for your system. It's been out for four months now and 99% of the bugs have been solved.
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.

Forret
Posts: 4
Joined: Sat Mar 07, 2015 3:16 pm

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

Sat Mar 07, 2015 10:22 pm

DougieLawson wrote:Device tree is the best thing since the RPi. It's going to make every future hardware addition a thousand times easier.

You can disable it (in the current kernel/firmware), but you'll be better off by embracing the new technology and working through why you think it doesn't work for your system. It's been out for four months now and 99% of the bugs have been solved.

You missed the point.

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

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

Sat Mar 07, 2015 10:26 pm

Forret wrote: You missed the point.
Eh?

It works, it's supported in Raspbian and raspi-config. Nothing breaks until you upgrade to a kernel that includes device tree. Not everyone runs i2c, spi or 1-wire.
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.

Return to “Troubleshooting”