Device Tree¶
Accessing device tree information in user space¶
The current device tree, including any loaded overlay, is available at /sys/firmware/devicetree/base
.
Reading the whole device tree from /sys
¶
Getting memory addresses from device tree symbols¶
Anything in /sys/firmware/devicetree/base/__symbols__/
can be cat
ted to get the memory address that the device occupies, or other information on the interface if it doesn't have an address:
Reading data from device tree addresses¶
Programs like devmem
, devmem2
, and pydevmem
can read arbitrary memory addresses by interacting with the /dev/mem
file.
devmem
¶
Note
devmem
is a busybox program and is unavailable on Ubuntu.
devmem2
¶
Usage: devmem2 { address } [ type [ data ] ]
address : memory address to act upon
type : access operation type : [b]yte, [h]alfword, [w]ord
data : data to be written
Warning
I do not recommend devmem2
; it never seems to do what I expect it to, and often results in bus errors on addresses that I believe should be accessible.
The same addresses accessed using pydevmem
do not result in these errors.
pydevmem
¶
Usage: pydevmem [options]
Options:
-h, --help show this help message and exit
-r ADDR, --read=ADDR read a value
-w ADDR VALUE, --write=ADDR VALUE
write a value
-n NUM, --num=NUM number of words to read
-s WORD_SIZE, --word-size=WORD_SIZE
size of word when displayed
-m FILE, --mmap=FILE file to open with mmap()
-v provide more information regarding operation
-d provide debugging information
Overlays¶
Installing an overlay¶
- Ensure that the
.dtbo
file and any required drivers are in the appropriate place in/lib/firmware
. -
Create an overlay directory and echo over the path:
Removing an overlay¶
For an already installed overlay called my_overlay
: