Skip to content

Changing driver parameters with devicetree

CarolaSchoenrock edited this page Jul 8, 2019 · 1 revision

Purpose of devicetree

Some use cases require changing camera driver parameters such as the MIPI clock or the number of lanes. To achieve this, devicetree files are used. The underlying principles are valid for all boards.

Devicetree introduction

Devicetree source files (DTS, file ending .dts) and devicetree source include files (.dtsi) describe a device as a human-readable tree of nodes and their properties. The DTS file is compiled into a binary devicetree blob file (DTB, file ending .dtb) that the bootloader puts into RAM. During the boot process, the kernel takes over the values from the devicetree.

Modifying and compiling the Allied Vision camera devicetree

You can modify the Allied Vision camera devicetree directly on the embedded board:

  1. Install the DTC (devicetree compiler) on the board:
# Install the DTC
sudo apt-get install device-tree-compiler
  1. Identify the correct devicetree blob for your board. Examples:
  • Nitrogen6_MAX: /boot/imx6qp-nitrogen6_max.dtb.
  • Wandboard: /media/ubuntu//imx6qp-wandboard-revd1.dtb
  1. Decompile the devicetree blob to devicetree source. In this example, we use Nitrogen6_MAX. Ignore warnings during this procedure:
# Decompile the devicetree blob
./dtc -I dtb -O dts -o ./devicetree.dts /boot/imx6qp-nitrogen6_max.dtb
  1. Make the desired changes to the devicetree source file devicetree.dts:
avt_imx6_csi2: avt_imx6_csi2@3C 
{
    compatible = "avti,avt_imx6_csi2";
    reg = <0x3C>;                      
# I2C camera address
    clocks = <&clks IMX6QDL_CLK_PWM3>; // Pixel clock frequency
    clock-names = "csi_mclk";
    av_cam_i2c_clk = <400000>;         
# Host I2C camera clock
# i.MX6 has two IPUs (IPU0 and IPU1), each IPU has CSI channels CSI0 and CSI1. 
# The virtual channel is defined based on the IPU and CSI selection. 
# Default: virtual channel 0. 
    ipu_id = <0>;          
# IPU ID value of the connected camera to choose stream and VC
    csi_id = <0>;          
# CSI ID value of the connected camera to choose stream and VC
    lanes = <4>;           
# Lane count. No effect when lanes_auto_conf = 1 
    lanes_auto_conf = <1>; 
# Value 1 sets lane auto negotiation and configuration. 
    mclk = <188000000>;    
# Master clock
    mclk_source = <0>;
    clk_auto_conf = <1>;   
# Value 1 sets clock auto negotiation and configuration
};
  1. Compile the devicetree source to devicetree blob and replace the original one. In this example, we use Nitrogen6_MAX. Ignore warnings during this procedure:
# Decompile the devicetree blob
sudo ./dtc -I dts -O dtb -o /boot/imx6qp-nitrogen6_max.dtb ./devicetree.dts
  1. Reboot the board to apply the changes.