What are the minimum lines of commands to update device tree from a host for TX2?

I have built a Ubuntu 14.04 machine just to flash TX2. After using the host to flash JetPack 3.1 to TX2, I took on the next task to figure out the procedure to update device tree blob (DTB).

Step 1. Download and copy the GCC toolchain from Jetson Download Center | NVIDIA Developer Go down to section “GCC Tool Chain for 64-bit BSP” and click to download the tar ball.

I copied the “install” directory and placed it under ~/toolchian/install

Step 2. Download and unpack L4T. Get the Latest L4T source “Linux For Tegra R28.1” from

go to the section “Source Packages”, click on “Sources”
which points to https://developer.nvidia.com/embedded/dlc/l4t-sources-28-1

Step 3. Make a work directory and unpack the L4T into the folder. In my case, it’s under ~/work/tx2

Step 4. Create a list of environment. My list is definitely more than needed for updating DTB, hope it does no harm either.

$  export HOME_TOP=/home/myuserid
 $  export BUILD_TOP=$HOME_TOP/work/tx2
 $  export CROSS_COMPILE=$HOME_TOP/toolchain/install/bin/aarch64-unknown-linux-gnu-
 $  export KERNEL_DIR=$BUILD_TOP/kernel/kernel-4.4
 $  export KERNEL_SUB=kernel/kernel-4.4/
 $  export TEGRA_KERNEL_OUT=$BUILD_TOP/linux_for_tegra/out
 $  export TEGRA_MODULES_OUT=$BUILD_TOP/linux_for_tegra/modules

Now we seem are ready to run the “make” tasks.

Step 5. Update the DTB

$  sudo make -C $KERNEL_SUB  O=$KERNEL_DIR ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE tegra18_defconfig
 $  sudo make -C $KERNEL_SUB  O=$TEGRA_KERNEL_OUT ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE TEGRA_KERNEL_OUT=$TEGRA_KERNEL_OUT dtbs

But it failed.

scripts/kconfig/conf  --silentoldconfig Kconfig
***
*** Configuration file ".config" not found!
***
*** Please run some configurator (e.g. "make oldconfig" or
*** "make menuconfig" or "make xconfig").
***
make[3]: *** [silentoldconfig] Error 1
make[2]: *** [silentoldconfig] Error 2
make[1]: *** No rule to make target `include/config/auto.conf', needed by `scripts'.  Stop.
make[1]: Leaving directory `/home/myuserid/work/tx2/linux_for_tegra/out'
make: *** [sub-make] Error 2
make: Leaving directory `/home/myuserid/work/tx2/kernel/kernel-4.4'

Step 6. Add a make menuconfig before make dtbs. Also add a make clean prior to it.

$ sudo make -C $KERNEL_SUB  mrproper
$ sudo make -C $KERNEL_SUB  O=$KERNEL_DIR ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE tegra18_defconfig
$ sudo make -C $KERNEL_SUB O=$TEGRA_KERNEL_OUT ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE menuconfig

But it still failed, though for a different reason:

make: Entering directory `/home/myuserid/work/tx2/kernel/kernel-4.4'
make[1]: Entering directory `/home/myuserid/work/tx2/linux_for_tegra/out'
  GEN     ./Makefile
  HOSTCC  scripts/kconfig/mconf.o
In file included from /home/myuserid/work/tx2/kernel/kernel-4.4/scripts/kconfig/mconf.c:23:0:
/home/myuserid/work/tx2/kernel/kernel-4.4/scripts/kconfig/lxdialog/dialog.h:38:20: fatal error: curses.h: No such file or directory
 #include CURSES_LOC
                    ^
compilation terminated.
make[2]: *** [scripts/kconfig/mconf.o] Error 1
make[1]: *** [menuconfig] Error 2
make[1]: Leaving directory `/home/myuserid/work/tx2/linux_for_tegra/out'
make: *** [sub-make] Error 2
make: Leaving directory `/home/myuserid/work/tx2/kernel/kernel-4.4'

Searched online for solutions, saw the mentioning of running “source_sync.sh”. I found the file and copy it from jetpack/64_TX2/Linux_for_Tegra_tx2/source_sync.sh to “~/work/tx2”.

The execution of the script shows “Cloning into ‘/home/myuserid/work/tx2/sources/kernel/kernel-4.4’…” (it takes a while to finish)

Duplicate another file structure for the kernel? I don’t think I ran the source_sync.sh script correctly. More importantly, the make tasks still failed.

Please help. . .

Edit: please notice an error in Step 6, line 2. See the comments in the thread below for further info.

I haven’t stepped through everything there, but the various config menu scripts for use in text mode use the libncurses5-dev package. You’ll have to install that before some of the config menus will show up:

sudo apt-get install libncurses5-dev

If you “make mrproper” it removes all config and temporary output. If you’ve used an “O=”, then you probably need mrproper to use this as well (the “O=” tells the compiler which directory to clean…you want the original location perfectly clean, and before starting on an external location, you probably want it clean). If you do a menuconfig, then you need to use the “O=” with that as well. It doesn’t hurt to run “make mrproper” on the main source tree, and then again on the “O=” directory.

Once that is done I recommend putting a copy of your existing “/proc/config.gz” as “.config” in the “O=” directory (don’t forget to gunzip it first before rename). If you’ve run “make tegra18_defconfig” or “make mrproper”, then you’ve wiped out any “.config” you’ve put there and need to put the “.config” back in place. If you run without the “O=” during a “make tegra18_defconfig”, then use “O=” later, it implies it is like your defconfig never took place…every step needs the same “O=” if they are to apply to the same build. Using “/proc/config.gz” is better than using “tegra18_defconfig” since this implies you’ll match the existing system and not a default which might not be installed. In earlier releases the two were the same, but I don’t believe the two versions match in newer releases.

“make O=… menuconfig” can be done any time after the copy of “/proc/config.gz” (or after “make tegra18_defconfig”), just don’t do any “make mrproper” after any kind of config step unless you want to wipe out the config and start over.

@linuxdev, you saved my day! I need to run more test, but the errors are gone. I believe the key is what you pointed out about “O=” in make mrproper. Without it, mrproper won’t be able to clean up the out directory as you indicated.

As for running “sudo apt-get install libncurses5-dev”, the host prompts:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
libncurses5-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded.

Look like the libncurses5 is already installed on my Ubuntu 14.04.

Now, let me share my experience in adding the -O option to make mrproper. Initially I got a complaine about the permissions.

make -C $KERNEL_SUB O=$TEGRA_KERNEL_OUT mrproper
make: Entering directory `/home/myuserid/work/tx2/kernel/kernel-4.4' 
make[1]: Entering directory `/home/myuserid/work/tx2/linux_for_tegra/out' 
rm: cannot remove ‘./scripts/kconfig/zconf.tab.o’: Permission denied 
rm: cannot remove ‘./scripts/kconfig/.conf.cmd’: Permission denied 
rm: cannot remove ‘./scripts/kconfig/conf.o’: Permission denied 
rm: cannot remove ‘./scripts/kconfig/.zconf.tab.o.cmd’: Permission denied 
rm: cannot remove ‘./scripts/kconfig/.conf.o.cmd’: Permission denied 
rm: cannot remove ‘./scripts/basic/.fixdep.cmd’: Permission denied make[1]: *** [clean] Error 123 make[1]: Leaving directory `/home/myuserid/work/tx2/linux_for_tegra/out' make: *** [sub-make] Error 2 
make: Leaving directory `/home/myuserid/work/tx2/kernel/kernel-4.4'

Then I added “sudo” to the command, everything went fine, including the pop up of make menuconfig. Here are the minimum set up make commands I ran to update the device tree (without generating a new kernel):

sudo make -C $KERNEL_SUB O=$TEGRA_KERNEL_OUT mrproper
sudo make -C $KERNEL_SUB  O=$KERNEL_DIR ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE tegra18_defconfig
sudo make -C $KERNEL_SUB O=$TEGRA_KERNEL_OUT ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE menuconfig
sudo make -C $KERNEL_SUB  O=$TEGRA_KERNEL_OUT ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE TEGRA_KERNEL_OUT=$TEGRA_KERNEL_OUT dtbs

(Please see my post earlier in this thread for the environment settings)

Continue my report.

I’m still have problem in . For some unknown reasons, the newly generated DTB seems not updating. fdtdump shows the DTB content is pretty much the same as the DTB from JetPack 3.1, except for date time minor differences.

I also realized the “make tegra18_defconfig” (command #2 in the list above) points to a different “O=” from other commands. But a change to it

sudo make -C $KERNEL_SUB  O=$TEGRA_KERNEL_OUT ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE tegra18_defconfig

makes no difference. The “make dtbs” still shows no update in the DTB file “tegra186-quill-p3310-1000-c03-00-base.dtb”。 The DTB output directory in my environments is as shown below.

~/work/tx2/linux_for_tegra/out/arch/arm64/boot/dts

Apparently the “make dtbs” command didn’t use the .config file in $TEGRA_KERNEL_OUT/arch/arm64/boot/dts.

I also found another .config file under ~/work/tx2/kernel/kernel-4.4 (which is $KERNEL_DIR).

I ran the make command in the directory ~/work/tx2

What change are you looking for? Did you edit something in the kernel source? Are you comparing what shows up in the kernel source, or are you comparing the result of a Jetson booted with the new DTB? So far as procedure to apply a DTB to a Jetson goes, this all changed with R28.1…the usual FDT entry of extlinux.conf can no longer be used to install the DTB, so the question is at what point in the process did you find no change?

I found the problem. The location of .config is defined by the way issuing the make tegra18_defconfig command. Therefore, it’s a mistake to call “O=$KERNEL_DIR” in my setting. The correct way should be
sudo make -C $KERNEL_SUB O=$TEGRA_KERNEL_OUT ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE tegra18_defconfig

In summary, all the make commands should be entered as follows:

$ cd $BUILD_TOP 
#-- if you need to clean up the previous build 
$ sudo make -C $KERNEL_SUB O=$TEGRA_KERNEL_OUT mrproper
#-- create the configuration
$ sudo make -C $KERNEL_SUB O=$TEGRA_KERNEL_OUT ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE tegra18_defconfig
#-- compile DTS source
$ sudo make -C $KERNEL_SUB O=$TEGRA_KERNEL_OUT ARCH=arm64 CROSS_COMPILE=$CROSS_COMPILE TEGRA_KERNEL_OUT=$TEGRA_KERNEL_OUT dtbs

As the result, the newly created device tree blob (DTB) will be at

$TEGRA_KERNEL_OUT/arch/arm64/boot/dts/tegra186-quill-p3310-1000-c03-00-base.dtb

I followed your new ideas of the “O=$TEGRA_KERNEL_OUT”, but still couldn’t see any updating in newly created DTB file. I used “diff” command and compared the newly generated DTB and the original DTB(hooked IMX219 module), reported no difference. Any idea? THX!

Although you can compile a kernel and use the directories for the source as the output location it tends to be discouraged…thus the O=/some/where option is added. You’d cd to where the kernel source is, and then use “make” with the O= option to name another location for all temporary files. The “.config” file and all commands related to setting up configuration also use the O= option and are considered temporary files. So if you used O= at any step, then O= needs to be used in all steps.

You could “make mrproper” in the kernel source directory before starting to make sure this is pristine unchanged code…and then use O=…and in fact you could also run “make O=/some/where mrproper” before starting a new configuration and apply mrproper to that location as well. However, because of other files interacting, I tend to just recursively delete my “O=” and create a new empty directory instead of using mrproper on it.

If your configuration or .config file and build commands do not name the same O= location, then some changes will mysteriously not be where you expect. Be sure you have the O= in all of your build commands, including configuration steps.

The “-C /some/where/kernel/source/is/at” simply names where the kernel source is. If you cd to that location it is the equivalent of using “-C /some/where/kernel/source/is/at”…the '-C" tells make where to cd to before starting. It’s useful in scripts, but not mandatory.