Linux Driver Package - Sample Build Procedure
Here is an example of the commands required to build the Meinberg driver package for Linux, and the output produced by the commands.
This should basically be the same on all supported Linux distros, but of course the specific device info, version numbers, etc., will vary across different systems.
Show Distribution Version Info
Most Linux distros provide a version information file in the /etc
directory.
However, the name of the file may depend on the distro type and version.
This is not required, but just for information.
This example is from an older CentOS 6.3 distro:
[martin@pc-martin1 ~]$ cat /etc/centos-release CentOS release 6.3 (Final)
Or from a newer CentOS 7 distro (7.5, actually):
[martin@pc-martin1 ~]$ cat /etc/centos-release CentOS Linux release 7.5.1804 (Core)
Show Kernel Version Info
This is not required, but just for information:
[martin@pc-martin1 ~]$ uname -r 2.6.32-279.22.1.el6.x86_64
or e.g.:
[martin@pc-martin1 ~]$ uname -r 3.10.0-862.el7.x86_64
Kernel Header Packages
Kernel header packages need to be installed in exactly the same version
as shown by the uname -r
command above:
[root@pc-martin1 ~]# rpm -qa | grep kernel kernel-3.10.0-862.el7.x86_64 kernel-headers-3.10.0-862.14.4.el7.x86_64 kernel-devel-3.10.0-862.el7.x86_64 kernel-tools-3.10.0-862.el7.x86_64 kernel-tools-libs-3.10.0-862.el7.x86_64
Please note:
- If the version numbers are not exactly the same then it is not possible to build a kernel driver that is appropriate for the running kernel.
- If the appropriate kernel headers are not installed then fiddling with the system by creating symbolic links, or similar actions, won't lead to a successful build.
- If the system (including the kernel) has just be upgraded then an older kernel may still be running, so the system may have to be rebooted to let the latest kernel become active, so that the output of
uname -r
matches the version numbers of the kernel header packages.
Preparing The Package Sources
Extract the driver source file and change to the directory which has been created when the archive was extracted:
[martin@pc-martin1 ~]$ tar xzf mbgtools-lx-4.2.6.tar.gz [martin@pc-martin1 ~]$ cd mbgtools-lx-4.2.6 [martin@pc-martin1 mbgtools-lx-4.2.6]$
Building The Driver And Tools
No special configuration has to be made to build the driver package, but of course the required build tools and the appropriate kernel headers need to be installed. If there are any error messages in this steps then probably something is missing.
[martin@pc-martin1 mbgtools-lx-4.2.6]$ make Making all in libmbg_so/mbgdevio cc mbgioctl.o cc gpsutils.o cc str_util.o cc mbgerror.o cc cfg_hlp.o cc mbgdevio.o Linking libmbgdevio.so.1.0.0 Making all in libmbg_so/mbgutil cc str_util.o cc mbgerror.o cc mbgutil.o Linking libmbgutil.so.1.0.0 Making all in libmbg_so/devel Making all in mbgstatus cc mbgstatus.o cc mbgdevio.o cc mbgioctl.o cc mbgutil.o cc timeutil.o cc str_util.o cc toolutil.o cc mbgerror.o cc cfg_hlp.o cc gpsutils.o cc pcpslstr.o cc deviohlp.o cc ctrydttm.o cc ctry.o cc lan_util.o cc nanotime.o cc mbgmktm.o Linking mbgstatus Making all in mbgsetsystime cc mbgsetsystime.o cc mbgdevio.o cc mbgioctl.o cc timeutil.o cc str_util.o cc toolutil.o cc mbgerror.o cc cfg_hlp.o cc gpsutils.o cc mbgmktm.o cc pcpsmktm.o Linking mbgsetsystime Making all in mbgctrl cc mbgctrl.o cc mbgdevio.o cc mbgioctl.o cc mbgutil.o cc timeutil.o cc str_util.o cc toolutil.o cc mbgerror.o cc cfg_hlp.o cc deviohlp.o cc gpsutils.o cc lan_util.o Linking mbgctrl Making all in mbgirigcfg cc mbgirigcfg.o cc mbgdevio.o cc mbgioctl.o cc mbgutil.o cc timeutil.o cc str_util.o cc toolutil.o cc mbgerror.o cc cfg_hlp.o cc gpsutils.o Linking mbgirigcfg Making all in mbgshowsignal cc mbgshowsignal.o cc mbgdevio.o cc mbgioctl.o cc timeutil.o cc str_util.o cc toolutil.o cc mbgerror.o cc cfg_hlp.o cc gpsutils.o Linking mbgshowsignal Making all in mbggpscap cc mbggpscap.o cc mbgdevio.o cc deviohlp.o cc lan_util.o cc mbgioctl.o cc timeutil.o cc str_util.o cc toolutil.o cc mbgerror.o cc cfg_hlp.o cc gpsutils.o Linking mbggpscap Making all in mbghrtime cc mbghrtime.o cc mbgdevio.o cc mbgioctl.o cc timeutil.o cc str_util.o cc toolutil.o cc mbgerror.o cc cfg_hlp.o cc gpsutils.o Linking mbghrtime Making all in mbgfasttstamp cc mbgfasttstamp.o cc mbgdevio.o cc mbgioctl.o cc timeutil.o cc str_util.o cc cfg_hlp.o cc toolutil.o cc mbgerror.o cc gpsutils.o Linking mbgfasttstamp Making all in mbgsvcd cc mbgsvcd.o cc mbgdevio.o cc mbgioctl.o cc timeutil.o cc str_util.o cc toolutil.o cc mbgerror.o cc cfg_hlp.o cc gpsutils.o cc chk_time_info.o cc ntp_shm.o Linking mbgsvcd Making all in mbgxhrtime cc mbgxhrtime.o cc mbgdevio.o cc mbgioctl.o cc timeutil.o cc str_util.o cc toolutil.o cc mbgerror.o cc cfg_hlp.o cc gpsutils.o Linking mbgxhrtime Making all in mbgcmptime cc mbgcmptime.o cc cmp_time_util.o cc mbgdevio.o cc mbgioctl.o cc mbgutil.o cc timeutil.o cc str_util.o cc deviohlp.o cc cfg_hlp.o cc toolutil.o cc mbgerror.o cc gpsutils.o cc lan_util.o Linking mbgcmptime Making all in mbgtcrcal cc mbgtcrcal.o cc mbgdevio.o cc mbgioctl.o cc timeutil.o cc str_util.o cc toolutil.o cc mbgerror.o cc cfg_hlp.o cc gpsutils.o Linking mbgtcrcal Making all in mbgclock Calling kernel build system to make “modules” =================================================================== Build completed successfully. Now type make install to install the executable files.
Become 'root'
Some commands require root privileges to be executed.
Usually those commands are automatically executed with
sudo
, but this may fail if the sudo
command is not available
or the user is not allowed to use it.
So becoming root now avoids permission problems in further steps.
[martin@pc-martin1 mbgtools-lx-4.2.6]$ su Passwort: ******
Installing The Driver And Tools
This command require root privileges.
[root@pc-martin1 mbgtools-lx-4.2.6]# make install Making install in libmbg_so/mbgdevio Making install in libmbg_so/mbgutil Making install in libmbg_so/devel Making install in mbgstatus Making install in mbgsetsystime Making install in mbgctrl Making install in mbgirigcfg Making install in mbgshowsignal Making install in mbggpscap Making install in mbghrtime Making install in mbgfasttstamp Making install in mbgsvcd Making install in mbgxhrtime Making install in mbgcmptime Making install in mbgtcrcal Making install in mbgclock Calling kernel build system to make “modules_install” Udev rules file 55-mbgclock.rules in /etc/udev/rules.d/ is unchanged. ==================================================================== Installation of the executables completed successfully. Now type sudo /sbin/modprobe mbgclock to load the kernel module for the first time. After this the kernel module should be loaded automatically whenever a supported device is detected by the kernel. Once the kernel module has been loaded, run make install_svc to register the mbgsvcd service so the service will be started automatically after reboot, and can be controlled via the usual commands. See the README file how to configure ntpd.
Load The Kernel Module And Check Module Startup Messages
This command require root privileges.
[root@pc-martin1 mbgtools-lx-4.2.6]# modprobe mbgclock [root@pc-martin1 mbgtools-lx-4.2.6]# dmesg … … mbgclock: Meinberg radio clock driver v4.2.6 loading. mbgclock: © Meinberg 2001-2019 mbgclock: Found GPS180PEX v2.47 © Meinberg '19, S/N 029511008290, port DE00, irq 19 usbcore: registered new interface driver mbgclock
Run 'mbgstatus' To See Device Information
This command does not require root privileges.
[root@pc-martin1 mbgtools-lx-4.2.6]# mbgstatus mbgstatus v4.2.6 copyright Meinberg 2001-2019 GPS180PEX 029511008290 (FW 2.47, ASIC 8.06) at port 0xDE00, irq 19 Normal Operation, 5 GPS sats tracked, 10 expected to be visible Date/time: Tu, 2019-05-14 10:18:13.71 CEST (UTC+2h) Status info: Input signal available Status info: Time is synchronized Status info: Receiver position has been verified Last sync: Tu, 2019-05-14 10:18:00.00 CEST (UTC+2h) Receiver Position: lat: +51.9824 lon: +9.2258 alt: 173m GPS/UTC offset parameter: 18s, no leap second announced.
— Martin Burnicki martin.burnicki@meinberg.de 2019-07-16