Write patches for LEDE

This howto will get your through a LEDE to create your own kernel patch using the LEDE infrastructure. It's based on LEDE reboot-1279-gc769c1b.

LEDE has already a lot of patches. They are all applied on one tree. We will create a new patch for lantiq. To get started, let see how LEDE organize the patches. First of all we take a look on /target/linux/*

All of these folders represent a architecture target, except generic. The generic target is used by all targets.

To continue, we need to know which kernel version your target architecture is running on. This is written down into target/linux/lantiq/Makefile.

We're running a 4.4.Y kernel. The Y is written down into /include/kernel-version.mk. We will use .15.

Ok. Now let's see. When LEDE is preparing the kernel build directory, it search for a matching patch directory.

  1. download the kernel 4.4.x (x from /include/kernel-version.mk)
  2. unpack the kernel under /build_dir/target-../linux-lantiq/linux-4.4.15
  3. apply generic patches
  4. apply lantiq patches
  5. create .config

But which is the right patches directory? It use the following make snippet from /include/kernel.mk

Meaning it will use /patches-4.4 if exists or if not try to use /patches.

Now we know how patches are applied to the linux kernel tree. We could go into the directory, create a new patches directory and use quilt...

Or we use the quilt target for that.

make target/linux/clean -> to clean up the old directory. Now make target/linux/prepare QUILT=1 will unpack the source, copy all present patches into ./patches and use quilt to apply.

With quilt you can move forwards and backwards between patches, aswell as modifying those. cd ./build_dir/target-mips_34kc+dsp_uClibc-0.9.33.2/linux-lantiq/linux-4.5.15/ to switch into the linux directory.

  1. quilt push -a to apply all patches from LEDE.
  2. quilt new platform/999-mymodification.patch to add a new patch
  3. quilt add net/l2tp/l2tp_core.c to track this file.
  4. Call your editor to modify this file.
  5. With quilt refresh it adds your modifcation to the patch platform/999-mymodification.patch.

Your modification is under ./build_dir/../linux-4.4.15/patches/platform/. With make target/linux/refresh it will refresh all patches and copy them to the correct folder under target/linux/*/patches.

social