I'm not sure if there's a proper solution to this, but rebuilding and
reinstalling the kernel and modules with CONFIG_MODVERSIONS unset, then
rebuilding and reinstalling RTAI and comedi in that order should work.
In "make menuconfig" for the kernel enter the "Enable loadable module
support" menu and disable the "Module versioning support" option.
The problem with CONFIG_MODVERSIONS seems to be when you have a set of
modules built externally to the kernel depending on some other set of
modules built externally to the kernel, e.g. comedi depending on rtai.
There might be a proper solution, but I don't know what it is. Probably
something to do with the Module.symvers files.
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abb...@mev.co.uk> )=-
-=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
To fix it properly, we probably need a configure option to set the
KBUILD_EXTRA_SYMBOLS variable - look for this in the kernel's
Documentation/kbuild/modules.txt file section 7.3.
Another workaround is to copy the Module.symvers file from the rtai's
build directory (or from rtai's module install directory) to Comedi's
"comedi" subdirectory (the directory where comedi.ko gets built, not the
top-level directory) before running "make" for comedi. When the make
completes, this Module.symvers in the "comedi" subdirectory will contain
CRC values for both the RTAI modules and the Comedi modules. A "make
install" will install this Module.symvers file along with the comedi
modules and "depmod -a" followed by "modprobe comedi" should then load
the comedi.ko module OK, even if the CONFIG_MODVERSIONS kernel config
option is used.
Even after doing that, there is still a problem with the rtai_comedi.ko
module if CONFIG_MODVERSIONS is set in the kernel and RTAI has the "Real
time COMEDI support in user space" add-on enabled. This is because
Comedi needs RTAI's Module.symvers file and the rtai_comedi module needs
Comedi's Module.symvers file.
This can be solved by copying Comedi's Module.symvers file back to the
RTAI build directory, going back to the RTAI build's "addons/comedi"
subdirectory, and running "make clean", "make", "cd ../..", and (as
root) "make install" to rebuild and reinstall the rtai_comedi.ko module.
In short:
1. Build and install rtai.
2. Copy rtai's Module.symvers to Comedi's "comedi" subdirectory.
3. Build and install comedi.
4. Copy the Module.symvers from Comedi's "comedi" subdirectory back to rtai.
5. Change directory to rtai's "addons/comedi", run "make clean", "make",
and (as root) "make install".
This is all a load of hassle. The simplest thing is to avoid using the
CONFIG_MODVERSIONS kernel option. :-)
At least you got it working!
> 2. However, all your hints were quite illuminating. Placing the rtai
> Module.symvers file
> into the comedi directory indeed works great, with CONFIG_MODVERSIONS
> selected for the kernel.
>
> 3. It would be really nice, if comedi configure or make would do this
> automatically! It should not be too difficult to add this to the
> Makefiles.
> Or by setting the KBUILD_EXTRA_SYMBOLS variable as you suggested.
>
> I guess that in the comedi/Makefile.am the following line before -$
> (MAKE) in the all-local target should do it:
>
> test "@HAVE_RTAI@" = "yes" && test -f "@RTAI_DIR@/modules/
> Module.symvers" && cp "@RTAI_DIR@/modules/Module.symvers"
> @abs_builddir@
>
> This requires in m4/rtai.m4 these two lines after AC_SUBST
> (RTAI_CFLAGS) (near the end):
>
> AC_SUBST(RTAI_DIR)
> AC_SUBST(HAVE_RTAI)
>
>
It's possible to configure RTAI to store its modules somewhere other
than its default "modules" subdirectory, at least when configuring it
using its configure script instead of the menu configuration. It's
configure script has a "--with-module-dir=<module_dir>" option, which is
quite handy for storing the modules somewhere sensible like
"/lib/modules/`uname -r`/rtai" instead of "/usr/realtime/modules".
There isn't a reasonable way for comedi to find out this information
other than looking in a few likely places (and possibly finding the
wrong set of modules first).
There are also a few kernel version niggles. 2.6.18 onwards uses the
current name "Module.symvers", 2.6.17 called it "Modules.symvers" (note
the extra 's'), and the file was not created at all before 2.6.17 (at
least for unpatched kernel sources).
That's why I thought a generic means to specify KBUILD_EXTRA_SYMBOLS
would be better, but I have yet to investigate when in kernel history
the KBUILD_EXTRA_SYMBOLS variable came into existence!
Still, there's no reason not to have both a configure option and some
automatic setting, with the configure option taking priority.
> 4. It would also be nice, if make install could copy the
> comedi/Module.symvers file into the /lib/modules/`uname -r`/comedi
> directory,
> so that building modules that use rtai and comedi can use this file
> for
> compilation without needing to know where the comedi built directory
> is.
>
> For example, in comedi/makefile.am at the end of the install-data-
> local target:
>
> cp @abs_builddir@/Module.symvers /lib/modules/`uname -r`/comedi
>
> Maybe there is a better way to do this through the kernel built
> system.
I don't think it can be done through the kernel build system, but
there's no reason it couldn't be done as you suggest.
> With these two little extensions, the unknown symbol problem could be
> easily
> solved.
We probably need some documentation in the "RTAI Support" section of
Comedi's "INSTALL" file as well. That's right next to the "RTLinux
Support" section, but I don't know if we still support that!
> Thanks again!
>
> Jan
You're welcome!
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abb...@mev.co.uk> )=-