mesa 5i20 anything IO card plus temperature control

480 views
Skip to first unread message

Bas de Bruijn

unread,
Aug 18, 2014, 11:44:37 AM8/18/14
to machi...@googlegroups.com
Hi guys,

5+ years ago I bought a mesa 5i20 anything I/O card. I’d like to use it sometimes, but for my printing I need analog inputs for temperature. What would be the easiest way (I have no need of real time temperature control) to get the temperature measurement into Machinekit with this set-up?

I was planning to have a charge pump for the heater (as I want to build for the BBB) so I already bought an arduino pro mini. Reading the mesa card firmware it has an watchdog, so maybe I don’t need the arduino for a charge pump after all. I could use it for off-loading the temperature control to the arduino.

What would be the best way to get the temperature and heater controlled? setting RS323 communication with the arduino and PC? PWM 5i20 output? and then reading an “on-temperature” output of the arduino with an input on the 5i20?
Any thoughts/pitfalls/recommendations on this?

Thanks in advance,
Bas

Andy Pugh

unread,
Aug 18, 2014, 11:53:24 AM8/18/14
to Bas de Bruijn, machi...@googlegroups.com


> On 18 Aug 2014, at 16:44, Bas de Bruijn <b...@basdebruijn.com> wrote:
>
> What would be the best way to get the temperature and heater controlled?

Possibly one of the Mesa SPI firmwares (7i65 for example) and
http://m.rs-online.com/h5/mobile/uk/catalog?url=%2Fweb%2Fp%2Ftemperature-humidity-sensors%2F7833882%2F


Bas de Bruijn

unread,
Aug 18, 2014, 3:13:34 PM8/18/14
to Andy Pugh, machi...@googlegroups.com
interesting. 

Ive come by a thread on the linuxcnc forum pointing to the serport component. It seems this would be a little bit overkill. Maybe there is another component which can read the (async) serial data? If not, how hard would it be to write a hal component which manages /CS, SO and a clock signal? Then any ADC converter which can be read serial could be used. something like this.

Came by a mesa_uart component, maybe simple in communication with an arduino.

This application had no high speed or super accurate requirements.



--
website: http://www.machinekit.io blog: http://blog.machinekit.io github: https://github.com/machinekit
---
You received this message because you are subscribed to the Google Groups "Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to machinekit+...@googlegroups.com.
Visit this group at http://groups.google.com/group/machinekit.
For more options, visit https://groups.google.com/d/optout.

andy pugh

unread,
Aug 18, 2014, 5:34:28 PM8/18/14
to Bas de Bruijn, machi...@googlegroups.com
On 18 August 2014 20:13, Bas de Bruijn <b...@basdebruijn.com> wrote:

> Came by a mesa_uart component, maybe simple in communication with an
> arduino.

I have used the Mesa UART (running at 1Mb) to communicate between a
5i23 and an Arduino.

I found that the only real difficulty was spotting the beginning and
end of a data frame. All you get is a byte stream.

--
atp
If you can't fix it, you don't own it.
http://www.ifixit.com/Manifesto

Bas de Bruijn

unread,
Aug 18, 2014, 5:43:50 PM8/18/14
to andy pugh, machi...@googlegroups.com


> On 18 aug. 2014, at 23:34, andy pugh <bodg...@gmail.com> wrote:
>
>> On 18 August 2014 20:13, Bas de Bruijn <b...@basdebruijn.com> wrote:
>>
>> Came by a mesa_uart component, maybe simple in communication with an
>> arduino.
>
> I have used the Mesa UART (running at 1Mb) to communicate between a
> 5i23 and an Arduino.
>
> I found that the only real difficulty was spotting the beginning and
> end of a data frame. All you get is a byte stream.

Would it be easy to have this component on the 5i20? If I understood correctly the component will need some of the gpio for this like on the 5i23.

>
> --
> atp
> If you can't fix it, you don't own it.
> http://www.ifixit.com/Manifesto
>

andy pugh

unread,
Aug 18, 2014, 5:55:37 PM8/18/14
to Bas de Bruijn, machi...@googlegroups.com
On 18 August 2014 22:43, Bas de Bruijn <b...@basdebruijn.com> wrote:

> Would it be easy to have this component on the 5i20? If I understood correctly the component will need some of the gpio for this like on the 5i23.

It's a firmware thing. If your 5i20 firmware has a UART in it, then
you get access to the UART.

Slightly messed-up docs are here, though they don't say much and there
is a spurious GPIO header
http://www.linuxcnc.org/docs/html/man/man9/hostmot2.9.html#BSPI

(I linked to the BSPI rather than the UART, you will see why)

You need to write a comp to access the UART data, the hostmot2 driver
provides a function that gives you access to the UART by name.
I thought that the functions were linked in the html docs, but it
appears not. man hm2_uart_setup should tell you what you need to know.

An example file exists in src/hal/drivers/mesa_uart.comp

Bas de Bruijn

unread,
Aug 19, 2014, 11:13:25 AM8/19/14
to andy pugh, machi...@googlegroups.com

On 18 Aug 2014, at 23:55, andy pugh <bodg...@gmail.com> wrote:

> On 18 August 2014 22:43, Bas de Bruijn <b...@basdebruijn.com> wrote:
>
>> Would it be easy to have this component on the 5i20? If I understood correctly the component will need some of the gpio for this like on the 5i23.
>
> It's a firmware thing. If your 5i20 firmware has a UART in it, then
> you get access to the UART.

How can I find out if firmwares have the bspi/uart functionality? http://linuxcnc.org/docs/html/drivers/hostmot2.html#_configurations does not talk about this. Any other source (other than digging thru the mesa source codes) available?

> Slightly messed-up docs are here, though they don't say much and there
> is a spurious GPIO header
> http://www.linuxcnc.org/docs/html/man/man9/hostmot2.9.html#BSPI
>
> (I linked to the BSPI rather than the UART, you will see why)

reading hostmot2.c I’m understanding that the BSPI doesn’t need an external component? did you mean that?
I need to figure out how to instal the hm2_* manuals. I’ve got a bare debian installation with only machinekit built. The synaptics package manager does not find the packages.

andy pugh

unread,
Aug 19, 2014, 11:24:35 AM8/19/14
to Bas de Bruijn, machi...@googlegroups.com
On 19 August 2014 16:13, Bas de Bruijn <b...@basdebruijn.com> wrote:

> reading hostmot2.c I’m understanding that the BSPI doesn’t need an external component? did you mean that?

No, both BSPI and UART need you to write a driver to use them. This
driver just needs to package and unwrap the data transmitted to put it
on HAL pins as needed and to configure things like baud rate and
timings.

> I need to figure out how to instal the hm2_* manuals. I’ve got a bare debian installation with only machinekit built. The synaptics package manager does not find the packages.

I have no idea what is installed by default with Machinekit.

Bas de Bruijn

unread,
Aug 19, 2014, 4:20:56 PM8/19/14
to andy pugh, machi...@googlegroups.com

On 19 Aug 2014, at 17:24, andy pugh <bodg...@gmail.com> wrote:

> On 19 August 2014 16:13, Bas de Bruijn <b...@basdebruijn.com> wrote:
>
>> reading hostmot2.c I’m understanding that the BSPI doesn’t need an external component? did you mean that?
>
> No, both BSPI and UART need you to write a driver to use them. This
> driver just needs to package and unwrap the data transmitted to put it
> on HAL pins as needed and to configure things like baud rate and
> timings.
>
>> I need to figure out how to instal the hm2_* manuals. I’ve got a bare debian installation with only machinekit built. The synaptics package manager does not find the packages.

I installed the packages of the firmwares, and they are in /lib/firmware/hm2/ I’ve been looking into them so that’s ok for now.
I also installed the linuxcnc wheezy live cd on a VM to have as a reference when I’m stuck in my search :) (I can’t find the documentation of the hm_* that are mentioned in http://www.linuxcnc.org/docs/html/man/man9/hostmot2.9.html#BSPI on the live cd also)

could you tell me if/which “standard" firmware for the 5i23 you actually used? or did you compile your own?

then deducing if I understand correctly:
reading UART/BSPI needs:

uart wires (physical) -> mesa card -> “dedicated" pin number (these pins are not available to HAL anymore) -> hostmot2 hal component -> special component which gathers the data from the hostmot2 component-> hal uart/bspi pins

Thanks
Bas

andy pugh

unread,
Aug 19, 2014, 6:15:08 PM8/19/14
to Bas de Bruijn, machi...@googlegroups.com
On 19 August 2014 21:20, Bas de Bruijn <b...@basdebruijn.com> wrote:
> I also installed the linuxcnc wheezy live cd on a VM to have as a reference when I’m stuck in my search :) (I can’t find the documentation of the hm_* that are mentioned in http://www.linuxcnc.org/docs/html/man/man9/hostmot2.9.html#BSPI on the live cd also)

The manpages exist, I am not sure what is missing. (They work on my system)
https://github.com/machinekit/machinekit/tree/master/docs/man/man3

Bas de Bruijn

unread,
Aug 20, 2014, 6:30:48 AM8/20/14
to andy pugh, machi...@googlegroups.com

On 20 Aug 2014, at 00:14, andy pugh <bodg...@gmail.com> wrote:

> On 19 August 2014 21:20, Bas de Bruijn <b...@basdebruijn.com> wrote:
>> I also installed the linuxcnc wheezy live cd on a VM to have as a reference when I’m stuck in my search :) (I can’t find the documentation of the hm_* that are mentioned in http://www.linuxcnc.org/docs/html/man/man9/hostmot2.9.html#BSPI on the live cd also)
>
> The manpages exist, I am not sure what is missing. (They work on my system)
> https://github.com/machinekit/machinekit/tree/master/docs/man/man3

Andy,

reading thru the docs and frequently encountering your name you are kind of an expert when it comes to this. http://wiki.linuxcnc.org/cgi-bin/wiki.pl?SPI_Sub-Driver_For_Hostmot2
I have to dive into the documentation and follow the mesa_7i65.comp example you wrote (although I plan to use just 1 ADC for now) etc.

but before I start experimenting I think I need to find out if/how the firmware of my 5i20 card can handle this. Would the linuxcnc list/forum regarding the 5i20 firmware be a more suitable place?

andy pugh

unread,
Aug 20, 2014, 7:22:56 AM8/20/14
to Bas de Bruijn, machi...@googlegroups.com
On 20 August 2014 11:30, Bas de Bruijn <b...@basdebruijn.com> wrote:
> but before I start experimenting I think I need to find out if/how the firmware of my 5i20 card can handle this.

If you can find a 5i20 firmware for the 5i20 + 7i65 then you could
experiment. For your actual application you probably need to make a
custom firmware.
(This isn't particularly difficult, and I have actually _almost_ got
an Amazon EC2 with all the required parts.)

Bas de Bruijn

unread,
Aug 20, 2014, 7:06:41 PM8/20/14
to andy pugh, machi...@googlegroups.com

On 20 Aug 2014, at 13:22, andy pugh <bodg...@gmail.com> wrote:

> On 20 August 2014 11:30, Bas de Bruijn <b...@basdebruijn.com> wrote:
>> but before I start experimenting I think I need to find out if/how the firmware of my 5i20 card can handle this.
>
> If you can find a 5i20 firmware for the 5i20 + 7i65 then you could
> experiment. For your actual application you probably need to make a
> custom firmware.

wow, I’d thought I’d install the Xilinx ISE 9.2 in the wheezy VM, but although I understood it was for linux and windows platforms I couldn’t get it to work. So I ended up with installation on the Win7 VM.
I’ll investigate further tomorrow. I’ve taken this http://linuxcnc.org/lucid/index.php/english/forum/27-driver-boards/24429-mesa-5i20-smart-serial-supporting-firmware?start=10 as a guide for now.

> (This isn't particularly difficult, and I have actually _almost_ got
> an Amazon EC2 with all the required parts.)
>
>
> --
> atp
> If you can't fix it, you don't own it.
> http://www.ifixit.com/Manifesto
>

andy pugh

unread,
Aug 20, 2014, 9:26:17 PM8/20/14
to Bas de Bruijn, machi...@googlegroups.com
On 21 August 2014 00:06, Bas de Bruijn <b...@basdebruijn.com> wrote:

> wow, I’d thought I’d install the Xilinx ISE 9.2 in the wheezy VM, but although I understood it was for linux and windows platforms I couldn’t get it to work. So I ended up with installation on the Win7 VM.

FWIW I have a Ubuntu VM that has everything required, I wonder if I
can send you that? It is for VMWare Fusion on the Mac, though.

I was going to make a UART + BSPI bitfile for the 5i20 for you with
that VM, but in a rather baffling way it seems to be trying to make it
for the 7i43 despite not being told to. I may try again tomorrow when
it isn't so late.

Bas de Bruijn

unread,
Aug 21, 2014, 8:18:19 AM8/21/14
to andy pugh, machi...@googlegroups.com
On 21 Aug 2014, at 03:25, andy pugh <bodg...@gmail.com> wrote:

On 21 August 2014 00:06, Bas de Bruijn <b...@basdebruijn.com> wrote:

wow, I’d thought I’d install the Xilinx ISE 9.2 in the wheezy VM, but although I understood it was for linux and windows platforms I couldn’t get it to work. So I ended up with installation on the Win7 VM.

FWIW I have a Ubuntu VM that has everything required, I wonder if I
can send you that? It is for VMWare Fusion on the Mac, though.

I was going to make a UART + BSPI bitfile for the 5i20 for you with
that VM, but in a rather baffling way it seems to be trying to make it
for the 7i43 despite not being told to. I may try again tomorrow when
it isn't so late.

I got the files from the forum thread of the 5i20 mesanet.com/software/parallel/5i20.zip and first thing it did when I opened the fivei20 project file was complaining about missing files :).
This morning I read up on VHDL a little bit and I think I now understand better what is needed/happening.
Basically the project should contain the logic (modules as in electrical schematics) and the pin layout which maps the pins to the “wires” of the modules.

My PIN file then is a combination of (mostly) different mesa cards, bit in my situation I would take a standard 4 encoder 8 stepper pin file and combine that with the BSPI pins needed like:
IOPortTag & x"00" & BSPITag & BSPIFramePin, -- I/O 38
IOPortTag & x"00" & BSPITag & BSPIOutPin, -- I/O 39
IOPortTag & x"00" & BSPITag & BSPIClkPin, -- I/O 40
IOPortTag & x"00" & BSPITag & BSPIInPin, -- I/O 41
IOPortTag & x"00" & BSPITag & BSPICS2Pin, -- I/O 42
IOPortTag & x"00" & BSPITag & BSPICS1Pin, -- I/O 43
IOPortTag & x"00" & BSPITag & BSPICS0Pin, -- I/O 44 

andy pugh

unread,
Aug 21, 2014, 10:29:23 AM8/21/14
to Bas de Bruijn, machi...@googlegroups.com
On 21 August 2014 13:18, Bas de Bruijn <b...@basdebruijn.com> wrote:

> My PIN file then is a combination of (mostly) different mesa cards, bit in
> my situation I would take a standard 4 encoder 8 stepper pin file and
> combine that with the BSPI pins needed like:
> IOPortTag & x"00" & BSPITag & BSPIFramePin, -- I/O 38
> IOPortTag & x"00" & BSPITag & BSPIOutPin, -- I/O 39
> IOPortTag & x"00" & BSPITag & BSPIClkPin, -- I/O 40
> IOPortTag & x"00" & BSPITag & BSPIInPin, -- I/O 41
> IOPortTag & x"00" & BSPITag & BSPICS2Pin, -- I/O 42
> IOPortTag & x"00" & BSPITag & BSPICS1Pin, -- I/O 43
> IOPortTag & x"00" & BSPITag & BSPICS0Pin, -- I/O 44

Pretty much, yes. You may be able to not bother to allocate some CS
pins if you are not intending to connect many devices.
You need to add the BSPI module near the top of the PIN file too.

Bas de Bruijn

unread,
Aug 21, 2014, 5:09:58 PM8/21/14
to andy pugh, machi...@googlegroups.com
ok, done that. The modules are as follows:

package PIN_WL_72 is
constant ModuleID : ModuleIDType :=(
(WatchDogTag, x"00", ClockLowTag, x"01", WatchDogTimeAddr&PadT, WatchDogNumRegs, x"00", WatchDogMPBitMask),
(IOPortTag, x"00", ClockLowTag, x"03", PortAddr&PadT, IOPortNumRegs, x"00", IOPortMPBitMask),
(StepGenTag, x"02", ClockLowTag, x"08", StepGenRateAddr&PadT, StepGenNumRegs, x"00", StepGenMPBitMask),
(BSPITag, x"00", ClockLowTag, x"01", BSPIDataAddr&PadT, BSPINumRegs, x"11", BSPIMPBitMask),
(PWMTag, x"00", ClockHighTag, x"03", PWMValAddr&PadT, PWMNumRegs, x"00", PWMMPBitMask),
(LEDTag, x"00", ClockLowTag, x"01", LEDAddr&PadT, LEDNumRegs, x"00", LEDMPBitMask),

I understand the x”0..” after ClockLowTag, thats the number of instances.
What do the first x”0..” and the last one mean?

When I omitted the CS* pins I got an ERROR:Xst:2683 - Unexpected error found while building hierarchy.
so after I added the pins everything went OK. Thinking now I realise I perhaps should have left at least the CS0 pin in the file.

Now when I run "generate programming file" the Top9030HostMot2.bit file gets generated if I understand correctly.
Is there a problem with manually renaming the file to “myfirmwarename” or do I need to do some other nifty thing?

Bas

andy pugh

unread,
Aug 21, 2014, 5:52:34 PM8/21/14
to Bas de Bruijn, machi...@googlegroups.com
On 21 August 2014 22:09, Bas de Bruijn <b...@basdebruijn.com> wrote:

> Now when I run "generate programming file" the Top9030HostMot2.bit file gets
> generated if I understand correctly.

Pass. I think you need input from PCW, possibly via the LinuxCNC forum.

Bas de Bruijn

unread,
Aug 22, 2014, 6:37:32 AM8/22/14
to andy pugh, machi...@googlegroups.com

On 21 Aug 2014, at 23:52, andy pugh <bodg...@gmail.com> wrote:

> On 21 August 2014 22:09, Bas de Bruijn <b...@basdebruijn.com> wrote:
>
>> Now when I run "generate programming file" the Top9030HostMot2.bit file gets
>> generated if I understand correctly.
>
> Pass. I think you need input from PCW, possibly via the LinuxCNC forum.

Here’s the thread.
http://linuxcnc.org/lucid/index.php/english/forum/27-driver-boards/28259-final-stages-of-custom-firmware-for-5i20-card

Bas de Bruijn

unread,
Aug 22, 2014, 6:36:44 PM8/22/14
to machi...@googlegroups.com, bodg...@gmail.com
Hi Andy,

so far the compilation of the firmware went OK and Machinekit loads my firmware.

Now I try to load the mesa_7i65 component in the .hal file, but it's not standard in the Machinekit binaries, so I downloaded the ggithub repo, compiled and came to the conslusion it's not there! oh no! arhg!
Igoogled 1 minute later and found this https://github.com/araisrobo/linuxcnc/blob/master/src/hal/drivers/mesa_7i65.comp

I put this file in ~/machinekit/scr/hal/components and rebuilt

compiling did not go ok, I got the messages

make[1]: *** No rule to make target `objects/posix/halcomp-srcs/hal/components/mesa_7i65.o', needed by `../rtlib/posix/mesa_7i65.so'.  Stop.
make[1]: Leaving directory `/home/machinekit/machinekit/src'

Making modules for flavor xenomai
make
[1]: Entering directory `/home/machinekit/machinekit/src'
hal/components/Submakefile:40: warning: overriding commands for target `
../docs/man/man9/mesa_7i65.9'
hal/components/Submakefile:35: warning: ignoring old commands for target `../docs/man/man9/mesa_7i65.9'


and a little bit further on

make[1]: *** No rule to make target `objects/xenomai/halcomp-srcs/hal/components/mesa_7i65.o', needed by `../rtlib/xenomai/mesa_7i65.so'.  Stop.

which quits the build.

I've played around with the ../ in this line, and even copied the hostmot2.h file to the /src/hal/components directory. to no avail. So I guess it's something else.
include "../../../hal/drivers/mesa-hostmot2/hostmot2.h";

I've been running thru the code but can't come up with a solution to compile this component. Any thoughts where I could search further?
Thanks,
Bas





andy pugh

unread,
Aug 22, 2014, 6:59:32 PM8/22/14
to Bas de Bruijn, machi...@googlegroups.com
On 22 August 2014 23:36, Bas de Bruijn <b...@basdebruijn.com> wrote:

> so I downloaded the ggithub repo,
> compiled and came to the conslusion it's not there! oh no! arhg!

It is a comp, so you should be able to sudo comp --install it
(or halcompile it, if you are in LinuxCNC 2.6+)

Bas de Bruijn

unread,
Aug 22, 2014, 7:50:11 PM8/22/14
to machi...@googlegroups.com, b...@basdebruijn.com


On Saturday, August 23, 2014 12:59:32 AM UTC+2, andy pugh wrote:
On 22 August 2014 23:36, Bas de Bruijn wrote:

> so I downloaded the ggithub repo,
> compiled and came to the conslusion it's not there! oh no! arhg!

It is a comp, so you should be able to sudo comp --install it
(or halcompile it, if you are in LinuxCNC 2.6+)

machinekit@debianXW6600:~$ sudo comp --install ./machinekit/src/hal/components/mesa_7i65.comp
sudo
: comp: command not found
machinekit@debianXW6600
:~$ halcompile
bash
: halcompile: command not found

btw, I have first got the binaries as per the http://www.machinekit.io/docs/packages-debian/, and then later downloaded and compiled the machinekit source.

that's strange, $sudo comp --install always worked on my BBB.
That means I need to find/locate the linuxcnc-dev package ?

(but I'll do that tomorrow)

Bas


andy pugh

unread,
Aug 22, 2014, 8:17:53 PM8/22/14
to Bas de Bruijn, machi...@googlegroups.com
On 23 August 2014 00:50, Bas de Bruijn <b...@basdebruijn.com> wrote:

> that's strange, $sudo comp --install always worked on my BBB.
> That means I need to find/locate the linuxcnc-dev package ?

Probably, but I confess to being completely blank where Machinekit is
concerned.

Bas de Bruijn

unread,
Aug 22, 2014, 8:27:41 PM8/22/14
to machi...@googlegroups.com, b...@basdebruijn.com, bodg...@gmail.com

On Saturday, August 23, 2014 2:17:53 AM UTC+2, andy pugh wrote:
On 23 August 2014 00:50, Bas de Bruijn wrote:

> that's strange, $sudo comp --install always worked on my BBB.
> That means I need to find/locate the linuxcnc-dev package ?

Probably, but I confess to being completely blank where Machinekit is
concerned.

I removed the binaries, recompiled machinekit and did:
$ sudo comp --install ./blabladirectory/mesa_7i65.comp
sudo
: comp: command not found

then without sudo:
$ comp --install ./blabladirectory/mesa_7i65.comp
Compiling realtime mesa_7i65.c
mesa_7i65
.c:12:47: fatal error: ../drivers/mesa-hostmot2/hostmot2.h: No such file or directory
compilation terminated
.
make
: *** [mesa_7i65.o] Error 1

now I'm really going to bed :)
Thanks so far Andy!

Bas de Bruijn

unread,
Aug 22, 2014, 8:45:38 PM8/22/14
to machi...@googlegroups.com, b...@basdebruijn.com, bodg...@gmail.com


On Saturday, August 23, 2014 2:27:41 AM UTC+2, Bas de Bruijn wrote:

On Saturday, August 23, 2014 2:17:53 AM UTC+2, andy pugh wrote:
On 23 August 2014 00:50, Bas de Bruijn wrote:

> that's strange, $sudo comp --install always worked on my BBB.
> That means I need to find/locate the linuxcnc-dev package ?

Probably, but I confess to being completely blank where Machinekit is
concerned.

I removed the binaries, recompiled machinekit and did:
$ sudo comp --install ./blabladirectory/mesa_7i65.comp
sudo
: comp: command not found

then without sudo:
$ comp --install ./blabladirectory/mesa_7i65.comp
Compiling realtime mesa_7i65.c
mesa_7i65
.c:12:47: fatal error: ../drivers/mesa-hostmot2/hostmot2.h: No such file or directory
compilation terminated
.
make
: *** [mesa_7i65.o] Error 1

now I'm really going to bed :)

yeah.... not...
turns out rip-environment (or lack thereof) was the reason for the erratic comp, and that in combination with reference to the file location of hostmot2.h

$ ./machinekit/scripts/rip-environment
$ comp
--install ./machinekit/src/hal/components/mesa_7i65.comp
Compiling realtime mesa_7i65.c
Linking mesa_7i65.so
cp mesa_7i65
.so /home/machinekit/machinekit/rtlib/xenomai/

what I had to do was change this line from
#include "../../../drivers/mesa-hostmot2/hostmot2.h";
to
#include "../drivers/mesa-hostmot2/hostmot2.h"

now I can finally go to bed and have nice dreams :)

andy pugh

unread,
Aug 22, 2014, 8:56:19 PM8/22/14
to Bas de Bruijn, machi...@googlegroups.com
On 23 August 2014 01:45, Bas de Bruijn <b...@basdebruijn.com> wrote:

> what I had to do was change this line from
> #include "../../../drivers/mesa-hostmot2/hostmot2.h";
> to
> #include "../drivers/mesa-hostmot2/hostmot2.h"


Yes, it is rather complicated by the fact that when the C-code that
that the pre-processor creates is compiled the C-code is somewhere
other than where the comp file was.

There is a super-sekrit command in comp "include" that can sometimes
help. I ought to see if that is clever enough to do the right thing
(and of not, see if it can be made to be)

Bas de Bruijn

unread,
Aug 22, 2014, 9:14:16 PM8/22/14
to machi...@googlegroups.com, b...@basdebruijn.com, bodg...@gmail.com


On Saturday, August 23, 2014 2:56:19 AM UTC+2, andy pugh wrote:
On 23 August 2014 01:45, Bas de Bruijn wrote:

> what I had to do was change this line from
> #include "../../../drivers/mesa-hostmot2/hostmot2.h";
> to
> #include "../drivers/mesa-hostmot2/hostmot2.h"


Yes, it is rather complicated by the fact that when the C-code that
that the pre-processor creates is compiled the C-code is somewhere
other than where the comp file was.

and that's why I was pulling my hair out because I tried the ../ stuff when compiling the entire code. and still the errors where there even if i added hostmot2.h in the same directory and changed the line to
#include "hostmot2.h";

Bas

andy pugh

unread,
Aug 22, 2014, 9:41:32 PM8/22/14
to Bas de Bruijn, machi...@googlegroups.com
On 23 August 2014 02:14, Bas de Bruijn <b...@basdebruijn.com> wrote:

> and that's why I was pulling my hair out because I tried the ../ stuff when
> compiling the entire code. and still the errors where there even if i added
> hostmot2.h in the same directory and changed the line to
> #include "hostmot2.h";
>

I _think_ that

include hostmot2.h;

_before_ the ;; and with no # works. But some other things are more tricksy.

Bas de Bruijn

unread,
Aug 23, 2014, 9:37:08 AM8/23/14
to machi...@googlegroups.com, b...@basdebruijn.com, bodg...@gmail.com
after installing the component I was able to get this out of the linuxcnc.log

Aug 23 15:19:14 debianXW6600 msgd:0: hal_lib:5723:rt hm2/hm2_5i20.0: IO Pin 048 (P4-01): Buffered SPI Interface #0, pin /Frame (Output)
Aug 23 15:19:14 debianXW6600 msgd:0: hal_lib:5723:rt hm2/hm2_5i20.0: IO Pin 049 (P4-03): Buffered SPI Interface #0, pin Serial Out (Output)
Aug 23 15:19:14 debianXW6600 msgd:0: hal_lib:5723:rt hm2/hm2_5i20.0: IO Pin 050 (P4-05): Buffered SPI Interface #0, pin Clock (Output)
Aug 23 15:19:14 debianXW6600 msgd:0: hal_lib:5723:rt hm2/hm2_5i20.0: IO Pin 051 (P4-07): Buffered SPI Interface #0, pin Serial In (Input)
Aug 23 15:19:14 debianXW6600 msgd:0: hal_lib:5723:rt hm2/hm2_5i20.0: IO Pin 052 (P4-09): Buffered SPI Interface #0, pin CS2 (Output)
Aug 23 15:19:14 debianXW6600 msgd:0: hal_lib:5723:rt hm2/hm2_5i20.0: IO Pin 053 (P4-11): Buffered SPI Interface #0, pin CS1 (Output)
Aug 23 15:19:14 debianXW6600 msgd:0: hal_lib:5723:rt hm2/hm2_5i20.0: IO Pin 054 (P4-13): Buffered SPI Interface #0, pin CS0 (Output)



On Saturday, August 23, 2014 3:41:32 AM UTC+2, andy pugh wrote:

andy pugh

unread,
Aug 23, 2014, 10:04:55 AM8/23/14
to Bas de Bruijn, machi...@googlegroups.com
On 23 August 2014 14:37, Bas de Bruijn <b...@basdebruijn.com> wrote:

> Aug 23 15:19:14 debianXW6600 msgd:0: hal_lib:5723:rt hm2/hm2_5i20.0: IO Pin
> 048 (P4-01): Buffered SPI Interface #0, pin /Frame (Output)
> Aug 23 15:19:14 debianXW6600 msgd:0: hal_lib:5723:rt hm2/hm2_5i20.0: IO Pin
> 049 (P4-03): Buffered SPI Interface #0, pin Serial Out (Output)
> Aug 23 15:19:14 debianXW6600 msgd:0: hal_lib:5723:rt hm2/hm2_5i20.0: IO Pin
> 050 (P4-05): Buffered SPI Interface #0, pin Clock (Output)
> Aug 23 15:19:14 debianXW6600 msgd:0: hal_lib:5723:rt hm2/hm2_5i20.0: IO Pin
> 051 (P4-07): Buffered SPI Interface #0, pin Serial In (Input)
> Aug 23 15:19:14 debianXW6600 msgd:0: hal_lib:5723:rt hm2/hm2_5i20.0: IO Pin
> 052 (P4-09): Buffered SPI Interface #0, pin CS2 (Output)
> Aug 23 15:19:14 debianXW6600 msgd:0: hal_lib:5723:rt hm2/hm2_5i20.0: IO Pin
> 053 (P4-11): Buffered SPI Interface #0, pin CS1 (Output)
> Aug 23 15:19:14 debianXW6600 msgd:0: hal_lib:5723:rt hm2/hm2_5i20.0: IO Pin
> 054 (P4-13): Buffered SPI Interface #0, pin CS0 (Output)

Looks good.

I was actually playing around with the Maxim thermocouple chip
yesterday, with an Arduino.
You probably only need on CS pin, and you don't need the Serial out
pin for that device.

The 7i65 driver is possibly a little too "clever" for these devices,
but it should be a reasonable starting point for how to get a handle
to the BSPI instance in the Hostmot2 driver structure.

Bas de Bruijn

unread,
Aug 23, 2014, 10:26:11 AM8/23/14
to machi...@googlegroups.com, b...@basdebruijn.com, bodg...@gmail.com


On Saturday, August 23, 2014 4:04:55 PM UTC+2, andy pugh wrote:

I have added this line to the hal file
loadrt mesa_7i65 bspi_chans=hm2_5i20.0.bspi.0

and set the debug level to 0x7FFFFFFF in the ini file

there seems to be a configuration error and machinekit won't start. and that's when I enable the line loadrt mesa_7i65 bspi_chans=hm2_5i20.0.bspi.0 in the hal file. with the line commented out machinekit just starts.

any hunches?

hal file
http://pastebin.com/aHbRXTjw

ini file
http://pastebin.com/5bxbktR8

linuxcnc.log
http://pastebin.com/VL2pxpp6

terminal output
http://pastebin.com/QJeH10Mq

dmesg :
[ 5609.967185] milltask[8824]: segfault at 0 ip 000000000043fab3 sp 00007fffd54734b8 error 4 in milltask[400000+62000]

linuxcnc_print.txt
http://pastebin.com/EHxLbZUi



 

andy pugh

unread,
Aug 23, 2014, 10:50:46 AM8/23/14
to Bas de Bruijn, machi...@googlegroups.com
> there seems to be a configuration error and machinekit won't start. and
> that's when I enable the line loadrt mesa_7i65 bspi_chans=hm2_5i20.0.bspi.0
> in the hal file. with the line commented out machinekit just starts.

When developing a new driver it is generally easier to only work with
the minimal set of components. So I generally work from the command
line:

halrun
loadrt hostmot2
loadrt hm2_pci {options}
loadrt {my new driver}

Then if that all seems to work

loadrt threads
addf hm2{tab}r{tab}{space}{tab}
addf hm2{tab}w{tab}{space}{tab}
addf hm2{tab}p{tab}{space}{tab}

start

And see what happens.

The segfault probably means a null pointer, as in the attempt to get a
handle to the BSPI module hasn't worked. (the driver really ought to
check that)

After the segfault you may well need to reboot to untangle the module
dependencies.

Michael Haberler

unread,
Aug 23, 2014, 11:02:09 AM8/23/14
to andy pugh, Bas de Bruijn, machi...@googlegroups.com

Am 23.08.2014 um 16:50 schrieb andy pugh <bodg...@gmail.com>:

> After the segfault you may well need to reboot to untangle the module
> dependencies.

That is required only for legacy kernel thread styles.

Since Bas uses Xenomai user threads, modules are just shared libraries which go away as soon as rtapi_app exits.

The easiest way to debug issues like segfaults is with gdb:

gdb -p `pidof rtapi:0`
continue

and it will stop at the segfault, giving a backtrace and variables.

-m

andy pugh

unread,
Aug 23, 2014, 11:08:16 AM8/23/14
to Michael Haberler, Bas de Bruijn, machi...@googlegroups.com
On 23 August 2014 16:02, Michael Haberler <mai...@mah.priv.at> wrote:

> Since Bas uses Xenomai user threads, modules are just shared libraries which go away as soon as rtapi_app exits.

I wonder if that is the problem? The BSPI driver uses, for example:

EXPORT_SYMBOL_GPL(hm2_tram_add_bspi_frame);

To make the function available to other modules, but possibly _only_
to modules?

Bas de Bruijn

unread,
Aug 23, 2014, 11:16:05 AM8/23/14
to machi...@googlegroups.com, mai...@mah.priv.at, b...@basdebruijn.com, bodg...@gmail.com


On Saturday, August 23, 2014 5:08:16 PM UTC+2, andy pugh wrote:
On 23 August 2014 16:02, Michael Haberler wrote:

> Since Bas uses Xenomai user threads, modules are just shared libraries which go away as soon as rtapi_app exits.

I wonder if that is the problem? The BSPI driver uses, for example:

EXPORT_SYMBOL_GPL(hm2_tram_add_bspi_frame);

To make the function available to other modules, but possibly _only_
to modules?

running gdp as per Michaels suggestion got me:
Illegal process-id: pidof rtapi:0.
(gdb) continue
The program is not being run.

this made me aware of the following in the terminal output
emcTaskOnce: extract(task_instance): KeyError: ('task',)

emcTaskOnce
: no Python Task() instance available, using default iocontrol-based task methods
usrmotintf
: ERROR: rtapi init failed
emcMotionInit
: ini_hal_init fail
/home/machinekit/machinekit/bin/milltask (pid 4950) died on signal 11, backtrace stored in /tmp/backtrace.4950

/tmp/backtrace.4950 holds:
stack trace for /home/machinekit/machinekit/bin/milltask pid=4950 signal=11
ptrace
: Operation not permitted.
/home/machinekit/linuxcnc/configs/by_interface.mesa.hm2-stepper/4950: No such file or directory.
No thread selected
No stack.

Bas
 

Bas de Bruijn

unread,
Aug 23, 2014, 11:21:21 AM8/23/14
to machi...@googlegroups.com, Michael Haberler, bodg...@gmail.com

Bas de Bruijn

unread,
Aug 23, 2014, 11:46:13 AM8/23/14
to machi...@googlegroups.com, Michael Haberler, bodg...@gmail.com

Michael Haberler

unread,
Aug 23, 2014, 11:48:54 AM8/23/14
to Bas de Bruijn, machi...@googlegroups.com, bodg...@gmail.com

Am 23.08.2014 um 17:21 schrieb Bas de Bruijn <b...@basdebruijn.com>:

>
> On 23 Aug 2014, at 17:16, Bas de Bruijn <b...@basdebruijn.com> wrote:
>
>>
>>
>> On Saturday, August 23, 2014 5:08:16 PM UTC+2, andy pugh wrote:
>> On 23 August 2014 16:02, Michael Haberler wrote:
>>
>> > Since Bas uses Xenomai user threads, modules are just shared libraries which go away as soon as rtapi_app exits.
>>
>> I wonder if that is the problem? The BSPI driver uses, for example:
>>
>> EXPORT_SYMBOL_GPL(hm2_tram_add_bspi_frame);
>>
>> To make the function available to other modules, but possibly _only_
>> to modules?
>>
>> running gdp as per Michaels suggestion got me:
>> Illegal process-id: pidof rtapi:0.

you can debug issues in RT only as long as RT is running (meaning the rtapi_app and rtapi_msgd processes, which show up in ps as rtapi:0 and msgd:0) .

If one of those already died, gdb naturally cannot attach to a dead process. However, the log should note the fact of the problem and where a core file was written.

example (I killed rtapi:0 on purpose with a segfault signal - 'kill -11 `pidof rtapi:0`' as root since RT runs with elevated privilegs):

Aug 23 17:38:31 amd64 msgd:0: rtapi_app:12894:user signal 11 - 'Segmentation fault' received, dumping core (current dir=/home/mah/machinekit)

So there is a core file which you can do post-mortem analysis with gdb on, the stacktrace should tell where the error occurred (in this case in the main loop since rtapi_app was waiting for RTAPI commands at that time; in the case of a faulty RT component it will show where the segfault occurred in the component):


sudo gdb libexec/rtapi_app_xenomai /home/mah/machinekit/core # (or wherever that core was dropped)

GNU gdb (GDB) 7.4.1-debian
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/mah/machinekit/libexec/rtapi_app_xenomai...done.

warning: core file may not match specified executable file.
[New LWP 12894]
[New LWP 12895]
[New LWP 12896]

warning: Can't read pathname for load map: Input/output error.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `rtapi:0 '.
Program terminated with signal 11, Segmentation fault.
#0 0x00007fcc7b5005c3 in *__GI___poll (fds=<optimized out>, nfds=<optimized out>, timeout=1000) at ../sysdeps/unix/sysv/linux/poll.c:87
87 ../sysdeps/unix/sysv/linux/poll.c: No such file or directory.
(gdb) backtrace
#0 0x00007fcc7b5005c3 in *__GI___poll (fds=<optimized out>, nfds=<optimized out>, timeout=1000) at ../sysdeps/unix/sysv/linux/poll.c:87
#1 0x00007fcc7c7c8aea in zmq_poll () from /usr/lib/x86_64-linux-gnu/libzmq.so.3
#2 0x00007fcc7ca3f82c in zloop_start () from /usr/lib/x86_64-linux-gnu/libczmq.so.1
#3 0x0000000000404f78 in main () at rtapi/xenomai/rtapi_app.cc:975
(gdb) q




I'll write up a note on debugging RT issues with gdb.

meanwhile please try the 7i65 patch, and verify it stops bringing down the house - I'll add it then.


- Michael



>> (gdb) continue
>> The program is not being run.
>>
>> this made me aware of the following in the terminal output
>> emcTaskOnce: extract(task_instance): KeyError: ('task',)
>>
>> emcTaskOnce: no Python Task() instance available, using default iocontrol-based task methods
>> usrmotintf: ERROR: rtapi init failed
>> emcMotionInit: ini_hal_init fail
>> /home/machinekit/machinekit/bin/milltask (pid 4950) died on signal 11, backtrace stored in /tmp/backtrace.4950
>>
>> /tmp/backtrace.4950 holds:
>> stack trace for /home/machinekit/machinekit/bin/milltask pid=4950 signal=11
>> ptrace: Operation not permitted.
>> /home/machinekit/linuxcnc/configs/by_interface.mesa.hm2-stepper/4950: No such file or directory.
>> No thread selected
>> No stack.
>>
>
> just got a mail of a reply from PCW on the forum thread.
> http://www.linuxcnc.org/index.php/english/forum/27-driver-boards/28259-final-stages-of-custom-firmware-for-5i20-card/50209
>
> note this recent 7I65 patch:
> psha.org.ru/irc/%23emc-devel/2014-05-09.html#16:36:29
>
>> Bas
>>
>>
>> --
>> atp
>> If you can't fix it, you don't own it.
>> http://www.ifixit.com/Manifesto
>
>

Bas de Bruijn

unread,
Aug 24, 2014, 11:37:28 AM8/24/14
to machi...@googlegroups.com, b...@basdebruijn.com, bodg...@gmail.com, mai...@mah.priv.at


On Saturday, August 23, 2014 5:48:54 PM UTC+2, Michael Haberler wrote:

Am 23.08.2014 um 17:21 schrieb Bas de Bruijn:
 
the 7i65 patch did the trick. Machinekit opens as expected.
attached  screenshot of hal configurator. all pins are there.
Thanks all so far!
Bas

Screenshot from 2014-08-24 17:26:24.png
Reply all
Reply to author
Forward
0 new messages