User Tools

Site Tools


devicetree

Device Tree Config

Since Kernel 3.18.3 the RaspberryPi image has the device tree (DT) activated by default. In the beginning people became really crazy as after an “rpi-update” or an “apt-get dist-upgrade” some of the 1wire or I²C sensors suddenly were not working anymore.

The easy part is, if everybody would have known in advance, it just could have been deactived by just setting the following line in file “/boot/config.txt”:

device_tree=

Today this can also be done by running “raspi-config”, there is an option in the advanced section.

But using the device tree is way more state-of-the-art and should be the prefered way. Setup is easy and really flexible, so give it a try!

Device Tree Switches to know

Before forgetting, I have made a list of “nice to know” DT options to switch on and off and to param if possible. All the following flags have to be set in “/boot/config.txt”:

dtparam=i2c=on #activates I²C interface
dtparam=i2s=on #activates I²S interface
dtparam=spi=on #activates SPI interface

Overlays

The “overlays” are an additional new feature for loading modules. By setting overlays, a module can be loaded or the settup can be overwritten. All overlays are also defined in “/boot/config.txt”.

By explaing an example for 1wire sensors (from w1-gpio-overlay.dtb), there is no need to load a module in /etc/modules anymore, 1wire can easily be activated by just adding the following line (default PIN is GPIO pin 4):

dtoverlay=w1-gpio

By adding the optional param for the pin, the 1wire GPIO pin can also be changed like here to e.g. GPIO 6:

dtoverlay=w1-gpio,gpiopin=6

Following a reference list with default values and possible additional overlays. Remind to only active what is really needed in production!

File:   <The base DTB>
Info:   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 pin 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.
File:   ads7846-overlay.dtb
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
File:   bmp085_i2s-sensor-overlay.dtb
Info:   BMP085/BMP180 digital barometric pressure and temperature
        sensors from Bosch Sensortec
Load:   dtoverlay=bmp085_i2s-sensor
Params: <None>
File:   ds1307-rtc-overlay.dtb
Info:   This overlay is now deprecated and will be deleted. Use i2c-rtc instead.
File:   enc28j60-overlay.dtb
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)
File:   hifiberry-amp-overlay.dtb
Info:   HifiBerry Amp and Amp+ audio cards
Load:   dtoverlay=hifiberry-amp
Params: <None>
File:   hifiberry-dac-overlay.dtb
Info:   HifiBerry DAC audio card
Load:   dtoverlay=hifiberry-dac
Params: <None>
File:   hifiberry-dacplus-overlay.dtb
Info:   HifiBerry DAC+ audio card
Load:   dtoverlay=hifiberry-dacplus
Params: <None>
File:   hifiberry-digi-overlay.dtb
Info:   HifiBerry Digi audio card
Load:   dtoverlay=hifiberry-digi
Params: <None>
File:   hy28a-overlay.dtb
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
File:   hy28b-overlay.dtb
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
File:   i2c-rtc-overlay.dtb
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
File:   iqaudio-dac-overlay.dtb
Info:   IQaudio DAC audio card
Load:   dtoverlay=iqaudio-dac
Params: <None>
File:   iqaudio-dacplus-overlay.dtb
Info:   IQaudio DAC+ audio card
Load:   dtoverlay=iqaudio-dacplus
Params: <None>
File:   lirc-rpi-overlay.dtb
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 pin for output (default "17")

        gpio_in_pin              GPIO pin 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")
File:   mz61581-overlay.dtb
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)
File:   pcf2127-rtc-overlay.dtb
Info:   This overlay is now deprecated and will be deleted. Use i2c-rtc instead.
File:   pcf8523-rtc-overlay.dtb
Info:   This overlay is now deprecated and will be deleted. Use i2c-rtc instead.
File:   piscreen-overlay.dtb
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}
File:   pitft28-resistive-overlay.dtb
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}
File:   pps-gpio-overlay.dtb
Info:   Configures the pps-gpio (pulse-per-second time signal via GPIO).
Load:   dtoverlay=pps-gpio,<param>=<val>
Params: gpiopin                  GPIO input pin (default "18")
File:   rpi-display-overlay.dtb
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)
File:   tinylcd35-overlay.dtb
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
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")

More details can be found in the original README of the RaspberryPi github account: https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README

devicetree.txt · Last modified: 30.03.2015 15:45 by andreas