Simplified Steps for Building a Loadable module on -CURRENT

David Christensen davidch at broadcom.com
Wed Aug 30 23:36:57 UTC 2006


> > I've been able to successfully build drivers in the past as
> > loadable modules but I'm getting some kernel panics with -CURRENT
> > when installing a module using kldload now where things used to
> > work before.
> 
> You did nuke /usr/obj, performed a full kernel build (cd /usr/src;  
> make buildkernel installkernel), and the module in question that was  
> installed alongside your new kernel is *not* panicking the system?

Yes

> 
> Then what's the panic message, and how exactly are you building your  
> module?
> 

The message wasn't readable on the serial console.  The text was jumbled
and I could only make out bits and pieces of it.

> > Assume I'm a complete FreeBSD noob for a moment
> > (which really isn't that far from the truth) and I want to build
> > a driver as a loadable module for testing.  After moving to
> > the appropriate directory in the source tree (/usr/src/sys/dev/XXX),
> > what steps do I need to follow to build the driver as a module?
> 
> That would be /usr/src/sys/modules/<modulename>
> 
> So far, just running make there has worked for me just fine.
> 

Ah, there's the simple piece I was missing!  I had previously
created my own Makefile and placed it in the /usr/src/sys/dev/XXX
directory.

> > Assume for the moment that I have already commented the driver out
> > of my kernel configuration file
> > (/usr/src/sys/<architecture>/conf/GENERIC)
> > and rebuilt and installed that kernel.
> 
> If the driver has been compiled into the kernel, kldload will error  
> out with EEXISTS. If the system panics, you should provide specifics.
> 

So I should do the following:

1) Comment out the driver I want to test in the kernel configuration
file.
   For example, modify /usr/src/sys/amd64/conf/MYCONFIG.
2) Rebuild and install the kernel (cd /usr/src; make kernel
KERNCONF=MYCONFIG)
3) Reboot the system to start using the new kernel
4) Edit the driver in /usr/src/sys/dev/XXX as necessary
5) Build the kernel module (cd /usr/src/sys/modules/XXX; make)
6) Load the kernel module (kldload ./if_XXX) and cross my fingers.



More information about the freebsd-current mailing list