gkaindl / rfm12b-linux Goto Github PK
View Code? Open in Web Editor NEWA Linux kernel SPI-driver for the RFM12B and RFM69CW RF modules by HopeRF
A Linux kernel SPI-driver for the RFM12B and RFM69CW RF modules by HopeRF
Hi, how is it possible to cross compile the kernel driver on an linux machine for BBB?
Maybee a howto would be good inside readme.
(This is because I don't want to blow up my sd card with the kernel headers and all the build stuff. I want to do this offline)
A quick hint would be fine.
Regards,
Benny
Hi,
first of all, thank you for your great job, amazing, just what I needed, was thinking of writing it until I found your. In Kernel module moreover. Nice job, I love these kind of code, quick and easy to use and interface.
For me it is working fine, but I noticed that one insmod rfm12b.ko is done then the device /dev/spidev0.x is not available anymore. that is making sense since it is used by the module. But after a rmmod rfm12b, the device no longer appears in the /dev folder, so I can not use SPI device for doing other stuff until I reboot.
Not really a issue, your module is working so good, but, just to know ;-)
When running insmod rfm12b.ko
I get the following error including a segmentation fault
[ 36.909874] Internal error: Oops: 5 [#1] PREEMPT SMP ARM
[ 36.930848] Modules linked in: rfm12b(O+) snd_soc_pcm512x_i2c snd_soc_pcm512x snd_soc_wm8804 snd_soc_tas5713 regmap_spi snd_soc_bcm2708_i2s regmap_mmio regmap_i2c snd_soc_core snd_compress snd_pcm_dmaengine snd_pcm snd_timer snd i2c_bcm2708 spi_bcm2708
[ 37.015737] CPU: 2 PID: 284 Comm: insmod Tainted: G W O 3.18.0-trunk-rpi2 #1 Debian 3.18.5-1~exp1.co1
[ 37.056599] task: b4035200 ti: b775a000 task.ti: b775a000
[ 37.077148] PC is at rfm12_init_module+0x64/0x214 [rfm12b]
[ 37.097559] LR is at rfm12_init_module+0x60/0x214 [rfm12b]
[ 37.117363] pc : [<7f0cb064>] lr : [<7f0cb060>] psr: 800f0013
sp : b775bda8 ip : 0000000d fp : b775bdd4
[ 37.156882] r10: 00000000 r9 : 00000000 r8 : 00000000
[ 37.175557] r7 : 00000007 r6 : 00000004 r5 : 7f0c8fe0 r4 : 00000008
[ 37.195124] r3 : 00000000 r2 : 0000000a r1 : 00000007 r0 : 00000000
[ 37.214187] Flags: Nzcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user
[ 37.233805] Control: 10c5387d Table: 3927006a DAC: 00000015
[ 37.251918] Process insmod (pid: 284, stack limit = 0xb775a238)
[ 37.269995] Stack: (0xb775bda8 to 0xb775c000)
[ 37.286262] bda0: 80161c90 800f1074 b775a018 809a9d4c 809ade18 b7626988
[ 37.318155] bdc0: 809ade18 b9152700 b775be64 b775bdd8 80008950 7f0cb00c 80152138 00000009
[ 37.350275] bde0: 8098bad0 7f0cb000 a0070013 396f3000 ba07ead0 7f0c8e48 b775be2c b775be08
[ 37.383655] be00: 80161c90 800f1074 00000002 00000009 b9152700 bbd37000 00000001 00000001
[ 37.417939] be20: b775be4c b775be30 80153c9c 80161c00 b775bf48 dc8cb005 b7626980 b775bf48
[ 37.452136] be40: 00000001 b7626980 b7626988 00000001 7f0c8e48 7f0c8e54 b775bf3c b775be68
[ 37.486655] be60: 800a70f0 80008870 7f0c8e54 00007fff 800a3b7c b74b8b80 000006b8 b775bf7c
[ 37.521327] be80: 000000f7 b775bf50 b775a028 7f0c8fd0 b775bf48 7f0c8e90 809a9d4c 00000000
[ 37.557055] bea0: 00000000 b74b8b80 00000000 00000000 00000000 00000000 00000000 00000000
[ 37.593879] bec0: 00000000 00000000 00000000 00000000 6e72656b 00006c65 00000000 00000000
[ 37.632092] bee0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 37.671741] bf00: 00000000 00000000 00000000 dc8cb005 b775bf2c 00000000 00000003 76fa8e80
[ 37.711769] bf20: 0000017b 8000fd44 b775a000 00000000 b775bfa4 b775bf40 800a7b18 800a5530
[ 37.752424] bf40: b775bf4c 8007fe70 bbd37000 00008dfc bbd3f71c bbd3c82b bbd3d960 00004000
[ 37.793459] bf60: 00004310 7f0c8e00 00000003 00000000 0000002a 0000002b 00000023 0000001e
[ 37.834493] bf80: 00000018 00000000 00000000 f7411c00 76fa4cdc 76f90f10 00000000 b775bfa8
[ 37.875527] bfa0: 8000fac0 800a7a94 f7411c00 76fa4cdc 00000003 76fa8e80 00000000 00000002
[ 37.916574] bfc0: f7411c00 76fa4cdc 76f90f10 0000017b 00000000 76fa4cdc 76fbb000 00000000
[ 37.957609] bfe0: 7ec5abc0 7ec5abb0 76f9f6c3 76f0b812 80070030 00000003 3a7fa821 3a7fac21
[ 37.998677] [<7f0cb064>](rfm12_init_module [rfm12b]) from <80008950>
[ 38.040753] <80008950> from <800a70f0>
[ 38.081918] <800a70f0> from <800a7b18>
[ 38.122884] <800a7b18> from <8000fac0>
[ 38.164321] Code: e1a08000 e1a00004 eb4ac86d e2844001 (e7993108)
[ 38.187270] ---[ end trace 121fedc6486cd9e7 ]---
First, I'd like to thank you for an awesome driver with well-written documentation. I've spent a few nights struggling with other tutorials, blog posts and forum posts to get the RFM12B connected to my Raspberry Pi talking to the one connected to my Arduino, until I tried your driver!
One minor comment: In README.md, step 6 should be "rfm12b.ko", not just "rfm12b"
modprobe: ERROR: could not insert 'spi_bcm2708': No such device
guys any ideas what i did wrong? i can run make, everything compiles, i also restarted, the RFM12b looks connected. no idea what is wrong :(((
Hello,
I try to recompile on raspi
Linux raspberrypi 4.1.13-v7+ #826 SMP PREEMPT Fri Nov 13 20:19:03 GMT 2015 armv7l GNU/Linux
I followed the process:
git clone --depth=1 git://github.com/raspberrypi/linux.git rpi-linux
make bcmrpi_defconfig
make prepare headers_install
make modules_prepare
then rebuild the module pointing to the above repository
I got just one warning
rfm12b.c: In function ‘rfm12_setup’:
rfm12b.c:1235:1: warning: the frame size of 2088 bytes is larger than 1024 bytes
but the module didn't load:
sudo insmod rfm12b.ko
insmod: ERROR: could not insert module rfm12b.ko: Invalid module format
the file seem OK:
rfm12b.ko: ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), BuildID[sha1]=025d39542e5b6f9666f4066e8697ff7463545ac0, not stripped
Any idea ?
Hello gkaindl thank you for the nice module.
Can you figure out a little strategy do get this module running with 3.18 ?
I am not really familiar with kernel-modules, but with a little help and some hints might its possible to port this project to newer kernels.
My first suspect was that the reported problems only based by a deprecated installation instruction ?
regards
Jens
Hi,
you cant insmod rfm12b.ko if you use device tree and a higher kernel then 3.18.0 trunk...
cost me 2 days ....
I have installed these drivers on a BeagleBone Black. I wish to communicate with an Arduino.
My question is if weather it is compatible with Arduino interfaced with PT4317-X and using the JeeLibs library for RF Communication
Can somebody please explain in details the following steps:
Load the kernel driver for the SPI interface: sudo modprobe spi-bcm2708
Load the driver module: sudo insmod rfm12b.ko.
Hello,
Updated my pi (and kernel source of course), I am able to compile the module but I can't install it, got a invalid module format.
root@pi02:/rfm12b-linux# uname -a/rfm12b-linux# make
Linux pi02 3.10.19+ #600 PREEMPT Sat Nov 16 20:34:43 GMT 2013 armv6l GNU/Linux
root@pi02:
make -C /lib/modules/3.10.19+/build M=/root/rfm12b-linux modules
make[1]: Entering directory /usr/src/linux-source-3.10.19+' CC [M] /root/rfm12b-linux/rfm12b.o Building modules, stage 2. MODPOST 1 modules CC /root/rfm12b-linux/rfm12b.mod.o LD [M] /root/rfm12b-linux/rfm12b.ko make[1]: Leaving directory
/usr/src/linux-source-3.10.19+'
root@pi02:~/rfm12b-linux# insmod ./rfm12b.ko
Error: could not insert module ./rfm12b.ko: Invalid module format
Any hints ? dmesg show me
rfm12b: disagrees about version of symbol module_layout
Module doesn't work with the last raspberry-pi kernel mainline (rpi-3.18.y).
insmod work after configured device-tree to add spi-bcm2708 but not work to achieve packet reception in exemple programm, work good on old rpi-3.12.y branch.
EDIT: exact version 3.18.7
Hi,
when i execute ./bb-enable-spi-devicetree.sh
i get the error failed to extract flattened device-tree file from /boot/uboot/u-boot.img
.
Any idea how to resolve it?
Hi,
I tried to get this nice code to work. I followed the hints at the other issues, but I was not able to get this working. For a Linux-newbe like me, it was hard to get the code compiled, but now the last problem seems to be this:
sudo insmod rfm12b.ko delivers this error:
Error: could not insert module rfm12b.ko: Invalid module format
thanks for helping
Christian from Hamburg, germany
Firstly, thanks for this amazing effort at getting the tricky RFM12B module working on the Pi. I tried in vain to get it working using SPIDEV and Python but alas it was too slow to cope with the tiny buffer on the RFM12.
I have compiled your module using the Yocto project system and I can load the module into the kernel. When I open the device using "cat /dev/rfm12b.0.1" I can see the nIRQ line go high but when hitting CTRL-C I get a kernel fault:
[ 94.090169] Unable to handle kernel NULL pointer dereference at virtual address 0000001c
I don't know if this is expected, but I was wondering if you could either explain it?
Thanks again.
Hello !
I'm trying to lauch rfm12b kernel module on OSMC OS. I've sucessfully downloaded kernel headers and sources (kernel version 4.4.8-3-osmc). I run sudo make command and .ko file was generated successfully but when I try to do sudo insmod rfm12b.ko
I got :
insmod: ERROR: could not insert module rfm12b.ko: Invalid module format
I also tried the steps described in #5 but it seems that is has no effect in my case - maybe it's because for Raspian.
Please help.
I'm testing it on Raspberry 3 but the insmod command hangs...
this my kernel version: 4.4.14-v7+
The make works and outputs correctly the .ko but when i do "sudo insmod rfm12b.ko" no results are returned and i'm forced to stop it
Hi.
In the attached rfm12b.c file I did changes in the 2 timer_callbacks to compile with new kernel.
might you will update the code ? the module runs on a pi-ZERO , I testet only receiving without ACK but that works for me :)
Thank you again for that stable little module.
Parts of your documentation seem to be deprecated, I just installed the kernel-source via apt-get as far as I remember...
Jens
rfm12b.zip
Is it possible to implement the read and write operations in the same time?
For the moment when I am trying to read some data and in the same time to send something, the write operation occurs only when I receive something! Thx
Hi
I,m try to do this
cat /dev/rfm12b.0.1
and i see received data, but i try open device with python open and not see anything
maybe you know how to work with device in python?
guys i try to run hello world example on the latest kernel version. i follow the instructions from here https://github.com/notro/rpi-source/wiki , but i get this. any ideas?
make -C /lib/modules/$(uname -r)/build M=$(pwd) modules make: Entering directory '/home/pi/linux-48ba943bfb614ad9a09d4ffd1cfe54adb1550e09' scripts/Makefile.build:44: /home/pi/hello/Makefile: No such file or directory make[1]: *** No rule to make target '/home/pi/hello/Makefile'. Stop. Makefile:1384: recipe for target '_module_/home/pi/hello' failed make: *** [_module_/home/pi/hello] Error 2 make: Leaving directory '/home/pi/linux-48ba943bfb614ad9a09d4ffd1cfe54adb1550e09'
the same problem occurs when i compile the drivers for the rfm12b board!
did somebody try it on jessy? if yes can you please write the commands that you typed in the command line! thx a lot !
Keep up the good work 👍
Hi,
when I run make, I get
Makefile:25: *** missing separator (did you mean TAB instead of 8 spaces?).
on a raspberry with raspbian. Any hints?
Regards
Stefan
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
make -C /lib/modules/3.18.11+/build M=/home/chris/rfm12b-linux modules
make[1]: *** /lib/modules/3.18.11+/build: No such file or directory. Stop.
Makefile:30: recipe for target 'all' failed
make: *** [all] Error 2
In rfm_filop_write() you are using this code fragment to increment the out_cur_end pointer to the end of the current buffer:
*rfm12->out_cur_end++ = 0; // hdr
*rfm12->out_cur_end++ = (u8)copied; // len
rfm_apply_crc16(rfm12, rfm12->out_cur_end-2, copied+offset);
rfm12->out_cur_end += copied + offset;
which is a bit confusing for me. If I understand this correctly the pointer increment in the first 2 lines actually does increment the pointer for the crc at this place, not the header (which is also 2 bytes), because the length of the header is already accumulated in offset.
recommended rewrite:
*rfm12->out_cur_end = 0;
*(rfm12->out_cur_end+1) = (u8)copied
rfm_apply_crc16(rfm12, rfm12->out_cur_end, copied+offset);
rfm12->out_cur_end += copied + offset + 2; // +2 byte crc
I stumbled about this when attempting to use your code with a protocol that does not know the first header byte, after a few modifications it works, thanks for sharing the code.
Also please use constants for header and crc length instead of using the value 2 for both. Sometimes it is a bit hard to spot which is which.
I've made changes for kernel 5.15.61
you have to add to /boot/config.txt two lines
dtoverlay=spi0-2cs, cs0_spidev=disabled
dtoverlay=spi1-2cs, cs1_spidev=disabled /not necessarily
and uncomment
dtparam=spi=on
The configuration says that I need to set a network/group ID. However, there's no indication of such an ID within the datasheet for neither the RFM12 nor the RFM12B. Is this a software-only feature?
If so, does it get disabled when not using the Jeelabs functionality?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.