First, the preparatory work
1. Download the latest kernel on the website Source Code :
https://developer.nvidia.com/embedded/downloads#?tx= $software, L4T-TX1
2, ubuntu16.04 compilation environment preparation:
Download two cross compiler Aarch64-linux-gnu and ARM-LINUX-GNUEABIHF, both compilers are required for cross-compilation, and can be downloaded on Linaro website: https://www.linaro.org/downloads/
3, decompression kernel source code and cross-compiler in the appropriate location:
TAR-XVJF kernel_src.tbz2
Second, kernel compilation
1. Export Environment variables
$ Export Cross_compile=<crossbin>
$ Export CROSS32CC=<CROSS32BNI>GCC
$ Export arch=arm64
2. Compile kernel file Zimage
$ make Mrproper
$ make Tegra21_defconfig
$ make Zimage
3. Compile kernel device tree components:
$ make Dtbs
4. Compile kernel modules
$ make Modules
Under all normal circumstances, the compiled target file can be obtained under ~/kernel/arch/arm64/boot. But the normal situation is always very few, the general compilation process will encounter some problems, then summarize the problems I encountered in compiling and solutions, for reference only.
Third, the compilation encountered problems to solve
1. Compile error: Prompt missing compiler-gcc6.h file
This is because the compiler AARCH64-LINUX-GNU used is 6.2.1 version, that is, GCC6 series version, view TX1 ~/include/linux/, only gcc5 the following version of the file
This problem, download complier-gcc6.h on the internet to ~/kernel/include/linux/can solve the problem.
2. Compile error: R7 cannot be used in ASM here
This error online has a solution:
Https://tls.mbed.org/kb/development/arm-thumb-error-r7-cannot-be-used-in-asm-here
Https://developer.ridgerun.com/wiki/index.php?title=Compiling_Tegra_X1_source_code#Flashing_the_board
Not much to say, directly affixed to the Git-diff
Index:kernel_source/arch/arm64/kernel/vdso32/makefile
===================================================================
---kernel_source.orig/arch/arm64/kernel/vdso32/makefile 2016-04-08 21:28:52.651992663-0600
+ + + kernel_source/arch/arm64/kernel/vdso32/makefile 2016-04-11 12:20:03.377388110-0600
@@ -11,7 +11,7 @@
Gcov_profile: = n
-ccflags-y: =-shared-fpic-fno-common-fno-builtin-march=armv7-a
+ccflags-y: =-shared-fpic-fomit-frame-pointer-fno-common-fno-builtin-march=armv7-a
Ccflags-y + =-nostdlib-wl,-soname=linux-vdso32.so.1 \
$ (Call cc-ldoption,-wl$ (comma)--hash-style=sysv)
Asflags-y: =-d__vdso32__-S
3, the new compiler GCC6 encountered "-werror=misleading-indentation"
The reason behind the GCC website is that the compiler has added many new features.
Specific reference: https://gcc.gnu.org/gcc-6/porting_to.html
But the source of this kind of things, not recommended to change the code directly, so try to avoid. Use #pragma to circumvent and add the following code to the code snippet you need to protect
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-wmisleading-indentation" ("double quotes contain ignored errors")
/* (code for which the warning are to be disabled) */
#pragma GCC diagnostic POPs
Many of these similar problems are encountered during compilation and are modified as such.
4, make menuconfig hint: Unable to find the ncurses libraries ....
Workaround:
Sudo Apt-get Install Libncurses5-dev
Finish.