cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
tscott.phoenix
Observer
Observer
3,115 Views
Registered: ‎06-03-2011

Problems with Linux/CAN on Zedboard

Jump to solution

I'm trying to get CAN going under Linux on my Zedboard but things are not working for me.  The kernel appears to see the CAN device is present, but as soon as I try to enable things via “ifconfig can0 up” or “ip link set can0 up”, the CAN driver locks up.

 

I’m following the instructions listed here:

 

http://www.wiki.xilinx.com/Linux+CAN+driver

 

I'm running the kernel found here:

 

https://github.com/Xilinx/linux-xlnx/

 

The specific repo revision I'm using is 6530a9b36265deb4bcf25298ba4e1aba443f6bd4 which is the current tip of the master-next branch.

 

I added the following entry into my zynq-zed.dts file:

 

ps7_can_0: ps7-can@e0008000 {

clock-names = "ref_clk", "aper_clk";

clocks = <&clkc 19>, <&clkc 36>;

compatible = "xlnx,zynq-can-1.0";

interrupt-parent = <&ps7_scugic_0>;

interrupts = <0 28 4>;

reg = <0xe0008000 0x1000>;

} ;

 

I've ensured that the CAN support in the kernel is enabled and built as part of the kernel (ie. it is not a loadable module).  Here is what dmesg is reporting:

 

# dmesg | grep -i can

[    1.077239] vcan: Virtual CAN interface driver

[    1.081615] CAN device driver interface

[    1.089399] XILINX_CAN e0008000.ps7-can: reg_base=0xe086a000 irq=60 clock=7999999, tx fifo depth:64

[    1.418208] can: controller area network core (rev 20120528 abi 9)

[    1.428933] can: raw protocol (rev 20120528)

[    1.433223] can: broadcast manager protocol (rev 20120528 t)

[    1.439054] can: netlink gateway (rev 20130117) max_hops=1

 

I configure the bit timing by doing this: “ip link set can0 type can bitrate 250000".  dmesg reports:

 

[  101.705476] XILINX_CAN e0008000.ps7-can can0: bitrate error 0.0%

[  101.711529] XILINX_CAN e0008000.ps7-can can0: brp=8,prop=1,phase_seg1:1,phase_reg2=1,sjw=1

[  101.719921] XILINX_CAN e0008000.ps7-can can0: Setting BTR0=0x07 BTR1=0x01

[  101.726970] XILINX_CAN e0008000.ps7-can can0: BRPR=0x00000007, BTR=0x00000001

 

"ip link" shows:

 

# ip link

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

2: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10

    link/can

3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000

    link/ether 00:0a:35:00:01:22 brd ff:ff:ff:ff:ff:ff

 

“ifconfig –a” shows:

 

# ifconfig -a

can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00

          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)

          Interrupt:60 Memory:e0008000-e0008fff

 

eth0      Link encap:Ethernet  HWaddr 00:0A:35:00:01:22

          inet addr:204.54.81.137  Bcast:204.54.81.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:4263 errors:0 dropped:0 overruns:0 frame:0

          TX packets:1618 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:3880919 (3.7 MiB)  TX bytes:257849 (251.8 KiB)

          Interrupt:54 Base address:0xb000

 

lo        Link encap:Local Loopback

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:65536  Metric:1

          RX packets:12 errors:0 dropped:0 overruns:0 frame:0

          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:948 (948.0 B)  TX bytes:948 (948.0 B)

 

When I issue “ifconfig can0 up” things hang.  After a bit of debugging, I discovered that hang is occurring in xilinx_can.c in the xcan_start() method, where it while-loops endlessly waiting for the NORMAL bit in XCAN_SR_OFFSET to get set.

 

One oddity that I’ve noticed is that I cannot even use U-Boot to query CAN controller registers.  If I interrupt the boot process and enter “md.l 0xe0008018 1” to read the CAN SR, U-Boot just hangs.  Other CAN registers fail similarly.  I see this behavior with both CAN0 and CAN1.

 

Any thoughts?

 

Thanks,

--tim

 

 

 

0 Kudos
1 Solution

Accepted Solutions
tscott.phoenix
Observer
Observer
3,989 Views
Registered: ‎06-03-2011
0 Kudos
1 Reply
tscott.phoenix
Observer
Observer
3,990 Views
Registered: ‎06-03-2011
0 Kudos