Compile / Flash Kernel and DTB from Jetson Nano natively

I have successfully compiled the Kernel and device tree binary on the Jetson Nano by following these instructions. https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/kernel_custom.html

However, all the flashing instructions are for cross compiling on a host machine but I am compiling it natively on the jetson nano. I am compiling from source using https://developer.nvidia.com/embedded/L4T/r32_Release_v4.4/r32_Release_v4.4-GMC3/Sources/T210/public_sources.tbz2

I dont see a flash.sh script as noted in the instructions. Im not sure what files to copy, where the files are located, and where to copy them. Any help?

To clarify, flash.sh is only on the host PC, and never on the Jetson. flash.sh is useful only when flashing. Kernels have more than one way they can be installed, and flashing is probably the least convenient and least safe method of doing so.

Basically, there is more than one way boot can find a kernel. If the kernel is found in a partition, then rules for signing (such as secure boot needs) are enforced. On the other hand, if your “/boot/extlinux/extlinux.conf” points to a kernel Image as a file in “/boot”, then it will just use that. When adding a kernel in “/boot” you can alter its name and keep the original for safe keeping (for example, the original is named Image, and yours could be named Image-test).

You could add your new kernel by copying it to “/boot” with its new name, add a second boot entry in “extlinux.conf”, edit that entry to use the new kernel name, and then either (a) pick that kernel using serial console at boot time, or (b) make that entry the default and only pick the original via serial console if you have problems. Just make sure you have a serial UART set up for serial console. See:
https://www.jetsonhacks.com/2019/04/19/jetson-nano-serial-console/

FYI, a very common problem is if the new kernel did not set CONFIG_LOCALVERSION to match that of the default kernel. If set to match, then it will find the original kernel modules. If not set to match, then you’ll need to also install all kernel modules in the new location for that version.

I can try that with the kernel, as it is in /boot, but what about the device tree? I can’t seem to find the dtb after compiling.

If you did not build the “dtbs” target, then there won’t be any device tree built. Make targets of “Image” builds a kernel, targets of “modules” builds modules, and the target “dtbs” builds device tree.

The extlinux.conf has an optional “FDT” key/value pair to name a device tree as well. You don’t have to flash to install this unless you have burned fuses. It is just a file copy into “/boot” if you do it the simple way. Just leave any old file name installed and use a new name for the test version, then point an “FDT /boot/something.dtb” line into the extlinux.conf for that boot entry.

Note that if you know what you want changed, and you know the file in “/boot” which is used now (if one is used from there), then it is sometimes easier to reverse compile what is there, edit that, then recompile to a new name (versus building from a kernel source tree).