gkaindl / rfm12b-linux

A Linux kernel SPI-driver for the RFM12B and RFM69CW RF modules by HopeRF
113 stars 46 forks source link

make error: implicit declaration of function ‘init_timer’; #29

Open bomilkar opened 4 years ago

bomilkar commented 4 years ago

I followed the instructions including rpi-source. Make fails early when it compiles rfm12b.c. Details below. Any idea??

$ make
make -C /lib/modules/4.19.118+/build  M=/opt/public/rfm69/rfm12b-linux-master modules
make[1]: Entering directory '/home/pi/linux-fe2c7bf4cad4641dfb6f12712755515ab15815ca'
  CC [M]  /opt/public/rfm69/rfm12b-linux-master/rfm12b.o
/opt/public/rfm69/rfm12b-linux-master/rfm12b.c: In function ‘rfm_update_rxtx_watchdog’:
/opt/public/rfm69/rfm12b-linux-master/rfm12b.c:765:6: error: implicit declaration of function ‘init_timer’; did you mean ‘init_timers’? [-Werror=implicit-function-declaration]
      init_timer(&rfm12->rxtx_watchdog);
      ^~~~~~~~~~
      init_timers
/opt/public/rfm69/rfm12b-linux-master/rfm12b.c:767:26: error: ‘struct timer_list’ has no member named ‘data’
      rfm12->rxtx_watchdog.data = (unsigned long)rfm12;
                          ^
/opt/public/rfm69/rfm12b-linux-master/rfm12b.c:768:36: error: assignment to ‘void (*)(struct timer_list *)’ from incompatible pointer type ‘void (*)(long unsigned int)’ [-Werror=incompatible-pointer-types]
      rfm12->rxtx_watchdog.function = rfm_rxtx_watchdog_expired;
                                    ^
/opt/public/rfm69/rfm12b-linux-master/rfm12b.c: In function ‘rfm_start_trysend_retry_timer’:
/opt/public/rfm69/rfm12b-linux-master/rfm12b.c:845:30: error: ‘struct timer_list’ has no member named ‘data’
    rfm12->retry_sending_timer.data = (unsigned long)rfm12;
                              ^
/opt/public/rfm69/rfm12b-linux-master/rfm12b.c:846:40: error: assignment to ‘void (*)(struct timer_list *)’ from incompatible pointer type ‘void (*)(long unsigned int)’ [-Werror=incompatible-pointer-types]
    rfm12->retry_sending_timer.function = rfm_trysend_retry_timer_expired;
                                        ^
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:310: /opt/public/rfm69/rfm12b-linux-master/rfm12b.o] Error 1
make[1]: *** [Makefile:1522: _module_/opt/public/rfm69/rfm12b-linux-master] Error 2
make[1]: Leaving directory '/home/pi/linux-fe2c7bf4cad4641dfb6f12712755515ab15815ca'
make: *** [Makefile:30: all] Error 2
gkaindl commented 4 years ago

Hi @bomilkar! Yes, this is because the module has originally been written for the 2.x line of kernels, but 4.x changes the structure for timer callbacks. There's an updated .c file in the #28 issue, which you can probably use.

Unfortunately, I haven't yet had the time to look into it and merge it to the repo, but a pull request would be welcome!

bomilkar commented 4 years ago

Thanks @gkaindl for pointing that out. make works now but how can I judge it's really working?? For instance: How can I see the register content? Or is there a loop back test which checks if all is well? I have a commit ready with changes to 3 files. As soon as I'm confident it's working I'll push and post a PR.

bomilkar commented 4 years ago

After playing with it for a bit I conclude it does NOT work with this modified rfm12b.c .

I can "make" the kernel module and "sudo insmod rfm12b.ko" says nothing (maybe good). But then I recompiled it after some change to rfm12b_config.h and tried to replace the module:

$ sudo insmod rfm12b.ko
insmod: ERROR: could not insert module rfm12b.ko: File exists
$ sudo rmmod rfm12b.ko
rmmod: ERROR: Module rfm12b is not currently loaded
$ sudo modprobe -v rfm12b.ko
modprobe: FATAL: Module rfm12b.ko not found in directory /lib/modules/4.19.118+

It seems as if the first "insmod rfm12b.ko" did not insert the module correctly.

Also suspicious:

$ ./examples/bin/rfm12b_chat
successfully opened /dev/spidev0.0 as fd 3.
error during ioctl(): Inappropriate ioctl for device. 
$ ls -l /dev/spidev0.0
crw-rw---- 1 root spi 153, 0 Jun 24 16:01 /dev/spidev0.0

Any idea what to try next?