compiling a driver
05 Jun 2017 20:11 - 05 Jun 2017 20:17 #94123
by Bertho
Replied by Bertho on topic compiling a driver
The module apparently loaded, but could not find a 7i90 device. The base clock can apparently not be read on your kernel config (no debug enabled), but the fallback should work
.
Attached a newly compiled version with some more debug messages. Please try run that one so I can see what it is calculating.
BTW, which SPI port are you using? I also see the hm2_7i90 module, but that module is for the parallel port firmwire. The hm2_rpspi module uses SPI exclusively.
(PS, having exam-week next days, replies may be a bit longer in between until friday)
.
Attached a newly compiled version with some more debug messages. Please try run that one so I can see what it is calculating.
BTW, which SPI port are you using? I also see the hm2_7i90 module, but that module is for the parallel port firmwire. The hm2_rpspi module uses SPI exclusively.
(PS, having exam-week next days, replies may be a bit longer in between until friday)
Last edit: 05 Jun 2017 20:17 by Bertho.
Please Log in or Create an account to join the conversation.
05 Jun 2017 20:16 #94124
by andypugh
I think you need a space between config="..." and spiclck_rate=...
Replied by andypugh on topic compiling a 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?[/attachment]
I think you need a space between config="..." and spiclck_rate=...
Please Log in or Create an account to join the conversation.
05 Jun 2017 20:19 #94125
by Bertho
Anyway, there are probably some more things going on.
Replied by Bertho on topic compiling a driver
Good catch! completely missed that.I think you need a space between config="..." and spiclck_rate=...
Anyway, there are probably some more things going on.
Please Log in or Create an account to join the conversation.
06 Jun 2017 12:30 #94149
by JR1050
Replied by JR1050 on topic compiling a driver
Hello there,
The space in the driver lini in hal didnt make any difference...worth a try. I loaded up the new driver and got the same" cant fine the clock rate" error,please see the attached file. Seems like it just isnt seeing the clock rate thru the variable. Can the rate be hard set to 32k in the file and compiled?
The space in the driver lini in hal didnt make any difference...worth a try. I loaded up the new driver and got the same" cant fine the clock rate" error,please see the attached file. Seems like it just isnt seeing the clock rate thru the variable. Can the rate be hard set to 32k in the file and compiled?
Please Log in or Create an account to join the conversation.
06 Jun 2017 12:38 #94151
by JR1050
Replied by JR1050 on topic compiling a driver
clkdiv = F_PERI / hm2->spiclkrate;
If the driver isnt seeing the input from the spiclk_rate, could we be getting divide by zero?
If the driver isnt seeing the input from the spiclk_rate, could we be getting divide by zero?
Please Log in or Create an account to join the conversation.
06 Jun 2017 12:47 #94153
by andypugh
Replied by andypugh on topic compiling a driver
I wonder if this is an ownership problem? A normal compile ends with "sudo make setuid". It is looking like perhaps the rpispi module doesn't have access to /sys/kernel/debug/clk/vpu/clk_rate
I don't know how to do this for an individual file, or even if this really is the problem.
I don't know how to do this for an individual file, or even if this really is the problem.
Please Log in or Create an account to join the conversation.
06 Jun 2017 15:09 #94176
by Bertho
Replied by Bertho on topic compiling a driver
Which version of the source are you using? The line you refer to does not exist (anymore). I think I checked all divisions for div-by-0. The error you get is rather harmless. You will just end up with a wrong (lower) SPI clock frequency (the module uses 400MHz as a fallback value by default). Wrong frequency should be no problem for initial testing purposes.
The files that I changed and are compiled to the .so module are attached:
This is the most recent version (no I have no git fork online, yet).
Access to /sys/kernel/debug/clk/vpu/clk_rate is for root only and you must have debug enabled in the kernel. If you do not run hal as root (actually rtapi_helper and linuxcnc_module_helper), then you end up with this message (normally these are installed setuid).
You can verify the existence and content of the file as root:
$ sudo cat /sys/kernel/debug/clk/vpu/clk_rate
and
$ sudo cat /sys/kernel/debug/clk/clk_summary
I also think that you need to remove the hm2_7i90 module from your config. It is for parallel port only and does not work on the Raspberry Pi. Also, you must have the proper SPI bitfile uploaded to the 7i90 card's FPGA for it to respond to SPI and make the proper SPI connections (MISO, MOSI, SCLK, CE and a GND).
Another thing you should ensure is to disable spidev. Otherwise there will be two systems competing for device access with all kinds of problems that can arise from it. You can use raspi-config to do so. If you have /dev/spidev* devices, then you have the kernel's spi device driver loaded and must unload it.
The files that I changed and are compiled to the .so module are attached:
This is the most recent version (no I have no git fork online, yet).
Access to /sys/kernel/debug/clk/vpu/clk_rate is for root only and you must have debug enabled in the kernel. If you do not run hal as root (actually rtapi_helper and linuxcnc_module_helper), then you end up with this message (normally these are installed setuid).
You can verify the existence and content of the file as root:
$ sudo cat /sys/kernel/debug/clk/vpu/clk_rate
and
$ sudo cat /sys/kernel/debug/clk/clk_summary
I also think that you need to remove the hm2_7i90 module from your config. It is for parallel port only and does not work on the Raspberry Pi. Also, you must have the proper SPI bitfile uploaded to the 7i90 card's FPGA for it to respond to SPI and make the proper SPI connections (MISO, MOSI, SCLK, CE and a GND).
Another thing you should ensure is to disable spidev. Otherwise there will be two systems competing for device access with all kinds of problems that can arise from it. You can use raspi-config to do so. If you have /dev/spidev* devices, then you have the kernel's spi device driver loaded and must unload it.
Please Log in or Create an account to join the conversation.
06 Jun 2017 15:17 #94178
by Bertho
Replied by Bertho on topic compiling a driver
The config line I use in the .hal file:
...
loadrt [HOSTMOT2](DRIVER) config=[HOSTMOT2](CONFIG) spiclk_rate=31250 spiclk_rate_rd=25000 spi_probe=1 spi_pull_miso=2
...
And when I run on my pi, then the message I see are:
...[snip]...
Starting LinuxCNC...
Starting LinuxCNC server program: linuxcncsvr
Loading Real Time OS, RTAPI, and HAL_LIB modules
Starting LinuxCNC IO program: io
Found file(REL): ./hm2-7i90-stepper.hal
Note: Using POSIX realtime
hm2: loading Mesa HostMot2 driver version 0.15
hm2_rpspi: Mapped peripherals from 0x3f200000 (size 0x00016000) to gpio:0x0x75f08000, spi:0x0x75f0c000, aux:0x0x75f1d000
hm2_rpspi: SPI0/CE0 clock rate: 33000000/25000000 Hz, VPU clock rate: 250000000 Hz
hm2_rpspi: SPI0/CE0 write clock rate calculated: 31250000 Hz
hm2_rpspi: SPI0/CE0 read clock rate calculated: 25000000 Hz
hm2_rpspi: SPI0/CE0 Invalid cookie, read: ffffffff ffffffff ffffffff ffffffff
hm2_rpspi: rtapi_app_main: No such device (-19)
./hm2-7i90-stepper.hal:33: waitpid failed /home/pi/linuxcnc-git/bin/rtapi_app hm2_rpspi
./hm2-7i90-stepper.hal:33: /home/pi/linuxcnc-git/bin/rtapi_app exited without becoming ready
./hm2-7i90-stepper.hal:33: insmod for hm2_rpspi failed, returned -1
Shutting down and cleaning up LinuxCNC...
Killing task linuxcncsvr, PID=1546
hm2_rpspi: not loaded
<commandline>:0: exit value: 255
<commandline>:0: rmmod failed, returned -1
hm2: unloading
<commandline>:0: unloadrt failed
Removing HAL_LIB, RTAPI, and Real Time OS modules
[snip]
...
loadrt [HOSTMOT2](DRIVER) config=[HOSTMOT2](CONFIG) spiclk_rate=31250 spiclk_rate_rd=25000 spi_probe=1 spi_pull_miso=2
...
And when I run on my pi, then the message I see are:
...[snip]...
Starting LinuxCNC...
Starting LinuxCNC server program: linuxcncsvr
Loading Real Time OS, RTAPI, and HAL_LIB modules
Starting LinuxCNC IO program: io
Found file(REL): ./hm2-7i90-stepper.hal
Note: Using POSIX realtime
hm2: loading Mesa HostMot2 driver version 0.15
hm2_rpspi: Mapped peripherals from 0x3f200000 (size 0x00016000) to gpio:0x0x75f08000, spi:0x0x75f0c000, aux:0x0x75f1d000
hm2_rpspi: SPI0/CE0 clock rate: 33000000/25000000 Hz, VPU clock rate: 250000000 Hz
hm2_rpspi: SPI0/CE0 write clock rate calculated: 31250000 Hz
hm2_rpspi: SPI0/CE0 read clock rate calculated: 25000000 Hz
hm2_rpspi: SPI0/CE0 Invalid cookie, read: ffffffff ffffffff ffffffff ffffffff
hm2_rpspi: rtapi_app_main: No such device (-19)
./hm2-7i90-stepper.hal:33: waitpid failed /home/pi/linuxcnc-git/bin/rtapi_app hm2_rpspi
./hm2-7i90-stepper.hal:33: /home/pi/linuxcnc-git/bin/rtapi_app exited without becoming ready
./hm2-7i90-stepper.hal:33: insmod for hm2_rpspi failed, returned -1
Shutting down and cleaning up LinuxCNC...
Killing task linuxcncsvr, PID=1546
hm2_rpspi: not loaded
<commandline>:0: exit value: 255
<commandline>:0: rmmod failed, returned -1
hm2: unloading
<commandline>:0: unloadrt failed
Removing HAL_LIB, RTAPI, and Real Time OS modules
[snip]
Please Log in or Create an account to join the conversation.
06 Jun 2017 16:47 #94184
by JR1050
Replied by JR1050 on topic compiling a driver
The source I referred to was from your source on sourceforge:
sourceforge.net/p/emc/mailman/emc-users/...arg.org/#msg35872514
I am presently using the last compiled driver you posted on this thread. The 7i90 has the correct spi bit file, it was working fairly well.
The connections are correct, as this was working.
This is the first ive seen of this---spiclk_rate=31250 spiclk_rate_rd=25000 spi_probe=1 spi_pull_miso=2
can you elaborate on what each one of these parameters does?
i do not have the hm2_7i90 loaded. i will disable spidev, as it is enabled
sourceforge.net/p/emc/mailman/emc-users/...arg.org/#msg35872514
I am presently using the last compiled driver you posted on this thread. The 7i90 has the correct spi bit file, it was working fairly well.
The connections are correct, as this was working.
This is the first ive seen of this---spiclk_rate=31250 spiclk_rate_rd=25000 spi_probe=1 spi_pull_miso=2
can you elaborate on what each one of these parameters does?
i do not have the hm2_7i90 loaded. i will disable spidev, as it is enabled
Please Log in or Create an account to join the conversation.
06 Jun 2017 17:38 #94187
by Bertho
The hm2_rpspi.so module loads initially, but does not get far. Maybe I fouled up and build the wrong one for you. Attached:
This one I build this afternoon (local time) to get the debug messages from lcnc on my rpi. You should be able to get similar messages on your system, which I'd like to see. If you do not get the messages, then there is something very weird or my build-system is not compatible with your installation. Once we get the messages, then we can start to look into details.
BTW, my local system complains about the "wrong cookie" because I have no card connected. If there is a card detected, then this line should get executed:
rtapi_print_msg(MSG_INFO, "hm2_rpspi: SPI%d/CE%d Base: %s.%d", board->spidevid, board->spiceid, base, board->nr);
It should give us the information that the board was detected and read as a 7i90 device.
spiclk_rate_rd= read command clock rate on SPI SCLK (same as write if not specified)
spi_probe= bitfield which SPI/CE combination to probe (1=SPI0/CE0, 2=SPI0/CE1, 4=SPI1/CE0,...)
spi_pull_miso=2 enables pull-up on the MISO line
For all details see updated manpage from post sourceforge.net/p/emc/mailman/message/35877854/
You might want to go for a lower frequency to start with in the first testing (say, 12500), just to make sure that we do not have to look into additional problems.
Where does "hm2/hm2_7i90.0: Smart Serial Firmware Version 43" come from?
Replied by Bertho on topic compiling a driver
Yes, an older version.The source I referred to was from your source on sourceforge:
sourceforge.net/p/emc/mailman/emc-users/...arg.org/#msg35872514
So you are using SPI0/CE0 on the 40-pin connector and you have the proper setup, check. Now we need to see the module's messages stating the SPI frequencies it calculates.I am presently using the last compiled driver you posted on this thread. The 7i90 has the correct spi bit file, it was working fairly well. The connections are correct, as this was working.
The hm2_rpspi.so module loads initially, but does not get far. Maybe I fouled up and build the wrong one for you. Attached:
This one I build this afternoon (local time) to get the debug messages from lcnc on my rpi. You should be able to get similar messages on your system, which I'd like to see. If you do not get the messages, then there is something very weird or my build-system is not compatible with your installation. Once we get the messages, then we can start to look into details.
BTW, my local system complains about the "wrong cookie" because I have no card connected. If there is a card detected, then this line should get executed:
rtapi_print_msg(MSG_INFO, "hm2_rpspi: SPI%d/CE%d Base: %s.%d", board->spidevid, board->spiceid, base, board->nr);
It should give us the information that the board was detected and read as a 7i90 device.
spiclk_rate= write command clock rate on SPI SCLKThis is the first ive seen of this---spiclk_rate=31250 spiclk_rate_rd=25000 spi_probe=1 spi_pull_miso=2
can you elaborate on what each one of these parameters does?
spiclk_rate_rd= read command clock rate on SPI SCLK (same as write if not specified)
spi_probe= bitfield which SPI/CE combination to probe (1=SPI0/CE0, 2=SPI0/CE1, 4=SPI1/CE0,...)
spi_pull_miso=2 enables pull-up on the MISO line
For all details see updated manpage from post sourceforge.net/p/emc/mailman/message/35877854/
You might want to go for a lower frequency to start with in the first testing (say, 12500), just to make sure that we do not have to look into additional problems.
Hm, smart-serial...i do not have the hm2_7i90 loaded. i will disable spidev, as it is enabled
Where does "hm2/hm2_7i90.0: Smart Serial Firmware Version 43" come from?
Please Log in or Create an account to join the conversation.
Time to create page: 0.102 seconds