elyssis
Posts: 4
Joined: Mon Jun 01, 2015 11:37 pm

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

Tue Jun 02, 2015 8:54 am

PhilE wrote:.
FYI, the i2c-dev module provides the userland interface to the I2C busses; kernel modules that use i2c (drivers for audio HATs, for example) don't need i2c-dev to be loaded.
I am using i2c-dev -> wiringpi -> Pi4J -> JavaApp. Is there a better - maybe more future prove - way to access i2c in java in the new DT driven world? Is there a page where the officially indented way to access the hardware in the current hardware/software version is documented and kept up to date?

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

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

Tue Jun 02, 2015 9:02 am

How you use I2C hasn't changed and is unlikely to change - possibly ever. What has changed is how you tell the OS that you want to use I2C (Device Tree to enable it rather than blacklisting a module to disable it), but once configured it is the same.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5856
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

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

Tue Jun 02, 2015 10:00 am

https://github.com/RPi-Distro/raspi-con ... be00e9dfd3

The next release of raspi-config should load i2c-dev when you tell it to automatically load i2c.

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

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

Tue Jun 02, 2015 10:05 am

Thanks, ShiftPlusOne. I think that will please quite a few people.

elyssis
Posts: 4
Joined: Mon Jun 01, 2015 11:37 pm

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

Tue Jun 02, 2015 11:49 am

PhilE wrote:Thanks, ShiftPlusOne. I think that will please quite a few people.
Indeed, thank you very much - both of you.

btw. just in case changing the permissions for the /dev/i2c is still necessary it could make sense to let raspi-config change them as well - especially since you said that i2c device is for the user anyway ...

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5856
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

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

Tue Jun 02, 2015 12:06 pm

I believe the last image has added an i2c group, added the pi user to it and made i2c devices belong to that group. If you're running an old image, you can do that manually.
https://github.com/RPi-Distro/spindle/b ... tage3#L142

User avatar
DougieLawson
Posts: 35789
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 Jun 02, 2015 12:20 pm

ShiftPlusOne wrote:I believe the last image has added an i2c group, added the pi user to it and made i2c devices belong to that group. If you're running an old image, you can do that manually.
https://github.com/RPi-Distro/spindle/b ... tage3#L142
Can I just say that and the identical change for SPI was an excellent thing. It reduces the need to use sudo which is a step in the right direction for system security. We just need something like that for /dev/mem and gpio access.
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.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5856
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

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

Tue Jun 02, 2015 12:31 pm

DougieLawson wrote:
ShiftPlusOne wrote:I believe the last image has added an i2c group, added the pi user to it and made i2c devices belong to that group. If you're running an old image, you can do that manually.
https://github.com/RPi-Distro/spindle/b ... tage3#L142
Can I just say that and the identical change for SPI was an excellent thing. It reduces the need to use sudo which is a step in the right direction for system security. We just need something like that for /dev/mem and gpio access.
I don't see a secure way to give users access to /dev/mem. There was talk of creating a /dev/gpio, which would let you map just the gpio page, but I don't think anybody has time for that right now. The kernel gpio driver should work though.

User avatar
DougieLawson
Posts: 35789
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 Jun 02, 2015 12:49 pm

ShiftPlusOne wrote: I don't see a secure way to give users access to /dev/mem. There was talk of creating a /dev/gpio, which would let you map just the gpio page, but I don't think anybody has time for that right now. The kernel gpio driver should work though.
/dev/gpio would be a nirvana.

I've got a kernel gpio driver, but that still needs sudo to modprobe it.
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.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5856
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

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

Tue Jun 02, 2015 1:03 pm

DougieLawson wrote:but that still needs sudo to modprobe it.
Not sure I follow. It would be up to the admin to put it in /etc/modules so the user doesn't need to use sudo.

User avatar
DougieLawson
Posts: 35789
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 Jun 02, 2015 1:06 pm

ShiftPlusOne wrote:
DougieLawson wrote:but that still needs sudo to modprobe it.
Not sure I follow. It would be up to the admin to put it in /etc/modules so the user doesn't need to use sudo.
Is there an example driver anywhere?
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.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5856
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

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

Tue Jun 02, 2015 1:16 pm

I don't think we're talking about the same thing anymore :?

When I was talking about the existing kernel gpio driver, it was about the /sysfs interface, which should be accessible by the user. I assume that everything is already loaded for that and it should just work. The /etc/modules comment was a response to the idea that the user needs sudo to modprobe something (that shouldn't be the case, since you can automatically load modules).
DougieLawson wrote:Is there an example driver anywhere?
Example driver of what?

User avatar
DougieLawson
Posts: 35789
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 Jun 02, 2015 3:20 pm

ShiftPlusOne wrote:
DougieLawson wrote:Is there an example driver anywhere?
Example driver of what?
kernel gpio driver that has a non-privileged userspace interface.
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.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5856
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

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

Tue Jun 02, 2015 3:22 pm

DougieLawson wrote:
ShiftPlusOne wrote:
DougieLawson wrote:Is there an example driver anywhere?
Example driver of what?
kernel gpio driver that has a non-privileged userspace interface.
https://www.kernel.org/doc/Documentation/gpio/sysfs.txt

User avatar
DougieLawson
Posts: 35789
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 Jun 02, 2015 3:31 pm

Ah ha! That has gpio as the group ownership which works like the spi and i2c groups.

Now to look at whether there's a python module for that stuff or whether it's just some painful file manipulation to use it.
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.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5856
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

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

Tue Jun 02, 2015 5:06 pm

This looks about right https://github.com/derekstavis/python-sysfs-gpio

I believe wiringpi supports using sysfs instead of /dev/mem as well. Of course it's all much slower.

stankfrone
Posts: 1
Joined: Sat Jul 11, 2015 11:11 am

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

Sat Jul 11, 2015 11:17 am

After having troubles install “dump1090” on Raspberry Pi 2 B, I found your article about kernel (3.18) and the Device Tree, It would seem to me that the “dvb_usb_rtl2832U” is not in the Device Tree yet and that the Blacklist in files like “no-rtl.conf” are not longer working. Can this be confirmed?

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

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

Sat Jul 11, 2015 12:41 pm

Device Tree is only needed for buses which don't support device discovery. USB devices have a vendor+product ID, so Device Tree isn't needed (except to locate the USB controller).

Blacklists should still work as before - DT just means that they aren't needed as often.

Soulafein
Posts: 14
Joined: Thu Jul 23, 2015 9:35 am

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

Thu Jul 23, 2015 12:15 pm

Hi,
I have started my adventure with Raspberry Pi lately and I am trying to use SPI on it. Followed by instructions in main post brings me to dead end . I am using
Linux raspberrypi 3.18.11-v7+ #781 SMP PREEMPT Tue Apr 21 18:07:59 BST 2015armv7l GNU/LinuxI
And I have:
1. Activated SPI by raspi-config (which added automatically line dtparam=spi=on in config.txt),
2. raspi-blacklist.conf has no content,
3. I added in /etc/modules 'spi-bcm2708'
4. typing lsmod results in no "spi" at all.
5. Additionally modprobe spi-bcm2708 throws 'could not insert 'spi_bcm2708': no such device
6. Even adding device_tree= did not change anything
7. There is no spidev.0.0 and spidev0.1 in /dev/

Despite that there is no effect on activating the SPI at all.
I would be very grateful for helping me with this topic.

Thanks in advance.

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

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

Thu Jul 23, 2015 1:49 pm

That's puzzling.

Does /proc/device-tree exist?

What does "sudo vcdbg log msg" say? (There will be lots of messages about HDMI that you can delete if you want.)

User avatar
jojopi
Posts: 3079
Joined: Tue Oct 11, 2011 8:38 pm

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

Thu Jul 23, 2015 4:56 pm

On a Model B Rev1 (Revision 0002), "dtoverlay=i2c-rtc,ds3231" gives:

Code: Select all

[   12.058082] bcm2708_i2c 20804000.i2c: BSC1 Controller at 0x20804000 (irq 79) (baudrate 100000)
[   14.493309] rtc-ds1307: probe of 1-0068 failed with error -5
This appears to have claimed the wrong bus. If I add "dtparam=i2c_arm=on" the kernel registers bus 0 as well, but still probes only 1-0068 for the RTC.

Same behaviour in apt-get and rpi-update (4.0) kernels. Is this a bug, or am I doing something wrong?

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

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

Thu Jul 23, 2015 7:59 pm

It's a bug. The overlay is hard-coded to use i2c1, which as you know is incorrect for a Rev 1 Model B. I'll come up with a fix, but in the meantime you can create your own i2c0-specific overlay like this:

Code: Select all

sudo apt-get install device-tree-compiler
dtc -I dtb -O dts /boot/i2c-rtc-overlay.dtb | sed "s/i2c1/i2c0/" | sudo dtc -I dts -O dtb -o /boot/i2c0-rtc-overlay.dtb

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

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

Thu Jul 23, 2015 8:11 pm

Come to think of it, you could try a proper fix:

Code: Select all

sudo cp /boot/i2c-rtc-overlay.dtb{,.bak}
dtc -I dtb -O dts /boot/i2c-rtc-overlay.dtb | sed "s/i2c1/i2c_arm/" | sudo dtc -I dts -O dtb -o /boot/i2c-rtc-overlay.dtb

User avatar
jojopi
Posts: 3079
Joined: Tue Oct 11, 2011 8:38 pm

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

Thu Jul 23, 2015 10:13 pm

PhilE wrote:Come to think of it, you could try a proper fix:
sed "s/i2c1/i2c_arm/"
Thanks. Yes, that works.

Soulafein
Posts: 14
Joined: Thu Jul 23, 2015 9:35 am

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

Fri Jul 24, 2015 8:01 am

PhilE wrote:That's puzzling.

Does /proc/device-tree exist?

What does "sudo vcdbg log msg" say? (There will be lots of messages about HDMI that you can delete if you want.)
1. /proc/device-tree exist
2.sudo vcdbg log msg says (without HDMI part)
000889.530: gpioman: gpioman_get_pin_num: pin LEDS_RUNNING not defined
000889.554: gpioman: gpioman_get_pin_num: pin LEDS_NAND_ACTIVITY not defined
000889.577: gpioman: gpioman_get_pin_num: pin LEDS_USB_ACTIVITY not defined
000889.598: gpioman: gpioman_get_pin_num: pin LEDS_FATAL_ERROR not defined
000889.618: gpioman: gpioman_get_pin_num: pin LEDS_APP_OK not defined
000889.638: gpioman: gpioman_get_pin_num: pin LEDS_APP_FAILED not defined
000889.659: gpioman: gpioman_get_pin_num: pin LEDS_HDCP_AUTH not defined
000889.680: gpioman: gpioman_get_pin_num: pin LEDS_HDCP_UNAUTH not defined
000889.699: gpioman: gpioman_get_pin_num: pin LEDS_HDMI_ON not defined
000889.719: gpioman: gpioman_get_pin_num: pin LEDS_DVI_ON not defined
000889.739: gpioman: gpioman_get_pin_num: pin LEDS_HDMI_HPD_UP not defined
000889.761: gpioman: gpioman_get_pin_num: pin LEDS_REMOTE_CONTROL not defined
000889.783: gpioman: gpioman_get_pin_num: pin LEDS_ARM_CONTROLLED not defined

000943.687: *** Restart logging

000944.595: Read command line from file 'cmdline.txt'
dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p6 rootfstype=ext4 elevator=deadline rootwait

000949.117: Loading 'kernel7.img' from SD card
001180.029: Kernel trailer DTOK property says yes
001180.158: Loading 'bcm2709-rpi-2-b.dtb' from SD card
001205.975: dtparam: arm_freq=900000000
001260.480: gpioman: gpioman_get_pin_num: pin SDCARD_CONTROL_POWER not defined
003383.682: vchiq_core: vchiq_init_state: slot_zero = 0xfa800000, is_master = 1
003387.273: hdmi: HDMI:hdmi_get_state is deprecated, use hdmi_get_display_state instead
003391.174: gpioman: gpioman_get_pin_num: pin LEDS_RUNNING not defined
003391.199: gpioman: gpioman_get_pin_num: pin LEDS_NAND_ACTIVITY not defined
003391.219: gpioman: gpioman_get_pin_num: pin LEDS_USB_ACTIVITY not defined
003391.238: gpioman: gpioman_get_pin_num: pin LEDS_FATAL_ERROR not defined
003391.261: gpioman: gpioman_get_pin_num: pin LEDS_APP_OK not defined
003391.282: gpioman: gpioman_get_pin_num: pin LEDS_APP_FAILED not defined
003391.304: gpioman: gpioman_get_pin_num: pin LEDS_HDCP_AUTH not defined
003391.326: gpioman: gpioman_get_pin_num: pin LEDS_HDCP_UNAUTH not defined
003391.349: gpioman: gpioman_get_pin_num: pin LEDS_HDMI_ON not defined
003391.370: gpioman: gpioman_get_pin_num: pin LEDS_DVI_ON not defined
003391.392: gpioman: gpioman_get_pin_num: pin LEDS_HDMI_HPD_UP not defined
003391.413: gpioman: gpioman_get_pin_num: pin LEDS_REMOTE_CONTROL not defined
003391.434: gpioman: gpioman_get_pin_num: pin LEDS_ARM_CONTROLLED not defined
003391.814: TV service:host side not connected, dropping notification 0x00000002, 0x00000002, 0x00000039

Return to “Troubleshooting”