Need help starting socketCAN

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Need help starting socketCAN

Ansell, John

Hi guys,

 

Apologies if this is a repost, I fear I may have hijacked another thread by mistake (sorry René!).

 

 

I need some advice regarding starting up the can0 and can1 devices please.

 

Hardware is an AT91SAM9 (ARM) driving two MCP2515 controllers, one on each of the SPI ports. SocketCAN support is built into the kernel, 2.6.38. dmesg shows probes are successful and the CAN drivers are being loaded.

 

I'm using busybox to handle the commands. Trouble is, its ip command doesn't support the 'type can' or 'bitrate' parameters so the can devices stay ‘down’.

 

How can I get my can interfaces ‘up’? Can I set the bitrate from a userland task, maybe via ioctls or something?

Has anybody got a busybox build to work?

I don’t see a CAN device in /dev – should I?

 

I’d be very grateful for any pointers!

 

Best regards

John Ansell

 


_______________________________________________
Socketcan-users mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/socketcan-users
Reply | Threaded
Open this post in threaded view
|

Re: Need help starting socketCAN

Müller, René
Am 22.08.2011 14:22, schrieb Ansell, John:
>
> Hi guys,
>
>  
>
> Apologies if this is a repost, I fear I may have hijacked another thread by mistake (sorry René!).

Hi John,

no problem :)

>  
>
>  
>
> I need some advice regarding starting up the can0 and can1 devices please.
>
>  
>
> Hardware is an AT91SAM9 (ARM) driving two MCP2515 controllers, one on each of the SPI ports. SocketCAN support is built into the kernel, 2.6.38. dmesg shows probes are successful and the CAN drivers are being loaded.
>
>  
>
> I'm using busybox to handle the commands. Trouble is, its ip command doesn't support the 'type can' or 'bitrate' parameters so the can devices stay 'down'.

I think, without support for CAN in the ip tool, you are a bit lost. The best solution is to compile your own ip, which is part of iproute2. CAN support should be part of it since 2 (?) years.

Best regards,
René

>  
>
> How can I get my can interfaces 'up'? Can I set the bitrate from a userland task, maybe via ioctls or something?
>
> Has anybody got a busybox build to work?
>
> I don't see a CAN device in /dev - should I?
>
>  
>
> I'd be very grateful for any pointers!
>
>  
>
> Best regards
>
> John Ansell
>
>  
> _______________________________________________
> Socketcan-users mailing list
> [hidden email]
> https://lists.berlios.de/mailman/listinfo/socketcan-users
_______________________________________________
Socketcan-users mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/socketcan-users
Reply | Threaded
Open this post in threaded view
|

Re: Need help starting socketCAN

Oliver Hartkopp
In reply to this post by Ansell, John
On 22.08.2011 14:22, Ansell, John wrote:

> Hi guys,



Hi John,

i'll try to enhance the answer from Rene a bit ;-)

> I need some advice regarding starting up the can0 and can1 devices please.
>
>  
>
> Hardware is an AT91SAM9 (ARM) driving two MCP2515 controllers, one on each of
> the SPI ports. SocketCAN support is built into the kernel, 2.6.38. dmesg shows
> probes are successful and the CAN drivers are being loaded.


Then you should see the CAN netdevices also in /proc/net/dev

There are no CAN files created in /dev/xxx as the CAN devices use the network
driver model like ethernet cards.

>
> I'm using busybox to handle the commands. Trouble is, its ip command doesn't
> support the 'type can' or 'bitrate' parameters so the can devices stay ‘down’.
>
> How can I get my can interfaces ‘up’? Can I set the bitrate from a userland
> task, maybe via ioctls or something?


As Rene wrote, you need a 'recent' 'ip' from the iproute2 package:

http://git.kernel.org/?p=network/iproute2/iproute2.git;a=summary

>
> Has anybody got a busybox build to work?


In our setup we disabled the 'ip' tool in busybox and compiled the 'ip' from
iproute2 ...

>
> I don’t see a CAN device in /dev – should I?


That's correct that you don't see things in /dev/xxx .-)

Regards,
Oliver

_______________________________________________
Socketcan-users mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/socketcan-users
Reply | Threaded
Open this post in threaded view
|

Re: Need help starting socketCAN

Ansell, John
> -----Original Message-----
> From: Oliver Hartkopp [mailto:[hidden email]]
> Sent: 22 August 2011 18:14
> To: Ansell, John
> Cc: [hidden email]
> Subject: Re: [Socketcan-users] Need help starting socketCAN
>
> On 22.08.2011 14:22, Ansell, John wrote:
>
> > Hi guys,
>
> Hi John,
>
> i'll try to enhance the answer from Rene a bit ;-)
>
> > probes are successful and the CAN drivers are being loaded.
>
> Then you should see the CAN netdevices also in /proc/net/dev

I have /sys/class/net/can0/ and .../can1/ but nothing in /proc/net/dev
I also have /proc/net/can.
Will there be a clue in the dmesg log?


> There are no CAN files created in /dev/xxx as the CAN devices use the
> network driver model like ethernet cards.

OK, thanks.

>
> As Rene wrote, you need a 'recent' 'ip' from the iproute2 package:
>
> http://git.kernel.org/?p=network/iproute2/iproute2.git;a=summary

Was really hoping you guys wouldn't say that, I was hoping I could do it all
from userland :(

I've been trying to get a version of iproute2 to build but it fails to build the misc
folder at the moment. :(  OK, will keep going!

>
> In our setup we disabled the 'ip' tool in busybox and compiled the 'ip'
> from iproute2 ...

Ah, but there's a difference - you know what you're doing :)

> >
> > I don’t see a CAN device in /dev – should I?
>
>
> That's correct that you don't see things in /dev/xxx .-)

Cool, at least I don't have devices where they shouldn't be. Now to get them where they should be!

>
> Regards,
> Oliver


_______________________________________________
Socketcan-users mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/socketcan-users
Reply | Threaded
Open this post in threaded view
|

Re: Need help starting socketCAN

Ansell, John
In reply to this post by Oliver Hartkopp
Some progress at last, thanks to Oliver and Rene!

I built the ip tool from the 2.6.38 tag. Decided to ignore its struggles with the misc directory and found that the ip tool does seem to work. So, I can set the bitrate etc.

On to the next problem...

When I try to bring the interface up (ip link set can0 up) I get two error messages:
"setting trigger mode 2 for irq 157 failed (gpio_irq_type+0x0/0x2c)" and
"mcp251x spi0.1: failed to acquire irq157"
RNETLINK answers: Invalid argument

Now, 157 corresponds to port D pin 29 which is where the irq is wired to. So I guess the fault may be in the board setup.

Any ideas guys?




> -----Original Message-----
> From: Oliver Hartkopp [mailto:[hidden email]]
> Sent: 22 August 2011 18:14
> To: Ansell, John
> Cc: [hidden email]
> Subject: Re: [Socketcan-users] Need help starting socketCAN
>
> On 22.08.2011 14:22, Ansell, John wrote:
>
> > Hi guys,
>
>
>
> Hi John,
>
> i'll try to enhance the answer from Rene a bit ;-)
>
> > I need some advice regarding starting up the can0 and can1 devices
> please.
> >
> >
> >
> > Hardware is an AT91SAM9 (ARM) driving two MCP2515 controllers, one on
> each of
> > the SPI ports. SocketCAN support is built into the kernel, 2.6.38.
> dmesg shows
> > probes are successful and the CAN drivers are being loaded.
>
>
> Then you should see the CAN netdevices also in /proc/net/dev
>
> There are no CAN files created in /dev/xxx as the CAN devices use the
> network
> driver model like ethernet cards.
>
> >
> > I'm using busybox to handle the commands. Trouble is, its ip command
> doesn't
> > support the 'type can' or 'bitrate' parameters so the can devices
> stay ‘down’.
> >
> > How can I get my can interfaces ‘up’? Can I set the bitrate from a
> userland
> > task, maybe via ioctls or something?
>
>
> As Rene wrote, you need a 'recent' 'ip' from the iproute2 package:
>
> http://git.kernel.org/?p=network/iproute2/iproute2.git;a=summary
>
> >
> > Has anybody got a busybox build to work?
>
>
> In our setup we disabled the 'ip' tool in busybox and compiled the 'ip'
> from
> iproute2 ...
>
> >
> > I don’t see a CAN device in /dev – should I?
>
>
> That's correct that you don't see things in /dev/xxx .-)
>
> Regards,
> Oliver

_______________________________________________
Socketcan-users mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/socketcan-users
Reply | Threaded
Open this post in threaded view
|

Re: Need help starting socketCAN

Ansell, John
Hi Ulrich,

I get the same errors with either method.

Only difference is the final message, instead of RNETLINK moaning, ifconfig does:

setting trigger mode 2 for irq 157 failed (gpio_irq_type+0x0/0x2c)
mcp251x spi0.1: failed to acquire irq 157
ifconfig: SIOCSIFFLAGS: Invalid argument

Nice try, keep 'em coming!

Cheers

> -----Original Message-----
> From: Ulrich Prinz [mailto:[hidden email]]
> Sent: 23 August 2011 23:39
> To: Ansell, John
> Subject: Re: [Socketcan-users] Need help starting socketCAN
>
> Hi!
>
> Could you try "ifconfig can0 up" instead of the ip tool?
>
> I had the same thing, ip tool works fine for the configuration, but not
> for starting/stopping it. My scripts now use this configuration and I
> never checked again, if ip tool could do the job.
>
> Kind Regards
> Ulrich
>
>
>
> On 23.08.2011 17:02, Ansell, John wrote:
> > Some progress at last, thanks to Oliver and Rene!
> >
> > I built the ip tool from the 2.6.38 tag. Decided to ignore its
> struggles with the misc directory and found that the ip tool does seem
> to work. So, I can set the bitrate etc.
> >
> > On to the next problem...
> >
> > When I try to bring the interface up (ip link set can0 up) I get two
> error messages:
> > "setting trigger mode 2 for irq 157 failed (gpio_irq_type+0x0/0x2c)"
> and
> > "mcp251x spi0.1: failed to acquire irq157"
> > RNETLINK answers: Invalid argument
> >
> > Now, 157 corresponds to port D pin 29 which is where the irq is wired
> to. So I guess the fault may be in the board setup.
> >
> > Any ideas guys?
> >

_______________________________________________
Socketcan-users mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/socketcan-users
Reply | Threaded
Open this post in threaded view
|

Re: Need help starting socketCAN

Ansell, John
Major progress! I can get messages through can0 now, I'll look at can1
later. But I'm not sure I understand the fix!

The problem as I see it is that the mcp251x driver requests a falling
edge triggered interrupt but function gpio_irq_type() (in gpio.c)
doesn't allow that for some reason.

The (temporary?) fix is to make gpio_irq_type() accept
IRQ_TYPE_EDGE_FALLING as well, but I suspect that will blow other stuff
out of the water.

What would be the best way to fix this properly?

Cheers
John


> -----Original Message-----
> From: [hidden email]
[mailto:socketcan-users-

> [hidden email]] On Behalf Of Ansell, John
> Sent: 24 August 2011 07:09
> To: [hidden email]
> Subject: Re: [Socketcan-users] Need help starting socketCAN
>
> Hi Ulrich,
>
> I get the same errors with either method.
>
> Only difference is the final message, instead of RNETLINK moaning,
> ifconfig does:
>
> setting trigger mode 2 for irq 157 failed (gpio_irq_type+0x0/0x2c)
> mcp251x spi0.1: failed to acquire irq 157
> ifconfig: SIOCSIFFLAGS: Invalid argument
>
> Nice try, keep 'em coming!
>
> Cheers
>
> > -----Original Message-----
> > From: Ulrich Prinz [mailto:[hidden email]]
> > Sent: 23 August 2011 23:39
> > To: Ansell, John
> > Subject: Re: [Socketcan-users] Need help starting socketCAN
> >
> > Hi!
> >
> > Could you try "ifconfig can0 up" instead of the ip tool?
> >
> > I had the same thing, ip tool works fine for the configuration, but
> not
> > for starting/stopping it. My scripts now use this configuration and
I

> > never checked again, if ip tool could do the job.
> >
> > Kind Regards
> > Ulrich
> >
> >
> >
> > On 23.08.2011 17:02, Ansell, John wrote:
> > > Some progress at last, thanks to Oliver and Rene!
> > >
> > > I built the ip tool from the 2.6.38 tag. Decided to ignore its
> > struggles with the misc directory and found that the ip tool does
> seem
> > to work. So, I can set the bitrate etc.
> > >
> > > On to the next problem...
> > >
> > > When I try to bring the interface up (ip link set can0 up) I get
> two
> > error messages:
> > > "setting trigger mode 2 for irq 157 failed
> (gpio_irq_type+0x0/0x2c)"
> > and
> > > "mcp251x spi0.1: failed to acquire irq157"
> > > RNETLINK answers: Invalid argument
> > >
> > > Now, 157 corresponds to port D pin 29 which is where the irq is
> wired
> > to. So I guess the fault may be in the board setup.
> > >
> > > Any ideas guys?
> > >
>
> _______________________________________________
> Socketcan-users mailing list
> [hidden email]
> https://lists.berlios.de/mailman/listinfo/socketcan-users
_______________________________________________
Socketcan-users mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/socketcan-users
Reply | Threaded
Open this post in threaded view
|

Re: Need help starting socketCAN

Wolfgang Grandegger
On 08/24/2011 12:56 PM, Ansell, John wrote:

> Major progress! I can get messages through can0 now, I'll look at can1
> later. But I'm not sure I understand the fix!
>
> The problem as I see it is that the mcp251x driver requests a falling
> edge triggered interrupt but function gpio_irq_type() (in gpio.c)
> doesn't allow that for some reason.
>
> The (temporary?) fix is to make gpio_irq_type() accept
> IRQ_TYPE_EDGE_FALLING as well, but I suspect that will blow other stuff
> out of the water.

Puh, heavy hack ;-).

> What would be the best way to fix this properly?

The platform code should provide a proper "pdata->irq_flags" setting:

  <a href="http://lxr.linux.no/#linux+v3.0.3/drivers/net/can/mcp251x.c#L933">http://lxr.linux.no/#linux+v3.0.3/drivers/net/can/mcp251x.c#L933

Wolfgang.

_______________________________________________
Socketcan-users mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/socketcan-users
Reply | Threaded
Open this post in threaded view
|

Re: Need help starting socketCAN

kedar
This post has NOT been accepted by the mailing list yet.
In reply to this post by Ansell, John
I am new guy to socket can i want to know the flow form user space to kernel space and form there to hardware .Please anybody send me the details so that it is very useful to me my mail id is kedare06@gmail.com.

Thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: Need help starting socketCAN

JunLan
This post has NOT been accepted by the mailing list yet.
In reply to this post by Ansell, John
Hi everybody:
Bellow is the  message of my arm-board printing.
/proc/469/net # cat dev
Inter-|   Receive                                                |  Transmit
 face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compresd
    lo:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0        0
  sit0:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0        0
  eth0:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0        0
  can0:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0        0
/proc/469/net # cd ../
/proc # cd
/ # ls
bin       etc       linuxrc   opt       sys       usr
demos     home      media     proc      tftpboot  var
dev       lib       mnt       sbin      tmp
/ # ifconfig can0 up
genirq: Setting trigger mode 2 for irq 123 failed (gpio_irq_type+0x0/0x20)
mcp251x spi0.1: failed to acquire irq 123
ifconfig: SIOCSIFFLAGS: Invalid argument

/ #
why? our CPU ;AT91SAM9G45   CAN controller is MCP2515, IRQ:PD27
who can help me  solve the above problem?
Ansell, John wrote
Hi Ulrich,

I get the same errors with either method.

Only difference is the final message, instead of RNETLINK moaning, ifconfig does:

setting trigger mode 2 for irq 157 failed (gpio_irq_type+0x0/0x2c)
mcp251x spi0.1: failed to acquire irq 157
ifconfig: SIOCSIFFLAGS: Invalid argument

Nice try, keep 'em coming!

Cheers

> -----Original Message-----
> From: Ulrich Prinz [mailto:[hidden email]]
> Sent: 23 August 2011 23:39
> To: Ansell, John
> Subject: Re: [Socketcan-users] Need help starting socketCAN
>
> Hi!
>
> Could you try "ifconfig can0 up" instead of the ip tool?
>
> I had the same thing, ip tool works fine for the configuration, but not
> for starting/stopping it. My scripts now use this configuration and I
> never checked again, if ip tool could do the job.
>
> Kind Regards
> Ulrich
>
>
>
> On 23.08.2011 17:02, Ansell, John wrote:
> > Some progress at last, thanks to Oliver and Rene!
> >
> > I built the ip tool from the 2.6.38 tag. Decided to ignore its
> struggles with the misc directory and found that the ip tool does seem
> to work. So, I can set the bitrate etc.
> >
> > On to the next problem...
> >
> > When I try to bring the interface up (ip link set can0 up) I get two
> error messages:
> > "setting trigger mode 2 for irq 157 failed (gpio_irq_type+0x0/0x2c)"
> and
> > "mcp251x spi0.1: failed to acquire irq157"
> > RNETLINK answers: Invalid argument
> >
> > Now, 157 corresponds to port D pin 29 which is where the irq is wired
> to. So I guess the fault may be in the board setup.
> >
> > Any ideas guys?
> >

_______________________________________________
Socketcan-users mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/socketcan-users
Reply | Threaded
Open this post in threaded view
|

Re: Need help starting socketCAN

JunLan
This post has NOT been accepted by the mailing list yet.
In reply to this post by Wolfgang Grandegger
Dear ,Wolfgang: > The (temporary?) fix is to make gpio_irq_type() accept > IRQ_TYPE_EDGE_FALLING as well, but I suspect that will blow other stuff > out of the water. Puh, heavy hack ;-). > What would be the best way to fix this properly? The platform code should provide a proper "pdata->irq_flags" setting: http://lxr.linux.no/#linux+v3.0.3/drivers/net/can/mcp251x.c#L933 Wolfgang. -->>>"http://lxr.linux.no/#linux+v3.0.3/drivers/net/can/mcp251x.c#L933 ",this website can't be opened now.Could you be kind to send the content ? Thank you very much ! Looking forward to your reply as soon as possible ! LanJun _______________________________________________ Socketcan-users mailing list [hidden email] https://lists.berlios.de/mailman/listinfo/socketcan-users
Reply | Threaded
Open this post in threaded view
|

Re: Need help starting socketCAN

JunLan
This post has NOT been accepted by the mailing list yet.
In reply to this post by Wolfgang Grandegger
Dear ,Wolfgang: > The (temporary?) fix is to make gpio_irq_type() accept > IRQ_TYPE_EDGE_FALLING as well, but I suspect that will blow other stuff > out of the water. Puh, heavy hack ;-). > What would be the best way to fix this properly? The platform code should provide a proper "pdata->irq_flags" setting: http://lxr.linux.no/#linux+v3.0.3/drivers/net/can/mcp251x.c#L933 Wolfgang. -->>>"http://lxr.linux.no/#linux+v3.0.3/drivers/net/can/mcp251x.c#L933 ",this website can't be opened now.Could you be kind to send the content ? Thank you very much ! Looking forward to your reply as soon as possible ! LanJun