I don't have knowledge about writing Linux kernel modules / drivers.

Let's take a basic example. I have an input device of my own which is connected to a microcontroller on one of the interrupt pins. I know that when I press a button on my device it causes a hardware interrupt to occur in the microntroller.

As a bare metal developer, I would put my interrupt handler code at an address where the interrupt vector for that particular interrupt would jump to when it occurs.

Now if we have a Linux Kernel running on the microcontroller and I wish to write a Kernel driver for my input device, how would I know exactly where to register my interrupt handlers via the Kernel?

Would I still need to know everything about the hardware, addresses etc. ? How do I know which interrupt line in the kernel is associated with the exact pin which I connect my input device to?

1 Answer 1


Whatever the device, whatever the OS, the starting point is : How is your device connected to the system. (Plugged into a PCI bus slot ? plugged into some USB port ? hardwired on some motherboard SMBus ?…)

Provided that interface is not too exotic, that your device is strictly conformant with the interface specifications, that you do not want to re-invent the wheel, there are good chances that the craziest part of the job (the closest to the hardware) is already written into the linux kernel and all you need first is to select the appropriate API.

Start with a global overview on Linux APIs made available to drivers' devs then tell us more regarding the choices you made or about your interface.

Regarding a microcontroller, I would expect it on an SMBus.

  • Thanks for the reply. My question is more hypothetical than anything. I don't actually have the "input device", but lets just say that it connects to a GPIO pin on the MCU and a logic low triggers an interrupt. How do I know what kernel interrupt is mapped to that specific pin? Now let's say the MCU is changed later to something completely different and the Linux kernel runs on it, will my interrupt handler registration be different, or would I be still abstracted from the low-level stuff? Jun 3 at 18:06
  • @Engineer999 : I do acknowledge the hypothetical aspect of your question and even more than… I am not aware of any microcontroller capable of running the Linux kernel on its own. (cont)
    – MC68020
    Jun 4 at 12:31
  • @Engineer999 : The soonest I can see this possible will almost certainly be a chip embedding whatever already supported arch core (running the kernel), whatever supported SMBus and the microcontroller itself which pins could be made available to the outside through whatever conventional parallel port. In which case, you could refer to my general answer building whatever I2C device driver (with all local (CPU<>Microcontroller) hardware knowledge abstracted.) (cont)
    – MC68020
    Jun 4 at 12:32
  • @Engineer999 : In this context, regarding your microcontroller local interrupts (not handled by the conventional core), you would still need the full knowledge of the microcontroller hardware (including local interrupts & wiring to external port) in order to design your driver.
    – MC68020
    Jun 4 at 12:37
  • "I am not aware of any microcontroller capable of running the Linux kernel on its own.".. I don't understand this sorry Jun 4 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.