-
Notifications
You must be signed in to change notification settings - Fork 495
Device Tree
FBTFT has support for Device Tree (as of 2014-08-16).
The BRANCH=latest uses this with a DT enabled kernel (fbtft_device can still be used).
rpi.dts is concatinated to bcm2708-rpi-b.dts. It contains nodes for some displays.
One file is added to /boot: bcm2708-rpi-b.dtb
This is the Device Tree in it's binary from.
/boot/config.txt has this addition to it's end:
# Boot a Device Tree enabled kernel
device_tree=bcm2708-rpi-b.dtb
device_tree_address=0x100
kernel_address=0x8000
disable_commandline_tags=2
This must be removed when going back to a non-DT kernel, or else it won't boot.
Install Device Tree Compiler
$ sudo apt-get install device-tree-compiler
$ dtc -v
Version: DTC 1.3.0
This dtc version can't add properties (in dtb), only change the ones currently there. Build dtc from source to be able to add properties.
There are two ways to change the Device Tree:
- use fdtput to change the binary .dtb directly
- change the source .dts and compile into a .dtb
(Device Tree Overlays is a third, but it's not standardized yet)
The status property determines whether the device is enabled or not.
Absent property, "okay" or "ok" value, means the device is enabled. Any other value means disabled.
Ref: http://lxr.free-electrons.com/ident?a=arm;i=__of_device_is_available
Enable SPI controller
$ fdtget /boot/bcm2708-rpi-b.dtb /soc/spi@7e204000 status
disabled
$ sudo fdtput -t s /boot/bcm2708-rpi-b.dtb /soc/spi@7e204000 status "okay"
Current piscreen and touch status
$ fdtget /boot/bcm2708-rpi-b.dtb /soc/spi@7e204000/piscreen@0 status
disabled
$ fdtget /boot/bcm2708-rpi-b.dtb /soc/spi@7e204000/piscreen_ts@1 status
disabled
Enable piscreen
# property type 's': string
$ sudo fdtput -t s /boot/bcm2708-rpi-b.dtb /soc/spi@7e204000/piscreen@0 status "okay"
$ sudo fdtput -t s /boot/bcm2708-rpi-b.dtb /soc/spi@7e204000/piscreen_ts@1 status "okay"
$ sudo reboot
Rotate display 180
$ fdtget /boot/bcm2708-rpi-b.dtb /soc/spi@7e204000/piscreen@0 rotate
270
# property type 'u': unsigned
$ sudo fdtput -t u /boot/bcm2708-rpi-b.dtb /soc/spi@7e204000/piscreen@0 rotate 90
$ sudo reboot
Change speed
$ fdtget /boot/bcm2708-rpi-b.dtb /soc/spi@7e204000/piscreen@0 spi-max-frequency
20000000
$ sudo fdtput -t u /boot/bcm2708-rpi-b.dtb /soc/spi@7e204000/piscreen@0 spi-max-frequency 32000000
Add node to Device Tree
# copy dts src to working directory
# this is the source used to build the shipped dtb file
$ cp -r /usr/local/src/fbtft_dts ~
$ cd ~/fbtft_dts
# add some node to bcm2708-rpi-b.dts
# compile
$ dtc -I dts -O dtb -o bcm2708-rpi-b.dtb bcm2708-rpi-b.dts
# make backup of the original file so we have a way back in if things get messed up
$ sudo cp /boot/bcm2708-rpi-b.dtb /boot/bcm2708-rpi-b.dtb.bak
# use the new dtb
$ sudo cp bcm2708-rpi-b.dtb /boot
$ sudo reboot
Dump device tree binary binary in dts form
$ dtc -I dtb /boot/bcm2708-rpi-b.dtb
Links:
- Device Tree on ARCH_BCM2708
- Upstreaming (ARCH_BCM2835)