world leader in high performance signal processing
Trace: » bfin_can

Blackfin SocketCAN Driver

SocketCAN is a framework which provides socket interfaces, then user processes can use the common socket way to communicate by CAN bus. It will replace the old driver using CAN4Linux framework.

Setup Board

Before start the CAN driver, the CAN PHY chip TJA1041 should be activated by setting up PIN CAN_EN and PIN CAN_STB properly according to schematics of different evaluation boards.

On BF537 STAMP board, switch SW2 need to be switched on.

The ADSP-BF544, ADSP-BF548, and ADSP-BF549 processors have two separate and identical CAN modules, referred to as CAN0 and CAN1. The CAN1 module is not present on ADSP-BF542 derivatives. By default on BF548-EZkit, we use CAN0. Please set SW6 to 1-2 off, 3-4 on.

Please also connect two boards with a telephone cable. The TX/RX lines of telephone cable need to be crossover.

Compile Driver and Utility

Configure Kernel

Networking support  --->
	<*>   CAN bus subsystem support  --->
		<*>   Raw CAN Protocol (raw access with CAN-ID filtering)
		<*>   Broadcast Manager CAN Protocol (with content filtering)
		CAN Device Drivers  --->
			<*> Platform CAN drivers with Netlink support
			[*]   CAN bit-timing calculation
			<M>   Analog Devices on-chip CAN

Configure Applications

Network Applications  --->
	[*] can-utils
	[*] iproute2  --->
		[*]   ip

SocketCAN Utilities

On the receiver and sender sides, load bfin-can driver and setup link:

root:/> modprobe bfin-can
bfin_can bfin_can.0: bfin_can device registered (reg_base=ffc02a00, rx_irq=22, tx_irq=23, err_irq=43, sclk=125000000)
root:/> ip link set can0 type can bitrate 125000
bfin_can bfin_can.0: setting can bitrate:125000 brp:125 prop_seg:3 phase_seg1:3 phase_seg2:1
root:/> ifconfig can0 up

On the receiver side, run candump to show received packets:

root:/> candump can0

On the other board, run cansend to send data or remote request packets:

root:/> cansend can0 123#AABBCCDD
root:/> cansend can0 123#R 
root:/> cansend can0 1F334455#1122334455667788
root:/> cansend can0 1F334455#R

The receiver is expected to receive message like:

  can0  123  [4] AA BB CC DD
  can0  123  [0] remote request
  can0  1F334455  [8] 11 22 33 44 55 66 77 88
  can0  1F334455  [0] remote request

On the sender side, you can also run cangen to send random packets:

root:/> cangen can0

Then on the receiver side, there will be a lot of packets received, for example:

  can0  7C9  [3] 80 6B EF
  can0   6E  [3] 28 6E B7
  can0  74C  [7] 6A 3F 6B 0E 19 18 B2
  can0  5ED  [2] D3 AA
  can0  14C  [8] 8B 00 6E 12 00 BC DF 34
  can0  322  [6] 9A 04 3C 02 D4 35
  can0  218  [1] FE
  can0  5D9  [8] 45 3E 84 07 A3 5D 81 09
  can0  191  [6] 01 3C 7E 1C FF 01
  can0  6C9  [8] D9 C4 74 5E 15 BE 3E 3B
  can0  301  [3] 2F D6 F0
  can0  115  [2] 87 65
  can0  67C  [3] 62 B6 93
  can0  369  [8] 72 9F 85 17 81 05 A1 3A
  can0   CD  [1] 65
  can0  43E  [8] 49 EC 79 2A CF 25 81 33
  can0  171  [8] CE 27 A3 4F 3A 98 73 18
  can0  275  [7] 4F 56 B2 53 76 9D 50
  can0   EA  [8] 64 86 C6 6E FF 31 0D 0E
  can0  581  [8] 61 2C C1 52 FD 53 DD 4B
  can0  1FE  [3] 9B BD 88
  can0  5BF  [8] E9 AA 6B 02 8C FE 02 2C
  can0  17E  [8] 32 8D FB 4C BD D5 A5 62
  can0  3F9  [8] 8C FB 26 16 6A 75 57 39
  can0  1C7  [8] A4 0D CB 51 3C 74 9B 7B
  can0    2  [4] B2 11 EC 70

More information