Live data from Hacker News

Easylkb: Easy Linux Kernel Builder

tmpout.sh

11–20 of 29 posts

Re: Easylkb: Easy Linux Kernel Builder

#11
post #6
post #4

Earlier quoted context omitted.

I just want to learn. Unfortunately those days with simple source commentary long gone. Hence whilst we have this good tutorial about setup … but how you start to learn more about.

Considering and size and complexity of the Linux kernel, I don't think any amount of source code comments would help you much, unless you already have a strong understanding of the underlying subsystem you want to hack on. "Understanding the Linux kernel", and "Linux device drivers" are pretty good, pragmatic books IMHO to give you a solid understanding of most useful subsystem. As for this kernel building script, I…

> unless you're hacking very frequently I never found the actual build of the kernel to be the more cumbersome part

Doesn't kernel use incremental builds? All well-designed C projects that I know of compile .c files into .o files and link them, so a single file modification only requires a single recompilation/relinking.

Re: Easylkb: Easy Linux Kernel Builder

#12
post #3

I found the NixOS wiki[1] to have a fairly decent guide on how to hack on a kernel. The process there isn't nearly as concise as it is here though :) [1]: https://nixos.wiki/wiki/Linux_kernel

I personally wen't this route last year and eventually got things working (networking etc. OK with only the kernel). My company then took a direction in which each compute node has its custom kernel, so that we can control the initial stages of boot better (initrd is dynamically downloaded from intranet, given that the network drivers are baked-in) to manage heterogeneous nodes with different "roles" (GPUs, add-on devices, etc.).

Something I have been surprised about is how much functionality exists in the Linux kernel and how much more reliable the modules are compared to many user-space tools (e.g. race-conditions).

Re: Easylkb: Easy Linux Kernel Builder

#13
post #6

Earlier quoted context omitted.

Considering and size and complexity of the Linux kernel, I don't think any amount of source code comments would help you much, unless you already have a strong understanding of the underlying subsystem you want to hack on. "Understanding the Linux kernel", and "Linux device drivers" are pretty good, pragmatic books IMHO to give you a solid understanding of most useful subsystem. As for this kernel building script, I…

> unless you're hacking very frequently I never found the actual build of the kernel to be the more cumbersome part Doesn't kernel use incremental builds? All well-designed C projects that I know of compile .c files into .o files and link them, so a single file modification only requires a single recompilation/relinking.

It does use incremental builds so long as you don't reset everything.

I'm not sure that a lot of people who don't work with make realize that it's smart enough to only rebuild what has changed, and that it's not just a command runner!

Re: Easylkb: Easy Linux Kernel Builder

#14

Mind. Officially. Blown. Sometimes the coincidental timeliness of things popping up on Hacker News is just weird. u ROCK deepseagirl! I've recently wanted to start building Linux kernels and play with device drivers again. Wanted to build and then execute on top of QEMU. Downloaded, configured, and built Linux kernel 6.6 following recipes from arch and a few other places. Doing a reasonable .config was a painful proc…

In the kernel source directory do:

    make help | less
and the various config targets are listed; to use the default configuration (for the current host architecture) do:

    make defconfig
To edit it further use one of the edit options such as menuconfig:

   make menuconfig
All of these create/operate on ./.config in the source-code 'root' directory.

This and much more is covered in

https://kernelnewbies.org/KernelBuild

Re: Easylkb: Easy Linux Kernel Builder

#15
post #14

Mind. Officially. Blown. Sometimes the coincidental timeliness of things popping up on Hacker News is just weird. u ROCK deepseagirl! I've recently wanted to start building Linux kernels and play with device drivers again. Wanted to build and then execute on top of QEMU. Downloaded, configured, and built Linux kernel 6.6 following recipes from arch and a few other places. Doing a reasonable .config was a painful proc…

In the kernel source directory do: make help | less and the various config targets are listed; to use the default configuration (for the current host architecture) do: make defconfig To edit it further use one of the edit options such as menuconfig: make menuconfig All of these create/operate on ./.config in the source-code 'root' directory. This and much more is covered in https://kernelnewbies.org/KernelBuild

Another useful tip is to grab an existing config, eg. the one for your current system found under /boot, rename it .config and then do 'make olddefconfig' (followed by building the kernel in the usual way).

Distro kernels are normally quite "full fat" so this may tend to build a lot, but it's a good way to get a kernel which closely matches what you're typically running, both in terms of device coverage and compilation options / hardening.

Re: Easylkb: Easy Linux Kernel Builder

#17

Mind. Officially. Blown. Sometimes the coincidental timeliness of things popping up on Hacker News is just weird. u ROCK deepseagirl! I've recently wanted to start building Linux kernels and play with device drivers again. Wanted to build and then execute on top of QEMU. Downloaded, configured, and built Linux kernel 6.6 following recipes from arch and a few other places. Doing a reasonable .config was a painful proc…

Greatly appreciate the suggestions and pointers! (Not sure how HN orders "reply's", but this is in response to other replys to my initial comment.)

Re: Easylkb: Easy Linux Kernel Builder

#18
Ooooh this is very cute.

I'm toying with building a little OS using the Linux kernel and an all-Go userspace, and one of the goals is to make the entire system as easy to cross-compile (both host OS and host/guest CPU arch) as possible. Linux being non-trivial to compile (let alone cross-compile) has been so far quite a nuissance, so I'll definitely be having a closer look at this.

Re: Easylkb: Easy Linux Kernel Builder

#19
post #18

Ooooh this is very cute. I'm toying with building a little OS using the Linux kernel and an all-Go userspace, and one of the goals is to make the entire system as easy to cross-compile (both host OS and host/guest CPU arch) as possible. Linux being non-trivial to compile (let alone cross-compile) has been so far quite a nuissance, so I'll definitely be having a closer look at this.

cross compilation equally non-trivial. set CROSS_COMPILE= and ARCH= and making the appropriate changes to .config (either set ARCH and `make defconfig`, or modify the relevant parts in `make menuconfig`). then build as usual

Re: Easylkb: Easy Linux Kernel Builder

#20
post #18

Ooooh this is very cute. I'm toying with building a little OS using the Linux kernel and an all-Go userspace, and one of the goals is to make the entire system as easy to cross-compile (both host OS and host/guest CPU arch) as possible. Linux being non-trivial to compile (let alone cross-compile) has been so far quite a nuissance, so I'll definitely be having a closer look at this.

The idea there sounds a lot like https://gokrazy.org/, which builds a minimal go userland, wrapping one or more user provided go applications, and bundles in a linux kernel.

Targets mostly at single board computers, and I think it downloads pre-built kernels (and bootloaters if needed), rather than trying to build them directly, since getting a working cross compilation toolchain set up and plumbed into the kernel compilation process is still a pain.

I've personally only used yocto/open-embedded for that which does nicely handle building the cross-compilation toolchain, kernel image, and modules. But it is kinda overkill for that task, being designed to build a whole userland too.

Post reply on HN