Skip to content

Commit

Permalink
Add example for applying kernel patches
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostbuster91 committed Oct 22, 2023
1 parent eea30cc commit 1e19d4d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions router2023/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ Before we even begin to attempt installing our beloved operating system on the d

What does that it mean to be supported?

The kernel needs to know what kind of hardware components are available to it. This is information is provided by so called device-tree.
The device-tree is a tree of descriptions of every device supported by linux kernel, and it lives in the linux repository.
The kernel needs to know what kind of hardware components are available to it. This information is provided by so called device-tree.
The device-tree is a tree of descriptions of every device supported by linux kernel.
In our case bpir3 is a device and there should be a device-tree entry for it. This entry will then list all its components together with their physical
addresses and drivers that are required to communicate with them.

Expand Down Expand Up @@ -297,6 +297,19 @@ The `bpir3_kernel.config` contains configuration for building the kernel specify
How the `bpir3_kernel.config` file was created is still a mystery for me, because even if some template config file can be generated you still
need to know what most of the kernel modules are for in order to select correct subset of them.

While it wasn't necessary for booting NixOS on this board, I realized that it would be a pity not to mention here how one can apply kernel patches.
In general, patching things in Nix is a daily routine. It is quite common that you will need to patch the source code of a project in order to make it compatible with Nix.
Below is an example of creating a kernel based on the 6.4 mainline version with an applied mtk-pcie patch.

```nix
patched_kernel = linux_6_4.override {
kernelPatches = [{
name = "PCI: mediatek-gen3: handle PERST after reset";
patch = ./linux-mtk-pcie.patch;
}];
};
```

## NixOS image

With kernel configured we can finally build the `rootfs` image:
Expand Down

0 comments on commit 1e19d4d

Please sign in to comment.