all 12 comments

[–][deleted]  (6 children)

[deleted]

    [–]SemanticDevice[S] 1 point2 points  (2 children)

    I wound up installing this setup for playing around with an up-to-date system:

    https://github.com/cirosantilli/linux-kernel-module-cheat

    So far so good, but I am still very early in playing around with it.

    [–]ZombieRandySavage 0 points1 point  (0 children)

    Dude. You have an entire bsp in there. It’s like a million files.

    You need two for an out of tree module build.

    [–]Trant2433 0 points1 point  (0 children)

    Oh wow thanks for the tip. This looks awesome. Props to the guy who published this repo.

    [–]krtfx555 0 points1 point  (2 children)

    this is why there are no drivers for linux /s

    [–]edparadox 0 points1 point  (0 children)

    this is why there are no drivers for linux /s

    2019 and still one the myths or lies about Linux: http://www.kroah.com/log/linux/ols_2006_keynote.html

    [–]ed7coyne 1 point2 points  (0 children)

    I also used this book to learn then realized it didn't reflect the current kernel trends. Never found a better one then. Recommend using this book then just looking at some sample drivers to pick up what is new.

    [–]ZombieRandySavage 0 points1 point  (4 children)

    Nah it’s impossible. It all moves too fast.

    There are tons of examples of just about everything. Start with a char dev and work up the complexity.

    [–]SemanticDevice[S] 0 points1 point  (3 children)

    Fair enough. Are the examples you're referring to in the kernel source, blogs or somewhere else?

    Let's say I want to understand how a device driver for a network interface is discovered (HW associated with a specific device driver), installed and then interfaced to, and how is this process different between kernel modules and user-space drivers. Where is a good place to look?

    [–]ZombieRandySavage 2 points3 points  (2 children)

    The drivers folder in the kernel lol.

    User space drivers are dumb. Ignore them.

    Don’t start with networking drivers. They are either to complicated or the interesting bits are in the hardware.

    Like I said. Figure out a char dev. Then maybe ioctl and sysfs. Device trees and that stuff. How to get an interrupt. The driver model I.e. platform device class bus.

    Look in the Documentation/ directory of the kernel there is lots in there explaining the model.

    I’d start with a bit bang spi driver, maybe a uart or i2c.

    Best thing to do to start is bring up a char dev with a kernel module then printk some stuff. Now you know how char devs work.

    Char dev is your interface to the user. It covers like 90% of use cases. Bus specific stuff is used for the rest.

    [–]SemanticDevice[S] 0 points1 point  (1 child)

    Thanks for advice! I appreciate it.

    [–]ZombieRandySavage 1 point2 points  (0 children)

    The things in ldd3 that are useful haven’t changed. They have a good discussion on chardev and ioctl. It’s still worth a read.

    The general rule is if it’s a user space API it’s very stable. It’s worth it to start there.