developing drivers for custom boards
- andypugh
- Offline
- Moderator
- Posts: 23559
- Thank you received: 4858
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
Please Log in or Create an account to join the conversation.
- BigJohnT
- Offline
- Administrator
- Posts: 7330
- Thank you received: 1177
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.
- btvpimill
- Offline
- Elite Member
- Posts: 229
- Thank you received: 3
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.
- btvpimill
- Offline
- Elite Member
- Posts: 229
- Thank you received: 3
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;
}
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
- Posts: 23559
- Thank you received: 4858
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.
- btvpimill
- Offline
- Elite Member
- Posts: 229
- Thank you received: 3
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.
- andypugh
- Offline
- Moderator
- Posts: 23559
- Thank you received: 4858
I mean that you could use: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.
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.
- btvpimill
- Offline
- Elite Member
- Posts: 229
- Thank you received: 3
outb(4,base_add+2)
I put this just before the RETURN 0 in the extra setup. Much to my surprize,
IT WORKED!!!!!!!!!!!!!
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.
- andypugh
- Offline
- Moderator
- Posts: 23559
- Thank you received: 4858
IT WORKED!!!!!!!!!!!!! :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.
- btvpimill
- Offline
- Elite Member
- Posts: 229
- Thank you received: 3
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.