linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Florian Feldbauer <florian@ep1.ruhr-uni-bochum.de>,
	linux-can@vger.kernel.org
Subject: Re: Writing socketCAN module for my own hardware
Date: Wed, 01 Oct 2014 09:49:47 +0200	[thread overview]
Message-ID: <542BB21B.4030200@pengutronix.de> (raw)
In-Reply-To: <542BACC0.4050707@ep1.ruhr-uni-bochum.de>

[-- Attachment #1: Type: text/plain, Size: 3390 bytes --]

On 10/01/2014 09:26 AM, Florian Feldbauer wrote:
> I still have some problems with the socket CAN driver for
> my Raspberry Pi CAN interface.
> I added a printk statement in the read/write register functions to
> see what happens.
> 
> Looking into the output of `dmesg` after loading the kernel module
> I see in an endless loop appearing the lines
> 
> [  129.210361] sja1000_raspi: Read register 0: 0x21
> [  129.210394] sja1000_raspi: Write register 4: 0x00
> [  129.210423] sja1000_raspi sja1000_raspi.0 can0: bit-timing not yet
> defined
> 
> Is this an expected behavior?

Do you have network manager or a similar program running that is trying
to handle the CAN interface?

> After setting the bitrate using
> $> ip link set can0 type can bitrate 250000
> The above messages stop.
> 
> dmesg output at this point:
> [  172.870195] sja1000_raspi: Read register 15: 0xff
> [  172.870231] sja1000_raspi: Read register 14: 0xff
> [  172.872933] sja1000_raspi sja1000_raspi.0 can0: setting BTR0=0x01
> BTR1=0x1c
> [  172.872971] sja1000_raspi: Write register 6: 0x01
> [  172.872987] sja1000_raspi: Write register 7: 0x1c
> [  173.269190] sja1000_raspi: Read register 0: 0x21
> [  173.269221] sja1000_raspi: Write register 4: 0x00
> [  173.269287] sja1000_raspi: Write register 15: 0x00
> [  173.269303] sja1000_raspi: Write register 14: 0x00
> [  173.269319] sja1000_raspi: Read register 12: 0xff
> [  173.269336] sja1000_raspi: Read register 0: 0x21
> [  173.269348] sja1000_raspi: Write register 0: 0x00
> [  173.269369] sja1000_raspi: Read register 0: 0x20
> [  173.269381] sja1000_raspi: Write register 4: 0x7f
> [  173.269446] sja1000_raspi: Read register 15: 0x0c
> [  173.269462] sja1000_raspi: Read register 14: 0x03
> 
> The main problem is: If I now try to change the bitrate again
> I get a "Device or resource busy" error.

You'll get this busy error if the device is still "up", so there is
someone who automatically does something similar to "ifconfig can0 up".

> demsg shows in this case simply these to lines:
> [  445.848207] sja1000_raspi: Read register 15: 0x0c
> [  445.848241] sja1000_raspi: Read register 14: 0x03
> 
> After bringing the interface up and trying to listen on the CANbus
> using candump from the can-utils I get nothing, although a second
> node is sending frames and bitrate settings are correct.

Do you get any interrupts?

> I'm working with the raspberry pi kernel
> (https://github.com/raspberrypi/linux)
> version 3.12.y commit c256eb9968c8997dce47350d2075e42f1b3991d3
> 
> Source of my own kernel module is also on github
> https://github.com/ffeldbauer/epics_RPi_can/blob/ver3.0.0/CAN_interface/driver/sja1000_raspi.c
> 
> 
> As written before, I could not find a documentation of socketCAN and
> simply tried
> to "copy" the sja1000_isa.c driver...naybe I did something completely
> wrong or missed
> something?

Yes, making a copy of the driver is probably not the right thing....
BTW: where's are the original copyright notes?

> Any help is very much appreciated!

regards,
Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  reply	other threads:[~2014-10-01  7:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-12  7:51 Writing socketCAN module for my own hardware Florian Feldbauer
2014-08-12  8:24 ` Marc Kleine-Budde
2014-08-12  8:57   ` Florian Feldbauer
2014-08-12 10:01     ` Marc Kleine-Budde
2014-10-01  7:26       ` Florian Feldbauer
2014-10-01  7:49         ` Marc Kleine-Budde [this message]
2014-10-01 12:32           ` Florian Feldbauer
2014-10-01 12:41             ` Marc Kleine-Budde
2014-10-01 12:56               ` Florian Feldbauer
2014-10-01 13:11                 ` Marc Kleine-Budde
2014-10-09 15:06               ` Florian Feldbauer
2014-10-09 16:13                 ` Marc Kleine-Budde
2014-10-10  7:43                   ` Florian Feldbauer
2014-10-10  8:06                     ` Marc Kleine-Budde
2014-10-10  8:09                       ` Florian Feldbauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=542BB21B.4030200@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=florian@ep1.ruhr-uni-bochum.de \
    --cc=linux-can@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).