|
|
Testing and debugging a driver is an iterative process, but the general steps are listed below.
You should test the functionality of the driver as you write it. If you are changing code from another driver, it is useful to install and test the driver after you have modified the initialization routines and the I/O routines. This testing could involve writing a short program that only reads and writes to the device to ensure that you can get into the device. When all the routines for the driver are written, you should install the hardware and perform full functionality testing.
Many of the steps that follow require you to modify files and directories owned by root. You must therefore be logged in as root or execute with the appropriate privileges to develop and debug device drivers.
See ``Using crash and the kernel debuggers'' for more information.
If you get errors, run modadmin with the -U option to unload the driver (unless your kernel has been corrupted by the driver, in which case you may need to reboot the system). You can also use the -u option to unload the driver but generally -U is easier during the testing phase. Study the driver to find the error; the information in the /usr/adm/syslog and /var/adm/log/osmlog files may help you identify the errors. When you have fixed the code, recompile it and try to load the driver again.
See ``Dynamically-loadable kernel modules (DLKM)'' for more information.
If the kernel built correctly, a new operating system image will have been created. Run shutdown or init 6 to cause the new kernel to be automatically copied to /stand/unix. On the next boot, the new kernel will execute, and upon entering init state 2, the new device nodes, inittab entries, and so on, will be installed.
If you get errors, study the driver to find the error, correct them, and repeat the above step. The information in the SCO OpenServer 5 /usr/adm/messages file or the SVR5 /usr/adm/syslog and /var/adm/log/osmlog files may help you find the error.
All error messages for DLKMs and many for static drivers are written to the kernel's putbuf message buffer; some of the messages are also written to the console. When a module fails to load and no detailed error message is displayed on the console, you can often determine the cause of the error by printing the messages in the putbuf using crash or one of the kernel debuggers. See ``Using crash and the kernel debuggers'' for more information.
It may be useful to divide your driver into separate sections and install each part separately until you find the problem. Fix the problem and install the driver. For a statically linked driver, you should then reset your system and boot your original kernel, assuming you saved it as recommended. To do this: