All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] Advantech PCM3680I with Xenomai: Probe failed with error -5
@ 2017-04-11 10:22 Ashwin Narayan
  2017-04-12  9:14 ` Philippe Gerum
  0 siblings, 1 reply; 4+ messages in thread
From: Ashwin Narayan @ 2017-04-11 10:22 UTC (permalink / raw)
  To: xenomai

Dear All,

I'm having trouble getting the Advantech PCM3680I working under
xenomai. I scanned the dmesg log and this is what I get:

[    1.344697] RT-Socket-CAN 0.90.2 - (C) 2006 RT-Socket-CAN Development Team
[    1.344794] RTCAN SJA1000 driver initialized
[    1.344989] ADV-PCI-CAN 0000:01:04.0: RTCAN Registering card
[    1.345281] ADV-PCI-CAN 0000:01:04.0: RTCAN detected Advantech PCI
card at slot #4
[    1.345295] ADV-PCI-CAN: Initializing device 13fe:c002:c002
[    1.345310] ADV-PCI-CAN: base_addr=000000000001ef00 conf_addr=
    (null) irq=16 ocr=0xfa cdr=0xc0
[    1.345373] rtcan: registered rtcan0
[    1.345386] Unregistering SJA1000 device rtcan0
[    1.345403] RTCAN: unregistered rtcan0
[    1.345646] ADV-PCI-CAN: probe of 0000:01:04.0 failed with error -5
[    1.345793] rtcan: registered rtcan0
[    1.345799] rtcan0: VIRT driver loaded
[    1.345818] rtcan: registered rtcan1
[    1.345824] rtcan1: VIRT driver loaded

At first I suspected that the problem could be that the kernel was
compiled with the Networking Devices -> CAN Subsystem enabled. So I
disabled that and recompiled the kernel and I got the same error
message.

To find out where the error message is coming from, I tried running
the command grep -rnw . -e "probe f" from the directory
xenomai-3.0.4/. Couldn't find that string anywhere in the source.

Does anyone have any experience with this CAN bus card and what it
might take to get it to work?

Thanks,
-Ashwin


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai] Advantech PCM3680I with Xenomai: Probe failed with error -5
  2017-04-11 10:22 [Xenomai] Advantech PCM3680I with Xenomai: Probe failed with error -5 Ashwin Narayan
@ 2017-04-12  9:14 ` Philippe Gerum
  2017-04-12 11:56   ` Ashwin Narayan
  0 siblings, 1 reply; 4+ messages in thread
From: Philippe Gerum @ 2017-04-12  9:14 UTC (permalink / raw)
  To: Ashwin Narayan, xenomai

On 04/11/2017 12:22 PM, Ashwin Narayan wrote:
> Dear All,
> 
> I'm having trouble getting the Advantech PCM3680I working under
> xenomai. I scanned the dmesg log and this is what I get:
> 
> [    1.344697] RT-Socket-CAN 0.90.2 - (C) 2006 RT-Socket-CAN Development Team
> [    1.344794] RTCAN SJA1000 driver initialized
> [    1.344989] ADV-PCI-CAN 0000:01:04.0: RTCAN Registering card
> [    1.345281] ADV-PCI-CAN 0000:01:04.0: RTCAN detected Advantech PCI
> card at slot #4
> [    1.345295] ADV-PCI-CAN: Initializing device 13fe:c002:c002
> [    1.345310] ADV-PCI-CAN: base_addr=000000000001ef00 conf_addr=
>     (null) irq=16 ocr=0xfa cdr=0xc0
> [    1.345373] rtcan: registered rtcan0
> [    1.345386] Unregistering SJA1000 device rtcan0
> [    1.345403] RTCAN: unregistered rtcan0
> [    1.345646] ADV-PCI-CAN: probe of 0000:01:04.0 failed with error -5
> [    1.345793] rtcan: registered rtcan0
> [    1.345799] rtcan0: VIRT driver loaded
> [    1.345818] rtcan: registered rtcan1
> [    1.345824] rtcan1: VIRT driver loaded
> 
> At first I suspected that the problem could be that the kernel was
> compiled with the Networking Devices -> CAN Subsystem enabled. So I
> disabled that and recompiled the kernel and I got the same error
> message.
> 
> To find out where the error message is coming from, I tried running
> the command grep -rnw . -e "probe f" from the directory
> xenomai-3.0.4/. Couldn't find that string anywhere in the source.
> 

This message is issued by the regular Linux driver core, upon return
from some probe() routine in the RTCAN driver. errno 5 is EIO, you may
want to check sja1000/rtcan_adv_pci.c to figure out the reason for
receiving it.

-- 
Philippe.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai] Advantech PCM3680I with Xenomai: Probe failed with error -5
  2017-04-12  9:14 ` Philippe Gerum
@ 2017-04-12 11:56   ` Ashwin Narayan
  2017-04-13  6:34     ` Ashwin Narayan
  0 siblings, 1 reply; 4+ messages in thread
From: Ashwin Narayan @ 2017-04-12 11:56 UTC (permalink / raw)
  To: Philippe Gerum; +Cc: xenomai

On Wed, Apr 12, 2017 at 5:14 PM, Philippe Gerum <rpm@xenomai.org> wrote:
> On 04/11/2017 12:22 PM, Ashwin Narayan wrote:
>> Dear All,
>>
>> I'm having trouble getting the Advantech PCM3680I working under
>> xenomai. I scanned the dmesg log and this is what I get:
>>
>> [    1.344697] RT-Socket-CAN 0.90.2 - (C) 2006 RT-Socket-CAN Development Team
>> [    1.344794] RTCAN SJA1000 driver initialized
>> [    1.344989] ADV-PCI-CAN 0000:01:04.0: RTCAN Registering card
>> [    1.345281] ADV-PCI-CAN 0000:01:04.0: RTCAN detected Advantech PCI
>> card at slot #4
>> [    1.345295] ADV-PCI-CAN: Initializing device 13fe:c002:c002
>> [    1.345310] ADV-PCI-CAN: base_addr=000000000001ef00 conf_addr=
>>     (null) irq=16 ocr=0xfa cdr=0xc0
>> [    1.345373] rtcan: registered rtcan0
>> [    1.345386] Unregistering SJA1000 device rtcan0
>> [    1.345403] RTCAN: unregistered rtcan0
>> [    1.345646] ADV-PCI-CAN: probe of 0000:01:04.0 failed with error -5
>> [    1.345793] rtcan: registered rtcan0
>> [    1.345799] rtcan0: VIRT driver loaded
>> [    1.345818] rtcan: registered rtcan1
>> [    1.345824] rtcan1: VIRT driver loaded
>>
>> At first I suspected that the problem could be that the kernel was
>> compiled with the Networking Devices -> CAN Subsystem enabled. So I
>> disabled that and recompiled the kernel and I got the same error
>> message.
>>
>> To find out where the error message is coming from, I tried running
>> the command grep -rnw . -e "probe f" from the directory
>> xenomai-3.0.4/. Couldn't find that string anywhere in the source.
>>
>
> This message is issued by the regular Linux driver core, upon return
> from some probe() routine in the RTCAN driver. errno 5 is EIO, you may
> want to check sja1000/rtcan_adv_pci.c to figure out the reason for
> receiving it.
>
> --
> Philippe.


Hi Philippe,

>Sorry, I forgot to send the reply to the mailing list.:

Thanks for the suggestion. I made some progress looking in that file.

I tried adding printk() statements in rtcan_adv_pci.c and compiling
and I figured out where the error is happening. In the rtcan_adv_pci.c
line 202 - 207:

    202 /* check if mode is set */
    203 ret = chip->read_reg(dev, SJA_CDR);
    204 if (ret != SJA_CDR_CAN_MODE) {
    205     ret = -EIO;
    206     goto failure_iounmap;
    207 }

The chip->read_reg(dev, SJA_CDR) does not return SJA_CDR_CAN_MODE. So
ret = -EIO (-5) and the probe fails. Could this be something wrong
with the way the driver assignes the io regions? I compared the code
in this file with the driver that is provided by advantech (which is
not realtime) and there were a few differences. Namely, the advantech
driver uses request_region() instead of pci_iomap(). I tried following
the execution paths of both the advantech and the xenomai drivers. My
device id is c002

For the advantech driver it goes like:
pci_enable_device(pdev)
ifndef CONFIG_PCI_MSI
pci_enable_msi(pdev)
#endif
for i=0; i<2: i++
    address = pci_resource_start(pdev, 0) + 0x100*i
    request_region(address, 0x100, "advcan")

For the xenomai driver, pci_iomap(pdev, 0, ADV_PCI_BASE_SIZE) is used instead.

I basically hit a dead end here because I only have a beginner's
knowledge of how PCI drivers work. Is this an error that is fixable by
modifying just rtcan_adv_pci.c?

Thanks for all the help,

-Ashwin


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai] Advantech PCM3680I with Xenomai: Probe failed with error -5
  2017-04-12 11:56   ` Ashwin Narayan
@ 2017-04-13  6:34     ` Ashwin Narayan
  0 siblings, 0 replies; 4+ messages in thread
From: Ashwin Narayan @ 2017-04-13  6:34 UTC (permalink / raw)
  To: Philippe Gerum; +Cc: xenomai

On Wed, Apr 12, 2017 at 7:56 PM, Ashwin Narayan
<ashwinnarayan1994@gmail.com> wrote:
> On Wed, Apr 12, 2017 at 5:14 PM, Philippe Gerum <rpm@xenomai.org> wrote:
>> On 04/11/2017 12:22 PM, Ashwin Narayan wrote:
>>> Dear All,
>>>
>>> I'm having trouble getting the Advantech PCM3680I working under
>>> xenomai. I scanned the dmesg log and this is what I get:
>>>
>>> [    1.344697] RT-Socket-CAN 0.90.2 - (C) 2006 RT-Socket-CAN Development Team
>>> [    1.344794] RTCAN SJA1000 driver initialized
>>> [    1.344989] ADV-PCI-CAN 0000:01:04.0: RTCAN Registering card
>>> [    1.345281] ADV-PCI-CAN 0000:01:04.0: RTCAN detected Advantech PCI
>>> card at slot #4
>>> [    1.345295] ADV-PCI-CAN: Initializing device 13fe:c002:c002
>>> [    1.345310] ADV-PCI-CAN: base_addr=000000000001ef00 conf_addr=
>>>     (null) irq=16 ocr=0xfa cdr=0xc0
>>> [    1.345373] rtcan: registered rtcan0
>>> [    1.345386] Unregistering SJA1000 device rtcan0
>>> [    1.345403] RTCAN: unregistered rtcan0
>>> [    1.345646] ADV-PCI-CAN: probe of 0000:01:04.0 failed with error -5
>>> [    1.345793] rtcan: registered rtcan0
>>> [    1.345799] rtcan0: VIRT driver loaded
>>> [    1.345818] rtcan: registered rtcan1
>>> [    1.345824] rtcan1: VIRT driver loaded
>>>
>>> At first I suspected that the problem could be that the kernel was
>>> compiled with the Networking Devices -> CAN Subsystem enabled. So I
>>> disabled that and recompiled the kernel and I got the same error
>>> message.
>>>
>>> To find out where the error message is coming from, I tried running
>>> the command grep -rnw . -e "probe f" from the directory
>>> xenomai-3.0.4/. Couldn't find that string anywhere in the source.
>>>
>>
>> This message is issued by the regular Linux driver core, upon return
>> from some probe() routine in the RTCAN driver. errno 5 is EIO, you may
>> want to check sja1000/rtcan_adv_pci.c to figure out the reason for
>> receiving it.
>>
>> --
>> Philippe.
>
>
> Hi Philippe,
>
>>Sorry, I forgot to send the reply to the mailing list.:
>
> Thanks for the suggestion. I made some progress looking in that file.
>
> I tried adding printk() statements in rtcan_adv_pci.c and compiling
> and I figured out where the error is happening. In the rtcan_adv_pci.c
> line 202 - 207:
>
>     202 /* check if mode is set */
>     203 ret = chip->read_reg(dev, SJA_CDR);
>     204 if (ret != SJA_CDR_CAN_MODE) {
>     205     ret = -EIO;
>     206     goto failure_iounmap;
>     207 }
>
> The chip->read_reg(dev, SJA_CDR) does not return SJA_CDR_CAN_MODE. So
> ret = -EIO (-5) and the probe fails. Could this be something wrong
> with the way the driver assignes the io regions? I compared the code
> in this file with the driver that is provided by advantech (which is
> not realtime) and there were a few differences. Namely, the advantech
> driver uses request_region() instead of pci_iomap(). I tried following
> the execution paths of both the advantech and the xenomai drivers. My
> device id is c002
>
> For the advantech driver it goes like:
> pci_enable_device(pdev)
> ifndef CONFIG_PCI_MSI
> pci_enable_msi(pdev)
> #endif
> for i=0; i<2: i++
>     address = pci_resource_start(pdev, 0) + 0x100*i
>     request_region(address, 0x100, "advcan")
>
> For the xenomai driver, pci_iomap(pdev, 0, ADV_PCI_BASE_SIZE) is used instead.
>
> I basically hit a dead end here because I only have a beginner's
> knowledge of how PCI drivers work. Is this an error that is fixable by
> modifying just rtcan_adv_pci.c?
>
> Thanks for all the help,
>
> -Ashwin

Hi All,

I managed to solve the problem with the PCM3680I by modifying the code
in the xenomai-3.0.4/kernel/drivers/can/sja1000/rtcan_adv_pci.c. I
thought I'd send out a mail so that others having trouble with the
card can see it. I'm attaching the modified file here.

To the maintainers of xenomai: is it possible to integrate this change
into the main xenomai code? I'm sure it will help lots of people.

Thanks for all the help :)

-Ashwin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rtcan_adv_pci.c
Type: text/x-csrc
Size: 9028 bytes
Desc: not available
URL: <http://xenomai.org/pipermail/xenomai/attachments/20170413/ffba9f47/attachment.c>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-04-13  6:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-11 10:22 [Xenomai] Advantech PCM3680I with Xenomai: Probe failed with error -5 Ashwin Narayan
2017-04-12  9:14 ` Philippe Gerum
2017-04-12 11:56   ` Ashwin Narayan
2017-04-13  6:34     ` Ashwin Narayan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.