Edit device tree at run time

From RidgeRun Developer Wiki


Introduction

Sometimes, when we are working on an embedded device adding a new module or debugging an existing one, we need to constantly modify the device tree. This wiki page explains an easy way of doing it from the same target board without the need of going to the source code. For this purpose we'll use a tool called devocet-tree-compitler

Using the tool

Install the tool

sudo apt-get install device-tree-compiler

After this should have these tools installed: fdtdump fdtget fdtput

Dumping the dtb

To dump the dtb you can use fdtdump as follows:

fdtdump [options] <file>

For instance:

fdtdump /boot/tegra186-quill-p3310-1000-c03-00-base.dtb

Getting a property

To get a property you can use fdtget as follows:

fdtget <options> <dt file> [<node> <property>]...

For instance, to get the clock frequency for i2c0:

fdtget /boot/tegra186-quill-p3310-1000-c03-00-base.dtb i2c0 clock-frequency

Setting a property

To set a property you can use fdtput as follows:

fdtput <options> <dt file> <node> <property> [<value>...]

So for example, to set the clock frequency for i2c0:

sudo fdtput -t i /boot/tegra186-quill-p3310-1000-c03-00-base.dtb i2c0 clock-frequency 100000

After this you should restart your board for the changes to take effect.



For direct inquiries, please refer to the contact information available on our Contact page. Alternatively, you may complete and submit the form provided at the same link. We will respond to your request at our earliest opportunity.


Links to RidgeRun Resources and RidgeRun Artificial Intelligence Solutions can be found in the footer below.