Building custom toolchain for cross compiling

I need newer version of gcc to compile my code. How do I create my own toolchain to do this? I’ve been looking at this guide but the kernel used on the nano is not listed there. Hence, I am unsure of how to run make install_headers.

Have a check below link, current only support Linaro 7.3.1 2018.05 toolchain.

I followed the link through to the download page to try get the kernel sources. However, when I run cat /etc/nv_tegra_release I get:

# R32 (release), REVISION: 5.1, GCID: 27362550, BOARD: t210ref, EABI: aarch64, DATE: Wed May 19 18:07:59 UTC 2021

I believe this means I am running l4t version 32.5.1. The latest version on the Jetson Download Center | NVIDIA Developer is 32.3.1.

How do I get the kernel sources for the version of l4t I am running?

In general, go here to find your L4T release:

Then go to the specific release (in your case R32.5.1):

Under “SOURCES” for the Nano, “L4T Driver Package (BSP) Sources”:

Within this there is this directory:

Within that directory is another package, “ kenrel_src.tbz2 ”. Unpacking that package provides both in-tree and out-of-tree content.