Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Help in custom kernel config
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
kumarayush2104
n00b
n00b


Joined: 06 May 2020
Posts: 2
Location: India

PostPosted: Wed May 06, 2020 5:58 pm    Post subject: Help in custom kernel config Reply with quote

I want to shift from genkernel to manually configuration, is there any tool or script to automatically detect the hardware and modules for generating .config ??

thanks in advance :D
Back to top
View user's profile Send private message
Banana
Guru
Guru


Joined: 21 May 2004
Posts: 447
Location: Germany

PostPosted: Wed May 06, 2020 6:24 pm    Post subject: Reply with quote

Hello kumarayush2104,

there is just right now another fresh topic about this question: https://forums.gentoo.org/viewtopic-t-1112610-highlight-.html
_________________
My personal space
Back to top
View user's profile Send private message
dr_wulsen
Tux's lil' helper
Tux's lil' helper


Joined: 21 Aug 2013
Posts: 132
Location: Austria

PostPosted: Wed May 06, 2020 6:30 pm    Post subject: Reply with quote

hi kumarayush2104

I haven't heard of such magic tool, and have wished for it many times already.
What comes closest to this is: Boot a live CD/DVD/USB and issue
Code:
lspci -vknn
the -k will output the kernel driver in use,
Example for my network card:
    00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (2) I219-V
    DeviceName: Onboard - Ethernet
    Subsystem: ASRock Incorporation Ethernet Connection (2) I219-V
    Kernel driver in use: e1000e
In menuconfig, you can use the forward slash "/" to open a search box, if I search for e1000e it will result in
    Symbol: E1000E [=y]
    │ Type : tristate
    │ Prompt: Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support
    │ Location:
    │ -> Device Drivers
    │ -> Network device support (NETDEVICES [=y])
    │ -> Ethernet driver support (ETHERNET [=y])
    (1) -> Intel devices (NET_VENDOR_INTEL [=y])
    │ Defined at drivers/net/ethernet/intel/Kconfig:58
    │ Depends on: NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_INTEL [=y] && PCI [=y] && (!SPARC32 || BROKEN [=n])
    │ Selects: CRC32 [=y]
    │ Implies: PTP_1588_CLOCK [=n]


    │ Symbol: E1000E_HWTS [=y]
    │ Type : bool
    │ Prompt: Support HW cross-timestamp on PCH devices
    │ Location:
    │ -> Device Drivers
    │ -> Network device support (NETDEVICES [=y])
    │ -> Ethernet driver support (ETHERNET [=y])
    │ -> Intel devices (NET_VENDOR_INTEL [=y])
    (2) -> Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support (E1000E [=y])
    │ Defined at drivers/net/ethernet/intel/Kconfig:78
    │ Depends on: NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_INTEL [=y] && E1000E [=y] && X86 [=y]
The lines I put bold tell you that you can jump to the item directly by pressing the number shown there.
So if I press "1" I'll get directly to the network driver item the kernel currently uses for my card.
Should you not be taken directly there, chances are that some dependency is not fulfilled. See below example:
Depends on: NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_INTEL [=n] && PCI [=y] && (!SPARC32 || BROKEN [=n])
in which the menu for Intel network devices is not enabled, Then it will take you to the menu point "Intel devices" (NET_VENDOR_INTEL) which you will have to enable in order to acces the sub-menu which then listst the available intel drivers.

Syntax for dependencies is as usual:
! must NOT be enabled in order for the menu to show up; like: !CRAZY - being NOT crazy is quite useful.
|| OR; like: ( SANE || NEARLY SANE ) - one of them is enough, both will also do. No sanity at all wil not work.
&& AND; like: ( !CRAZY || SANE ) - being NOT crayz AND sane will work.

If you jump to an option using the search field and corresponding number, <Exit> will take you back to the previous screen. If you should hit exit once too much, you will exit the kernel configuration; better save your progress with <Yes> then.
Reverting back to where you were before is easy if you create a backup of /usr/src/linux/.config before you fiddle with the config.
And should your make whatever say: scripts/Kconfig.include:39: gold linker 'ld' not supported you will have to use make whatever LD="ld.bfd".
The kernel does not like the gold linker, if it's your default linker you need to tell make to use ld.bfd instead. (GNU LD)

I assume that there's a ton of guides about how to install the kernel and modules which is quite easy, so I'll leave you here for now.
Just keep a working kernel on /boot in parallel, it will save you a lot of time fixing things. I've always configured my kernels manually and ended up quite many times with non-booting or partially-booting ones, but that's a learning curve no one can evade.
_________________
There's no stupid questions, only stupid answers.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 45435
Location: 56N 3W

PostPosted: Wed May 06, 2020 6:51 pm    Post subject: Reply with quote

kumarayush2104,

Welcome.

I made this post in 2005. The method is still correct but the details have changed over the years.

More recently, Pappy produced kernel seeds. That site has not been maintained for several years but it expands greatly on my forum post.

The kernel has got bigger over the years too.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
kumarayush2104
n00b
n00b


Joined: 06 May 2020
Posts: 2
Location: India

PostPosted: Thu May 07, 2020 5:13 am    Post subject: Reply with quote

dr_wulsen wrote:
hi kumarayush2104

I haven't heard of such magic tool, and have wished for it many times already.
What comes closest to this is: Boot a live CD/DVD/USB and issue
Code:
lspci -vknn
the -k will output the kernel driver in use,
Example for my network card:
    00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (2) I219-V
    DeviceName: Onboard - Ethernet
    Subsystem: ASRock Incorporation Ethernet Connection (2) I219-V
    Kernel driver in use: e1000e
In menuconfig, you can use the forward slash "/" to open a search box, if I search for e1000e it will result in
    Symbol: E1000E [=y]
    │ Type : tristate
    │ Prompt: Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support
    │ Location:
    │ -> Device Drivers
    │ -> Network device support (NETDEVICES [=y])
    │ -> Ethernet driver support (ETHERNET [=y])
    (1) -> Intel devices (NET_VENDOR_INTEL [=y])
    │ Defined at drivers/net/ethernet/intel/Kconfig:58
    │ Depends on: NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_INTEL [=y] && PCI [=y] && (!SPARC32 || BROKEN [=n])
    │ Selects: CRC32 [=y]
    │ Implies: PTP_1588_CLOCK [=n]


    │ Symbol: E1000E_HWTS [=y]
    │ Type : bool
    │ Prompt: Support HW cross-timestamp on PCH devices
    │ Location:
    │ -> Device Drivers
    │ -> Network device support (NETDEVICES [=y])
    │ -> Ethernet driver support (ETHERNET [=y])
    │ -> Intel devices (NET_VENDOR_INTEL [=y])
    (2) -> Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support (E1000E [=y])
    │ Defined at drivers/net/ethernet/intel/Kconfig:78
    │ Depends on: NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_INTEL [=y] && E1000E [=y] && X86 [=y]
The lines I put bold tell you that you can jump to the item directly by pressing the number shown there.
So if I press "1" I'll get directly to the network driver item the kernel currently uses for my card.
Should you not be taken directly there, chances are that some dependency is not fulfilled. See below example:
Depends on: NETDEVICES [=y] && ETHERNET [=y] && NET_VENDOR_INTEL [=n] && PCI [=y] && (!SPARC32 || BROKEN [=n])
in which the menu for Intel network devices is not enabled, Then it will take you to the menu point "Intel devices" (NET_VENDOR_INTEL) which you will have to enable in order to acces the sub-menu which then listst the available intel drivers


Thanks it really helped me, one more question, if i enable only those stuffs which are showing up in lspci -kvnn and disable everything which are left, will my laptop work fine or do i need some extra configuration ??
Back to top
View user's profile Send private message
dr_wulsen
Tux's lil' helper
Tux's lil' helper


Joined: 21 Aug 2013
Posts: 132
Location: Austria

PostPosted: Thu May 07, 2020 7:06 am    Post subject: Reply with quote

Well, that depends on - things that are not installed in your Laptop, you don't need.
Things that are there and don't show up in the output could be essential.
So for a good measure, I'd start with the x86_64_defconfig and enable what I know I'll need, disable nothing and build the kernel.
Once it boots and I'm happy, I'll disable what I *know* I won't need. Drivers from von vendors that just arent present in my laptop.
Build, boot, continue to disable stuff I *guess* I don't need. At some point it will stop booting, then you will have gone too far.
A good point to start is gentoo-sources or ck-sources, as. they have a menupoint "Gentoo Linux" "OpenRC" and "Systemd", which will enable all that's definitely needed for those things to work. (If you use OpenRC, you don't have to enable the systemd-meta option of course).

Things will break, so keep a bootable copy of your kernel, configure your bootloader to boot both just fine (duplicate your current vmlinux for starters, name. it vmlinux-experimental or something like it), make sure you can boot from both kernel files and only then start replacing the experimental file with your freshly built kernel again and again until boot fails.
Then boot the original kernel and improve your kernel config, enabling what you just disabled and now guess you'll need, then try again.
Of course, disabling too much can lead to a booting, but terrible-performing system.
So many options take a lot of searching online, a lot of trial-and-error and a big pot of coffee.
_________________
There's no stupid questions, only stupid answers.
Back to top
View user's profile Send private message
Havin_it
Veteran
Veteran


Joined: 17 Jul 2005
Posts: 1187
Location: Edinburgh, UK

PostPosted: Thu May 07, 2020 10:14 am    Post subject: Reply with quote

I've been building gentoo-sources for something like 16yrs and still don't have a perfect answer for this, inasmuch as I'm never very sure I couldn't be doing it better or I'm not missing something. I just grew older and found bigger things to stress more about ;)

I guess one simple(ish) cheat that springs to mind, which I've used once on a new machine, is to fire up a liveCD/USB on it (systemrescuecd might be a good choice as it is Gentoo-based) and examine what modules are loaded using lsmod, then locate and enable those modules (or you can make them built-in) when doing your make menuconfig.

Actually think I might go and try this now on one of my existing machines, because I get that anxiety with every new kernel: Oh, what's this new sensor/LED/widget chip driver? Do I have one of those? How TF would I know, maybe I do and it just never was supported before now... (multiply by a couple dozen for every new kernel release these days). #OldManYellsAtCloud
Back to top
View user's profile Send private message
Goverp
l33t
l33t


Joined: 07 Mar 2007
Posts: 837

PostPosted: Thu May 07, 2020 12:15 pm    Post subject: Reply with quote

A further cheat: like Havin_it says, boot up some *up-to-date* USB linux, mount your system, change to /usr/src/linux, take a backup of .config (!) and run "make localmodconfig". Then you can play with diff, kdiff3, pencil and paper, whatever, and merge the bits to give you a new, slim kernel.
_________________
Greybeard
Back to top
View user's profile Send private message
Havin_it
Veteran
Veteran


Joined: 17 Jul 2005
Posts: 1187
Location: Edinburgh, UK

PostPosted: Thu May 07, 2020 12:38 pm    Post subject: Reply with quote

Ooooo I like that a lot, thanks! I'm havin' that :)
Back to top
View user's profile Send private message
dr_wulsen
Tux's lil' helper
Tux's lil' helper


Joined: 21 Aug 2013
Posts: 132
Location: Austria

PostPosted: Thu May 07, 2020 12:41 pm    Post subject: Reply with quote

I.'ll be on that too, FOMO in kernel drivers is a terrible thing.
thanks :)
_________________
There's no stupid questions, only stupid answers.
Back to top
View user's profile Send private message
Banana
Guru
Guru


Joined: 21 May 2004
Posts: 447
Location: Germany

PostPosted: Thu May 07, 2020 1:23 pm    Post subject: Reply with quote

Goverp wrote:
A further cheat: like Havin_it says, boot up some *up-to-date* USB linux, mount your system, change to /usr/src/linux, take a backup of .config (!) and run "make localmodconfig". Then you can play with diff, kdiff3, pencil and paper, whatever, and merge the bits to give you a new, slim kernel.

thats just to easy to be true ;-)
_________________
My personal space
Back to top
View user's profile Send private message
Goverp
l33t
l33t


Joined: 07 Mar 2007
Posts: 837

PostPosted: Thu May 07, 2020 4:11 pm    Post subject: Reply with quote

Banana wrote:
...
thats just to easy to be true ;-)
Of course, it is. As it puts everything into modules, if you need anything odd at startup requiring an initramfs, you'll have to either change a bunch of modules to being built into the kernel, or setup an initramfs configuration to make whichever modules you need to boot the system - video drivers, fancy disk access, etc. But at least you get a head start.
_________________
Greybeard
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 45435
Location: 56N 3W

PostPosted: Thu May 07, 2020 6:04 pm    Post subject: Reply with quote

kumarayush2104,

Its not that easy, no.

The kernel is written in a modular fashion, so that new pieces can be added with the minimum amount of work.
It goes together like the layers in a cake, so much so that a group of layers that works together is called a 'stack'

Lets look at the thing you need in your kernel to be able to boot.

First, the kernel needs to be able to control your hard drive. That one is easy, its the hard drive controller that lspci says you have.
That's the bottom layer of the cake.
Look in the kernel and all the different ones. They are uniquie in the hardware they work with but present a common interface to the layer above.
What the layer above is varies, often with the physical interface, so there is SATA, SCSI and others.
They tend to be menu item with the lower level drivers below them. That's a good thing as its not possible to select your hardware driver from the menu unless the menu is selected too.

Above this is the Scsi Disk layer. Almost all block devices use the SCSI protcol for commands and data, regardless of the actual physical interface.
Almost everyone needs this. There are several different sorts of devices at this level including Tape drives, Optical Drives (called CDROM in the kernel)

Above that is the SCSI layer. Its a menu item. Setting it off turns all of the above off, so don't do that.

Above that is the Block layer. You need that too.

That lets the kernel talk to your hard drive but that's not enough. It needs to know how to interpret the data if finds there.

Your hard drive is partitioned, the kernel needs to be able to understand the partition table. Be sure to include the drivers for the partition tables you are going to need.
After the kernel has read the partition table, it needs to be able to read the filesystems on the partition because the boot process will want to read files, so the kernel needs to know how to do that for your chosen filesystems.

This is just for your hard drive. The structure for everything else follows the same concepts.

One perl of wisdom. Make everything needed to boot built into the kernel. Then you don't need an initrd.
That keeps the complexity down.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Goverp
l33t
l33t


Joined: 07 Mar 2007
Posts: 837

PostPosted: Fri May 08, 2020 9:11 am    Post subject: Reply with quote

I forgot to mention that make localmodconfig only selects configuration for the modules in use, so when booting from a USB/CD linux, the modules in use will be (a) the ones for the hardware needed for the USB/CD device; and (b) the devices then attached to your computer. So if you have other devices you'd like supported, plug them in before using "make localmodconfig", as that (should) load any other modules needed for those devices.
_________________
Greybeard
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum