My customized device tree has gone after CSI driver installatoin

Hi

I have a custom designed carrier board, and flashed my Jetson TX2 with customized device tree (full flash).

After installation of the Allied Vision CSI-2 driver, the device tree returned to its original, with Allied Vision patchs applied in it.

I see the actual loaded device tree with:

dtc -I fs -O dts -o extracted.dts /proc/device-tree

which content is different from the flashed dtb.

I know that a FDT entry in /boot/extlinux/extlinux.conf can be used to force Jetson use the dtb file in a directory in file system, And, I assume the driver installer uses this method to apply its patchs to device tree. But, there is no FDT entry in the extlinux.conf after AlliedVision driver installation.

Here is the contents of the extlinux.conf file:

TIMEOUT 30
DEFAULT primary

MENU TITLE L4T boot options

LABEL primary
      MENU LABEL primary kernel
      LINUX /boot/Image
      INITRD /boot/initrd
      APPEND ${cbootargs} quiet root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0 isolcpus=1-2 

# When testing a custom kernel, it is recommended that you create a backup of
# the original kernel and add a new entry to this file so that the device can
# fallback to the original kernel. To do this:
#
# 1, Make a backup of the original kernel
#      sudo cp /boot/Image /boot/Image.backup
#
# 2, Copy your custom kernel into /boot/Image
#
# 3, Uncomment below menu setting lines for the original kernel
#
# 4, Reboot

# LABEL backup
#    MENU LABEL backup kernel
#    LINUX /boot/Image.backup
#    INITRD /boot/initrd
#    APPEND ${cbootargs}

Jetpack Version: 4.5.1
Allied Vision driver:

Any help would be appreciated.

hello AliHaeri,

it’ll load binary file via kernel-dtb partition when extlinux.conf file without FDT entry,
it’ should be sensor vendor to provide binary file and using installer to write the kernel-dtb partition.
you may examine $ dmesg | grep DTS for checking kernel logs.

according to the github you’ve shared, you should download the sources and integrate your customize device tree to create another new device tree blob.

Hi JerryChang.

Thanks for your reply.

Here is content of the installer bash script:

#!/bin/bash
#==============================================================================
# Copyright (C) 2021 Allied Vision Technologies.  All Rights Reserved.
#
# Redistribution of this file, in original or modified form, without
# prior written consent of Allied Vision Technologies is prohibited.
#
#------------------------------------------------------------------------------
#
# File:         -install.sh
#
# Description:  -bash script for installing the kernel and CSI-2 driver
#
#------------------------------------------------------------------------------
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
# NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR  PURPOSE ARE
# DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#==============================================================================

NC='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
REQ_MACHINE="NVidia Jetson TX2"
REQ_KERNEL="4.9.201"
DEST="/boot"

echo -e ${RED}"Allied Vision"${NC}" MIPI CSI-2 camera driver for "${GREEN}${REQ_MACHINE}${NC}" (kernel "${REQ_KERNEL}")"


# ========================================================= usage function
usage() {
  echo -e "Options:"  
  echo -e "-h:\t Display help"
  echo -e "-y:\t Automatic install and reboot"
  exit 0
}

function install_dtb_extlinux() {
  ELC=/boot/extlinux/extlinux.conf
  echo "Updating extlinux configuration in $ELC."
  if sed -n '/^LABEL primary$/,/^$/p' $ELC | grep -Eq '^\s+FDT\s+/boot'; then
    echo "Device tree already configured in $ELC, removing old entry."
    sudo sed -i '/^\s\+FDT\s\+\/boot/d' $ELC
  fi

  sudo sed -i '/^\s\+INITRD\s\+/a \ \ \ \ \ \ FDT /boot/dtb/'$1 $ELC
}

function valid_nano_model() {
  case "$NANO_CARRIER" in
  b00)
    true
    return
    ;;
  a02)
    true
    return
    ;;
  *)
    if [ ! -z "$NANO_CARRIER" ]; then
      echo "Invalid Nano carrier board selection"
    fi
    ;;
  esac
  false
}

inst() {
  MODEL="$(tr -d '\000' < /proc/device-tree/model)"

  if [[ "$MODEL" == *"Nano"* ]]; then
    sudo l4t_payload_updater_t210 bl_update_payload >nv_update_engine.log

  else
    sudo nv_update_engine -e 2>&1 >nv_update_engine.log
    sudo nv_update_engine -i --payload bl_update_payload --no-reboot 2>&1 >>nv_update_engine.log
  fi

  # All boards: copy Image + DTBs in rootfs
  sudo cp -r Image* $DEST
  
  # All boards: Install modules in rootfs
  echo "Unpacking modules to /$(tar tzf modules.tar.gz | head -n 1)"
  sudo tar zxf modules.tar.gz -C /
}


if [[ ( $1 == "-help") || ( $1 == "-h") ]]; then
  usage
fi  

if [[ ( $1 == "-y" ) ]]; then
  inst
  sudo init 6
  exit 0
fi  


read -p "Install kernel driver (y/n)? " answer
case $answer in
  [Yy]* )
    echo -e "\nInstalling..."
    inst
  ;;
  [Nn]* )
    echo -e
  ;;
esac

read -p "Reboot now (y/n)? " answer
case $answer in
  [Yy]* )
    echo -e "Reboot..."
    sudo init 6
  ;;
  [Nn]* )
    echo -e
    exit 0
  ;;
esac

exit 0

Looks it uses nv_update_engine to do dtb partition update.
Is the method used by this script is one described in this link?:

https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3251/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/bootloader_update.html#

it’s bl_update_payload (i.e. BUP) to contain all required binaries, that’s bootloader update to update all partitions contained in the BUP.

Thanks JerryChang.

As I said in post #1, I flashed my customized device tree to jetson with full flash.
But, my changes disappeared after installing the CSI camera driver.

To be clear, my question is :

How to apply my changes to device tree after installing the driver?

I tried the following method:

1- Getting the system current device tree (after installing the driver):

dtc -I fs -O dts -o extracted.dts /proc/device-tree

2- Editing the .dts file, to apply my patchs.

3- Re-compile the dts file:

dtc -I dts -O dtb -o kernel_tegra186-quill-p3310-1000-c03-00-base.dtb extracted.dts

4- Place the kernel_tegra186-quill-p3310-1000-c03-00-base.dtb file in /boot/dtb directory.
5- Adding the following lines to /extlinux/extlinux.conf, and reboot.

LABEL JetsonIO
       MENU LABEL Custom 40-pin Header Config
       LINUX /boot/Image
       FDT /boot/kernel_tegra186-quill-p3310-1000-c03-00-base-user-custom.dtb
       INITRD /boot/initrd
       APPEND ${cbootargs} quiet root=/dev/mmcblk0p1 rw rootwait rootfstype=ex$

After that, my changes to device tree is applied, but the camera is not detected.

Would you please help to solve this problem?

Thanks.

output of dmesg | grep DTS after driver installation:

[    0.161528] DTS File Name: arch/arm64/boot/dts/../../../../../../hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c03-00-base.dts
[    0.403430] DTS File Name: arch/arm64/boot/dts/../../../../../../hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c03-00-base.dts

output of dmesg | grep DTS after trying method in post #5.

[    0.184546] DTS File Name: /dvs/git/dirty/git-master_linux/kernel/kernel-4.9/arch/arm64/boot/dts/../../../../../../hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c03-00-base.dts
[    0.454088] DTS File Name: /dvs/git/dirty/git-master_linux/kernel/kernel-4.9/arch/arm64/boot/dts/../../../../../../hardware/nvidia/platform/t18x/quill/kernel-dts/tegra186-quill-p3310-1000-c03-00-base.dts

hello AliHaeri,

don’t you have device tree sources of CSI camera,
you may integrate the changes to built new device tree blob from public release sources.

If i understand you correctly, You mean I should integrate the CSI driver device tree into the original device tree…
But, the driver installer script updates the device tree and do other tasks that I don’t know.

according to the linkage you provide, i.e. Release 2.1.0 · alliedvision/linux_nvidia_jetson · GitHub
there’s Source code(zip) you should download for code integration.

1 Like

Hi

Thanks JerryChang.

I was trying to integrate my changes to kernel source code provided in github page, and today managed to have all things work on jetson, both CSI driver and my changes to device tree.

Thanks a lot for your help.