Re: MCP251x driver for linux 2.6.25

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

Re: MCP251x driver for linux 2.6.25

Christian Pellegrin
On Mon, Oct 20, 2008 at 2:40 PM, Pierre Savary <[hidden email]> wrote:
> Hi all,

Hi,

> development. Where could I find this source code please? Could you help me
> to integrate it?

Right now everything is in the socketcan SVN. I usually compile
socketcan out of tree (since it uses SVN it's a bit difficult to track
it's file when they are mixed in the kernel tree that is managed by
git). Just make sure that the file mcp251x.h is in the include file
path of the kernel (you can symlink it there, I know it's not the most
elegant thing). You have to add the spi_board_info and the
mcp251x_platform_data structs in your machine definition file to tell
what's the wiring, the crystal used and such. Then modprobe can-raw,
mcp251x and the spi master driver (if not already in the kernel) and
it should work. Tell me if you encounter some problem, I'll try to
help.

--
Christian Pellegrin, see http://www.evolware.org/chri/
"Real Programmers don't play tennis, or any other sport which requires
you to change clothes. Mountain climbing is OK, and Real Programmers
wear their climbing boots to work in case a mountain should suddenly
spring up in the middle of the computer room."
_______________________________________________
Socketcan-core mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/socketcan-core
Reply | Threaded
Open this post in threaded view
|

Re: MCP251x driver for linux 2.6.25

Christian Pellegrin
On Mon, Oct 20, 2008 at 5:43 PM, Pierre Savary <[hidden email]> wrote:
> Thanks a lot for your help. But I didn't find the mcp251x.c file on the
> site. Where is it, please?

Have a look here:

http://developer.berlios.de/svn/?group_id=6475


--
Christian Pellegrin, see http://www.evolware.org/chri/
"Real Programmers don't play tennis, or any other sport which requires
you to change clothes. Mountain climbing is OK, and Real Programmers
wear their climbing boots to work in case a mountain should suddenly
spring up in the middle of the computer room."
_______________________________________________
Socketcan-core mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/socketcan-core
Reply | Threaded
Open this post in threaded view
|

Re: MCP251x driver for linux 2.6.25

Wolfgang Grandegger
Pierre Savary wrote:
> Hi use version 2.6.25, so I imagine that it's not necessary to take all the
> stack on this repository? I can take only the mcp215x driver?

No, just copying the mcp215x will not work. Please build the relevant
kernel modules out of tree from the SVN repository as usual. An
up-to-date kernel patch is not available for 2.6.25. If switching to a
recent version of Linux is an option, you can pull from Marc's repository.

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

MCP251x driver crash report

lancos
In reply to this post by Christian Pellegrin
Hi,
I'm new to this list.
I'm in the process to upgrade our ARM9 board with 2.6.19 kernel + can
MCP2515 (driver by Arcom Control Systems Ltd reworked by CHRI and by me)
to latest socketcan SVN 841 + 2.6.27 kernel.

I tried to send 2 consecutive can frames without any other can device on
the bus, and I got a crash. Look at the attachment for the log.
The problem seems due to a TX timeout followed by another tx request.
Do you have similar problems?

Cheers,
Claudio Lanconelli


[root@s162 /root]# cat resetboard.sh
#!/bin/sh
can-utils/can_speak can0 t 0x610 0 0 6 0 0 0 0 0 0 0
can-utils/can_speak can0 t 0x710 0 0 6 0 0 0 0 0 0 0

[root@s162 /root]# ./resetboard.sh
[root@s162 /root]# mcp251x spi1.0: timeout in txing a packet, restarting
Unable to handle kernel NULL pointer dereference at virtual address 00000094
pgd = c0004000
[00000094] *pgd=00000000
Internal error: Oops: 17 [#1]
CPU: 0    Tainted: G        W  (2.6.27-EK20081022-3 #10)
PC is at mcp251x_tx_work_handler+0x1c/0x2c8
LR is at run_workqueue+0xb0/0x140
pc : [<c0149ccc>]    lr : [<c0050764>]    psr: 60000013
sp : c3a53efc  ip : c3a53f94  fp : c3a53f90
r10: 00000000  r9 : 00000000  r8 : 00000000
r7 : 00000000  r6 : c0149cb0  r5 : c3a4b600  r4 : c3a48300
r3 : 00000000  r2 : 60000013  r1 : c386dc20  r0 : c3a4b600
Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
Control: c000717f  Table: 33b90000  DAC: 00000017
Process mcp251x_wq (pid: 18, stack limit = 0xc3a52260)
Stack: (0xc3a53efc to 0xc3a54000)
3ee0:                                                                c3a53f08
3f00: c004212c c0041e20 c3a53f20 c3a53f90 c3a53f2c c014a904 c0042118 c02d1e80
3f20: c02d2140 c3a4b68c c3a4b600 c02c4438 c02c4438 c02c4438 c02c4438 c02c4438
3f40: c02c4438 c02c4438 00000000 00000000 00000000 00000000 00000000 c3a4b600
3f60: c386d800 00000001 c3a48300 c3a52000 c0149cb0 00000000 00000000 00000000
3f80: 00000000 c3a53fac c3a53f94 c0050764 c0149cc0 c3a48308 c3a48300 c0051190
3fa0: c3a53fd8 c3a53fb0 c0051234 c00506c4 00000000 c3a496a0 c00543a4 c3a53fbc
3fc0: c3a53fbc c3a52000 c3a48300 c3a53ff4 c3a53fdc c005407c c00511a0 00000000
3fe0: 00000000 00000000 00000000 c3a53ff8 c0043de4 c0054030 ffffffff ffffffff
Backtrace:
[<c0149cb0>] (mcp251x_tx_work_handler+0x0/0x2c8) from [<c0050764>] (run_workqueue+0xb0/0x140)
[<c00506b4>] (run_workqueue+0x0/0x140) from [<c0051234>] (worker_thread+0xa4/0xb8)
 r6:c0051190 r5:c3a48300 r4:c3a48308
[<c0051190>] (worker_thread+0x0/0xb8) from [<c005407c>] (kthread+0x5c/0x90)
 r5:c3a48300 r4:c3a52000
[<c0054020>] (kthread+0x0/0x90) from [<c0043de4>] (do_exit+0x0/0x68c)
 r6:00000000 r5:00000000 r4:00000000
Code: e24dd06c e5105028 e5103008 e1a00005 (e5937094)
---[ end trace 93289d93b9ca6c90 ]---


#cat /var/log/messages
Oct 23 15:36:00 s162 user.debug kernel: mcp251x spi1.0: mcp251x_hard_start_xmit
Oct 23 15:36:00 s162 user.debug kernel: mcp251x spi1.0: mcp251x_tx_work_handler
Oct 23 15:36:00 s162 user.debug kernel: mcp251x spi1.0: mcp251x_hw_tx
Oct 23 15:36:02 s162 user.warn kernel: mcp251x spi1.0: timeout in txing a packet, restarting
Oct 23 15:36:02 s162 user.debug kernel: mcp251x spi1.0: mcp251x_hard_start_xmit
Oct 23 15:36:02 s162 user.debug kernel: mcp251x spi1.0: mcp251x_read_reg: read 2c = 80
Oct 23 15:36:02 s162 user.debug kernel: mcp251x spi1.0: interrupt: MERR
Oct 23 15:36:02 s162 user.debug kernel: mcp251x spi1.0: mcp251x_read_reg: read 30 = 10
Oct 23 15:36:02 s162 user.debug kernel: mcp251x spi1.0: mcp251x_read_reg: read 2c = 00
Oct 23 15:36:02 s162 user.debug kernel: mcp251x spi1.0: mcp251x_read_reg: read 0e = 00
Oct 23 15:36:02 s162 user.debug kernel: mcp251x spi1.0: interrupt ended
Oct 23 15:36:02 s162 user.alert kernel: Unable to handle kernel NULL pointer dereference at virtual address 00000094
Oct 23 15:36:02 s162 user.alert kernel: pgd = c0004000
Oct 23 15:36:02 s162 user.alert kernel: [00000094] *pgd=00000000
Oct 23 15:36:02 s162 user.warn kernel: Internal error: Oops: 17 [#1]
Oct 23 15:36:02 s162 user.warn kernel: CPU: 0    Tainted: G        W  (2.6.27-EK20081022-3 #10)
Oct 23 15:36:02 s162 user.warn kernel: PC is at mcp251x_tx_work_handler+0x1c/0x2c8
Oct 23 15:36:02 s162 user.warn kernel: LR is at run_workqueue+0xb0/0x140
Oct 23 15:36:02 s162 user.warn kernel: pc : [<c0149ccc>]    lr : [<c0050764>]    psr: 60000013
Oct 23 15:36:02 s162 user.warn kernel: sp : c3a53efc  ip : c3a53f94  fp : c3a53f90
Oct 23 15:36:02 s162 user.warn kernel: r10: 00000000  r9 : 00000000  r8 : 00000000
Oct 23 15:36:02 s162 user.warn kernel: r7 : 00000000  r6 : c0149cb0  r5 : c3a4b600  r4 : c3a48300
Oct 23 15:36:02 s162 user.warn kernel: r3 : 00000000  r2 : 60000013  r1 : c386dc20  r0 : c3a4b600
Oct 23 15:36:02 s162 user.warn kernel: Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
Oct 23 15:36:02 s162 user.warn kernel: Control: c000717f  Table: 33b90000  DAC: 00000017
Oct 23 15:36:02 s162 user.warn kernel: Process mcp251x_wq (pid: 18, stack limit = 0xc3a52260)
Oct 23 15:36:02 s162 user.warn kernel: Stack: (0xc3a53efc to 0xc3a54000)
Oct 23 15:36:02 s162 user.warn kernel: 3ee0:                                                                c3a53f08
Oct 23 15:36:02 s162 user.warn kernel: 3f00: c004212c c0041e20 c3a53f20 c3a53f90 c3a53f2c c014a904 c0042118 c02d1e80
Oct 23 15:36:02 s162 user.warn kernel: 3f20: c02d2140 c3a4b68c c3a4b600 c02c4438 c02c4438 c02c4438 c02c4438 c02c4438
Oct 23 15:36:02 s162 user.warn kernel: 3f40: c02c4438 c02c4438 00000000 00000000 00000000 00000000 00000000 c3a4b600
Oct 23 15:36:02 s162 user.warn kernel: 3f60: c386d800 00000001 c3a48300 c3a52000 c0149cb0 00000000 00000000 00000000
Oct 23 15:36:02 s162 user.warn kernel: 3f80: 00000000 c3a53fac c3a53f94 c0050764 c0149cc0 c3a48308 c3a48300 c0051190
Oct 23 15:36:02 s162 user.warn kernel: 3fa0: c3a53fd8 c3a53fb0 c0051234 c00506c4 00000000 c3a496a0 c00543a4 c3a53fbc
Oct 23 15:36:02 s162 user.warn kernel: 3fc0: c3a53fbc c3a52000 c3a48300 c3a53ff4 c3a53fdc c005407c c00511a0 00000000
Oct 23 15:36:02 s162 user.warn kernel: 3fe0: 00000000 00000000 00000000 c3a53ff8 c0043de4 c0054030 ffffffff ffffffff
Oct 23 15:36:02 s162 user.warn kernel: Backtrace:
Oct 23 15:36:02 s162 user.warn kernel: [<c0149cb0>] (mcp251x_tx_work_handler+0x0/0x2c8) from [<c0050764>] (run_workqueue+0xb0/0x140)
Oct 23 15:36:02 s162 user.warn kernel: [<c00506b4>] (run_workqueue+0x0/0x140) from [<c0051234>] (worker_thread+0xa4/0xb8)
Oct 23 15:36:02 s162 user.warn kernel:  r6:c0051190 r5:c3a48300 r4:c3a48308
Oct 23 15:36:02 s162 user.warn kernel: [<c0051190>] (worker_thread+0x0/0xb8) from [<c005407c>] (kthread+0x5c/0x90)
Oct 23 15:36:02 s162 user.warn kernel:  r5:c3a48300 r4:c3a52000
Oct 23 15:36:02 s162 user.warn kernel: [<c0054020>] (kthread+0x0/0x90) from [<c0043de4>] (do_exit+0x0/0x68c)
Oct 23 15:36:02 s162 user.warn kernel:  r6:00000000 r5:00000000 r4:00000000
Oct 23 15:36:02 s162 user.warn kernel: Code: e24dd06c e5105028 e5103008 e1a00005 (e5937094)
Oct 23 15:36:02 s162 user.warn kernel: ---[ end trace 93289d93b9ca6c90 ]---
Oct 23 15:38:10 s162 syslog.info -- MARK --

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

Re: MCP251x driver crash report

Christian Pellegrin
On Thu, Oct 23, 2008 at 4:40 PM, Claudio Lanconelli
<[hidden email]> wrote:
> Hi,

Hi!

>
> I tried to send 2 consecutive can frames without any other can device on
> the bus, and I got a crash. Look at the attachment for the log.
> The problem seems due to a TX timeout followed by another tx request.
> Do you have similar problems?

Never seen something like that, but I didn't test with a MCP2515. So I
will be happy to work with you to solve any problems. So, can you
kindly:

1) provide me the platform data you used to configure the driver.

2) if the bus is present (correctly connected I mean) do you see such
problems? You receive the packets on the other side? (I mean: do you
see the problem only where there is a bus down condition?)

3) can you declared the model as CAN_MCP251X_MCP2510 in the platform
data and see what happens? The MCP2515 has the ability to reduce the
number of transfers with special commands but otherwise is backward.
compatible

TIA

--
Christian Pellegrin, see http://www.evolware.org/chri/
"Real Programmers don't play tennis, or any other sport which requires
you to change clothes. Mountain climbing is OK, and Real Programmers
wear their climbing boots to work in case a mountain should suddenly
spring up in the middle of the computer room."
_______________________________________________
Socketcan-core mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/socketcan-core
Reply | Threaded
Open this post in threaded view
|

Re: MCP251x driver crash report

lancos
chri ha scritto:
>
> Never seen something like that, but I didn't test with a MCP2515. So I
> will be happy to work with you to solve any problems. So, can you
> kindly:
>
> 1) provide me the platform data you used to configure the driver.

/*
 ** SPI **
 */
#define MEGAHERTZ(a) ( (a) * 1000 * 1000L )

static int mcp251x_setup(struct spi_device *spi)
{
        s3c2410_gpio_cfgpin(S3C2410_GPG3, S3C2410_GPIO_IRQ);
        return 0;
}

static struct mcp251x_platform_data mcp251x_info = {
        .oscillator_frequency = MEGAHERTZ(16),
        .board_specific_setup = &mcp251x_setup,
        .model = CAN_MCP251X_MCP2515,
        .power_enable = NULL,
        .transceiver_enable = NULL,
};

static struct spi_board_info __initdata s162_spi_devs[] = {
        [0] = {
                .modalias       = "enc28j60",
                .irq            = IRQ_EINT2,
                .max_speed_hz   = MEGAHERTZ(12),
                .bus_num        = 0,
                .chip_select    = 0,
                .mode = SPI_MODE_0,
        },
        [1] = {
                .modalias       = "mcp251x",
                .platform_data  = &mcp251x_info,
                .irq            = IRQ_EINT11,
                .max_speed_hz   = MEGAHERTZ(8),
                .bus_num        = 1,
                .chip_select    = 0,
                .mode = SPI_MODE_0,
        },
};

static struct s3c2410_spi_info spi0_platdata = {
        .pin_cs = S3C2410_GPG12,
        .num_cs = 1,
        .bus_num = 0,
};

static struct s3c2410_spi_info spi1_platdata = {
        .pin_cs = S3C2410_GPH0,
        .num_cs = 1,
        .bus_num = 1,
};

bit timing parameters are:
bitrate 125000
sample_point 750
sjw 1
tq 500
prop_seg 5
phase_seg1 6
phase_seg2 4

>
> 2) if the bus is present (correctly connected I mean) do you see such
> problems? You receive the packets on the other side? (I mean: do you
> see the problem only where there is a bus down condition?)

Yes I see the problem only when there are no other device on the bus, so
the mcp2515 get no acknowledeg.
When there are other devices attached to the bus there are no error,
all seems to work fine, no crash.
Do you know another way to force a TX timeout error?

>
> 3) can you declared the model as CAN_MCP251X_MCP2510 in the platform
> data and see what happens? The MCP2515 has the ability to reduce the
> number of transfers with special commands but otherwise is backward.
> compatible

I will try it tomorrow.

Cheers,
Claudio Lanconelli

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

Re: MCP251x driver for linux 2.6.25

jptalledo
In reply to this post by Christian Pellegrin
I am having some CAN lost frames every 90  - 100 CAN messages.

I am running Linux 2.6.27 on a DM355. I am wondering if I can tweak the driver to increase the RX buffer, enable DMA and using interrupts.

Thanks

Christian Pellegrin wrote
On Mon, Oct 20, 2008 at 2:40 PM, Pierre Savary <pierre.savary@kerlink.fr> wrote:
> Hi all,

Hi,

> development. Where could I find this source code please? Could you help me
> to integrate it?

Right now everything is in the socketcan SVN. I usually compile
socketcan out of tree (since it uses SVN it's a bit difficult to track
it's file when they are mixed in the kernel tree that is managed by
git). Just make sure that the file mcp251x.h is in the include file
path of the kernel (you can symlink it there, I know it's not the most
elegant thing). You have to add the spi_board_info and the
mcp251x_platform_data structs in your machine definition file to tell
what's the wiring, the crystal used and such. Then modprobe can-raw,
mcp251x and the spi master driver (if not already in the kernel) and
it should work. Tell me if you encounter some problem, I'll try to
help.

--
Christian Pellegrin, see http://www.evolware.org/chri/
"Real Programmers don't play tennis, or any other sport which requires
you to change clothes. Mountain climbing is OK, and Real Programmers
wear their climbing boots to work in case a mountain should suddenly
spring up in the middle of the computer room."
_______________________________________________
Socketcan-core mailing list
Socketcan-core@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/socketcan-core
Reply | Threaded
Open this post in threaded view
|

Re: MCP251x driver for linux 2.6.25

redoc
This post has NOT been accepted by the mailing list yet.
In reply to this post by Christian Pellegrin
Hi Christian,

I am trying to use the mcp2515 device to provide CAN functionality with a processor running 2.6.28 linux kernel. I am trying to build the mcp251x.c driver as an external module (I got the driver from 2.6.33 which is the first kernel release I could find with this driver). I am having problems getting this to work, with the network device registration changes that have happened between 2.6.28 and 2.6.33.

It would be really helpful if you could post the new link to this driver code that you had posted earlier to work with 2.6.25 (I see that berlios is shutdown and so not able to access the currently posted link).

Thank you,