User Tools

Site Tools



Compiling own kernels from L4T sources

I can compile and run the kernel with the patches from June 2018 on the Fedora30 userland, but it has many issues: compiling with '-j5' leads to resets, just '-j1' works. Also no sound output. So here I try to recompile L4T kernels.

Note: With the steps below I get a compiled kernel and dts, but I can not boot these, and did not succeed to debug further what fails, as I do not get any output on the internal or HDMI connected screen when booting the self compiled kernel.

This is based on this post. Recompiling the L4T kernel from a running L4T 1.3.1. Also install updates, the gcc updates are required - attempts to recompile with the plain gcc from the L4T image fails.

mkdir -p ~/buildkernel
cd ~/buildkernel

#Download Nvidia Bits
echo "Downloading All Required Files, This may take a while..... Please Wait"
wget -O "linux-nvgpu-r32.1.tar.gz" \
  ";a=snapshot;h=tegra-l4t-r32.1;sf=tgz" > /dev/null
wget -O "soc-tegra-rel-30-r2.tar.gz" \
  ";a=snapshot;h=rel-30-r2;sf=tgz" > /dev/null
wget -O "soc-tegra-t210-rel-30-r2.tar.gz" \
  ";a=snapshot;h=rel-30-r2;sf=tgz" > /dev/null
wget -O "platform-tegra-common-rel-30-r2.tar.gz" \
  ";a=snapshot;h=rel-30-r2;sf=tgz" > /dev/null
wget -O "platform-tegra-t210-common-rel-30-r2.tar.gz" \
  ";a=snapshot;h=rel-30-r2;sf=tgz" > /dev/null

#Clone Switchroot Bits
git clone "" > /dev/null
git clone "" > /dev/null
git clone "" > /dev/null

#Move Switchroot bits

# Handle Standard Kernel Bits
mkdir -p $KERNEL_DIR
mv ./l4t-kernel-4.9/* $KERNEL_DIR
rm -rf ./l4t-kernel-4.9

# Handle Nvidia Kernel bits
mkdir -p ./kernel/nvidia
mv ./l4t-kernel-nvidia*/* ./kernel/nvidia
rm -rf ./l4t-kernel-nvidia*

# Handle Switchroot DTS files
mkdir -p ./kernel/hardware/nvidia/platform/t210/switch
mv ./l4t-platform-t210-switch*/* ./kernel/hardware/nvidia/platform/t210/switch/
rm -rf ./l4t-platform-t210-switch*

# Extract and place nvidia bits
mkdir -p ./kernel/nvgpu
mkdir linux-nvgpu
tar -xf "./linux-nvgpu-r32.1.tar.gz" -C linux-nvgpu --strip 1
mv ./linux-nvgpu/* ./kernel/nvgpu
rm -r linux-nvgpu ./linux-nvgpu-r32.1.tar.gz

# Extracting Tegra SOC Data
mkdir -p ./kernel/hardware/nvidia/soc/tegra/ soc-tegra
tar -xf "./soc-tegra-rel-30-r2.tar.gz" -C soc-tegra --strip 1
mv ./soc-tegra/* ./kernel/hardware/nvidia/soc/tegra/
rm -r soc-tegra soc-tegra-rel-30-r2.tar.gz

# Extracting T210 SOC Data
mkdir -p ./kernel/hardware/nvidia/soc/t210/ soc-tegra-t210
tar -xf "soc-tegra-t210-rel-30-r2.tar.gz" -C soc-tegra-t210 --strip 1
mv ./soc-tegra-t210/* ./kernel/hardware/nvidia/soc/t210/
rm -r soc-tegra-t210 soc-tegra-t210-rel-30-r2.tar.gz

# Extracting Tegra Common Platform Data
mkdir -p ./kernel/hardware/nvidia/platform/tegra/common/ platform-tegra-common
tar -xf "platform-tegra-common-rel-30-r2.tar.gz" -C platform-tegra-common --strip 1
mv ./platform-tegra-common/* ./kernel/hardware/nvidia/platform/tegra/common/
rm -r platform-tegra-common platform-tegra-common-rel-30-r2.tar.gz

# Extracting T210 Common Platform Data
mkdir -p ./kernel/hardware/nvidia/platform/t210/common/ common-t210
tar -xf "platform-tegra-t210-common-rel-30-r2.tar.gz" -C common-t210 --strip 1
mv ./common-t210/* ./kernel/hardware/nvidia/platform/t210/common/
rm -r common-t210 platform-tegra-t210-common-rel-30-r2.tar.gz

# Preparing Source and Creating Defconfig
cd ./kernel/kernel-4.9
# This command fails, because it is missing .config, but is
# needed to create the defconfig which becomes .config.... Not sure why.
make prepare
make t210_switch_defconfig
make prepare
make modules_prepare

# To change settings: 
make menuconfig

# compile kernel
make -j5 tegra-dtstree="../hardware/nvidia/"
# install modules type
make modules_install

# also, additional files required.

# To install, these files are needed, i.e. in /boot
cp arch/arm64/boot/Image.gz /boot/l4t-ubuntu/Image
cp arch/arm64/boot/dts/tegra210-icosa.dtb /boot/l4t-ubuntu/tegra210-icosa.dtb
  • The build fails here:
make[1]: *** No rule to make target '/lib/firmware/brcm/BCM4356A3.hcd', needed by 'firmware/brcm/BCM4356A3.hcd.gen.o'.  Stop.
Makefile:1025: recipe for target 'firmware' failed
make: *** [firmware] Error 2

booting kernels via usb

The normal L4T kernel can via usb be booted as follows. The partition which the initrd should jump into is set in file switch.scr . After changing the file, 'mkimage' from coreboot has to be used to compile a new switch.scr.img which is then used for booting. This output is from the x86_64 system which is supplying the kernel to the switch.

[root@電脳 usb_loader_l4tkernel]# cat imx_usb.conf
#vid:pid, config_file
0x0955:0x701a, switch.conf
[root@電脳 usb_loader_l4tkernel]# 

[root@電脳 usb_loader_l4tkernel]# cat switch.conf 
Image:load 0x83000000
tegra210-icosa.dtb:load 0x8d000000
initramfs:load 0x92000000
switch.scr.img:load 0x8e000000,jump_direct 0x8e000000
[root@電脳 usb_loader_l4tkernel]# 

[root@電脳 usb_loader_l4tkernel]# cat switch.scr
# mkimage -A arm64 -T script -C none -n "boot.scr" -d switch.scr switch.scr.img
load mmc 1:1 0x83000000 Image
load mmc 1:1 0x8d000000 tegra210-icosa.dtb
load mmc 1:1 0x92000000 initramfs
setenv bootargs 'root=/dev/mmcblk0p2 rw rootwait relative_sleep_states=1 access=m2  console=tty0 firmware_class.path=/lib/firmware/ fbcon=primary:1'
usb reset
booti 0x83000000 0x92000000 0x8d000000
[root@電脳 usb_loader_l4tkernel]# 

# this is my shellscript which will
# - supply coreboot to the switch
# - copy a raw switch.scr.3 file (same as above, but instructing
#   to boot /dev/mmcblk0p3
# - run 'mkimage' from coreboot to compile switch.scr.img
# - and then supply kernel, initrd, dtb-file and switch.scr.img
#   as specified in switch.conf
[root@電脳 usb_loader_l4tkernel]# 
software/switch/l4t-kernel-compile.txt · Last modified: 2019/07/03 14:02 by chris