compiling a driver

More
05 Jun 2017 12:05 #94084 by JR1050
compiling a driver was created by JR1050
The hm2_rpspi driver has been updated. I would like to install it, as it looks like it has solved some spi related issues. The original
hm2_rpspi appears to live in the modules directory with the other components. To compile this driver, several header files are required,
some already exist in the include directory, the following do not.
sserial.h, hostmot2-lowlevel.h,hostmot2.h.,spi_common_rpspi.h

question what the correct directories to put these headers in ? Im new to compiling a driver. Thanks

Please Log in or Create an account to join the conversation.

More
05 Jun 2017 12:52 #94088 by andypugh
Replied by andypugh on topic compiling a driver
I think it might be easier to download the entire source code, compile run-in-place and the (if running the run-in-place version works) copy the .ko file into the installed location.

Though if you are compiling on the Pi, this might take a long time.

Please Log in or Create an account to join the conversation.

More
05 Jun 2017 13:14 #94090 by JR1050
Replied by JR1050 on topic compiling a driver
Im new to the source code thing, how do i do what you describe above? The source files live at git hub. To be honest, im used to loading off the cd and going....Its cool stuff, but new to me.

Please Log in or Create an account to join the conversation.

More
05 Jun 2017 15:37 #94101 by JR1050
Replied by JR1050 on topic compiling a driver
I am truly stuck. Compiling the whole linuxcnc program is not an option. It was difficult enuff just to get it on the rspi. As of now I just need an updated driver. I have the updated source for the driver and the header file. When i try to compile with halcompile, it wont see the standard headers

sudo halcompile --compile hm2_rpspi.c
[sudo] password for user:
make KBUILD_EXTRA_SYMBOLS=/usr/realtime-3.4-9-rtai-686-pae/modules/linuxcnc/Module.symvers -C /usr/src/linux-headers-3.4-9-rtai-686-pae SUBDIRS=`pwd` CC=gcc V=0 modules
make[1]: Entering directory `/usr/src/linux-headers-3.4-9-rtai-686-pae'
CC [M] /tmp/tmpSyLe0E/hm2_rpspi.o
/tmp/tmpSyLe0E/hm2_rpspi.c:23:19: fatal error: ctype.h: No such file or directory
compilation terminated.
make[4]: *** [/tmp/tmpSyLe0E/hm2_rpspi.o] Error 1
make[3]: *** [_module_/tmp/tmpSyLe0E] Error 2
make[2]: *** [sub-make] Error 2
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.4-9-rtai-686-pae'
make: *** [modules] Error 2


and when i try to use the standard compiler it doesnt seem to find the linuxcnc specifc headers

user@CMP-0179:/usr/realtime-3.4-9-rtai-686-pae/modules/linuxcnc$ cc hm2_rpspi.c -o hm2_rpspi
In file included from hm2_rpspi.c:36:0:
hal.h:126:19: fatal error: rtapi.h: No such file or directory
compilation terminated.

I have copied the linuxcnc specific headers into the modules directory where the driver file lives and have had no sucess. How
do i do this? Ill admit, i dont exactly know what im doing, doesnt seem like it should be this hard...

Please Log in or Create an account to join the conversation.

More
05 Jun 2017 16:10 #94104 by Bertho
Replied by Bertho on topic compiling a driver
You do not need to sudo for compilation (actually a bad habit) and it may give you problems. What happens when you do as a normal user:
$ halcompile --compile hm2_rpspi.c

BTW, what version linuxcnc are you using?

You may still run into problems, like I just did, because the driver uses local include files found in the source-tree outside the normal include directory. But I'd like to see what happens as a reference to see what can be done.

My install uses a locally compiled RT kernel (4.9.30-rt20-v7+), and I use a locally compiled linuxcnc, 2.8.0~pre1 from git, so there may be a few differences.
The following user(s) said Thank You: JR1050

Please Log in or Create an account to join the conversation.

More
05 Jun 2017 16:38 - 05 Jun 2017 16:49 #94107 by JR1050
Replied by JR1050 on topic compiling a driver
On my desktop,where im trying to get this going initially, 2.7.8. Stock from the cd install.

I am using 2.80 pre from bulidbot, on the rspi3. My kernel is patched rt prempt, 4.49, I think.

This happened:

user@CMP-0179:/usr/realtime-3.4-9-rtai-686-pae/modules/linuxcnc$ halcompile --compile hm2_rpspi.c
make KBUILD_EXTRA_SYMBOLS=/usr/realtime-3.4-9-rtai-686-pae/modules/linuxcnc/Module.symvers -C /usr/src/linux-headers-3.4-9-rtai-686-pae SUBDIRS=`pwd` CC=gcc V=0 modules
make[1]: Entering directory `/usr/src/linux-headers-3.4-9-rtai-686-pae'
CC [M] /tmp/tmpRt5nDg/hm2_rpspi.o
/tmp/tmpRt5nDg/hm2_rpspi.c:23:19: fatal error: ctype.h: No such file or directory
compilation terminated.
make[4]: *** [/tmp/tmpRt5nDg/hm2_rpspi.o] Error 1
make[3]: *** [_module_/tmp/tmpRt5nDg] Error 2
make[2]: *** [sub-make] Error 2
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.4-9-rtai-686-pae'
make: *** [modules] Error 2
user@CMP-0179:/usr/realtime-3.4-9-rtai-686-pae/modules/linuxcnc$


How do I get around the header files and the source tree stuff? Can the local files simply be put in the normal include directory?
Last edit: 05 Jun 2017 16:49 by JR1050.

Please Log in or Create an account to join the conversation.

More
05 Jun 2017 17:15 #94109 by Bertho
Replied by Bertho on topic compiling a driver
...got bitten by captcha...

Can you try adding --userspace? This is not a kernel module but a userspace module.

I cannot compile using halcompile because i have not installed the kernel headers (and my kernel is not a deb package). It is often an all-or-nothing proposition this compile this stuff.

Anyway, since you are running a recent git version, you may go with a binary, which I can supply, if all else fails.

Please Log in or Create an account to join the conversation.

More
05 Jun 2017 17:21 - 05 Jun 2017 17:25 #94110 by JR1050
Replied by JR1050 on topic compiling a driver
That didnt work either :(

user@CMP-0179:/usr/realtime-3.4-9-rtai-686-pae/modules/linuxcnc$ halcompile --compile hm2_rpspi.c --userspace
make KBUILD_EXTRA_SYMBOLS=/usr/realtime-3.4-9-rtai-686-pae/modules/linuxcnc/Module.symvers -C /usr/src/linux-headers-3.4-9-rtai-686-pae SUBDIRS=`pwd` CC=gcc V=0 modules
make[1]: Entering directory `/usr/src/linux-headers-3.4-9-rtai-686-pae'
CC [M] /tmp/tmpndLI0M/hm2_rpspi.o
/tmp/tmpndLI0M/hm2_rpspi.c:23:19: fatal error: ctype.h: No such file or directory
compilation terminated.
make[4]: *** [/tmp/tmpndLI0M/hm2_rpspi.o] Error 1
make[3]: *** [_module_/tmp/tmpndLI0M] Error 2
make[2]: *** [sub-make] Error 2
make[1]: *** [all] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-3.4-9-rtai-686-pae'
make: *** [modules] Error 2
user@CMP-0179:/usr/realtime-3.4-9-rtai-686-pae/modules/linuxcnc$

binary, as in precompiled?
Last edit: 05 Jun 2017 17:25 by JR1050.

Please Log in or Create an account to join the conversation.

More
05 Jun 2017 17:28 #94111 by Bertho
Replied by Bertho on topic compiling a driver
No, compiled as in, I attach a binary compiled in my RPI3. See attachment. It goes into the rtlib from the linuxcnc install (you may have to look for its exact filesystem location). Copy the old module to something like hm2_rpspi.so.orig and ungzip/move the new one in place. Then you can test. Let me know if that works.

File Attachment:

File Name: hm2_rpspi.so.gz
File Size:27 KB
Attachments:

Please Log in or Create an account to join the conversation.

More
05 Jun 2017 19:50 #94120 by JR1050
Replied by JR1050 on topic compiling a driver
I got the driver copied to the modules directory successfully. Lcnc errors with a cant find the clock frequency( see attachment)
I added the spiclock lines to the ini and hal, and it seems it doesn't like it. Consider:

# load low-level driver
loadrt hm2_rpspi config="num_encoders=1 num_pwmgens=0 num_stepgens=2 sserial_port_0=001xxx"spiclk_rate=[HOSTMOT2]SPICLK

it doesn't seem to matter where the clockrate goes.Im suspecting syntax with the driver load command. How is this supposed to look?

File Attachment:

File Name: errors_2017-06-05.txt
File Size:5 KB
Attachments:

Please Log in or Create an account to join the conversation.

Time to create page: 0.086 seconds
Powered by Kunena Forum