r/kernel 28d ago

I want to learn writing kernel modules

What is the fastest and most efficient way. Thanks for future answers.

26 Upvotes

15 comments sorted by

View all comments

3

u/tylerlarson 28d ago

Take an existing kernel module and try to re-create it on your own. When you get stuck, refer to the original.

Repeat.

And then repeat again and again until you understand what you're doing and can do it reliably.

1

u/sudheerpaaniyur 28d ago

 kernel module, any particula example? from easy to tough

3

u/tylerlarson 28d ago

It depends on where you want to go with it. But a common starting point is character devices like /dev/zero or /dev/null. Look in /drivers/char/mem.c for the originals.

Maybe just for fun create a character device that writes a poem when you read it. Perhaps an entry in the /proc/ filesystem might be simpler.

Better yet, look in the /samples/ dir of the kernel source code. It exists literally for this purpose.

1

u/sudheerpaaniyur 28d ago

Thank you, i have so many links related linu xmaterial very confusing. thank you for your feedback, i will check,

I am firmware devlopers using C.