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


276 posts   Page 1 of 12   1, 2, 3, 4, 5 ... 12
by PhilE » Wed Jan 21, 2015 4:45 pm
The January 2015 Raspbian release, with Pi 2 support, switches to a new kernel (3.18), and includes a configuration change to enable Device Tree support by default. This has caused some previously working things to mysteriously stop working, but with a few configuration changes normal service should be resumed. We'll tell you how to do that in a moment, but first here's some background information. You can skip forward to Fixing the problem if you are in a hurry.

In the early days, Linux was distributed in source form, or as a bare-bones generic kernel along with the source to build a better one. One of the steps in the installation process was configuring the kernel to your requirements, followed by the compilation phase. This was time consuming and potentially overwhelming for new users.

The Holy Grail of Linux Distributions is a platform-specific (ideally OS-neutral) loader (U-boot, GRUB etc.), a generic kernel (one per processor architecture) and a collection of loadable modules. Since not all hardware sits on discoverable (plug-and-play) buses like PCI and USB, what is missing from this picture is a mechanism to describe the rest of the hardware; Device Tree is that mechanism.

Device Tree (DT) is the recommended way to describe hardware on Linux platforms (although it is actually OS-independent). It is a hierarchical structure consisting of nodes, sub-nodes and properties. It is not unlike XML in some respects, but thankfully it is more readable, less verbose, and comes with a standard binary representation, Flattened Device Tree (FDT), that is easy for programmes to parse and manipulate. Desktop processor platforms made the switch to DT years ago, and after years in the wilderness the ARM SoC platforms are catching up.

So, why should Raspberry Pi use Device Tree? The change is primarily a practical one. Until now, supporting some peripheral cards has required the addition of "struct platform_device" objects to the board support code. These are usually conditionally compiled based on the kernel configuration options, but in order to prevent regular users from having to compile their own kernel these options are turned on in the standard builds. As a result, at boot time, many (typically unwanted) modules are loaded unless they added to the blacklist (which prevents the automatic loading but still allows subsequent manual loading). Insufficient blacklisting could lead to nasty contention for GPIO pins, usually experienced after a kernel update since the blacklist file (/etc/modprobe.d/raspi-blacklist.conf) isn't a part of the kernel and hence doesn't automatically get updated.

Device Tree turns this system on its head, by replacing those "struct platform_device"s with nodes in the DT, allowing users to control which devices are enabled and hence which modules get loaded. Adding a new device driver module to the kernel doesn't automatically result in a module being loaded - the appropriate nodes must also be added to the DT.

Fixing the problem

If you are really impatient and just want out, or if for some reason your bit of hardware doesn't yet have a suitable overlay, add "device_tree=" to your config.txt and reboot. But be aware that this option may not be supported indefinitely.

A better choice would be to run:
Code: Select all
sudo raspi-config


Select "Advanced Options" from the menu, then either "SPI" or "I2C", and enable the interfaces there. If you want the driver modules to load automatically (and you probably do) then answer "Yes" to the follow-up question. raspi-config can also be used to disable and re-enable Device Tree.

Writing Device Trees is hard, particularly if you've never encountered one before. It shouldn't be necessary to write (or even edit) one in order to use commercial hardware. So the Raspberry Pi loader (start.elf, and its siblings) can combine a base DT Blob (DTB) with a number of overlays, each of which can be customised with a number of parameters. This is all controlled from /boot/config.txt.

The mechanism is described in a new README file (/boot/overlays/README - you may need to update your firmware), and full documentation can be found here: http://www.raspberrypi.org/documentation/configuration/device-tree.md.

FAQ:
  • My I2C interface has disappeared. What do I do?
    Add "dtparam=i2c_arm=on" to your config.txt and reboot. If you are feeling terse you can omit the "=on", since that is the default option. Or use raspi-config, as described above.
  • My SPI interface has disappeared. What do I do?
    Add "dtparam=spi=on" to your config.txt and reboot. Or use raspi-config, as described above.
  • My I2S interface has disappeared. What do I do?
    In case you haven't spotted the pattern, add "dtparam=i2s=on" to your config.txt.
    And reboot. This one isn't in raspi-config.
  • My lirc-rpi module doesn't load anymore. What do I do?
    "dtoverlay=lirc-rpi".
  • But what about the lirc-rpi module parameters?
    Add them to the end of the dtoverlay line, like this: "dtoverlay=lirc-rpi,gpio_in_pin=16,gpio_in_pull=high".
  • What about "w1-gpio"?
    Slightly more complicated. If you require the external pullup enable pin, use:
    "dtoverlay=w1-gpio-pullup,gpiopin=<x>,extpullup=<y>"
    otherwise use:
    "dtoverlay=w1-gpio,gpiopin=<x>"
    (where <x> and <y> are GPIO pins, obviously).
    If you are using the parasitic power (power over data, 2-wire) mode, add ",pullup=1" (or ",pullup=on")
  • How about "pps-gpio"?
    Another pesky overlay. You can probably guess the name and parameter:
    "dtoverlay=pps-gpio,gpiopin=<x>"
  • And what about my audio card?
    Add one of the following:
    • dtoverlay=hifiberry-dac
    • dtoverlay=hifiberry-dacplus
    • dtoverlay=hifiberry-digi
    • dtoverlay=hifiberry-amp
    • dtoverlay=iqaudio-dac
    • dtoverlay=iqaudio-dacplus
    If your card doesn't appear here, you'll need to turn off device tree for now ("device_tree=") and contact the manufacturer. It's worth posting a query about it as well.
  • I2C Real Time Clock?
    dtoverlay=i2c-rtc,<model>
    where <model> is one of: ds1307, ds3231, pcf2127, pcf8523, pcf8563
    Note that the old individual RTC overlays have been deprecated and will be deleted in future releases.
  • Can I give my Pi a heartbeat LED?
    dtparam=act_led_trigger=heartbeat
  • Cool: thanks.
    You're welcome.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 764
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge
by PhilE » Wed Jan 21, 2015 4:48 pm
Here's the new README:

Code: Select all
Introduction
============

This directory contains Device Tree overlays. Device Tree makes it possible
to support many hardware configurations with a single kernel and without the
need to explicitly load or blacklist kernel modules. Note that this isn't a
"pure" Device Tree configuration (c.f. MACH_BCM2835) - some on-board devices
are still configured by the board support code, but the intention is to
eventually reach that goal.

On Raspberry Pi, Device Tree usage is controlled from /boot/config.txt. By
default, the Raspberry Pi kernel boots with device tree enabled. You can
completely disable DT usage (for now) by adding:

    device_tree=

to your config.txt, which should cause your Pi to revert to the old way of
doing things after a reboot.

In /boot you will find a .dtb for each base platform. This describes the
hardware that is part of the Raspberry Pi board. The loader (start.elf and its
siblings) selects the .dtb file appropriate for the platform by name, and reads
it into memory. At this point, all of the optional interfaces (i2c, i2s, spi)
are disabled, but they can be enabled using Device Tree parameters:

    dtparam=i2c=on,i2s=on,spi=on

However, this shouldn't be necessary in many use cases because loading an
overlay that requires one of those interfaces will cause it to be enabled
automatically, and it is advisable to only enable interfaces if they are
needed.

Configuring additional, optional hardware is done using Device Tree overlays
(see below).

raspi-config
============

The Advanced Options section of the raspi-config utility can enable and disable
Device Tree use, as well as toggling the I2C and SPI interfaces. Note that it
is possible to both enable an interface and blacklist the driver, if for some
reason you should want to defer the loading.

Modules
=======

As well as describing the hardware, Device Tree also gives enough information
to allow suitable driver modules to be located and loaded, with the corollary
that unneeded modules are not loaded. As a result it should be possible to
remove lines from /etc/modules, and /etc/modprobe.d/raspi-blacklist.conf can
have its contents deleted (or commented out).

Using Overlays
==============

Overlays are loaded using the "dtoverlay" directive. As an example, consider the
popular lirc-rpi module, the Linux Infrared Remote Control driver. In the
pre-DT world this would be loaded from /etc/modules, with an explicit
"modprobe lirc-rpi" command, or programmatically by lircd. With DT enabled,
this becomes a line in config.txt:

    dtoverlay=lirc-rpi

This causes the file /boot/overlays/lirc-rpi-overlay.dtb to be loaded. By
default it will use GPIOs 17 (out) and 18 (in), but this can be modified using
DT parameters:

    dtoverlay=lirc-rpi,gpio_out_pin=17,gpio_in_pin=13

Parameters always have default values, although in some cases (e.g. "w1-gpio")
it is necessary to provided multiple overlays in order to get the desired
behaviour. See the list of overlays below for a description of the parameters and their defaults.

The Overlay and Parameter Reference
===================================

Name:   <The base DTB>
Info:   Configures the base Raspberry Pi hardware
Load:   <loaded automatically>
Params:
        i2c_arm                  Set to "on" to enable the ARM's i2c interface
                                 (default "off")

        i2c_vc                   Set to "on" to enable the i2c interface
                                 usually reserved for the VideoCore processor
                                 (default "off")

        i2c                      An alias for i2c_arm

        i2c_arm_baudrate         Set the baudrate of the ARM's i2c interface
                                 (default "100000")

        i2c_vc_baudrate          Set the baudrate of the VideoCore i2c interface
                                 (default "100000")

        i2c_baudrate             An alias for i2c_arm_baudrate

        i2s                      Set to "on" to enable the i2s interface
                                 (default "off")

        spi                      Set to "on" to enable the spi interfaces
                                 (default "off")

        act_led_trigger          Choose which activity the LED tracks.
                                 Use "heartbeat" for a nice load indicator.
                                 (default "mmc")

        act_led_activelow        Set to "on" to invert the sense of the LED
                                 (default "off")

        act_led_gpio             Set which GPIO to use for the activity LED
                                 (in case you want to connect it to an external
                                 device)
                                 (default "16" on a non-Plus board, "47" on a
                                 Plus or Pi 2)

        pwr_led_trigger
        pwr_led_activelow
        pwr_led_gpio
                                 As for act_led_*, but using the PWR LED.
                                 Not available on Model A/B boards.

        N.B. It is recommended to only enable those interfaces that are needed.
        Leaving all interfaces enabled can lead to unwanted behaviour (i2c_vc
        interfering with Pi Camera, I2S and SPI hogging GPIO pins, etc.)
        Note also that i2c, i2c_arm and i2c_vc are aliases for the physical
        interfaces i2c0 and i2c1. Use of the numeric variants is still possible
        but deprecated because the ARM/VC assignments differ between board
        revisions. The same board-specific mapping applies to i2c_baudrate,
        and the other i2c baudrate parameters.


Name:   ads7846
Info:   ADS7846 Touch controller
Load:   dtoverlay=ads7846,<param>=<val>
Params: cs                       SPI bus Chip Select (default 1)
        speed                    SPI bus speed (default 2Mhz, max 3.25MHz)
        penirq                   GPIO used for PENIRQ. REQUIRED
        penirq_pull              Set GPIO pull (default 0=none, 2=pullup)
        swapxy                   Swap x and y axis
        xmin                     Minimum value on the X axis (default 0)
        ymin                     Minimum value on the Y axis (default 0)
        xmax                     Maximum value on the X axis (default 4095)
        ymax                     Maximum value on the Y axis (default 4095)
        pmin                     Minimum reported pressure value (default 0)
        pmax                     Maximum reported pressure value (default 65535)
        xohms                    Touchpanel sensitivity (X-plate resistance)
                                 (default 400)

        penirq is required and usually xohms (60-100) has to be set as well.
        Apart from that, pmax (255) and swapxy are also common.
        The rest of the calibration can be done with xinput-calibrator.
        See: github.com/notro/fbtft/wiki/FBTFT-on-Raspian
        Device Tree binding document:
        www.kernel.org/doc/Documentation/devicetree/bindings/input/ads7846.txt


Name:   bmp085_i2c-sensor
Info:   Configures the BMP085/BMP180 digital barometric pressure and temperature
        sensors from Bosch Sensortec
Load:   dtoverlay=bmp085_i2c-sensor
Params: <None>


[ The ds1307-rtc overlay has been deleted. See i2c-rtc. ]


Name:   enc28j60
Info:   Overlay for the Microchip ENC28J60 Ethernet Controller (SPI)
Load:   dtoverlay=enc28j60,<param>=<val>
Params: int_pin                  GPIO used for INT (default 25)

        speed                    SPI bus speed (default 12000000)


Name:   hifiberry-amp
Info:   Configures the HifiBerry Amp and Amp+ audio cards
Load:   dtoverlay=hifiberry-amp
Params: <None>


Name:   hifiberry-dac
Info:   Configures the HifiBerry DAC audio card
Load:   dtoverlay=hifiberry-dac
Params: <None>


Name:   hifiberry-dacplus
Info:   Configures the HifiBerry DAC+ audio card
Load:   dtoverlay=hifiberry-dacplus
Params: <None>


Name:   hifiberry-digi
Info:   Configures the HifiBerry Digi audio card
Load:   dtoverlay=hifiberry-digi
Params: <None>


Name:   hy28a
Info:   HY28A - 2.8" TFT LCD Display Module by HAOYU Electronics
        Default values match Texy's display shield
Load:   dtoverlay=hy28a,<param>=<val>
Params: speed                    Display SPI bus speed

        rotate                   Display rotation {0,90,180,270}

        fps                      Delay between frame updates

        debug                    Debug output level {0-7}

        xohms                    Touchpanel sensitivity (X-plate resistance)

        resetgpio                GPIO used to reset controller

        ledgpio                  GPIO used to control backlight


Name:   hy28b
Info:   HY28B - 2.8" TFT LCD Display Module by HAOYU Electronics
        Default values match Texy's display shield
Load:   dtoverlay=hy28b,<param>=<val>
Params: speed                    Display SPI bus speed

        rotate                   Display rotation {0,90,180,270}

        fps                      Delay between frame updates

        debug                    Debug output level {0-7}

        xohms                    Touchpanel sensitivity (X-plate resistance)

        resetgpio                GPIO used to reset controller

        ledgpio                  GPIO used to control backlight


Name:   i2c-rtc
Info:   Adds support for a number of I2C Real Time Clock devices
Load:   dtoverlay=i2c-rtc,<param>
Params: ds1307                   Select the DS1307 device

        ds3231                   Select the DS3231 device

        pcf2127                  Select the PCF2127 device

        pcf8523                  Select the PCF8523 device

        pcf8563                  Select the PCF8563 device


Name:   iqaudio-dac
Info:   Configures the IQaudio DAC audio card
Load:   dtoverlay=iqaudio-dac
Params: <None>


Name:   iqaudio-dacplus
Info:   Configures the IQaudio DAC+ audio card
Load:   dtoverlay=iqaudio-dacplus
Params: <None>


Name:   lirc-rpi
Info:   Configures lirc-rpi (Linux Infrared Remote Control for Raspberry Pi)
        Consult the module documentation for more details.
Load:   dtoverlay=lirc-rpi,<param>=<val>,...
Params: gpio_out_pin             GPIO for output (default "17")

        gpio_in_pin              GPIO for input (default "18")

        gpio_in_pull             Pull up/down/off on the input pin
                                 (default "down")

        sense                    Override the IR receive auto-detection logic:
                                   "1" = force active high
                                   "0" = force active low
                                   "-1" = use auto-detection
                                 (default "-1")

        softcarrier              Turn the software carrier "on" or "off"
                                 (default "on")

        invert                   "on" = invert the output pin (default "off")

        debug                    "on" = enable additional debug messages
                                 (default "off")


Name:   mcp2515-can0
Info:   Configures the MCP2515 CAN controller
Load:   dtoverlay=mcp2515-can0,<param>=<val>
Params: oscillator               Clock frequency for the CAN controller (Hz)

        spimaxfrequency          Maximum SPI frequence (Hz)

        interrupt                GPIO for interrupt signal


Name:   mmc
Info:   Selects the bcm2835-mmc SD/MMC driver, optionally with overclock
Load:   dtoverlay=mmc,<param>=<val>
Params: overclock_50             Clock (in MHz) to use when the MMC framework
                                 requests 50MHz
        force_pio                Disable DMA support


Name:   mz61581
Info:   MZ61581 display by Tontec
Load:   dtoverlay=mz61581,<param>=<val>
Params: speed                    Display SPI bus speed

        rotate                   Display rotation {0,90,180,270}

        fps                      Delay between frame updates

        debug                    Debug output level {0-7}

        xohms                    Touchpanel sensitivity (X-plate resistance)


[ The pcf2127-rtc overlay has been deleted. See i2c-rtc. ]


[ The pcf8523-rtc overlay has been deleted. See i2c-rtc. ]


[ The pcf8563-rtc overlay has been deleted. See i2c-rtc. ]


Name:   piscreen
Info:   PiScreen display by OzzMaker.com
Load:   dtoverlay=piscreen,<param>=<val>
Params: speed                    Display SPI bus speed

        rotate                   Display rotation {0,90,180,270}

        fps                      Delay between frame updates

        debug                    Debug output level {0-7}

        xohms                    Touchpanel sensitivity (X-plate resistance)


Name:   pitft28-resistive
Info:   Adafruit PiTFT 2.8" resistive touch screen
Load:   dtoverlay=pitft28-resistive,<param>=<val>
Params: speed                    Display SPI bus speed

        rotate                   Display rotation {0,90,180,270}

        fps                      Delay between frame updates

        debug                    Debug output level {0-7}


Name:   pps-gpio
Info:   Configures the pps-gpio (pulse-per-second time signal via GPIO).
Load:   dtoverlay=pps-gpio,<param>=<val>
Params: gpiopin                  Input GPIO (default "18")


Name:   rpi-dac
Info:   Configures the RPi DAC audio card
Load:   dtoverlay=rpi-dac
Params: <None>


Name:   rpi-display
Info:   RPi-Display - 2.8" Touch Display by Watterott
Load:   dtoverlay=rpi-display,<param>=<val>
Params: speed                    Display SPI bus speed

        rotate                   Display rotation {0,90,180,270}

        fps                      Delay between frame updates

        debug                    Debug output level {0-7}

        xohms                    Touchpanel sensitivity (X-plate resistance)


Name:   rpi-proto
Info:   Configures the RPi Proto audio card
Load:   dtoverlay=rpi-proto
Params: <None>


Name:   sdhost
Info:   Selects the bcm2835-sdhost SD/MMC driver, optionally with overclock
Load:   dtoverlay=sdhost,<param>=<val>
Params: overclock_50             Clock (in MHz) to use when the MMC framework
                                 requests 50MHz
        force_pio                Disable DMA support


Name:   spi-bcm2835
Info:   Selects the bcm2835-spi SPI driver
Load:   dtoverlay=spi-bcm2835
Params: <None>


Name:   tinylcd35
Info:   3.5" Color TFT Display by www.tinlylcd.com
        Options: Touch, RTC, keypad
Load:   dtoverlay=tinylcd35,<param>=<val>
Params: speed                    Display SPI bus speed

        rotate                   Display rotation {0,90,180,270}

        fps                      Delay between frame updates

        debug                    Debug output level {0-7}

        touch                    Enable touch panel

        touchgpio                Touch controller IRQ GPIO

        xohms                    Touchpanel: Resistance of X-plate in ohms

        rtc-pcf                  PCF8563 Real Time Clock

        rtc-ds                   DS1307 Real Time Clock

        keypad                   Enable keypad

        Examples:
            Display with touchpanel, PCF8563 RTC and keypad:
                dtoverlay=tinylcd35,touch,rtc-pcf,keypad
            Old touch display:
                dtoverlay=tinylcd35,touch,touchgpio=3


Name:   w1-gpio
Info:   Configures the w1-gpio Onewire interface module.
        Use this overlay if you *don't* need a GPIO to drive an external pullup.
Load:   dtoverlay=w1-gpio,<param>=<val>
Params: gpiopin                  GPIO for I/O (default "4")

        pullup                   Non-zero, "on", or "y" to enable the parasitic
                                 power (2-wire, power-on-data) feature


Name:   w1-gpio-pullup
Info:   Configures the w1-gpio Onewire interface module.
        Use this overlay if you *do* need a GPIO to drive an external pullup.
Load:   dtoverlay=w1-gpio-pullup,<param>=<val>,...
Params: gpiopin                  GPIO for I/O (default "4")

        pullup                   Non-zero, "on", or "y" to enable the parasitic
                                 power (2-wire, power-on-data) feature

        extpullup                GPIO for external pullup (default "5")


Troubleshooting
===============

If you are experiencing problems that you think are DT-related, enable DT
diagnostic output by adding this to /boot/config.txt:

    dtdebug=on

and rebooting. Then run:

    sudo vcdbg log msg

and look for relevant messages.

Further reading
===============

This is only meant to be a quick introduction to the subject of Device Tree on
Raspberry Pi. There is a more complete explanation here:

http://www.raspberrypi.org/documentation/configuration/device-tree.md
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 764
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge
by DougieLawson » Wed Jan 21, 2015 4:57 pm
Thanks Phil. That's nice and concise and all in one place.

Perhaps this should be a sticky thread in the Troubleshooting part of the forum.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
RPi owner since '12.
Twitter: @DougieLawson

2B, B+, A+, 5Bs, zero, 3B

Please post ALL technical questions on the forum.Do not send private messages.
User avatar
Posts: 22321
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
by te36 » Fri Jan 23, 2015 9:19 am
So, what's the endgame to operationalize this device-tree stuff , eg: how should it be made easier for someone installing lirc in the future to get it running ? setting up those devices via raspi-config ?

Having every individual device driver come up with its own solution so that a user with 3 non-PnP devices has to figure out for each one of them how to configure DT would sound fairly brutal.
Posts: 1
Joined: Fri Jan 23, 2015 9:06 am
by PhilE » Fri Jan 23, 2015 11:22 am
Yes, raspi-config is likely to change to support DT. But even without that, the first resource for users configuring non-PnP devices is /boot/overlays/README. Detailed documentation would be provided by a link to an external source.

There are likely to be some unsupported devices initially, so the sequence should be:

  1. Ask the manufacturer/supplier.
  2. Ask the Forums.
  3. Consider writing your own overlay (and possibly adding DT support to the driver), or locate a fellow user who can, then raise a Pull Request to get it added.
  4. Raise an Issue requesting support for the device.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 764
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge
by ShiftPlusOne » Sat Jan 24, 2015 4:34 pm
Deleted off-topic posts. Take it elsewhere.

Edit: If people keep going on with off-topic discussion in an important thread after being asked to stop, they don't get to complain that their posts were deleted.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3804
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy
by kazzttor » Tue Jan 27, 2015 12:05 am
Hi, people,

I made this procedure (edit file /boot/config.txt, but the best way to change it is by raspi-config > 8. Advanced options > A6. I2C), but i had a trouble and my rtc with chip pcf8563 conected to my Pi.

When I try to use the command to update time of rtc this error occours:

Code: Select all
pi@raspberrypi ~ $ sudo hwclock -w
hwclock: select() to /dev/rtc0 to wait for clock tick timed out: Arquivo ou diretório não encontrado


I also used the dmesg command to find any error. This is the message related of i2c and pcf8563:

Code: Select all
pi@raspberrypi ~ $ dmesg|grep i2c
[    5.503791] bcm2708_i2c_init_pinmode(0,0)
[    5.666925] bcm2708_i2c_init_pinmode(0,1)
[    5.674016] bcm2708_i2c 20205000.i2c: BSC0 Controller at 0x20205000 (irq 79) (baudrate 100000)
[    5.991503] bcm2708_i2c_init_pinmode(1,2)
[    6.206989] bcm2708_i2c_init_pinmode(1,3)
[    6.213990] bcm2708_i2c 20804000.i2c: BSC1 Controller at 0x20804000 (irq 79) (baudrate 100000)
[   12.084975] i2c /dev entries driver
[   39.789832] i2c i2c-1: new_device: Instantiated device pcf8563 at 0x51


Code: Select all
pi@raspberrypi ~ $ dmesg|grep rtc
[   39.782178] rtc-pcf8563 1-0051: chip found, driver version 0.4.3
[   39.789131] rtc (null): invalid alarm value: 2015-2-6 62:47:0
[   39.789709] rtc-pcf8563 1-0051: rtc core: registered rtc-pcf8563 as rtc0


The rtc module is loaded and detected, in according with i2cdetect command:

Code: Select all
pi@raspberrypi ~ $ 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: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --



I don't know why rtc chip is not working. Is it necessary any configuration or the issue is with rtc chip (ex. low battery)?
Kazzttor

Diadema-SP, Brazil
Linux-Windows-Mac User
Raspberry Pi Lover
User avatar
Posts: 4
Joined: Wed Jan 21, 2015 2:57 am
Location: Diadema - São Paulo, Brazil
by snapdan » Tue Jan 27, 2015 3:57 am
This may be another simple fix people can use, or it may be that my problem was unrelated, but anyway: the device_tree fix didn't work for me so I reverted the rpi-update as detailed here to the commit prior to the kernel upgrade and that fixed it for me.
Posts: 1
Joined: Tue Jan 27, 2015 3:50 am
by DougieLawson » Tue Jan 27, 2015 8:32 am
add
Code: Select all
device_tree_param=i2c1=on

to /boot/config.txt
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
RPi owner since '12.
Twitter: @DougieLawson

2B, B+, A+, 5Bs, zero, 3B

Please post ALL technical questions on the forum.Do not send private messages.
User avatar
Posts: 22321
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
by kazzttor » Tue Jan 27, 2015 1:59 pm
2 things that we must know about /boot/config.txt:

:!: Change configurations require administrative privileges. To change the /boot/config.txt, you must use sudo nano (or another text editor) /boot/config.txt or sudo raspi-config
:!: Changes in configurations will take effect after reboot. After saved the configuration file, you must type the command: sudo reboot.
Kazzttor

Diadema-SP, Brazil
Linux-Windows-Mac User
Raspberry Pi Lover
User avatar
Posts: 4
Joined: Wed Jan 21, 2015 2:57 am
Location: Diadema - São Paulo, Brazil
by jkbai28 » Tue Jan 27, 2015 6:33 pm
Not working for me
Posts: 1
Joined: Tue Jan 27, 2015 6:29 pm
by PuppetHoundZ » Tue Jan 27, 2015 10:22 pm
You can also use leafpad if you want to use X to modify config.txt:
Code: Select all
sudo leafpad

Then go to file-> Open-> boot/config.txt
this method also works when modifying /etc/modprobe.d/raspi-blacklist.conf

Or if you got NOOBS. Go to recovery page and select config.txt editor. :)
Setup: (Raspbian w/o NOOBs) Raspberry Pi 2 B w/ Official Broadcom WiFi Adapter w/ 2usb ports & Various USB Drives. I use default Clock.
Use: Raspberry Pi Every day to learn Linux as desktop replacement.
Twitter: @PuppetHoundZ
User avatar
Posts: 135
Joined: Wed Jan 21, 2015 2:57 am
Location: Nevada, USA.
by hugo_figueiredo » Thu Jan 29, 2015 12:23 pm
Someone have another way to resolve the problem? the fix above, for me didnt work.
I have a raspbian installed in HDD and after i made the rpi-update, everytime i start the raspberry, a few minutes running and the raspberry loses the connection to the HDD.
Posts: 9
Joined: Tue Jan 27, 2015 12:46 pm
by PhilE » Thu Jan 29, 2015 1:44 pm
@hugo_figueiredo I suggest you rpi-update back to an earlier version until you find when the problem first appeared. There are instructions here.

If you are overclocked you might also try turning that off for now.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 764
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge
by PhilE » Sat Jan 31, 2015 4:59 pm
I've updated the initial post and README to reflect a few recent changes:

1) The next Raspbian and NOOBS releases will contain a raspi-config that can enable and disable Device Tree, and the I2C and SPI interfaces (in addition to controlling the blacklisting for the drivers).

2) To remove any confusion surrounding the use of i2c0 and i2c1 on different board revisions, three new DT parameters have been added to the latest firmware - "i2c_arm" (the ARM's I2C interface), "i2c_vc" (the I2C used by VideoCore - don't enable unless you know what you are doing and aren't planning to use a PiCamera), and "i2c" - an alias for "i2c_arm". People using an i2c device can now add "dtparam=i2c=on" to their config.txt, regardless of the Pi model (or use raspi-config to do the same thing).

3) The HifiBerry Amp card has an overlay, as has the pfc8523 RTC chip.

4) The parasitic power (power and data over two wires) feature of the w1-gpio driver has been found to not work when DT is enabled. This will be fixed in a future release.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 764
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge
by emgi » Sun Feb 01, 2015 2:56 pm
Another thing which is not broken but has changed its behavior is the nfs client.
Since this update, it appears to default to nfs version 4 so nfs didn't work after rpi-update because my server was still running version 3.

I changed /etc/fstab to include the bold text like this:
rpi:/usb1 /usb1 nfs nfsvers=3 0 0

That solved the issue.
When mounting manually, you need to incorporate the version as an nfs-option.

/emgi
User avatar
Posts: 320
Joined: Thu Nov 07, 2013 4:08 pm
Location: NL
by frickeln » Tue Feb 03, 2015 8:14 am
Hi,

yesterday I made a apt-get update/upgrade and also get the problem, that I2c does not work anymore. I did no rpi-update !

Kernel seems to be the newest one now. Anyhow, with your hints (thanks!) I managed to get it running again.

But the i2c module seems to ignore my baud settings now. I used

"options i2c_bcm2708 baudrate=4000" in the /etc/modprobe.d/i2c-bcm2708.conf
( see this topic: viewtopic.php?f=44&t=34734)

When I call after the update dmesg | grep i2c, I get:

bcm2708_i2c 20804000.i2c: BSC1 Controller at 0x20804000 (irq 79) (baudrate 100000)

Anyone any idea ?

Peter
Posts: 1
Joined: Tue Feb 03, 2015 8:03 am
Location: Hamburg
by PhilE » Tue Feb 03, 2015 10:21 am
Yes, sorry about that. Your module parameter is being overridden by a device tree property, and without a parameter to change that you are a bit stuck.

The next release will add parameters to the base dtbs to set the baudrate, but for now you can use an overlay.

Copy the following into a file - I'll assume it's called i2c-baudrate-overlay.b64:
Code: Select all
0A3+7QAAAWEAAAA4AAABMAAAACgAAAARAAAAEAAAAAAAAAAxAAAA+AAAAAAAAAAAAAAAAAAAAAAA
AAABAAAAAAAAAAMAAAANAAAAAGJyY20sYmNtMjcwOAAAAAAAAAABX19vdmVycmlkZXNfXwAAAAAA
AAMAAAAWAAAAC96tvu9jbG9jay1mcmVxdWVuY3k6MAAAAAAAAAMAAAAWAAAAGd6tvu9jbG9jay1m
cmVxdWVuY3k6MAAAAAAAAAIAAAABX19maXh1cHNfXwAAAAAAAwAAAB8AAAAnL19fb3ZlcnJpZGVz
X186aTJjMF9iYXVkcmF0ZTowAAAAAAADAAAAHwAAACwvX19vdmVycmlkZXNfXzppMmMxX2JhdWRy
YXRlOjAAAAAAAAIAAAACAAAACWNvbXBhdGlibGUAaTJjMF9iYXVkcmF0ZQBpMmMxX2JhdWRyYXRl
AGkyYzAAaTJjMQA=

Make sure the file is in the current directory on your Pi, then type:
Code: Select all
base64 -d i2c-baudrate-overlay.b64 > i2c-baudrate-overlay.dtb
sudo cp i2c-baudrate-overlay.dtb /boot/overlays/

This overlay creates the following parameters:
* i2c0_baudrate
* i2c1_baudrate
Then you can add this to your config.txt:
Code: Select all
dtoverlay=i2c-baudrate,i2c1_baudrate=4000

Once the update rolls out, you'll be able to replace that with:
Code: Select all
dtparam=i2c1_baudrate=4000

In fact, if you prefer you could use this format instead:
Code: Select all
# Comment out or delete the next line when the base DTBs are fixed
dtoverlay=i2c-baudrate
dtparam=i2c1_baudrate=4000

A future firmware release will add some board-specific aliases for these: i2c/i2c_arm and i2c_vc.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 764
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge
by PhilE » Tue Feb 03, 2015 10:54 am
For the curious, the source for the overlay looks like this:
Code: Select all
// Definitions for the missing i2c baudrate parameters
/dts-v1/;
/plugin/;

/ {
   compatible = "brcm,bcm2708";

   __overrides__ {
      i2c0_baudrate = <&i2c0>,"clock-frequency:0";
      i2c1_baudrate = <&i2c1>,"clock-frequency:0";
   };
};

and it can be compiled by the dtc command you get by building the latest Pi kernels, like this:
Code: Select all
dtc -@ -I dts O dtb -o i2c-baudrate-overlay.dtb i2c-baudrate-overlay.dts

where the .dts file is the input and the .dtb file is the output.

The strange "<&i2c1>" syntax is a reference to a label, in this case the label on the DT node describing the i2c1 controller. The string that follows it identifies a property of that node ("clock-frequency") and the ":0" means that it is an integer parameter at offset 0 bytes into the property.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 764
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge
by jpsa » Wed Feb 04, 2015 8:49 am
I did an apt-get upgrade (*not* an rpi-update) yesterday, and found that me 1-wire temperature probe had stopped working. After quite a bit of Googling, I fixed it by adding

# 1-wire settings
dtoverlay=w1-gpio,gpiopin=4

to the end of my /boot/config.txt. I'm puzzled, though, that the advice given in the first post of this sticky recommends use of

dtoverlay=w1-gpio-pullup ...

even if you don't need a separate pullup pin: this also seems to conflict with the README in the second post. Is this a typo?
Posts: 12
Joined: Wed Feb 04, 2015 8:22 am
by PhilE » Wed Feb 04, 2015 9:22 am
Yes, that's a cut-and-paste error (now fixed).

Thanks.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 764
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge
by PhilE » Wed Feb 04, 2015 1:33 pm
I've updated the README (2nd post in this thread) to reflect the w1-gpio changes. The next release will support the following overlays and parameters:
Code: Select all
File:   w1-gpio-overlay.dtb
Info:   Configures the w1-gpio Onewire interface module.
        Use this overlay if you *don't* need a pin to drive an external pullup.
Load:   dtoverlay=w1-gpio,<param>=<val>
Params: gpiopin                  GPIO pin for I/O (default "4")

        pullup                   Non-zero, "on", or "y" to enable the parasitic
                                 power (2-wire, power-on-data) feature


File:   w1-gpio-pullup-overlay.dtb
Info:   Configures the w1-gpio Onewire interface module.
        Use this overlay if you *do* need a pin to drive an external pullup.
Load:   dtoverlay=w1-gpio-pullup,<param>=<val>,...
Params: gpiopin                  GPIO pin for I/O (default "4")

        pullup                   Non-zero, "on", or "y" to enable the parasitic
                                 power (2-wire, power-on-data) feature

        extpullup                GPIO pin for external pullup (default "5")


This update separates the external pullup enable pin ("extpullup") and the parasitic power ("pullup") features of the driver, which had become conflated. But the most significant change is the fix to the pinctrl driver that makes it all work with Device Tree.

There is likely to be an rpi-update release later today.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 764
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge
by GMan2XS » Wed Feb 04, 2015 1:49 pm
Thank you so much for this thread.

I have several Pis & a couple of NAS drives on my home network. The existing Pis each have a cron job on them to backup important stuff to one of the NAS drives. Yesterday I was setting up my new Pi2 and having installed autofs & configured it I tried to setup the backup job on the Pi2. It failed to connect to my normal backup drive, but would connect to the other NAS. I then discovered that one of my other Pis on which I had recently done an apt-get update/upgrade had the same problem.

After reading this thread I downgraded the kernel on the Pi (not the Pi2) and the problem is gone from the Pi.

Then a bit later I got a PM from jpsa telling me about this thread http://www.raspberrypi.org/forums/viewtopic.php?f=28&t=98524

I tried it on the Pi2 and it works.

Gotta love this forum =;-)
Posts: 7
Joined: Tue Sep 18, 2012 3:44 pm
by PhilE » Thu Feb 05, 2015 5:35 pm
The w1-gpio/DT issues should now have been resolved, provided you rpi-update; it will take a bit longer to hit a Raspbian image. Shout if you still have problems.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 764
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge
by msmithy12 » Mon Feb 09, 2015 1:19 pm
Hi, so Ive been using the spi.h include in my software as shown here
http://www.raspberry-projects.com/pi/programming-in-c/spi/using-the-spi-interface

and since doing the updates my SpiWriteAndRead() has been throwing up the following error

Code: Select all
Error - Problem transmitting spi data..ioctl: invalid argument


I am aware this cause by retVal being less than 0, but I can not seem to rectify the issue.

Any ideas
Thanks
Matt
I assume I know what I`m talking about... I probably don`t

Home: 256mb Made in UK, Rasbmc, 40" Sony Bravia KDL-40v3000
Work: 2b+, Rasbian, 6" Lilliput touchscreen
Posts: 94
Joined: Fri Aug 10, 2012 8:57 am