developing drivers for custom boards

More
09 Aug 2011 19:07 - 09 Aug 2011 19:11 #12351 by andypugh
It just worked fine for me, on a stock install. The errors are there, but it still loads with halrun.
What does dmesg say after your attempted loadrt?
do you see the highlighted line below?

andypugh@ubuntu:~/emc2$ sudo comp --install constant.comp
make -C /usr/src/linux-headers-2.6.32-122-rtai SUBDIRS=`pwd` CC=gcc V=0 -o /Module.symvers modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-122-rtai'
CC [M] /tmp/tmpmKP5S1/constant.o
Building modules, stage 2.
MODPOST 1 modules
WARNING: "hal_init" [/tmp/tmpmKP5S1/constant.ko] undefined!
WARNING: "hal_exit" [/tmp/tmpmKP5S1/constant.ko] undefined!
WARNING: "hal_export_funct" [/tmp/tmpmKP5S1/constant.ko] undefined!
WARNING: "hal_malloc" [/tmp/tmpmKP5S1/constant.ko] undefined!
WARNING: "hal_pin_bit_newf" [/tmp/tmpmKP5S1/constant.ko] undefined!
WARNING: "rtapi_snprintf" [/tmp/tmpmKP5S1/constant.ko] undefined!
WARNING: "hal_ready" [/tmp/tmpmKP5S1/constant.ko] undefined!
WARNING: "hal_pin_u32_newf" [/tmp/tmpmKP5S1/constant.ko] undefined!
WARNING: "rtapi_print" [/tmp/tmpmKP5S1/constant.ko] undefined!
CC /tmp/tmpmKP5S1/constant.mod.o
LD [M] /tmp/tmpmKP5S1/constant.ko
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-122-rtai'
cp constant.ko /usr/realtime-2.6.32-122-rtai/modules/emc2/
andypugh@ubuntu:~/emc2$ halrun
halcmd: loadrt constant ioaddr=0x378
halcmd: show pin
Component Pins:
Owner Type Dir Value Name
3 u32 OUT 0x00000000 constant.0.R0-in
3 u32 OUT 0x00000000 constant.0.R0-out
3 u32 OUT 0x00000000 constant.0.R1-in
3 u32 OUT 0x00000000 constant.0.R1-out
3 u32 OUT 0x00000000 constant.0.R2-in
Last edit: 09 Aug 2011 19:11 by andypugh.

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

More
09 Aug 2011 19:11 #12353 by BigJohnT
andypugh wrote:

This probably isn't the problem, but "constant" is a bad choice of name, as that is a pre-existing hal module.


I just grabbed the example out of the HAL manual... might be a bad example.

John

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

More
09 Aug 2011 19:19 #12354 by btvpimill
well I tried it again, but I cd'd to emc2 directory (I was in configs). Seems to work the same as Andy shows. So I guess I am now back at square 2. :)

Still need to study tonight to figure out how to add the EPP port setup to my comp file. Then maybe I will be able to talk to my card

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

More
10 Aug 2011 10:06 #12372 by btvpimill
Now that I've had a good sleep, and maybe some digestion of all my reading last night, here is my next question.

Does the port set-up refered to by PCW go in the EXTRA_SETUP section? This makes sense to me based on how I understand the comp descripton page. If this is so, would it go like this:
EXTRA_SETUP(){
if (ioaddr[extra_arg] > 0) {
base_addr = ioaddr[extra_arg];
rtapi_print("Loading EPP custom board driver at base addr %X\n", base_addr);

*******************************************************************
INSERT PORT SETUP HERE
******************************************************************

return 0;
}
return -EINVAL;
}
And if not, I just don't understand how to invoke the port setup within the comp file. When I get to work, I am going to compare the .c generated by comp to the examples listed in the first page. Now that I realize they are straight C, it may make more sense.

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

More
10 Aug 2011 10:33 #12373 by andypugh
btvpimill wrote:

Does the port set-up refered to by PCW go in the EXTRA_SETUP section? This makes sense to me based on how I understand the comp descripton page. If this is so, would it go like this:


Yes that is exactly what it is for.

EXTRA_SETUP gets macro-expanded in the generated C-code and is called once per-instance. So if you loadrt 2 of your comp, EXTRA_SETUP will get called twice.
You can use the extra_arg variable to differentiate which instance is being set up. (as your code shows), but in your case, and for your own use, you could use the pre-defined "personality" modparam for the ioaddr and keep things a bit simpler. I have tended not to, so that the modparam name is a little more self-explanatory. I can think of good arguments to switch from "personality" to "cfg" for the pre-defined name too, but it is now too late.

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

More
10 Aug 2011 11:15 #12374 by btvpimill
Oh THANK YOU for that. I have been going nuts trying to figure out WHERE to put the tid-bit of code needed to get the port initalzied.

I don't understand what you mean by this:

but in your case, and for your own use, you could use the pre-defined "personality" modparam for the ioaddr and keep things a bit simpler.


Are you just saying I could have just hardcoded the ioaddr, then I would not need the original part of the extra setup? I would like to keep that part, as I think that is the part of how to specify the address from my hal file. I want to be able to do this so I can use a PCI card instead of the built in port. But maybe that is not what it is doing at all.

If I have this wrong, could you explain that a little bit more for me?

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

More
10 Aug 2011 12:04 #12377 by andypugh
btvpimill wrote:

I don't understand what you mean by this:

but in your case, and for your own use, you could use the pre-defined "personality" modparam for the ioaddr and keep things a bit simpler.

I mean that you could use:

option personality;

and then

loadrt mycomponent personality=0x378

and then just use "personality" everywhere you want the base address instead of ioaddr[extra_arg] and leave out the modparam parsing code at the beginning of the function.

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

More
10 Aug 2011 22:33 #12388 by btvpimill
Well Finally just befor leaving work, I tried this out:
outb(4,base_add+2)

I put this just before the RETURN 0 in the extra setup. Much to my surprize,

IT WORKED!!!!!!!!!!!!!:woohoo: :woohoo:

Now there is much more work to be done, but I think at least for now I have some control over things.

Thanks everyone, I am 1 happy man right now!!

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

More
11 Aug 2011 22:40 #12441 by andypugh
btvpimill wrote:

IT WORKED!!!!!!!!!!!!!:woohoo: :woohoo!


Once you get things working you tend to notice that, actually, it is quite easy if you do the right things in the right order.

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

More
11 Aug 2011 23:10 #12442 by btvpimill
Yes that is very true. And thanks to you guys, I am closer to getting that order right.

The next order of business for me is to finish modifying John's ptest to test all 32 pins. I started to do that today, but must have messed up something. I can change things around in his, for using different io pins, but when I wrote all 64 pins into it, it quit working. More with that tomorrow.

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

Moderators: PCWjmelson
Time to create page: 0.127 seconds
Powered by Kunena Forum