how to upgrade linux-headers-4.4.38-tegra to latest kernel and headers

My driver needs most recent linux-headers-generic and linux-image-generic, but the jetson tx2 has a customized linux kernel which does not have some header files.

I tried upgrade the kernel but failed, boot grub ignore the changes.

What should I do to upgrade the kernel and linux-header files?

Specifically, the issue was a source file was missing.
ls /usr/src/linux-headers-4.4.0-145-generic/arch/arm/include/asm/opcodes.h

The file is linked from /usr/src/linux-headers-4.4.0-145-generic/arch/arm64/include/asm/opcodes.h

cat /usr/src/linux-headers-4.4.0-145-generic/arch/arm64/include/asm/opcodes.h

#include <…/…/arm/include/asm/opcodes.h>

Which L4T release are you using? If you are building directly on the Jetson you will find it is best to install the full source from the kernel in question, but you have not stated which L4T version you are using. See “head -n 1 /etc/nv_tegra_release”. The setup for headers is less than ideal, but suggesting how to adjust isn’t possible without knowing which release you are using (the file you are looking for is available in the full source, and the full source can be dropped in to take over for the default headers and is complete…the original headers are not complete).

The L4T version is R27(release) REV 0.1,
head -n 1 /etc/nv_tegra_release

R27 (release), REVISION: 0.1, GCID: 8462615, BOARD: t186ref, EABI: aarch64, DATE: Thu Feb 9 02:14:58 UTC 2017

Should I install the full source from the kernel? Where is the full source that I can download and build, then install?

If you have ever flashed you will have a “Linux_for_Tegra/” subdirectory on your host PC. Within that is a script, “”. This script can be copied to the Jetson and run there to get the full source (including both in-tree and out-of-tree content). An example for R27.1 kernel download of TX2 is (incidentally, I would advise to upgrade to a far newer release unless you have a good reason to stay with the developer preview release):

./ -k tegra-l4t-r27.1

Note that if you look at this file it points to where headers are expected if doing out of tree builds against the current running kernel:

ls -l /lib/modules/$(uname -r)/build

This will point at “/usr/src/linux-headers-4.4.15-tegra/”. The content there is a cut down version of the full kernel source. You can point this at full source instead.

Since the headers are part of a package I would not recommend simply overwriting it. Instead I would suggest changing the symbolic link. There are a couple of extra subdirectories when adding full source, but here is an example:

sudo -s
cd /usr/src
cp /where/ever/it/is/ .
# EDIT: I forgot arguments to those in for R27.1:
./ <b>-k tegra-l4t-r271</b>
cd sources/kernel/kernel-4.4
cp /proc/config.gz .
gunzip config.gz
mv config .config
# Now edit ".config" to set CONFIG_LOCALVERSION to your system. Once edited the line should
# look like this:
# Now aim the symbolic link here:
rm /lib/modules/$(uname -r)/build
ln -s /lib/modules/$(uname -r)/build `pwd`
# Now prepare this to match and you are ready to build out of tree:
make modules_prepare

I did not just run this since I don’t have R27.1 installed on anything, but double check that this is pointing at the new source location where the “.config” is:

ls -l /lib/modules/$(uname -r)/build

Your original headers are still in place, and if you change the symbolic link to point at those again, then you are back to original setup.

Thanks, however I haven’t done the ‘flash’ yet.

I followed this page, and downloaded the nano developer kit onto a sd card.

System will not boot from this sd card.

I checked the following discussion, but still cannot boot from an sd card. I guess the ‘flash’ means booting from a sd_card instead of eMMC?

So, my question is:
How do I flash the tx2 and get the script?

This particular forum is for TX2 and so anything Nano-related might be different. The part about and headers will be exactly the same instructions across all platforms so long as you use the correct release (making sure headers are correct will have the same instructions regardless of which L4T release or which Jetson you are talking about). Nano’s currently start at R32.1, but R27.1 would otherwise be the same steps.

For R27.1 (TX2):

./ -k tegra-l4t-r27.1

For R32.1 (Nano or TX2 or Xavier):

./ -k tegra-l4t-r32.1

For questions on booting to an SD card you should probably start a new thread (in the TX2 or Nano forum, depending on which you are asking about…they are quite different).

However, when flashing don’t confuse the flash target for saying this is where content is placed. The target is where boot points to in order to find configuration. If it happens to be eMMC of a TX2, then this is also where rootfs is placed. In the case of a TX2 having named the SD card, then you still have to build your SD card content, although the pointer internal to the TX2 will no longer search eMMC for that content. Even so the non-rootfs content of a TX2 will remain on eMMC for boot stages prior to loading Linux (the content you would prepare for a TX2 SD card would be rootfs only, and would require correct SD “/boot” content).

The Nano has a very different mechanism since it has no eMMC (at least not the versions currently out). For the Nano everything goes on SD card, not just rootfs.

Note that it is no different to replace headers with the full source through the mechanism on the sample rootfs prior to flash than it is to do so on a booted Jetson. The changes can be put in place prior to flash and will exist immediately on first boot. You just have to know what the “uname -r” is and have a copy of what the initial “/proc/config.gz” will be to run the “make modules_prepare” step (the first time you boot you can save a pristine copy of this for the future, but probably need to flash once and boot once to get that first copy).