Add kernel-modul uio_netx
- t1m0n
- Offline
- Junior Member
-
- Posts: 34
- Thank you received: 0
I want to run emc with sercos-iii.
I use a Hilscher-PCI-Card: cifx-50.
The required kernel-module uio_netx is integrated in newer kernel version but not in the kernel-version which comes with LiveCD.
I installed LinuxCNC with LiveCD - I use Ubuntu 10.04, Kernel: 2.6.32-122-rtai.
The driver I need calls "uio_netx" and is available by using:
wget "git.kernel.org/?p=linux/kernel/git/stabl...7218992b270a9e01067f" -O drivers/uio/uio_netx.c.
It is imported for the communication. I think it have to run in real-time.
I downloaded the kernel-sources by typing:
apt-get source linux-image-2.6.32-122-rtai
I did some changes in /drivers/uio/Makefile and /drivers/uio/Kconfig
I compiled it but it doesn't work.
modprobe uio_netx doesn't work
If I copy the uio_netx.ko from
/drivers/uio/
or from
/lib/modules/2.6.32.11+drm33.2/kernel/drivers/uio/
to /lib/modules/2.6.32-122-rtai/kernel/drivers/uio/
and try to modprobe uio_netx i get the answer that this module is invalid. (I compiled the Kernel 2 times).
How is the way to install a new kernel modul for installed live-cd?
Have I to use another why? For example using HAL in this step?
I have no idea. Is rtai the problem?
Please Log in or Create an account to join the conversation.
- ArcEye
- Offline
- Junior Member
-
- Posts: 24
- Thank you received: 758
Unless something has changed between you trying it and this morning, what you actually get when you run
apt-get source linux-image-2.6.32-122-rtai
is
Picking 'linux' as source package instead of 'linux-image-2.6.32-122-rtai'
Get: 1 gb.archive.ubuntu.com/ubuntu/ lucid-updates/main linux 2.6.32-41.94
Which means you have compiled an unpatched different linux sources tar from Ubuntu rather than the rtai kernel Linuxcnc used
If you want to try compiling again get magma source tree by running below from /usr/src
cvs -d:pserver:anonymous@cvs.gna.org:/cvs/rtai co magma
and from root of the linux sources run
patch -p 1 < ../magma/base/arch/x86/patches/hal-linux-2.6.32.20-x86-2.7-03.patch
(that seems to be the latest patch)
You will then have to build magma for realtime and build Linuxcnc again against the new kernel.
Alternately - assuming the headers for 2.6.32-122 contain what they should, consider using the Debian module-assistant
This is only one article from searching the web
www.debian-administration.org/articles/640
regards
Please Log in or Create an account to join the conversation.
- t1m0n
- Offline
- Junior Member
-
- Posts: 34
- Thank you received: 0
I use the Linux-Sources without RTAI-Patch, right?
I need the whole source-code with linux, rtai-patch included, right? How?
I try to get the linux-sources with:
apt-get gb.archive.ubuntu.com/ubuntu/ lucid-updates/main linux 2.6.32-41.94
but it doesn't work and on gb.archive.ubuntu.com/ubuntu/ is no path named lucid-updates.
I downloaded magma with
cvs -d:pserver:anonymous@cvs.gna.org:/cvs/rtai co magma
it is in /usr/src/
- But now, I miss the required and correct linux-sources which I have to use.
- what do patch -p 1 < ../magma/base/arch/x86/patches/hal-linux-2.6.32.20-x86-2.7-03.patch
- How I can build magma for realtime and build Linuxcnc again against the new kernel?
Please Log in or Create an account to join the conversation.
- t1m0n
- Offline
- Junior Member
-
- Posts: 34
- Thank you received: 0
Alternately - assuming the headers for 2.6.32-122 contain what they should, consider using the Debian module-assistant
This is only one article from searching the web
www.debian-administration.org/articles/640
regards
Now I try to go another way.
I create a Makefile to compile the module out-of-tree.
Makefile:
obj-m += uio_netx.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
/*
* UIO driver for Hilscher NetX based fieldbus cards (cifX, comX).
* See http://www.hilscher.com for details.
*
* (C) 2007 Hans J. Koch <hjk@hansjkoch.de>
* (C) 2008 Manuel Traut <manut@linutronix.de>
*
* Licensed under GPL version 2 only.
*
*/
#include <linux/device.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <linux/uio_driver.h>
#define PCI_VENDOR_ID_HILSCHER 0x15CF
#define PCI_DEVICE_ID_HILSCHER_NETX 0x0000
#define PCI_DEVICE_ID_HILSCHER_NETPLC 0x0010
#define PCI_SUBDEVICE_ID_NETPLC_RAM 0x0000
#define PCI_SUBDEVICE_ID_NETPLC_FLASH 0x0001
#define PCI_SUBDEVICE_ID_NXSB_PCA 0x3235
#define PCI_SUBDEVICE_ID_NXPCA 0x3335
#define DPM_HOST_INT_EN0 0xfff0
#define DPM_HOST_INT_STAT0 0xffe0
#define DPM_HOST_INT_MASK 0xe600ffff
#define DPM_HOST_INT_GLOBAL_EN 0x80000000
static irqreturn_t netx_handler(int irq, struct uio_info *dev_info)
{
void __iomem *int_enable_reg = dev_info->mem[0].internal_addr
+ DPM_HOST_INT_EN0;
void __iomem *int_status_reg = dev_info->mem[0].internal_addr
+ DPM_HOST_INT_STAT0;
/* Is one of our interrupts enabled and active ? */
if (!(ioread32(int_enable_reg) & ioread32(int_status_reg)
& DPM_HOST_INT_MASK))
return IRQ_NONE;
/* Disable interrupt */
iowrite32(ioread32(int_enable_reg) & ~DPM_HOST_INT_GLOBAL_EN,
int_enable_reg);
return IRQ_HANDLED;
}
static int __devinit netx_pci_probe(struct pci_dev *dev,
const struct pci_device_id *id)
{
struct uio_info *info;
int bar;
info = kzalloc(sizeof(struct uio_info), GFP_KERNEL);
if (!info)
return -ENOMEM;
if (pci_enable_device(dev))
goto out_free;
if (pci_request_regions(dev, "netx"))
goto out_disable;
switch (id->device) {
case PCI_DEVICE_ID_HILSCHER_NETX:
bar = 0;
info->name = "netx";
break;
case PCI_DEVICE_ID_HILSCHER_NETPLC:
bar = 0;
info->name = "netplc";
break;
default:
bar = 2;
info->name = "netx_plx";
}
/* BAR0 or 2 points to the card's dual port memory */
info->mem[0].addr = pci_resource_start(dev, bar);
if (!info->mem[0].addr)
goto out_release;
info->mem[0].internal_addr = ioremap(pci_resource_start(dev, bar),
pci_resource_len(dev, bar));
if (!info->mem[0].internal_addr)
goto out_release;
info->mem[0].size = pci_resource_len(dev, bar);
info->mem[0].memtype = UIO_MEM_PHYS;
info->irq = dev->irq;
info->irq_flags = IRQF_SHARED;
info->handler = netx_handler;
info->version = "0.0.1";
/* Make sure all interrupts are disabled */
iowrite32(0, info->mem[0].internal_addr + DPM_HOST_INT_EN0);
if (uio_register_device(&dev->dev, info))
goto out_unmap;
pci_set_drvdata(dev, info);
dev_info(&dev->dev, "Found %s card, registered UIO device.\n",
info->name);
return 0;
out_unmap:
iounmap(info->mem[0].internal_addr);
out_release:
pci_release_regions(dev);
out_disable:
pci_disable_device(dev);
out_free:
kfree(info);
return -ENODEV;
}
static void netx_pci_remove(struct pci_dev *dev)
{
struct uio_info *info = pci_get_drvdata(dev);
/* Disable all interrupts */
iowrite32(0, info->mem[0].internal_addr + DPM_HOST_INT_EN0);
uio_unregister_device(info);
pci_release_regions(dev);
pci_disable_device(dev);
pci_set_drvdata(dev, NULL);
iounmap(info->mem[0].internal_addr);
kfree(info);
}
static struct pci_device_id netx_pci_ids[] = {
{
.vendor = PCI_VENDOR_ID_HILSCHER,
.device = PCI_DEVICE_ID_HILSCHER_NETX,
.subvendor = 0,
.subdevice = 0,
},
{
.vendor = PCI_VENDOR_ID_HILSCHER,
.device = PCI_DEVICE_ID_HILSCHER_NETPLC,
.subvendor = PCI_VENDOR_ID_HILSCHER,
.subdevice = PCI_SUBDEVICE_ID_NETPLC_RAM,
},
{
.vendor = PCI_VENDOR_ID_HILSCHER,
.device = PCI_DEVICE_ID_HILSCHER_NETPLC,
.subvendor = PCI_VENDOR_ID_HILSCHER,
.subdevice = PCI_SUBDEVICE_ID_NETPLC_FLASH,
},
{
.vendor = PCI_VENDOR_ID_PLX,
.device = PCI_DEVICE_ID_PLX_9030,
.subvendor = PCI_VENDOR_ID_PLX,
.subdevice = PCI_SUBDEVICE_ID_NXSB_PCA,
},
{
.vendor = PCI_VENDOR_ID_PLX,
.device = PCI_DEVICE_ID_PLX_9030,
.subvendor = PCI_VENDOR_ID_PLX,
.subdevice = PCI_SUBDEVICE_ID_NXPCA,
},
{ 0, }
};
static struct pci_driver netx_pci_driver = {
.name = "netx",
.id_table = netx_pci_ids,
.probe = netx_pci_probe,
.remove = netx_pci_remove,
};
static int __init netx_init_module(void)
{
return pci_register_driver(&netx_pci_driver);
}
static void __exit netx_exit_module(void)
{
pci_unregister_driver(&netx_pci_driver);
}
module_init(netx_init_module);
module_exit(netx_exit_module);
MODULE_DEVICE_TABLE(pci, netx_pci_ids);
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Hans J. Koch, Manuel Traut");
Check with lsmod:
Module Size Used by
uio_netx 1879 0
Now, my question is:
does it work with linuxcnc now?
What have I to do to run it?
Something with HAL, right?
Please Log in or Create an account to join the conversation.
- ArcEye
- Offline
- Junior Member
-
- Posts: 24
- Thank you received: 758
It will enable your card to be seen and read and written to presumably, but as for whether it is possible to use it with Linuxcnc, that is another question.
Post your output from lspci -vv that relates to the card (assuming it is PCI?) and any link you have to the vendors information and hopefully one of the card boffins will be able to give you an answer
See also
www.mailinglistarchive.com/html/emc-user...011-02/msg00271.html
www.digipedia.pl/usenet/thread/18400/2133/
comments.gmane.org/gmane.linux.distributions.emc.user/11049
old.linuxcnc.org/component/option,com_ku...,10/id,3005/lang,en/
This product appears to have been discussed before
regards
Please Log in or Create an account to join the conversation.
- t1m0n
- Offline
- Junior Member
-
- Posts: 34
- Thank you received: 0
After reboot a have a new problem.
The Module is not loaded.
I try to reload it with insmod.
insmod: error inserting 'uio_netx.ko': -l Unknown symbol in module.
I start
make
it runs but insmod send the same message.
dmesg | tail:
....
[ 1059.539830] uio_netx: Unknown symbol -_uio_register_device
[ 1059.540093] uio_netx: Unknown symbol uio_unregister_device
But if I try to test a sample from www.cyberciti.biz/tips/build-linux-kerne...nel-source-tree.html
It works.
When you have this problem you have to do:
sudo modprobe uio
to load uio first!
Please Log in or Create an account to join the conversation.
- t1m0n
- Offline
- Junior Member
-
- Posts: 34
- Thank you received: 0
:/usr/src/linux-2.3.6.32$ dmesg | tail
[10846.586853] sd 7:0:0:0: [sdb] Attached SCSI removable disk
[11068.639397] hello: module license 'unspecified' taints kernel.
[11068.639401] Disabling lock debugging due to kernel taint
[11068.639555] init_module() called
[11164.040452] cleanup_module() called
[11442.039026] alloc irq_desc for 21 on node -1
[11442.039029] alloc kstat_irqs on node -1
[11442.039038] netx 0000:04:07.0: PCI INT A -> GSI 21 (level, low) -> IRQ 21
[11442.041162] netx 0000:04:07.0: Found netx card, registered UIO device.
[11722.672567] usb 1-4: USB disconnect, address 4
cd /usr/src/linux-2.3.6.32
/usr/src/linux-2.3.6.32$ ls /sys/class/uio
uio0
/usr/src/linux-2.3.6.32$ cat /sys/class/uio/uio0/name
netx
/usr/src/linux-2.3.6.32$ lspci -vv
04:07.0 Class ff00: Hilscher GmbH Device 0000
Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR+ FastB2B- DisINTx-
Status: Cap- 66MHz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
Latency: 64
Interrupt: pin A routed to IRQ 21
Region 0: Memory at fbff0000 (32-bit, non-prefetchable) [size=64K]
Kernel driver in use: netx
Please Log in or Create an account to join the conversation.
- t1m0n
- Offline
- Junior Member
-
- Posts: 34
- Thank you received: 0
./configure
doesn't work!
./configure PCIACCESS_CFLAGS="-I/opt/pciaccess/include -L/opt/pciaccess/lib" PCIACCESS_LIBS="-lpciaccess"
doen't work!
i get:
configure: error: No usable libpciaccess found. See config.log for details!
My idea is, that the PCI-Port is not supported for normal software and the kernel module, uio_netx, i had integrated above is not ready for realtime.
1. What can I do to integrate the kernel module in RTAI as a realtime kernel module?
2. How can I run ./configure
Please Log in or Create an account to join the conversation.
- andypugh
-
- Offline
- Moderator
-
- Posts: 23297
- Thank you received: 4938
1. What can I do to integrate the kernel module in RTAI as a realtime kernel module?
You are way over my head with this. You might, however, pick up some ideas from:
www.linuxcnc.org/index.php/english/compo...22346&catid=24#22346
As that seems to have some similar features to what you are trying to do.
The "missing" link is that you will need to write a HAL driver to create pins and handle the interface between HAL and the hardware.
Please Log in or Create an account to join the conversation.
- t1m0n
- Offline
- Junior Member
-
- Posts: 34
- Thank you received: 0
Please Log in or Create an account to join the conversation.