Adding to KERNEL_OVERLAYS

Using tegra-l4t-r32.3.1

I would like to add custom code to the kernel without modifying the code maintained by nvidia. This seems to be accomplished by the “KERNEL_OVERLAYS” variable in $(SOURCEDIR)/kernel/kernel-4.9/Makefile:

ifeq ($(KERNEL_OVERLAYS),)
KERNEL_OVERLAYS :=
KERNEL_OVERLAYS += $(CURDIR)/../nvidia
KERNEL_OVERLAYS += $(CURDIR)/../nvgpu
KERNEL_OVERLAYS += $(CURDIR)/../nvgpu-next
KERNEL_OVERLAYS += $(CURDIR)/../nvidia-t23x
else
override KERNEL_OVERLAYS := $(subst :, ,$(KERNEL_OVERLAYS))
endif
override KERNEL_OVERLAYS := $(abspath $(KERNEL_OVERLAYS))
export KERNEL_OVERLAYS

By default this defines the locations of the kernel/nvidia and kernel/nvgpu source directories that are in their own git repositories alongside kernel-4.9.

From the above it looks like KERNEL_OVERLAYS is able to be passed into make as a string of variables separated by ‘:’ to be turned into a list with subst and processed with foreach.

So I tried that:

KERNEL_OVERLAYS="$SOURCEDIR/kernel/nvidia:$SOURCEDIR/kernel/nvgpu:$SOURCEDIR/kernel/nova"

make -C $SOURCEDIR/kernel/kernel-4.9 \
    KERNEL_OVERLAYS=$KERNEL_OVERLAYS \
    CROSS_COMPILE=/opt/linaro/bin/aarch64-linux-gnu- \
    O=$SOURCEDIR/compiled \
    ARCH=arm64 \
    tegra_defconfig

But the make fails with some arcane error about not being able to find one of the Kconfigs in kernel/nvidia.

configuring for tx2
make: Entering directory '/home/ww/l4t/sources/kernel/kernel-4.9'
before processing KERNEL_OVERLAYS is /home/ww/l4t/sources/kernel/nvidia:/home/ww/l4t/sources/kernel/nvgpu:/home/ww/l4t/sources/kernel/nova
after processing KERNEL_OVERLAYS is /home/ww/l4t/sources/kernel/nvidia /home/ww/l4t/sources/kernel/nvgpu /home/ww/l4t/sources/kernel/nova
make[1]: Entering directory '/home/ww/l4t/sources/compiled-tx2'
before processing KERNEL_OVERLAYS is /home/ww/l4t/sources/kernel/nvidia:/home/ww/l4t/sources/kernel/nvgpu:/home/ww/l4t/sources/kernel/nova
after processing KERNEL_OVERLAYS is /home/ww/l4t/sources/kernel/nvidia /home/ww/l4t/sources/kernel/nvgpu /home/ww/l4t/sources/kernel/nova
  GEN     ./Makefile
drivers/net/ethernet/nvidia/Kconfig:30: can't open file "drivers/net/ethernet/nvidia/eqos/Kconfig"
/home/ww/l4t/sources/kernel/kernel-4.9/scripts/kconfig/Makefile:113: recipe for target 'tegra_defconfig' failed
make[2]: *** [tegra_defconfig] Error 1
/home/ww/l4t/sources/kernel/kernel-4.9/Makefile:569: recipe for target 'tegra_defconfig' failed
make[1]: *** [tegra_defconfig] Error 2
make[1]: Leaving directory '/home/ww/l4t/sources/compiled-tx2'
Makefile:175: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2
make: Leaving directory '/home/ww/l4t/sources/kernel/kernel-4.9'

I tried printing out the value of KERNEL_OVERRIDES before and after that block:

Passing KERNEL_OVERLAYS (fails)

before processing KERNEL_OVERLAYS is /home/ww/l4t/sources/kernel/nvidia:/home/ww/l4t/sources/kernel/nvgpu:/home/ww/l4t/sources/kernel/nova
after processing KERNEL_OVERLAYS is /home/ww/l4t/sources/kernel/nvidia /home/ww/l4t/sources/kernel/nvgpu /home/ww/l4t/sources/kernel/nova

Not passing KERNEL_OVERLAYS (passes)

before processing KERNEL_OVERLAYS is 
after processing KERNEL_OVERLAYS is /home/ww/l4t/sources/kernel/nvidia /home/ww/l4t/sources/kernel/nvgpu /home/ww/l4t/sources/kernel/nvgpu-next /home/ww/l4t/sources/kernel/nvidia-t23x

The result seems to be the same to me. Is there something I’m done wrong?

Thanks!

I should mention that if I hardcode my directory it works. But I do not want to modify the kernel-4.9 directory.

ifeq ($(KERNEL_OVERLAYS),)
KERNEL_OVERLAYS :=
KERNEL_OVERLAYS += $(CURDIR)/../nvidia
KERNEL_OVERLAYS += $(CURDIR)/../nvgpu
<b>KERNEL_OVERLAYS += $(CURDIR)/../nova</b>
else
override KERNEL_OVERLAYS := $(subst :, ,$(KERNEL_OVERLAYS))
endif
override KERNEL_OVERLAYS := $(abspath $(KERNEL_OVERLAYS))
export KERNEL_OVERLAYS

Figured it out, I had to export the variable rather than passing it into make directly:

export KERNEL_OVERLAYS=$SOURCEDIR/kernel/nvidia:$SOURCEDIR/kernel/nvgpu:$SOURCEDIR/kernel/nova

make -C $SOURCEDIR/kernel/kernel-4.9 \
    CROSS_COMPILE=/opt/linaro/bin/aarch64-linux-gnu- \
    O=$SOURCEDIR/compiled \
    ARCH=arm64 \
    tegra_defconfig
1 Like