Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing a device driver module that was statically compiled

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

Now I'm working on a simple serial driver and I want to test it, but since the module is loaded when the kernel boots up, the IO port regions (0x3f8 and onwards) are registered to the serial module. I need to remove(unregister) it so that I can allocate it to my driver.

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


1 Answers

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

Once it's loaded (either done automatically by modprobe or manually with insmod), you may remove it (using rmmod), modify the code, compile it again and load it again.

Of course, if there was some critical error that was not handled properly during the driver's operation, the whole kernel will be in an unstable state and you will have to reboot (until you fix what causes this).

like image 70
eepp Avatar answered Jan 29 '26 17:01

eepp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!