Linux – Removes statically compiled device driver modules

Removes statically compiled device driver modules… here is a solution to the problem.

Removes statically compiled device driver modules

I statically compiled the linux kernel, i.e. obj-y, with serial device drivers.

Now I’m working on a simple serial driver, and I want to test it, but since the module is loaded at kernel startup, the IO port area (0x3f8 and later) is registered with the serial module. I need to remove (unregister) it so I can assign it to my driver.

So, is there any way to remove statically linked device drivers? Or should I recompile the whole kernel :/

Solution

You should recompile the entire kernel and make this driver an obj-m.

After loading (autocomplete via modprobe or manually using insmod), you can delete it (using rmmod), modify the code, compile again, and load again.

Of course, if there are some critical errors while the driver is running that are not handled properly, the entire kernel will be in an unstable state and you will have to restart (until you fix what caused this problem).

Related Problems and Solutions