Hi Michael and thanks for your assistance, don't forget to cc the
maillist aswell.

I have done step 1 and 3 already, I tried to do step 2 now aswell but
don't know if it made any real difference. My patch is quite similar
to yours with the main difference being that I don't have access to
the physical reset function on the mcp2515 and must use the reset
instruction instead. I have attached my patches for the
linux-omap3-2.6.31 kernel and u-boot-omap3.


Kindest regards,

//Erik


On Sun, Sep 27, 2009 at 11:43 PM, Michael Stocks
<[email protected]> wrote:
> Dear Erik,
> I'm using the MCP2515 on a custom expansion board for the Overo.
> At the moment I'm suing SVN 935 with Kernel 2.6.31. with no problem.
> I will try a build of SVN1064 tomorrow to see if we have a similar problem.
> I notice that you have modprobed your module.
>
> This is how I got the CAN bus working. You may want to check that you have 
> performed similar steps as socket-can will not work on the standard Overo 
> builds.
>
> 1.      Modify defconfig for the kernel by setting all the CONFIG_CAN options 
> to m. I assume you have done this as you cant build the modules without it.
> 2.      Make any changes you need to the pin mux in overo.h in the u-boot 
> recipes. You will only need to do this if you are using different pins for 
> the SPI & IRQ lines.
> 3.      Modify or patch board-overo.c from the linux-omp3_2.6.31.bb recipe. 
> To add details of the MCP2515 interface. The standard overo builds use SPI1 
> for the optional touch screen interface so if like me you are using SPI1 then 
> these changes need to be made. Attached is the patch I use for the kernel 
> build.
>
> At boot up you will see a message about initialising CAN and MCP251x being 
> probed. All you should need to do now is bring up the can0 interface as you 
> are already doing.
>
> Cheers Mike.
>
>
>
> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of Erik 
> Calissendorff
> Sent: Sunday, 27 September 2009 09:00
> To: [email protected]
> Subject: [Socketcan-users] CAN communication with MCP2515
>
> Hi I have tried to get the mcp251x driver to work with the Overo
> Gumstix for sometime now.
>
> I finally got the driver and the SPI communication to work with kernel
> 2.6.31 and was thereafter able to use iproute to initiate the bitrate,
> which didn't work with previous kernel versions. But I still can't see
> any data sent or received on the can0 interface. I have inserted print
> statements in the module to be able to debug it but I'm still stuck.
> If someone could point me in the right direction it would be highly
> appreciated. I'm running the modules from SVN rev 1064.
>
>
> Below is a capture of the initiation of the module and can0:
> ---
> r...@overo:~# modprobe mcp251x
> CAN device driver interface
> Running: mcp251x_can_probe
> Running: mcp251x_setup
>  ret 0
> Running: mcp251x_hw_probe
> Running: mcp251x_hw_reset
> Running: mcp251x_read_reg(*spi,reg=14)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
>  return: 128
> Running: mcp251x_read_reg(*spi,reg=15)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
>  return: 135
> Running: mcp251x_hw_sleep
> Running: mcp251x_write_reg(*spi,reg=15,val=32)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
> mcp251x spi1.0: probed
> r...@overo:~#
>
>
> Setting the bitrate, my oscillator frequence is set to 20000000
>
> r...@overo:~# ip link set can0 type can bitrate 250000
> Running: mcp251x_do_set_bittiming
> Running: mcp251x_read_reg(*spi,reg=15)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
>  return: 96
> Running: mcp251x_read_reg(*spi,reg=14)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
>  return: 32
> Running: mcp251x_write_bits(*spi,reg=15,mask=224,val=128)
> Running: mcp251x_spi_trans(*spi,len=4)
>  return: 0
> Running: mcp251x_write_reg(*spi,reg=42,val=1)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
> Running: mcp251x_write_reg(*spi,reg=41,val=191)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
> Running: mcp251x_write_bits(*spi,reg=40,mask=7,val=2)
> Running: mcp251x_spi_trans(*spi,len=4)
>  return: 0
> Running: mcp251x_write_bits(*spi,reg=15,mask=224,val=32)
> Running: mcp251x_spi_trans(*spi,len=4)
>  return: 0
> r...@overo:~#
>
> r...@overo:~# ifconfig can0 up
> Running: mcp251x_open
> enable irq=274
> Running: mcp251x_wakeup
> Running: mcp251x_write_bits(*spi,reg=43,mask=64,val=64)
> Running: mcp251x_spi_trans(*spi,len=4)
>  return: 0
> Running: mcp251x_write_bits(*spi,reg=44,mask=64,val=64)
> Running: mcp251x_spi_trans(*spi,len=4)
> Running: mcp251x_can_isr
> Running: mcp251x_irq_work_handler
> while(!priv->force_quit && !freezing(current))
> Running: mcp251x_read_reg(*spi,reg=44)
>  return: 0
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
>  return: 64
> Running: mcp251x_write_bits(*spi,reg=44,mask=64,val=0)
> Running: mcp251x_spi_trans(*spi,len=4)
>  return: 0
> while(!priv->force_quit && !freezing(current))
> Running: mcp251x_read_reg(*spi,reg=44)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
>  return: 0
> Running: mcp251x_read_reg(*spi,reg=14)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
>  return: 96
> Running: mcp251x_hw_reset
> Running: mcp251x_setup
> Running: mcp251x_write_bits(*spi,reg=96,mask=100,val=100)
> Running: mcp251x_spi_trans(*spi,len=4)
>  return: 0
> Running: mcp251x_write_bits(*spi,reg=112,mask=96,val=96)
> Running: mcp251x_spi_trans(*spi,len=4)
>  return: 0
> Running: mcp251x_set_normal_mode
> Running: mcp251x_write_reg(*spi,reg=43,val=63)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
> Running: mcp251x_write_reg(*spi,reg=15,val=0)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
> Running: mcp251x_read_reg(*spi,reg=14)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
>  return: 0
> r...@overo:~#
>
> r...@overo:~# cansend can0 000#
> can: controller area network core (rev 20090105 abi 8)
> NET: Registered protocol family 29
> can: raw protocol (rev 20090105)
> Running: mcp251x_hard_start_xmit
> Running: mcp251x_tx_work_handler
> Running: mcp251x_hw_tx
> Running: mcp251x_write_reg(*spi,reg=49,val=0)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
> Running: mcp251x_write_reg(*spi,reg=50,val=0)
> Running: mcp251x_spi_trans(*spi,len=3)r...@overo:~#
>  return: 0
> Running: mcp251x_write_reg(*spi,reg=51,val=0)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
> Running: mcp251x_write_reg(*spi,reg=52,val=0)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
> Running: mcp251x_write_reg(*spi,reg=53,val=0)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
> Running: mcp251x_write_reg(*spi,reg=48,val=8)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
>
> r...@overo:~# ifconfig
> can0      Link encap:UNSPEC  HWaddr
> 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
>          UP RUNNING NOARP  MTU:16  Metric:1
>          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
>          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
>          collisions:0 txqueuelen:10
>          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
>
> lo        Link encap:Local Loopback
>          inet addr:127.0.0.1  Mask:255.0.0.0
>          inet6 addr: ::1/128 Scope:Host
>          UP LOOPBACK RUNNING  MTU:16436  Metric:1
>          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
>          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
>          collisions:0 txqueuelen:0
>          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
>
> r...@overo:~#
>
> As soon as I connect the other CAN devices I get this output:
> [...]
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
>  return: 31
> Running: mcp251x_write_reg(*spi,reg=45,val=0)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
> while(!priv->force_quit && !freezing(current))
> Running: mcp251x_read_reg(*spi,reg=44)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
>  return: 128
> Running: mcp251x_write_bits(*spi,reg=44,mask=128,val=0)
> Running: mcp251x_spi_trans(*spi,len=4)
>  return: 0
> Running: mcp251x_read_reg(*spi,reg=48)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
>  return: 16
> ------------[ cut here ]------------
> WARNING: at 
> /home/plejd/overo-oe/tmp/work/overo-angstrom-linux-gnueabi/socketcan-modules-0.0+svnr1064-r45/trunk/kernel/2.6/drivers/net/can/mcp251x.c:840
> mcp251x_irq_work_handler+0x24c/0x5d0 [mcp251x]()
> Modules linked in: can_raw can ipv6 mcp251x can_dev
> [<c00f45d4>] (unwind_backtrace+0x0/0xdc) from [<c0116288>]
> (warn_slowpath_common+0x4c/0x80)
> [<c0116288>] (warn_slowpath_common+0x4c/0x80) from [<bf009040>]
> (mcp251x_irq_work_handler+0x24c/0x5d0 [mcp251x])
> [<bf009040>] (mcp251x_irq_work_handler+0x24c/0x5d0 [mcp251x]) from
> [<c0126d2c>] (worker_thread+0x19c/0x218)
> [<c0126d2c>] (worker_thread+0x19c/0x218) from [<c012a6c0>] (kthread+0x78/0x80)
> [<c012a6c0>] (kthread+0x78/0x80) from [<c00f0800>] 
> (kernel_thread_exit+0x0/0x8)
> ---[ end trace 2c66beb10b4a4a3e ]---
> while(!priv->force_quit && !freezing(current))
> Running: mcp251x_read_reg(*spi,reg=44)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
>  return: 0
> Running: mcp251x_read_reg(*spi,reg=14)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
>  return: 0
> Running: mcp251x_irq_work_handler
> while(!priv->force_quit && !freezing(current))
> Running: mcp251x_read_reg(*spi,reg=44)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
>  return: 0
> Running: mcp251x_read_reg(*spi,reg=14)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
>  return: 0
>
> If I try to send anything while having other nodes connected the
> driver doesn't get out from the while loop in the irq_handler:
>
> r...@overo:~# cansend can0 000#
> [...]
> while(!priv->force_quit && !freezing(current))
> Running: mcp251x_read_reg(*spi,reg=44)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
>  return: 128
> Running: mcp251x_write_bits(*spi,reg=44,mask=128,val=0)
> Running: mcp251x_spi_trans(*spi,len=4)
>  return: 0
> Running: mcp251x_read_reg(*spi,reg=48)
> Running: mcp251x_spi_trans(*spi,len=3)
>  return: 0
>  return: 24
> while(!priv->force_quit && !freezing(current))
> [...]
>
> Hope someone can give me some pointers of how to get the communication going.
>
>
>
> Kindest regards,
>
> //Erik
> _______________________________________________
> Socketcan-users mailing list
> [email protected]
> https://lists.berlios.de/mailman/listinfo/socketcan-users
>

Attachment: mcp251x.patch
Description: Binary data

Attachment: spi1.0_pins.patch
Description: Binary data

_______________________________________________
Socketcan-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-users

Reply via email to